3 import java.util.Hashtable;
4 import javax.security.auth.callback.*;
9 private static SaslClientFactory client_factory = null;
10 private static SaslServerFactory server_factory = null;
13 Creates a SaslClient using the parameters supplied. It returns null
14 if no SaslClient can be created using the parameters supplied. Throws
15 SaslException if it cannot create a SaslClient because of an error.
17 The algorithm for selection is as follows:
19 1. If a factory has been installed via setSaslClientFactory(), try it
20 first. If non-null answer produced, return it.
21 2. Use the packages listed in the javax.security.sasl.client.pkgs
22 property from props to load in a factory and try to create a
23 SaslClient, by looking for a class named ClientFactory. Repeat
24 this for each package on the list until a non-null answer is
25 produced. If non-null answer produced, return it.
26 3. Repeat previous step using the javax.security.sasl.client.pkgs
28 4. If no non-null answer produced, return null.
32 mechanisms The non-null list of mechanism names to try. Each
33 is the IANA-registered name of a SASL mechanism.
34 (e.g. "GSSAPI", "CRAM-MD5").
38 authorizationID The possibly null protocol-dependent
39 identification to be used for authorization, e.g.
40 user name or distinguished name. When the SASL
41 authentication completes successfully, the entity
42 named by authorizationId is granted access. If
43 null, access is granted to a protocol-dependent
44 default (for example, in LDAP this is the DN in
47 protocol The non-null string name of the protocol for
48 which the authentication is being performed, e.g
51 serverName The non-null fully qualified host name of the
52 server to authenticate to.
54 props The possibly null additional configuration
55 properties for the session, e.g.
59 public static SaslClient
60 createSaslClient(String[] mechanisms,
61 String authorizationID,
65 javax.security.auth.callback.CallbackHandler cbh) throws SaslException
67 if (client_factory == null)
69 client_factory = new ClientFactory();
72 return client_factory.createSaslClient(mechanisms,
80 public static void setSaslClientFactory(SaslClientFactory fac) {
84 public static void setSaslServerFactory(SaslServerFactory fac) {
89 public static SaslServer CreateSaslServer(String mechanism,
93 javax.security.auth.callback.CallbackHandler cbh)
96 if (server_factory == null)
98 server_factory = new ServerFactory();
101 return server_factory.createSaslServer(mechanism,
108 public static String[] getMechanismNames()
110 if (server_factory == null)
112 server_factory = new ServerFactory();
115 return server_factory.getMechanismNames();