author | coleenp |
Wed, 30 Aug 2017 19:18:22 -0400 | |
changeset 47098 | e704f55561c3 |
parent 40416 | 5d91b2fd668c |
permissions | -rw-r--r-- |
2 | 1 |
/* |
40416
5d91b2fd668c
8130181: Deprecate java.security.Provider(String, double, String), add Provider(Strin
valeriep
parents:
32931
diff
changeset
|
2 |
* Copyright (c) 2003, 2016, 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. |
|
40416
5d91b2fd668c
8130181: Deprecate java.security.Provider(String, double, String), add Provider(Strin
valeriep
parents:
32931
diff
changeset
|
53 |
* @deprecated use {@link #AuthProvider(String, String, String)} instead. |
2 | 54 |
*/ |
40416
5d91b2fd668c
8130181: Deprecate java.security.Provider(String, double, String), add Provider(Strin
valeriep
parents:
32931
diff
changeset
|
55 |
@Deprecated(since="9") |
2 | 56 |
protected AuthProvider(String name, double version, String info) { |
40416
5d91b2fd668c
8130181: Deprecate java.security.Provider(String, double, String), add Provider(Strin
valeriep
parents:
32931
diff
changeset
|
57 |
super(name, Double.toString(version), info); |
5d91b2fd668c
8130181: Deprecate java.security.Provider(String, double, String), add Provider(Strin
valeriep
parents:
32931
diff
changeset
|
58 |
} |
5d91b2fd668c
8130181: Deprecate java.security.Provider(String, double, String), add Provider(Strin
valeriep
parents:
32931
diff
changeset
|
59 |
|
5d91b2fd668c
8130181: Deprecate java.security.Provider(String, double, String), add Provider(Strin
valeriep
parents:
32931
diff
changeset
|
60 |
/** |
5d91b2fd668c
8130181: Deprecate java.security.Provider(String, double, String), add Provider(Strin
valeriep
parents:
32931
diff
changeset
|
61 |
* Constructs a provider with the specified name, version string, |
5d91b2fd668c
8130181: Deprecate java.security.Provider(String, double, String), add Provider(Strin
valeriep
parents:
32931
diff
changeset
|
62 |
* and information. |
5d91b2fd668c
8130181: Deprecate java.security.Provider(String, double, String), add Provider(Strin
valeriep
parents:
32931
diff
changeset
|
63 |
* |
5d91b2fd668c
8130181: Deprecate java.security.Provider(String, double, String), add Provider(Strin
valeriep
parents:
32931
diff
changeset
|
64 |
* @param name the provider name. |
5d91b2fd668c
8130181: Deprecate java.security.Provider(String, double, String), add Provider(Strin
valeriep
parents:
32931
diff
changeset
|
65 |
* @param versionStr the provider version string. |
5d91b2fd668c
8130181: Deprecate java.security.Provider(String, double, String), add Provider(Strin
valeriep
parents:
32931
diff
changeset
|
66 |
* @param info a description of the provider and its services. |
5d91b2fd668c
8130181: Deprecate java.security.Provider(String, double, String), add Provider(Strin
valeriep
parents:
32931
diff
changeset
|
67 |
* @since 9 |
5d91b2fd668c
8130181: Deprecate java.security.Provider(String, double, String), add Provider(Strin
valeriep
parents:
32931
diff
changeset
|
68 |
*/ |
5d91b2fd668c
8130181: Deprecate java.security.Provider(String, double, String), add Provider(Strin
valeriep
parents:
32931
diff
changeset
|
69 |
protected AuthProvider(String name, String versionStr, String info) { |
5d91b2fd668c
8130181: Deprecate java.security.Provider(String, double, String), add Provider(Strin
valeriep
parents:
32931
diff
changeset
|
70 |
super(name, versionStr, info); |
2 | 71 |
} |
72 |
||
73 |
/** |
|
74 |
* Log in to this provider. |
|
75 |
* |
|
18579
b678846778ad
8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents:
5506
diff
changeset
|
76 |
* <p> The provider relies on a {@code CallbackHandler} |
2 | 77 |
* to obtain authentication information from the caller |
18579
b678846778ad
8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents:
5506
diff
changeset
|
78 |
* (a PIN, for example). If the caller passes a {@code null} |
2 | 79 |
* 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
|
80 |
* {@code setCallbackHandler} method. |
2 | 81 |
* If no handler was set in that method, the provider queries the |
82 |
* <i>auth.login.defaultCallbackHandler</i> security property |
|
83 |
* for the fully qualified class name of a default handler implementation. |
|
84 |
* If the security property is not set, |
|
85 |
* the provider is assumed to have alternative means |
|
86 |
* for obtaining authentication information. |
|
87 |
* |
|
18579
b678846778ad
8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents:
5506
diff
changeset
|
88 |
* @param subject the {@code Subject} which may contain |
2 | 89 |
* principals/credentials used for authentication, |
90 |
* or may be populated with additional principals/credentials |
|
91 |
* after successful authentication has completed. |
|
18579
b678846778ad
8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents:
5506
diff
changeset
|
92 |
* This parameter may be {@code null}. |
b678846778ad
8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents:
5506
diff
changeset
|
93 |
* @param handler the {@code CallbackHandler} used by |
2 | 94 |
* this provider to obtain authentication information |
18579
b678846778ad
8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents:
5506
diff
changeset
|
95 |
* from the caller, which may be {@code null} |
2 | 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 login 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 login(Subject subject, CallbackHandler handler) |
|
107 |
throws LoginException; |
|
108 |
||
109 |
/** |
|
110 |
* Log out from this provider. |
|
111 |
* |
|
32931
2ba4f06f8684
8130648: JCK test api/java_security/AuthProvider/ProviderTests_login starts failing after JDK-7191662
valeriep
parents:
25859
diff
changeset
|
112 |
* @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
|
113 |
* 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
|
114 |
* @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
|
115 |
* @throws SecurityException if the caller does not pass a |
2 | 116 |
* security check for |
18579
b678846778ad
8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents:
5506
diff
changeset
|
117 |
* {@code SecurityPermission("authProvider.name")}, |
b678846778ad
8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents:
5506
diff
changeset
|
118 |
* where {@code name} is the value returned by |
b678846778ad
8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents:
5506
diff
changeset
|
119 |
* this provider's {@code getName} method |
2 | 120 |
*/ |
121 |
public abstract void logout() throws LoginException; |
|
122 |
||
123 |
/** |
|
18579
b678846778ad
8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents:
5506
diff
changeset
|
124 |
* Set a {@code CallbackHandler}. |
2 | 125 |
* |
126 |
* <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
|
127 |
* {@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
|
128 |
* if it invokes {@code login} on behalf of callers. |
2 | 129 |
* In either case if a handler is not set via this method, |
130 |
* the provider queries the |
|
131 |
* <i>auth.login.defaultCallbackHandler</i> security property |
|
132 |
* for the fully qualified class name of a default handler implementation. |
|
133 |
* If the security property is not set, |
|
134 |
* the provider is assumed to have alternative means |
|
135 |
* for obtaining authentication information. |
|
136 |
* |
|
18579
b678846778ad
8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents:
5506
diff
changeset
|
137 |
* @param handler a {@code CallbackHandler} for obtaining |
b678846778ad
8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents:
5506
diff
changeset
|
138 |
* authentication information, which may be {@code null} |
2 | 139 |
* |
32931
2ba4f06f8684
8130648: JCK test api/java_security/AuthProvider/ProviderTests_login starts failing after JDK-7191662
valeriep
parents:
25859
diff
changeset
|
140 |
* @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
|
141 |
* 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
|
142 |
* @throws SecurityException if the caller does not pass a |
2 | 143 |
* security check for |
18579
b678846778ad
8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents:
5506
diff
changeset
|
144 |
* {@code SecurityPermission("authProvider.name")}, |
b678846778ad
8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents:
5506
diff
changeset
|
145 |
* where {@code name} is the value returned by |
b678846778ad
8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents:
5506
diff
changeset
|
146 |
* this provider's {@code getName} method |
2 | 147 |
*/ |
148 |
public abstract void setCallbackHandler(CallbackHandler handler); |
|
149 |
} |