Smack

org.jivesoftware.smack.sasl
Class SASLMechanism

java.lang.Object
  extended by org.jivesoftware.smack.sasl.SASLMechanism
Direct Known Subclasses:
SASLAnonymous, SASLPlainMechanism

public abstract class SASLMechanism
extends Object

Base class for SASL mechanisms. Subclasses must implement three methods:

Author:
Gaston Dombiak

Constructor Summary
SASLMechanism(SASLAuthentication saslAuthentication)
           
 
Method Summary
 void authenticate(String username, String host, String password)
          Builds and sends the auth stanza to the server.
 void challengeReceived(String challenge)
          The server is challenging the SASL mechanism for the stanza he just sent.
protected abstract  String getAuthenticationText(String username, String host, String password)
          Returns the authentication text to include in the initial auth stanza or null if nothing should be added.
protected abstract  String getChallengeResponse(byte[] bytes)
          Returns the response text to send answering the challenge sent by the server.
protected abstract  String getName()
          Returns the common name of the SASL mechanism.
protected  SASLAuthentication getSASLAuthentication()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SASLMechanism

public SASLMechanism(SASLAuthentication saslAuthentication)
Method Detail

authenticate

public void authenticate(String username,
                         String host,
                         String password)
                  throws IOException
Builds and sends the auth stanza to the server.

Parameters:
username - the username of the user being authenticated.
host - the hostname where the user account resides.
password - the password of the user.
Throws:
IOException - If a network error occures while authenticating.

challengeReceived

public void challengeReceived(String challenge)
                       throws IOException
The server is challenging the SASL mechanism for the stanza he just sent. Send a response to the server's challenge.

Parameters:
challenge - a base64 encoded string representing the challenge.
Throws:
IOException

getChallengeResponse

protected abstract String getChallengeResponse(byte[] bytes)
Returns the response text to send answering the challenge sent by the server. Mechanisms that will never receive a challenge may redefine this method returning null.

Parameters:
bytes - the challenge sent by the server.
Returns:
the response text to send to answer the challenge sent by the server.

getName

protected abstract String getName()
Returns the common name of the SASL mechanism. E.g.: PLAIN, DIGEST-MD5 or KERBEROS_V4.

Returns:
the common name of the SASL mechanism.

getAuthenticationText

protected abstract String getAuthenticationText(String username,
                                                String host,
                                                String password)
Returns the authentication text to include in the initial auth stanza or null if nothing should be added.

Parameters:
username - the username of the user being authenticated.
host - the hostname where the user account resides.
password - the password of the user.
Returns:
the authentication text to include in the initial auth stanza or null if nothing should be added.

getSASLAuthentication

protected SASLAuthentication getSASLAuthentication()

Smack

Copyright © 2003-2007 Jive Software.