jdk/src/share/classes/java/security/AuthProvider.java
author ohair
Tue, 25 May 2010 15:58:33 -0700
changeset 5506 202f599c92aa
parent 2 90ce3da70b43
child 18579 b678846778ad
permissions -rw-r--r--
6943119: Rebrand source copyright notices Reviewed-by: darcy, weijun
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     2
 * Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package java.security;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import javax.security.auth.Subject;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import javax.security.auth.login.LoginException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import javax.security.auth.callback.CallbackHandler;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * This class defines login and logout methods for a provider.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * <p> While callers may invoke <code>login</code> directly,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * the provider may also invoke <code>login</code> on behalf of callers
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * if it determines that a login must be performed
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * prior to certain operations.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
public abstract class AuthProvider extends Provider {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
     * Constructs a provider with the specified name, version number,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
     * and information.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
     * @param name the provider name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
     * @param version the provider version number.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
     * @param info a description of the provider and its services.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    protected AuthProvider(String name, double version, String info) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
        super(name, version, info);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
     * Log in to this provider.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
     * <p> The provider relies on a <code>CallbackHandler</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
     * to obtain authentication information from the caller
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
     * (a PIN, for example).  If the caller passes a <code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
     * handler to this method, the provider uses the handler set in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
     * <code>setCallbackHandler</code> method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
     * If no handler was set in that method, the provider queries the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
     * <i>auth.login.defaultCallbackHandler</i> security property
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
     * for the fully qualified class name of a default handler implementation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
     * If the security property is not set,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
     * the provider is assumed to have alternative means
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
     * for obtaining authentication information.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
     * @param subject the <code>Subject</code> which may contain
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     *          principals/credentials used for authentication,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     *          or may be populated with additional principals/credentials
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     *          after successful authentication has completed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     *          This parameter may be <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     * @param handler the <code>CallbackHandler</code> used by
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     *          this provider to obtain authentication information
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     *          from the caller, which may be <code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     * @exception LoginException if the login operation fails
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     * @exception SecurityException if the caller does not pass a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     *  security check for
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     *  <code>SecurityPermission("authProvider.<i>name</i>")</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     *  where <i>name</i> is the value returned by
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     *  this provider's <code>getName</code> method
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    public abstract void login(Subject subject, CallbackHandler handler)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
        throws LoginException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     * Log out from this provider.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     * @exception LoginException if the logout operation fails
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     * @exception SecurityException if the caller does not pass a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     *  security check for
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     *  <code>SecurityPermission("authProvider.<i>name</i>")</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     *  where <i>name</i> is the value returned by
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     *  this provider's <code>getName</code> method
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    public abstract void logout() throws LoginException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     * Set a <code>CallbackHandler</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     * <p> The provider uses this handler if one is not passed to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     * <code>login</code> method.  The provider also uses this handler
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     * if it invokes <code>login</code> on behalf of callers.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     * In either case if a handler is not set via this method,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     * the provider queries the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     * <i>auth.login.defaultCallbackHandler</i> security property
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     * for the fully qualified class name of a default handler implementation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     * If the security property is not set,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     * the provider is assumed to have alternative means
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     * for obtaining authentication information.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     * @param handler a <code>CallbackHandler</code> for obtaining
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     *          authentication information, which may be <code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     * @exception SecurityException if the caller does not pass a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     *  security check for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     *  <code>SecurityPermission("authProvider.<i>name</i>")</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     *  where <i>name</i> is the value returned by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     *  this provider's <code>getName</code> method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    public abstract void setCallbackHandler(CallbackHandler handler);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
}