Package jadex.bdi.planlib.messaging
Class AIM
- java.lang.Object
- 
- jadex.bdi.planlib.messaging.AIM
 
- 
 public class AIM extends java.lang.ObjectAIM The class provides utilities to connect to the AIM instant messaging network and send messages using TOC version 2.
- 
- 
Field SummaryFields Modifier and Type Field Description java.lang.StringauthHostThe OSCAR authentication server.intauthPortThe OSCAR authentication server's port.protected java.net.SocketconnectionThe connection to the TOC server.static intDATAThe ID number for a DATA packet (flap).protected java.lang.StringidScreen name of current user.protected java.io.InputStreamisAn InputStream to the connection.java.lang.StringlanguageWhat language to use.protected java.io.OutputStreamosAn OutputStream to the connection.java.lang.StringroastStringThe string used to "roast" passwords.protected shortsequenceThe sequence number used for FLAP packets.static intSIGNONThe ID number for a SIGNON packet(FLAP).java.lang.StringtocHostThe host address of the TOC server.inttocPortThe port used to connect to the TOC server.java.lang.StringversionThe version of the client.
 - 
Constructor SummaryConstructors Constructor Description AIM(java.lang.String id, java.lang.String password)Constructor for AIM.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description protected intcalculateCode(java.lang.String uid, java.lang.String pwd)Calculate a login security code from the user id and password.protected java.lang.Stringencode(java.lang.String str)Called to encode a message.java.lang.StringgetError()Getter for errorprotected java.lang.StringgetFlap()Get a FLAP packetbooleanisLoggedin()Getter for loggedinbooleanlogin(java.lang.String id, java.lang.String password)Log in to TOCvoidlogout()Logout of toc and close the socketprotected java.lang.Stringnormalize(java.lang.String name)Called to normalize a screen name.protected java.lang.StringroastPassword(java.lang.String str)Called to roast the password.voidsend(java.lang.String to, java.lang.String msg)Send a IMprotected voidsendFlap(int type, java.lang.String str)Send a FLAP packetprotected voidsendFlapSignon()Send a FLAP signon packetprotected voidsendRaw(java.lang.String str)Send a string over the socket as raw bytesprotected voidwriteWord(short word)Write a little endian word
 
- 
- 
- 
Field Detail- 
tocHostpublic java.lang.String tocHost The host address of the TOC server.
 - 
tocPortpublic int tocPort The port used to connect to the TOC server.
 - 
authHostpublic java.lang.String authHost The OSCAR authentication server.
 - 
authPortpublic int authPort The OSCAR authentication server's port.
 - 
languagepublic java.lang.String language What language to use.
 - 
versionpublic java.lang.String version The version of the client.
 - 
roastStringpublic java.lang.String roastString The string used to "roast" passwords. See the roastPassword method for more info.
 - 
sequenceprotected short sequence The sequence number used for FLAP packets.
 - 
connectionprotected java.net.Socket connection The connection to the TOC server.
 - 
isprotected java.io.InputStream is An InputStream to the connection.
 - 
osprotected java.io.OutputStream os An OutputStream to the connection.
 - 
idprotected java.lang.String id Screen name of current user.
 - 
SIGNONpublic static final int SIGNON The ID number for a SIGNON packet(FLAP).- See Also:
- Constant Field Values
 
 - 
DATApublic static final int DATA The ID number for a DATA packet (flap).- See Also:
- Constant Field Values
 
 
- 
 - 
Method Detail- 
loginpublic boolean login(java.lang.String id, java.lang.String password)Log in to TOC- Parameters:
- id- The screen name to login with
- password- The screen name's password
- Returns:
- true on success
 
 - 
logoutpublic void logout() Logout of toc and close the socket
 - 
roastPasswordprotected java.lang.String roastPassword(java.lang.String str) Called to roast the password. Passwords are roasted when sent to the host. This is done so they aren't sent in "clear text" over the wire, although they are still trivial to decode. Roasting is performed by first xoring each byte in the password with the equivalent modulo byte in the roasting string. The result is then converted to ascii hex, and prepended with "0x". So for example the password "password" roasts to "0x2408105c23001130"- Parameters:
- str- The password to roast
- Returns:
- The password roasted
 
 - 
calculateCodeprotected int calculateCode(java.lang.String uid, java.lang.String pwd)Calculate a login security code from the user id and password.- Parameters:
- uid- The user id to encode
- pwd- The password to encoude
- Returns:
- The code, which is used to login
 
 - 
sendRawprotected void sendRaw(java.lang.String str) throws java.io.IOExceptionSend a string over the socket as raw bytes- Parameters:
- str- The string to send
- Throws:
- java.io.IOException
 
 - 
writeWordprotected void writeWord(short word) throws java.io.IOExceptionWrite a little endian word- Parameters:
- word- A word to write
- Throws:
- java.io.IOException
 
 - 
sendFlapSignonprotected void sendFlapSignon() throws java.io.IOExceptionSend a FLAP signon packet- Throws:
- java.io.IOException
 
 - 
sendFlapprotected void sendFlap(int type, java.lang.String str) throws java.io.IOExceptionSend a FLAP packet- Parameters:
- type- The type DATA or SIGNON
- str- The string message to send
- Throws:
- java.io.IOException
 
 - 
getFlapprotected java.lang.String getFlap() throws java.io.IOExceptionGet a FLAP packet- Returns:
- The data as a string
- Throws:
- java.io.IOException
 
 - 
sendpublic void send(java.lang.String to, java.lang.String msg)Send a IM- Parameters:
- to- Screen name to send an IM to
- msg- The instant message
 
 - 
normalizeprotected java.lang.String normalize(java.lang.String name) Called to normalize a screen name. This removes all spaces and converts the name to lower case.- Parameters:
- name- The screen name
- Returns:
- The normalized screen name
 
 - 
encodeprotected java.lang.String encode(java.lang.String str) 
 
- 
 
-