author | valeriep |
Thu, 08 Oct 2015 20:51:08 +0000 | |
changeset 32931 | 2ba4f06f8684 |
parent 25859 | 3317bb8137f4 |
child 40416 | 5d91b2fd668c |
permissions | -rw-r--r-- |
2 | 1 |
/* |
32931
2ba4f06f8684
8130648: JCK test api/java_security/AuthProvider/ProviderTests_login starts failing after JDK-7191662
valeriep
parents:
25859
diff
changeset
|
2 |
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. |
2 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
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 |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5506 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
2 | 24 |
*/ |
25 |
||
26 |
package java.security; |
|
27 |
||
28 |
import javax.security.auth.Subject; |
|
29 |
import javax.security.auth.login.LoginException; |
|
30 |
import javax.security.auth.callback.CallbackHandler; |
|
31 |
||
32 |
/** |
|
33 |
* This class defines login and logout methods for a provider. |
|
34 |
* |
|
18579
b678846778ad
8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents:
5506
diff
changeset
|
35 |
* <p> While callers may invoke {@code login} directly, |
b678846778ad
8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents:
5506
diff
changeset
|
36 |
* the provider may also invoke {@code login} on behalf of callers |
2 | 37 |
* if it determines that a login must be performed |
38 |
* prior to certain operations. |
|
39 |
* |
|
40 |
* @since 1.5 |
|
41 |
*/ |
|
42 |
public abstract class AuthProvider extends Provider { |
|
43 |
||
18813 | 44 |
private static final long serialVersionUID = 4197859053084546461L; |
45 |
||
2 | 46 |
/** |
47 |
* Constructs a provider with the specified name, version number, |
|
48 |
* and information. |
|
49 |
* |
|
50 |
* @param name the provider name. |
|
51 |
* @param version the provider version number. |
|
52 |
* @param info a description of the provider and its services. |
|
53 |
*/ |
|
54 |
protected AuthProvider(String name, double version, String info) { |
|
55 |
super(name, version, info); |
|
56 |
} |
|
57 |
||
58 |
/** |
|
59 |
* Log in to this provider. |
|
60 |
* |
|
18579
b678846778ad
8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents:
5506
diff
changeset
|
61 |
* <p> The provider relies on a {@code CallbackHandler} |
2 | 62 |
* to obtain authentication information from the caller |
18579
b678846778ad
8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents:
5506
diff
changeset
|
63 |
* (a PIN, for example). If the caller passes a {@code null} |
2 | 64 |
* handler to this method, the provider uses the handler set in the |
18579
b678846778ad
8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents:
5506
diff
changeset
|
65 |
* {@code setCallbackHandler} method. |
2 | 66 |
* If no handler was set in that method, the provider queries the |
67 |
* <i>auth.login.defaultCallbackHandler</i> security property |
|
68 |
* for the fully qualified class name of a default handler implementation. |
|
69 |
* If the security property is not set, |
|
70 |
* the provider is assumed to have alternative means |
|
71 |
* for obtaining authentication information. |
|
72 |
* |
|
18579
b678846778ad
8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents:
5506
diff
changeset
|
73 |
* @param subject the {@code Subject} which may contain |
2 | 74 |
* principals/credentials used for authentication, |
75 |
* or may be populated with additional principals/credentials |
|
76 |
* after successful authentication has completed. |
|
18579
b678846778ad
8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents:
5506
diff
changeset
|
77 |
* This parameter may be {@code null}. |
b678846778ad
8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents:
5506
diff
changeset
|
78 |
* @param handler the {@code CallbackHandler} used by |
2 | 79 |
* this provider to obtain authentication information |
18579
b678846778ad
8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents:
5506
diff
changeset
|
80 |
* from the caller, which may be {@code null} |
2 | 81 |
* |
32931
2ba4f06f8684
8130648: JCK test api/java_security/AuthProvider/ProviderTests_login starts failing after JDK-7191662
valeriep
parents:
25859
diff
changeset
|
82 |
* @throws IllegalStateException if the provider requires configuration |
2ba4f06f8684
8130648: JCK test api/java_security/AuthProvider/ProviderTests_login starts failing after JDK-7191662
valeriep
parents:
25859
diff
changeset
|
83 |
* and {@link configure} has not been called |
2ba4f06f8684
8130648: JCK test api/java_security/AuthProvider/ProviderTests_login starts failing after JDK-7191662
valeriep
parents:
25859
diff
changeset
|
84 |
* @throws LoginException if the login operation fails |
2ba4f06f8684
8130648: JCK test api/java_security/AuthProvider/ProviderTests_login starts failing after JDK-7191662
valeriep
parents:
25859
diff
changeset
|
85 |
* @throws SecurityException if the caller does not pass a |
2 | 86 |
* security check for |
18579
b678846778ad
8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents:
5506
diff
changeset
|
87 |
* {@code SecurityPermission("authProvider.name")}, |
b678846778ad
8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents:
5506
diff
changeset
|
88 |
* where {@code name} is the value returned by |
b678846778ad
8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents:
5506
diff
changeset
|
89 |
* this provider's {@code getName} method |
2 | 90 |
*/ |
91 |
public abstract void login(Subject subject, CallbackHandler handler) |
|
92 |
throws LoginException; |
|
93 |
||
94 |
/** |
|
95 |
* Log out from this provider. |
|
96 |
* |
|
32931
2ba4f06f8684
8130648: JCK test api/java_security/AuthProvider/ProviderTests_login starts failing after JDK-7191662
valeriep
parents:
25859
diff
changeset
|
97 |
* @throws IllegalStateException if the provider requires configuration |
2ba4f06f8684
8130648: JCK test api/java_security/AuthProvider/ProviderTests_login starts failing after JDK-7191662
valeriep
parents:
25859
diff
changeset
|
98 |
* and {@link configure} has not been called |
2ba4f06f8684
8130648: JCK test api/java_security/AuthProvider/ProviderTests_login starts failing after JDK-7191662
valeriep
parents:
25859
diff
changeset
|
99 |
* @throws LoginException if the logout operation fails |
2ba4f06f8684
8130648: JCK test api/java_security/AuthProvider/ProviderTests_login starts failing after JDK-7191662
valeriep
parents:
25859
diff
changeset
|
100 |
* @throws SecurityException if the caller does not pass a |
2 | 101 |
* security check for |
18579
b678846778ad
8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents:
5506
diff
changeset
|
102 |
* {@code SecurityPermission("authProvider.name")}, |
b678846778ad
8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents:
5506
diff
changeset
|
103 |
* where {@code name} is the value returned by |
b678846778ad
8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents:
5506
diff
changeset
|
104 |
* this provider's {@code getName} method |
2 | 105 |
*/ |
106 |
public abstract void logout() throws LoginException; |
|
107 |
||
108 |
/** |
|
18579
b678846778ad
8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents:
5506
diff
changeset
|
109 |
* Set a {@code CallbackHandler}. |
2 | 110 |
* |
111 |
* <p> The provider uses this handler if one is not passed to the |
|
18579
b678846778ad
8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents:
5506
diff
changeset
|
112 |
* {@code login} method. The provider also uses this handler |
b678846778ad
8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents:
5506
diff
changeset
|
113 |
* if it invokes {@code login} on behalf of callers. |
2 | 114 |
* In either case if a handler is not set via this method, |
115 |
* the provider queries the |
|
116 |
* <i>auth.login.defaultCallbackHandler</i> security property |
|
117 |
* for the fully qualified class name of a default handler implementation. |
|
118 |
* If the security property is not set, |
|
119 |
* the provider is assumed to have alternative means |
|
120 |
* for obtaining authentication information. |
|
121 |
* |
|
18579
b678846778ad
8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents:
5506
diff
changeset
|
122 |
* @param handler a {@code CallbackHandler} for obtaining |
b678846778ad
8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents:
5506
diff
changeset
|
123 |
* authentication information, which may be {@code null} |
2 | 124 |
* |
32931
2ba4f06f8684
8130648: JCK test api/java_security/AuthProvider/ProviderTests_login starts failing after JDK-7191662
valeriep
parents:
25859
diff
changeset
|
125 |
* @throws IllegalStateException if the provider requires configuration |
2ba4f06f8684
8130648: JCK test api/java_security/AuthProvider/ProviderTests_login starts failing after JDK-7191662
valeriep
parents:
25859
diff
changeset
|
126 |
* and {@link configure} has not been called |
2ba4f06f8684
8130648: JCK test api/java_security/AuthProvider/ProviderTests_login starts failing after JDK-7191662
valeriep
parents:
25859
diff
changeset
|
127 |
* @throws SecurityException if the caller does not pass a |
2 | 128 |
* security check for |
18579
b678846778ad
8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents:
5506
diff
changeset
|
129 |
* {@code SecurityPermission("authProvider.name")}, |
b678846778ad
8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents:
5506
diff
changeset
|
130 |
* where {@code name} is the value returned by |
b678846778ad
8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents:
5506
diff
changeset
|
131 |
* this provider's {@code getName} method |
2 | 132 |
*/ |
133 |
public abstract void setCallbackHandler(CallbackHandler handler); |
|
134 |
} |