Smack

org.jivesoftware.smack.packet
Class Authentication

java.lang.Object
  extended by org.jivesoftware.smack.packet.Packet
      extended by org.jivesoftware.smack.packet.IQ
          extended by org.jivesoftware.smack.packet.Authentication

public class Authentication
extends IQ

Authentication packet, which can be used to login to a XMPP server as well as discover login information from the server.


Nested Class Summary
 
Nested classes/interfaces inherited from class org.jivesoftware.smack.packet.IQ
IQ.Type
 
Field Summary
 
Fields inherited from class org.jivesoftware.smack.packet.Packet
DEFAULT_LANGUAGE, ID_NOT_AVAILABLE
 
Constructor Summary
Authentication()
          Create a new authentication packet.
 
Method Summary
 String getChildElementXML()
          Returns the sub-element XML section of the IQ packet, or null if there isn't one.
 String getDigest()
          Returns the password digest or null if the digest hasn't been set.
 String getPassword()
          Returns the plain text password or null if the password hasn't been set.
 String getResource()
          Returns the resource or null if the resource hasn't been set.
 String getUsername()
          Returns the username, or null if the username hasn't been sent.
 void setDigest(String digest)
          Sets the digest value directly.
 void setDigest(String connectionID, String password)
          Sets the digest value using a connection ID and password.
 void setPassword(String password)
          Sets the plain text password.
 void setResource(String resource)
          Sets the resource.
 void setUsername(String username)
          Sets the username.
 
Methods inherited from class org.jivesoftware.smack.packet.IQ
createErrorResponse, createResultIQ, getType, setType, toXML
 
Methods inherited from class org.jivesoftware.smack.packet.Packet
addExtension, deleteProperty, equals, getDefaultLanguage, getError, getExtension, getExtension, getExtensions, getExtensionsXML, getFrom, getPacketID, getProperty, getPropertyNames, getTo, getXmlns, hashCode, nextID, removeExtension, setDefaultXmlns, setError, setFrom, setPacketID, setProperty, setTo
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Authentication

public Authentication()
Create a new authentication packet. By default, the packet will be in "set" mode in order to perform an actual authentication with the server. In order to send a "get" request to get the available authentication modes back from the server, change the type of the IQ packet to "get":

setType(IQ.Type.GET);

Method Detail

getUsername

public String getUsername()
Returns the username, or null if the username hasn't been sent.

Returns:
the username.

setUsername

public void setUsername(String username)
Sets the username.

Parameters:
username - the username.

getPassword

public String getPassword()
Returns the plain text password or null if the password hasn't been set.

Returns:
the password.

setPassword

public void setPassword(String password)
Sets the plain text password.

Parameters:
password - the password.

getDigest

public String getDigest()
Returns the password digest or null if the digest hasn't been set. Password digests offer a more secure alternative for authentication compared to plain text. The digest is the hex-encoded SHA-1 hash of the connection ID plus the user's password. If the digest and password are set, digest authentication will be used. If only one value is set, the respective authentication mode will be used.

Returns:
the digest of the user's password.

setDigest

public void setDigest(String connectionID,
                      String password)
Sets the digest value using a connection ID and password. Password digests offer a more secure alternative for authentication compared to plain text. The digest is the hex-encoded SHA-1 hash of the connection ID plus the user's password. If the digest and password are set, digest authentication will be used. If only one value is set, the respective authentication mode will be used.

Parameters:
connectionID - the connection ID.
password - the password.
See Also:
Connection.getConnectionID()

setDigest

public void setDigest(String digest)
Sets the digest value directly. Password digests offer a more secure alternative for authentication compared to plain text. The digest is the hex-encoded SHA-1 hash of the connection ID plus the user's password. If the digest and password are set, digest authentication will be used. If only one value is set, the respective authentication mode will be used.

Parameters:
digest - the digest, which is the SHA-1 hash of the connection ID the user's password, encoded as hex.
See Also:
Connection.getConnectionID()

getResource

public String getResource()
Returns the resource or null if the resource hasn't been set.

Returns:
the resource.

setResource

public void setResource(String resource)
Sets the resource.

Parameters:
resource - the resource.

getChildElementXML

public String getChildElementXML()
Description copied from class: IQ
Returns the sub-element XML section of the IQ packet, or null if there isn't one. Packet extensions must be included, if any are defined.

Extensions of this class must override this method.

Specified by:
getChildElementXML in class IQ
Returns:
the child element section of the IQ XML.

Smack

Copyright © 2003-2007 Jive Software.