equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2016, 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. |
23 package login; |
23 package login; |
24 |
24 |
25 import java.security.Principal; |
25 import java.security.Principal; |
26 import javax.security.auth.login.LoginContext; |
26 import javax.security.auth.login.LoginContext; |
27 import javax.security.auth.login.LoginException; |
27 import javax.security.auth.login.LoginException; |
28 import com.sun.security.auth.UnixPrincipal; |
28 import com.sun.security.auth.UserPrincipal; |
29 |
29 |
30 public class JaasClientWithDefaultHandler { |
30 public class JaasClientWithDefaultHandler { |
31 |
31 |
32 private static final String USER_NAME = "testUser"; |
32 private static final String USER_NAME = "testUser"; |
33 private static final String LOGIN_CONTEXT = "ModularLoginConf"; |
33 private static final String LOGIN_CONTEXT = "ModularLoginConf"; |
59 + "cleared."); |
59 + "cleared."); |
60 } |
60 } |
61 return; |
61 return; |
62 } |
62 } |
63 for (Principal p : loginContext.getSubject().getPrincipals()) { |
63 for (Principal p : loginContext.getSubject().getPrincipals()) { |
64 if (p instanceof UnixPrincipal |
64 if (p instanceof UserPrincipal |
65 && USER_NAME.equals(p.getName())) { |
65 && USER_NAME.equals(p.getName())) { |
66 //Proper principal was found, return. |
66 //Proper principal was found, return. |
67 return; |
67 return; |
68 } |
68 } |
69 } |
69 } |
70 throw new RuntimeException("Test failed. UnixPrincipal " |
70 throw new RuntimeException("Test failed. UserPrincipal " |
71 + USER_NAME + " expected."); |
71 + USER_NAME + " expected."); |
72 } |
72 } |
73 |
73 |
74 } |
74 } |