com.echomine.jabber.msg
Class AuthIQMessage

java.lang.Object
  extended by com.echomine.jabber.JabberMessage
      extended by com.echomine.jabber.JabberJDOMMessage
          extended by com.echomine.jabber.AbstractJabberMessage
              extended by com.echomine.jabber.JabberIQMessage
                  extended by com.echomine.jabber.msg.AuthIQMessage
All Implemented Interfaces:
JabberCode, JabberMessageParsable

public class AuthIQMessage
extends JabberIQMessage
implements JabberCode

This message object deals with all the workings of sending and receiving authentication messages. The auth message doesn't require to and from field so they're not required by this message. The outgoing auth message is synchronized by default since it requires waiting for a reply to know the status of the outgoing message. Incoming auth message is not synchronized by default since incoming message normally won't get sent out again.


Field Summary
static int AUTH_CLEARTEXT
           
static int AUTH_DIGEST
           
static int AUTH_ZERO_KNOWLEDGE
           
 
Fields inherited from class com.echomine.jabber.JabberIQMessage
TYPE_GET, TYPE_RESULT, TYPE_SET
 
Fields inherited from class com.echomine.jabber.AbstractJabberMessage
TYPE_ERROR
 
Fields inherited from class com.echomine.jabber.JabberMessage
messageID
 
Fields inherited from interface com.echomine.jabber.JabberCode
MSG_CHAT, MSG_INIT, MSG_IQ, MSG_IQ_AGENTS, MSG_IQ_AUTH, MSG_IQ_BROWSE, MSG_IQ_DISCO_INFO, MSG_IQ_DISCO_ITEMS, MSG_IQ_GATEWAY, MSG_IQ_LAST, MSG_IQ_OOB, MSG_IQ_PRIVATE, MSG_IQ_REGISTER, MSG_IQ_ROSTER, MSG_IQ_SEARCH, MSG_IQ_TIME, MSG_IQ_VACATION, MSG_IQ_VCARD, MSG_IQ_VERSION, MSG_IQ_XMLRPC, MSG_PRESENCE, MSG_UNKNOWN, MSG_X_DATA, MSG_X_DELAY, MSG_X_EVENT, MSG_X_EXPIRE, MSG_X_OOB, MSG_X_PGP_ENCRYPTED, MSG_X_PGP_SIGNED, MSG_X_ROSTER, PARSER_CHAT, PARSER_IQ, PARSER_IQ_AGENTS, PARSER_IQ_AUTH, PARSER_IQ_BROWSE, PARSER_IQ_DISCO_INFO, PARSER_IQ_DISCO_ITEMS, PARSER_IQ_GATEWAY, PARSER_IQ_LAST, PARSER_IQ_OOB, PARSER_IQ_PRIVATE, PARSER_IQ_REGISTER, PARSER_IQ_ROSTER, PARSER_IQ_SEARCH, PARSER_IQ_TIME, PARSER_IQ_VACATION, PARSER_IQ_VCARD, PARSER_IQ_VERSION, PARSER_IQ_XMLRPC, PARSER_PRESENCE, PARSER_X_DATA, PARSER_X_DELAY, PARSER_X_EVENT, PARSER_X_EXPIRE, PARSER_X_OOB, PARSER_X_PGP_ENCRYPTED, PARSER_X_PGP_SIGNED, PARSER_X_ROSTER, XMLNS_CHAT, XMLNS_ERROR_STANZA, XMLNS_ERROR_STREAM, XMLNS_IQ, XMLNS_IQ_AGENTS, XMLNS_IQ_AUTH, XMLNS_IQ_BROWSE, XMLNS_IQ_DISCO_INFO, XMLNS_IQ_DISCO_ITEMS, XMLNS_IQ_GATEWAY, XMLNS_IQ_LAST, XMLNS_IQ_OOB, XMLNS_IQ_PRIVATE, XMLNS_IQ_REGISTER, XMLNS_IQ_ROSTER, XMLNS_IQ_SEARCH, XMLNS_IQ_TIME, XMLNS_IQ_VACATION, XMLNS_IQ_VCARD, XMLNS_IQ_VERSION, XMLNS_IQ_XMLRPC, XMLNS_PRESENCE, XMLNS_STREAM, XMLNS_X_DATA, XMLNS_X_DELAY, XMLNS_X_EVENT, XMLNS_X_EXPIRE, XMLNS_X_OOB, XMLNS_X_PGP_ENCRYPTED, XMLNS_X_PGP_SIGNED, XMLNS_X_ROSTER
 
Constructor Summary
AuthIQMessage()
          this constructor is used for incoming iq:auth messages.
AuthIQMessage(java.lang.String type)
          this constructor is used for creating an initial outgoing message.
 
Method Summary
static AuthIQMessage createGetAuthMethodsMessage(JabberContext context)
          this returns a default message instance for getting authentication information.
static AuthIQMessage createLoginMessage(JabberContext context, int authType, java.lang.String zerokToken, int zerokSeq)
          creates an auth message that has everything set for sending a login message.
protected  java.lang.String getCleartextPassword(JabberContext context)
           
protected  java.lang.String getDigestPassword(JabberContext context)
          The way a digest password is computed is as follows.
 int getMessageType()
          the default message type is unknown.
 int getMostSecureAuth()
          retrieves the most secure authentication method that exists inside the reply message.
 java.lang.String getPassword(JabberContext context, int authType)
          This method checks to see which is the most secure authentication method first, and based on that, return the password for that authentication method.
protected  java.lang.String getZeroKnowledgePassword(JabberContext context, java.lang.String zerokToken, int zerokSeq)
          The way to compute zero-k password is as follows (all using SHA1).
 int getZerokSeq()
           
 java.lang.String getZerokToken()
           
 
Methods inherited from class com.echomine.jabber.AbstractJabberMessage
getErrorMessage, getFrom, getTo, getType, isError, parse, setErrorMessage, setFrom, setTo, setType
 
Methods inherited from class com.echomine.jabber.JabberJDOMMessage
encode, getDOM, getXMLOutputter, setMessageID, toString
 
Methods inherited from class com.echomine.jabber.JabberMessage
getMessageID, getReplyMessage, getTimeout, getXMessage, getXMessages, interrupt, isReplyRequired, isSendXMessages, isSynchronized, replyReceived, setReplyRequired, setSendXMessages, setSynchronized, setTimeout, setXMessage, setXMessages
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

AUTH_CLEARTEXT

public static final int AUTH_CLEARTEXT
See Also:
Constant Field Values

AUTH_DIGEST

public static final int AUTH_DIGEST
See Also:
Constant Field Values

AUTH_ZERO_KNOWLEDGE

public static final int AUTH_ZERO_KNOWLEDGE
See Also:
Constant Field Values
Constructor Detail

AuthIQMessage

public AuthIQMessage(java.lang.String type)
this constructor is used for creating an initial outgoing message. It does nothing except set the type and add in the default tag.


AuthIQMessage

public AuthIQMessage()
this constructor is used for incoming iq:auth messages. Outgoing messages should use the static methods instead.

Method Detail

getMostSecureAuth

public int getMostSecureAuth()
retrieves the most secure authentication method that exists inside the reply message. This message can only be called when the message is a "get" message type AND has already received a reply. If this did not occur, then calling this method will return the least secure authentication method by default. Thus, it is wise that you create and send this message first before using this message.

Returns:
the most secure authentication method that can be used by this server

getPassword

public java.lang.String getPassword(JabberContext context,
                                    int authType)
This method checks to see which is the most secure authentication method first, and based on that, return the password for that authentication method.

Returns:
the password for the most secure authentication method

getCleartextPassword

protected java.lang.String getCleartextPassword(JabberContext context)
Returns:
the cleartext password

getDigestPassword

protected java.lang.String getDigestPassword(JabberContext context)
The way a digest password is computed is as follows. Append the password to the Session ID (sent by the server), and then run it through a SHA1 hash algorithm. Then return the HEX representation of the hash.

Returns:
the digest password

getZeroKnowledgePassword

protected java.lang.String getZeroKnowledgePassword(JabberContext context,
                                                    java.lang.String zerokToken,
                                                    int zerokSeq)
The way to compute zero-k password is as follows (all using SHA1). Client performs a digest(password) resulting in hashA, and retrieves the token "garbagerandom" and sequence 462 from the server. The client then performs another digest(hashA + token) resulting in hash0, and then performs 461 recursive digest calls resulting in hash461. The client then sends hash461 to the server. The server receives hash461 from the client, and performs an additional hash to result in hash462, and compares it to the stored hash for that sequence#. If they match, store the hash461 from the now authenticated client as the new hash and reduce the sequence#. This feature is not supported

Returns:
the zero-knowledge password

createGetAuthMethodsMessage

public static AuthIQMessage createGetAuthMethodsMessage(JabberContext context)
this returns a default message instance for getting authentication information. It is the "get" auth message type. uses for this is normally to retrieve the available authentication methods (ie. password, digest, zero-knowledge)


createLoginMessage

public static AuthIQMessage createLoginMessage(JabberContext context,
                                               int authType,
                                               java.lang.String zerokToken,
                                               int zerokSeq)
creates an auth message that has everything set for sending a login message. Internally, it uses a set message type to create the message. Authentication will also support anonymous resource if you set the username and password both to null. If authentication is zero-knowledge authentication, you must provide the Token and the Sequence. Otherwise, you can pass in null for the values.

Parameters:
context - the context that will contains the login information
authType - the authentication type that will be used to login (valid types are listed in this class as constants)
zerokToken - the token sent by the server, required only if you're using Zero-Knowledge Authentication
zerokSeq - the sequence sent by the server, required only if you're using Zero-Knowledge Authentication

getZerokToken

public java.lang.String getZerokToken()
Returns:
the 0k token associated with the message. null if none exists

getZerokSeq

public int getZerokSeq()
Returns:
the 0k sequence associated with the message

getMessageType

public int getMessageType()
Description copied from class: JabberJDOMMessage
the default message type is unknown. It doesn't mean that there is no type. It just means that there is no known message parser for this particular object.

Overrides:
getMessageType in class JabberIQMessage
Returns:
the MSG_IQ_AUTH message type
See Also:
JabberCode


Copyright © 2001-2005 Echomine. All Rights Reserved.