Class Sasl

java.lang.Object
com.netscape.sasl.Sasl

public class Sasl extends Object
A static class for creating SASL clients and servers.

This class defines the policy of how to locate, load, and instantiate SASL clients and servers. Currently, only the client methods are available.

For example, an application or library gets a SASL client by doing something like:

 SaslClient sc = Sasl.createSaslClient(mechanisms,
     authorizationId, protocol, serverName, props, callbackHandler);
It can then proceed to use the client create an authentication connection. For example, an LDAP library might use the client as follows:

 InputStream is = ldap.getInputStream();
 OutputStream os = ldap.getOutputStream();
 byte[] toServer = sc.createInitialResponse();
 LdapResult res = ldap.sendBindRequest(dn, sc.getName(), toServer);
 while (!sc.isComplete() && res.status == SASL_BIND_IN_PROGRESS) {
     toServer = sc.evaluateChallenge(res.getBytesFromServer());
     if (toServer != null) {
        res = ldap.sendBindRequest(dn, sc.getName(), toServer);
     }
 }
 if (sc.isComplete() && res.status == SUCCESS) {
     // Get the input and output streams; may be unchanged
     is = sc.getInputStream( is );
     os = sc.getOutputStream( os );
     // Use these streams from now on
     ldap.setInputStream( is );
     ldap.setOutputStream( os );
 }
 
IMPLEMENTATION NOTE: To use this class on JDK1.2, the caller needs:
  • java.lang.RuntimePermission("getSecurityManager")
  • java.lang.RuntimePermission("getClassLoader")
  • java.util.PropertyPermission("javax.security.sasl.client.pkgs", "read");