Path: blob/master/src/java.security.sasl/share/classes/javax/security/sasl/SaslServerFactory.java
41159 views
/*1* Copyright (c) 2000, 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 SaslServer}.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 server, which will use the38* {@code Sasl} static methods39* instead. However, a particular environment may provide and install a40* new or different {@code SaslServerFactory}.41*42* @since 1.543*44* @see SaslServer45* @see Sasl46*47* @author Rosanna Lee48* @author Rob Weltman49*/50public abstract interface SaslServerFactory {51/**52* Creates a {@code SaslServer} using the parameters supplied.53* It returns null54* if no {@code SaslServer} can be created using the parameters supplied.55* Throws {@code SaslException} if it cannot create a {@code SaslServer}56* because of an error.57*58* @param mechanism The non-null59* IANA-registered name of a SASL mechanism. (e.g. "GSSAPI", "CRAM-MD5").60* @param protocol The non-null string name of the protocol for which61* the authentication is being performed (e.g., "ldap").62* @param serverName The fully qualified host name of the server to63* authenticate to, or null if the server is not bound to any specific host64* name. If the mechanism does not allow an unbound server, a65* {@code SaslException} will be thrown.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 SaslServer} created using the parameters84* supplied. If null, this factory cannot produce a {@code SaslServer}85* using the parameters supplied.86*@exception SaslException If cannot create a {@code SaslServer} because87* of an error.88*/89public abstract SaslServer createSaslServer(90String mechanism,91String protocol,92String serverName,93Map<String,?> props,94CallbackHandler cbh) throws SaslException;9596/**97* Returns an array of names of mechanisms that match the specified98* mechanism selection policies.99* @param props The possibly null set of properties used to specify the100* security policy of the SASL mechanisms. For example, if {@code props}101* contains the {@code Sasl.POLICY_NOPLAINTEXT} property with the value102* {@code "true"}, then the factory must not return any SASL mechanisms103* that are susceptible to simple plain passive attacks.104* See the {@code Sasl} class for a complete list of policy properties.105* Non-policy related properties, if present in {@code props}, are ignored,106* including any map entries with non-String keys.107* @return A non-null array containing a IANA-registered SASL mechanism names.108*/109public abstract String[] getMechanismNames(Map<String,?> props);110}111112113