Path: blob/master/src/java.security.sasl/share/classes/javax/security/sasl/SaslClientFactory.java
41159 views
/*1* Copyright (c) 1999, 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 javax.security.sasl;2627import java.util.Map;28import javax.security.auth.callback.CallbackHandler;2930/**31* An interface for creating instances of {@code SaslClient}.32* A class that implements this interface33* must be thread-safe and handle multiple simultaneous34* requests. It must also have a public constructor that accepts no35* argument.36*<p>37* This interface is not normally accessed directly by a client, which will use the38* {@code Sasl} static methods39* instead. However, a particular environment may provide and install a40* new or different {@code SaslClientFactory}.41*42* @since 1.543*44* @see SaslClient45* @see Sasl46*47* @author Rosanna Lee48* @author Rob Weltman49*/50public abstract interface SaslClientFactory {51/**52* Creates a SaslClient using the parameters supplied.53*54* @param mechanisms The non-null list of mechanism names to try. Each is the55* IANA-registered name of a SASL mechanism. (e.g. "GSSAPI", "CRAM-MD5").56* @param authorizationId The possibly null protocol-dependent57* identification to be used for authorization.58* If null or empty, the server derives an authorization59* ID from the client's authentication credentials.60* When the SASL authentication completes successfully,61* the specified entity is granted access.62* @param protocol The non-null string name of the protocol for which63* the authentication is being performed (e.g., "ldap").64* @param serverName The non-null fully qualified host name65* of the server to authenticate to.66* @param props The possibly null set of properties used to select the SASL67* mechanism and to configure the authentication exchange of the selected68* mechanism. See the {@code Sasl} class for a list of standard properties.69* Other, possibly mechanism-specific, properties can be included.70* Properties not relevant to the selected mechanism are ignored,71* including any map entries with non-String keys.72*73* @param cbh The possibly null callback handler to used by the SASL74* mechanisms to get further information from the application/library75* to complete the authentication. For example, a SASL mechanism might76* require the authentication ID, password and realm from the caller.77* The authentication ID is requested by using a {@code NameCallback}.78* The password is requested by using a {@code PasswordCallback}.79* The realm is requested by using a {@code RealmChoiceCallback} if there is a list80* of realms to choose from, and by using a {@code RealmCallback} if81* the realm must be entered.82*83*@return A possibly null {@code SaslClient} created using the parameters84* supplied. If null, this factory cannot produce a {@code SaslClient}85* using the parameters supplied.86*@exception SaslException If cannot create a {@code SaslClient} because87* of an error.88*/89public abstract SaslClient createSaslClient(90String[] mechanisms,91String authorizationId,92String protocol,93String serverName,94Map<String,?> props,95CallbackHandler cbh) throws SaslException;9697/**98* Returns an array of names of mechanisms that match the specified99* mechanism selection policies.100* @param props The possibly null set of properties used to specify the101* security policy of the SASL mechanisms. For example, if {@code props}102* contains the {@code Sasl.POLICY_NOPLAINTEXT} property with the value103* {@code "true"}, then the factory must not return any SASL mechanisms104* that are susceptible to simple plain passive attacks.105* See the {@code Sasl} class for a complete list of policy properties.106* Non-policy related properties, if present in {@code props}, are ignored,107* including any map entries with non-String keys.108* @return A non-null array containing a IANA-registered SASL mechanism names.109*/110public abstract String[] getMechanismNames(Map<String,?> props);111}112113114