equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
29 import javax.security.auth.callback.NameCallback; |
29 import javax.security.auth.callback.NameCallback; |
30 import javax.security.auth.callback.PasswordCallback; |
30 import javax.security.auth.callback.PasswordCallback; |
31 import javax.security.auth.callback.UnsupportedCallbackException; |
31 import javax.security.auth.callback.UnsupportedCallbackException; |
32 import javax.security.auth.login.LoginException; |
32 import javax.security.auth.login.LoginException; |
33 import javax.security.auth.login.LoginContext; |
33 import javax.security.auth.login.LoginContext; |
34 import com.sun.security.auth.UnixPrincipal; |
34 import com.sun.security.auth.UserPrincipal; |
35 |
35 |
36 /** |
36 /** |
37 * JAAS client which will try to authenticate a user through a custom JAAS LOGIN |
37 * JAAS client which will try to authenticate a user through a custom JAAS LOGIN |
38 * Module. |
38 * Module. |
39 */ |
39 */ |
69 + "cleared."); |
69 + "cleared."); |
70 } |
70 } |
71 return; |
71 return; |
72 } |
72 } |
73 for (Principal p : loginContext.getSubject().getPrincipals()) { |
73 for (Principal p : loginContext.getSubject().getPrincipals()) { |
74 if (p instanceof UnixPrincipal |
74 if (p instanceof UserPrincipal |
75 && USER_NAME.equals(p.getName())) { |
75 && USER_NAME.equals(p.getName())) { |
76 //Proper principal was found, return. |
76 //Proper principal was found, return. |
77 return; |
77 return; |
78 } |
78 } |
79 } |
79 } |
80 throw new RuntimeException("Test failed. UnixPrincipal " |
80 throw new RuntimeException("Test failed. UserPrincipal " |
81 + USER_NAME + " expected."); |
81 + USER_NAME + " expected."); |
82 |
82 |
83 } |
83 } |
84 |
84 |
85 private static class MyCallbackHandler implements CallbackHandler { |
85 private static class MyCallbackHandler implements CallbackHandler { |