Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/java/security/AuthProvider.java
38829 views
1
/*
2
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
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
7
* published by the Free Software Foundation. Oracle designates this
8
* particular file as subject to the "Classpath" exception as provided
9
* by Oracle in the LICENSE file that accompanied this code.
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
*
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.
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
*
35
* <p> While callers may invoke {@code login} directly,
36
* the provider may also invoke {@code login} on behalf of callers
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
44
private static final long serialVersionUID = 4197859053084546461L;
45
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
*
61
* <p> The provider relies on a {@code CallbackHandler}
62
* to obtain authentication information from the caller
63
* (a PIN, for example). If the caller passes a {@code null}
64
* handler to this method, the provider uses the handler set in the
65
* {@code setCallbackHandler} method.
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
*
73
* @param subject the {@code Subject} which may contain
74
* principals/credentials used for authentication,
75
* or may be populated with additional principals/credentials
76
* after successful authentication has completed.
77
* This parameter may be {@code null}.
78
* @param handler the {@code CallbackHandler} used by
79
* this provider to obtain authentication information
80
* from the caller, which may be {@code null}
81
*
82
* @exception LoginException if the login operation fails
83
* @exception SecurityException if the caller does not pass a
84
* security check for
85
* {@code SecurityPermission("authProvider.name")},
86
* where {@code name} is the value returned by
87
* this provider's {@code getName} method
88
*/
89
public abstract void login(Subject subject, CallbackHandler handler)
90
throws LoginException;
91
92
/**
93
* Log out from this provider.
94
*
95
* @exception LoginException if the logout operation fails
96
* @exception SecurityException if the caller does not pass a
97
* security check for
98
* {@code SecurityPermission("authProvider.name")},
99
* where {@code name} is the value returned by
100
* this provider's {@code getName} method
101
*/
102
public abstract void logout() throws LoginException;
103
104
/**
105
* Set a {@code CallbackHandler}.
106
*
107
* <p> The provider uses this handler if one is not passed to the
108
* {@code login} method. The provider also uses this handler
109
* if it invokes {@code login} on behalf of callers.
110
* In either case if a handler is not set via this method,
111
* the provider queries the
112
* <i>auth.login.defaultCallbackHandler</i> security property
113
* for the fully qualified class name of a default handler implementation.
114
* If the security property is not set,
115
* the provider is assumed to have alternative means
116
* for obtaining authentication information.
117
*
118
* @param handler a {@code CallbackHandler} for obtaining
119
* authentication information, which may be {@code null}
120
*
121
* @exception SecurityException if the caller does not pass a
122
* security check for
123
* {@code SecurityPermission("authProvider.name")},
124
* where {@code name} is the value returned by
125
* this provider's {@code getName} method
126
*/
127
public abstract void setCallbackHandler(CallbackHandler handler);
128
}
129
130