893N/A/*
3909N/A * Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.
893N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
893N/A *
893N/A * This code is free software; you can redistribute it and/or modify it
893N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
893N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
893N/A *
893N/A * This code is distributed in the hope that it will be useful, but WITHOUT
893N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
893N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
893N/A * version 2 for more details (a copy is included in the LICENSE file that
893N/A * accompanied this code).
893N/A *
893N/A * You should have received a copy of the GNU General Public License version
893N/A * 2 along with this work; if not, write to the Free Software Foundation,
893N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
893N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
893N/A */
893N/A
893N/Apackage java.security;
893N/A
893N/Aimport javax.security.auth.Subject;
893N/Aimport javax.security.auth.login.LoginException;
893N/Aimport javax.security.auth.callback.CallbackHandler;
893N/A
893N/A/**
893N/A * This class defines login and logout methods for a provider.
893N/A *
893N/A * <p> While callers may invoke <code>login</code> directly,
893N/A * the provider may also invoke <code>login</code> on behalf of callers
893N/A * if it determines that a login must be performed
893N/A * prior to certain operations.
893N/A *
893N/A * @since 1.5
893N/A */
893N/Apublic abstract class AuthProvider extends Provider {
893N/A
893N/A /**
893N/A * Constructs a provider with the specified name, version number,
893N/A * and information.
893N/A *
908N/A * @param name the provider name.
893N/A * @param version the provider version number.
893N/A * @param info a description of the provider and its services.
893N/A */
893N/A protected AuthProvider(String name, double version, String info) {
893N/A super(name, version, info);
893N/A }
893N/A
893N/A /**
908N/A * Log in to this provider.
893N/A *
893N/A * <p> The provider relies on a <code>CallbackHandler</code>
893N/A * to obtain authentication information from the caller
893N/A * (a PIN, for example). If the caller passes a <code>null</code>
893N/A * handler to this method, the provider uses the handler set in the
893N/A * <code>setCallbackHandler</code> method.
893N/A * If no handler was set in that method, the provider queries the
893N/A * <i>auth.login.defaultCallbackHandler</i> security property
893N/A * for the fully qualified class name of a default handler implementation.
893N/A * If the security property is not set,
893N/A * the provider is assumed to have alternative means
893N/A * for obtaining authentication information.
908N/A *
893N/A * @param subject the <code>Subject</code> which may contain
893N/A * principals/credentials used for authentication,
893N/A * or may be populated with additional principals/credentials
893N/A * after successful authentication has completed.
893N/A * This parameter may be <code>null</code>.
* @param handler the <code>CallbackHandler</code> used by
* this provider to obtain authentication information
* from the caller, which may be <code>null</code>
*
* @exception LoginException if the login operation fails
* @exception SecurityException if the caller does not pass a
* security check for
* <code>SecurityPermission("authProvider.<i>name</i>")</code>,
* where <i>name</i> is the value returned by
* this provider's <code>getName</code> method
*/
public abstract void login(Subject subject, CallbackHandler handler)
throws LoginException;
/**
* Log out from this provider.
*
* @exception LoginException if the logout operation fails
* @exception SecurityException if the caller does not pass a
* security check for
* <code>SecurityPermission("authProvider.<i>name</i>")</code>,
* where <i>name</i> is the value returned by
* this provider's <code>getName</code> method
*/
public abstract void logout() throws LoginException;
/**
* Set a <code>CallbackHandler</code>.
*
* <p> The provider uses this handler if one is not passed to the
* <code>login</code> method. The provider also uses this handler
* if it invokes <code>login</code> on behalf of callers.
* In either case if a handler is not set via this method,
* the provider queries the
* <i>auth.login.defaultCallbackHandler</i> security property
* for the fully qualified class name of a default handler implementation.
* If the security property is not set,
* the provider is assumed to have alternative means
* for obtaining authentication information.
*
* @param handler a <code>CallbackHandler</code> for obtaining
* authentication information, which may be <code>null</code>
*
* @exception SecurityException if the caller does not pass a
* security check for
* <code>SecurityPermission("authProvider.<i>name</i>")</code>,
* where <i>name</i> is the value returned by
* this provider's <code>getName</code> method
*/
public abstract void setCallbackHandler(CallbackHandler handler);
}