Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/java/security/AuthProvider.java
38829 views
/*1* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package java.security;2627import javax.security.auth.Subject;28import javax.security.auth.login.LoginException;29import javax.security.auth.callback.CallbackHandler;3031/**32* This class defines login and logout methods for a provider.33*34* <p> While callers may invoke {@code login} directly,35* the provider may also invoke {@code login} on behalf of callers36* if it determines that a login must be performed37* prior to certain operations.38*39* @since 1.540*/41public abstract class AuthProvider extends Provider {4243private static final long serialVersionUID = 4197859053084546461L;4445/**46* Constructs a provider with the specified name, version number,47* and information.48*49* @param name the provider name.50* @param version the provider version number.51* @param info a description of the provider and its services.52*/53protected AuthProvider(String name, double version, String info) {54super(name, version, info);55}5657/**58* Log in to this provider.59*60* <p> The provider relies on a {@code CallbackHandler}61* to obtain authentication information from the caller62* (a PIN, for example). If the caller passes a {@code null}63* handler to this method, the provider uses the handler set in the64* {@code setCallbackHandler} method.65* If no handler was set in that method, the provider queries the66* <i>auth.login.defaultCallbackHandler</i> security property67* for the fully qualified class name of a default handler implementation.68* If the security property is not set,69* the provider is assumed to have alternative means70* for obtaining authentication information.71*72* @param subject the {@code Subject} which may contain73* principals/credentials used for authentication,74* or may be populated with additional principals/credentials75* after successful authentication has completed.76* This parameter may be {@code null}.77* @param handler the {@code CallbackHandler} used by78* this provider to obtain authentication information79* from the caller, which may be {@code null}80*81* @exception LoginException if the login operation fails82* @exception SecurityException if the caller does not pass a83* security check for84* {@code SecurityPermission("authProvider.name")},85* where {@code name} is the value returned by86* this provider's {@code getName} method87*/88public abstract void login(Subject subject, CallbackHandler handler)89throws LoginException;9091/**92* Log out from this provider.93*94* @exception LoginException if the logout operation fails95* @exception SecurityException if the caller does not pass a96* security check for97* {@code SecurityPermission("authProvider.name")},98* where {@code name} is the value returned by99* this provider's {@code getName} method100*/101public abstract void logout() throws LoginException;102103/**104* Set a {@code CallbackHandler}.105*106* <p> The provider uses this handler if one is not passed to the107* {@code login} method. The provider also uses this handler108* if it invokes {@code login} on behalf of callers.109* In either case if a handler is not set via this method,110* the provider queries the111* <i>auth.login.defaultCallbackHandler</i> security property112* for the fully qualified class name of a default handler implementation.113* If the security property is not set,114* the provider is assumed to have alternative means115* for obtaining authentication information.116*117* @param handler a {@code CallbackHandler} for obtaining118* authentication information, which may be {@code null}119*120* @exception SecurityException if the caller does not pass a121* security check for122* {@code SecurityPermission("authProvider.name")},123* where {@code name} is the value returned by124* this provider's {@code getName} method125*/126public abstract void setCallbackHandler(CallbackHandler handler);127}128129130