src/java.security.sasl/share/classes/javax/security/sasl/SaslServerFactory.java
author erikj
Tue, 12 Sep 2017 19:03:39 +0200
changeset 47216 71c04702a3d5
parent 25859 jdk/src/java.security.sasl/share/classes/javax/security/sasl/SaslServerFactory.java@3317bb8137f4
permissions -rw-r--r--
8187443: Forest Consolidation: Move files to unified layout Reviewed-by: darcy, ihse
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
18830
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 14342
diff changeset
     2
 * Copyright (c) 2000, 2013, 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 javax.security.sasl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.util.Map;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import javax.security.auth.callback.CallbackHandler;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
/**
18830
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 14342
diff changeset
    32
 * An interface for creating instances of {@code SaslServer}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * A class that implements this interface
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * must be thread-safe and handle multiple simultaneous
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * requests. It must also have a public constructor that accepts no
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * argument.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 *<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * This interface is not normally accessed directly by a server, which will use the
18830
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 14342
diff changeset
    39
 * {@code Sasl} static methods
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * instead. However, a particular environment may provide and install a
18830
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 14342
diff changeset
    41
 * new or different {@code SaslServerFactory}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * @see SaslServer
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * @see Sasl
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * @author Rosanna Lee
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * @author Rob Weltman
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
public abstract interface SaslServerFactory {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    /**
18830
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 14342
diff changeset
    53
     * Creates a {@code SaslServer} using the parameters supplied.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
     * It returns null
18830
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 14342
diff changeset
    55
     * if no {@code SaslServer} can be created using the parameters supplied.
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 14342
diff changeset
    56
     * Throws {@code SaslException} if it cannot create a {@code SaslServer}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
     * because of an error.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
     * @param mechanism The non-null
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
     * IANA-registered name of a SASL mechanism. (e.g. "GSSAPI", "CRAM-MD5").
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
     * @param protocol The non-null string name of the protocol for which
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
     * the authentication is being performed (e.g., "ldap").
14340
e150cbaf584e 7110803: SASL service for multiple hostnames
weijun
parents: 5506
diff changeset
    63
     * @param serverName The fully qualified host name of the server to
e150cbaf584e 7110803: SASL service for multiple hostnames
weijun
parents: 5506
diff changeset
    64
     * authenticate to, or null if the server is not bound to any specific host
e150cbaf584e 7110803: SASL service for multiple hostnames
weijun
parents: 5506
diff changeset
    65
     * name. If the mechanism does not allow an unbound server, a
18830
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 14342
diff changeset
    66
     * {@code SaslException} will be thrown.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
     * @param props The possibly null set of properties used to select the SASL
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
     * mechanism and to configure the authentication exchange of the selected
18830
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 14342
diff changeset
    69
     * mechanism. See the {@code Sasl} class for a list of standard properties.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
     * Other, possibly mechanism-specific, properties can be included.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
     * Properties not relevant to the selected mechanism are ignored,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     * including any map entries with non-String keys.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     * @param cbh The possibly null callback handler to used by the SASL
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     * mechanisms to get further information from the application/library
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     * to complete the authentication. For example, a SASL mechanism might
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     * require the authentication ID, password and realm from the caller.
18830
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 14342
diff changeset
    78
     * The authentication ID is requested by using a {@code NameCallback}.
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 14342
diff changeset
    79
     * The password is requested by using a {@code PasswordCallback}.
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 14342
diff changeset
    80
     * The realm is requested by using a {@code RealmChoiceCallback} if there is a list
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 14342
diff changeset
    81
     * of realms to choose from, and by using a {@code RealmCallback} if
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     * the realm must be entered.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     *
18830
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 14342
diff changeset
    84
     *@return A possibly null {@code SaslServer} created using the parameters
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 14342
diff changeset
    85
     * supplied. If null, this factory cannot produce a {@code SaslServer}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     * using the parameters supplied.
18830
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 14342
diff changeset
    87
     *@exception SaslException If cannot create a {@code SaslServer} because
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     * of an error.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    public abstract SaslServer createSaslServer(
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
        String mechanism,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
        String protocol,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
        String serverName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
        Map<String,?> props,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
        CallbackHandler cbh) throws SaslException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     * Returns an array of names of mechanisms that match the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     * mechanism selection policies.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     * @param props The possibly null set of properties used to specify the
18830
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 14342
diff changeset
   101
     * security policy of the SASL mechanisms. For example, if {@code props}
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 14342
diff changeset
   102
     * contains the {@code Sasl.POLICY_NOPLAINTEXT} property with the value
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 14342
diff changeset
   103
     * {@code "true"}, then the factory must not return any SASL mechanisms
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     * that are susceptible to simple plain passive attacks.
18830
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 14342
diff changeset
   105
     * See the {@code Sasl} class for a complete list of policy properties.
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 14342
diff changeset
   106
     * Non-policy related properties, if present in {@code props}, are ignored,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     * including any map entries with non-String keys.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     * @return A non-null array containing a IANA-registered SASL mechanism names.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    public abstract String[] getMechanismNames(Map<String,?> props);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
}