net.kano.joscar.snaccmd.auth
Class AuthRequest

java.lang.Object
  extended bySnacCommand
      extended byAuthCommand
          extended byAuthRequest

public class AuthRequest
extends AuthCommand

A SNAC command used to log into the OSCAR server.

For those interested, authorization is done by sending an MD5 hash of the string formed by concatenating the authorization key, the user's password, and the string "AOL Instant Messenger (SM)". This way the user's password is never sent over an OSCAR connection.

Newer clients use a slightly different algorithm and send an extra empty 0x4c TLV to indicate that this algorithm was used. The algorithm is almost identical to the one mentioned above except that instead of using the user's password, the password's MD5 hash is used. An MD5 hash of the string formed by concatenating the authorization key, an MD5 hash of the user's password, and the string "AOL Instant Messenger (SM)" is sent. The reason for adding this extra step is unknown, as it does not appear to increase security.

As of version 0.9.3, joscar always uses the second algorithm.

See Also:
AuthResponse
Source of this SNAC:
AIM client
SNAC command type:
Family 0x17, command 0x02

Field Summary
 
Fields inherited from class AuthCommand
CMD_AUTH_REQ, CMD_AUTH_RESP, CMD_KEY_REQ, CMD_KEY_RESP, FAMILY_AUTH, FAMILY_INFO
 
Fields inherited from class SnacCommand
SNACFLAG_DEFAULT
 
Constructor Summary
protected AuthRequest(SnacPacket packet)
          Generates an auth request command from the given incoming SNAC packet.
  AuthRequest(java.lang.String sn, java.lang.String pass, ClientVersionInfo version, ByteBlock key)
          Creates an outgoing authorization request command with the given screenname, password, client version, and authorization key, and with the JVM's current locale.
  AuthRequest(java.lang.String sn, java.lang.String pass, ClientVersionInfo version, java.util.Locale locale, ByteBlock key)
          Creates an outgoing authorization request command with the given screenname, password, client version, locale, and authorization key.
 
Method Summary
 ByteBlock getEncryptedPass()
          The raw encrypted password sent in this authorization request.
 java.util.Locale getLocale()
          Returns the user's locale.
 java.lang.String getScreenname()
          Returns the screen name whose login is being attempted.
 ClientVersionInfo getVersionInfo()
          Returns the user's client information block.
 boolean isPassHashed()
          Returns whether the password was encoded as its MD5 hash.
 java.lang.String toString()
           
 void writeData(java.io.OutputStream out)
          Writes this command's SNAC data block to the given stream.
 
Methods inherited from class SnacCommand
getCommand, getFamily, getFlag1, getFlag2
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AuthRequest

protected AuthRequest(SnacPacket packet)
Generates an auth request command from the given incoming SNAC packet.

Parameters:
packet - an authorization request SNAC packet

AuthRequest

public AuthRequest(java.lang.String sn,
                   java.lang.String pass,
                   ClientVersionInfo version,
                   ByteBlock key)
Creates an outgoing authorization request command with the given screenname, password, client version, and authorization key, and with the JVM's current locale.

Calling this method is equivalent to calling new AuthRequest(sn, pass, version, Locale.getDefault(), key).

Parameters:
sn - the user's screenname
pass - the user's password
version - a client information block
key - an authorization key block provided by the server in a KeyResponse

AuthRequest

public AuthRequest(java.lang.String sn,
                   java.lang.String pass,
                   ClientVersionInfo version,
                   java.util.Locale locale,
                   ByteBlock key)
Creates an outgoing authorization request command with the given screenname, password, client version, locale, and authorization key.

Parameters:
sn - the user's screenname
pass - the user's password
version - a client information block
locale - the user's locale
key - an authorization key block provided by the server in a KeyResponse
Method Detail

getScreenname

public final java.lang.String getScreenname()
Returns the screen name whose login is being attempted.

Returns:
the user's screen name

getVersionInfo

public final ClientVersionInfo getVersionInfo()
Returns the user's client information block.

Returns:
the user's client version information

getLocale

public final java.util.Locale getLocale()
Returns the user's locale.

Returns:
the user's locale

getEncryptedPass

public final ByteBlock getEncryptedPass()
The raw encrypted password sent in this authorization request.

Returns:
the user's password, encrypted

isPassHashed

public final boolean isPassHashed()
Returns whether the password was encoded as its MD5 hash.

Returns:
whether the password was encoded as its MD5 hash

writeData

public void writeData(java.io.OutputStream out)
               throws java.io.IOException
Description copied from class: SnacCommand
Writes this command's SNAC data block to the given stream. The SNAC data block is the data after the first ten bytes of a SNAC packet.

Specified by:
writeData in class SnacCommand
Parameters:
out - the stream to which to write the SNAC data
Throws:
java.io.IOException - if an I/O error occurs

toString

public java.lang.String toString()