Class AIM


  • public class AIM
    extends java.lang.Object
    AIM The class provides utilities to connect to the AIM instant messaging network and send messages using TOC version 2.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      java.lang.String authHost
      The OSCAR authentication server.
      int authPort
      The OSCAR authentication server's port.
      protected java.net.Socket connection
      The connection to the TOC server.
      static int DATA
      The ID number for a DATA packet (flap).
      protected java.lang.String id
      Screen name of current user.
      protected java.io.InputStream is
      An InputStream to the connection.
      java.lang.String language
      What language to use.
      protected java.io.OutputStream os
      An OutputStream to the connection.
      java.lang.String roastString
      The string used to "roast" passwords.
      protected short sequence
      The sequence number used for FLAP packets.
      static int SIGNON
      The ID number for a SIGNON packet(FLAP).
      java.lang.String tocHost
      The host address of the TOC server.
      int tocPort
      The port used to connect to the TOC server.
      java.lang.String version
      The version of the client.
    • Constructor Summary

      Constructors 
      Constructor Description
      AIM​(java.lang.String id, java.lang.String password)
      Constructor for AIM.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected int calculateCode​(java.lang.String uid, java.lang.String pwd)
      Calculate a login security code from the user id and password.
      protected java.lang.String encode​(java.lang.String str)
      Called to encode a message.
      java.lang.String getError()
      Getter for error
      protected java.lang.String getFlap()
      Get a FLAP packet
      boolean isLoggedin()
      Getter for loggedin
      boolean login​(java.lang.String id, java.lang.String password)
      Log in to TOC
      void logout()
      Logout of toc and close the socket
      protected java.lang.String normalize​(java.lang.String name)
      Called to normalize a screen name.
      protected java.lang.String roastPassword​(java.lang.String str)
      Called to roast the password.
      void send​(java.lang.String to, java.lang.String msg)
      Send a IM
      protected void sendFlap​(int type, java.lang.String str)
      Send a FLAP packet
      protected void sendFlapSignon()
      Send a FLAP signon packet
      protected void sendRaw​(java.lang.String str)
      Send a string over the socket as raw bytes
      protected void writeWord​(short word)
      Write a little endian word
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • tocHost

        public java.lang.String tocHost
        The host address of the TOC server.
      • tocPort

        public int tocPort
        The port used to connect to the TOC server.
      • authHost

        public java.lang.String authHost
        The OSCAR authentication server.
      • authPort

        public int authPort
        The OSCAR authentication server's port.
      • language

        public java.lang.String language
        What language to use.
      • version

        public java.lang.String version
        The version of the client.
      • roastString

        public java.lang.String roastString
        The string used to "roast" passwords. See the roastPassword method for more info.
      • sequence

        protected short sequence
        The sequence number used for FLAP packets.
      • connection

        protected java.net.Socket connection
        The connection to the TOC server.
      • is

        protected java.io.InputStream is
        An InputStream to the connection.
      • os

        protected java.io.OutputStream os
        An OutputStream to the connection.
      • id

        protected java.lang.String id
        Screen name of current user.
      • SIGNON

        public static final int SIGNON
        The ID number for a SIGNON packet(FLAP).
        See Also:
        Constant Field Values
      • DATA

        public static final int DATA
        The ID number for a DATA packet (flap).
        See Also:
        Constant Field Values
    • Constructor Detail

      • AIM

        public AIM​(java.lang.String id,
                   java.lang.String password)
        Constructor for AIM.
        Parameters:
        id -
        password -
    • Method Detail

      • login

        public 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
      • logout

        public void logout()
        Logout of toc and close the socket
      • roastPassword

        protected 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
      • calculateCode

        protected 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
      • sendRaw

        protected void sendRaw​(java.lang.String str)
                        throws java.io.IOException
        Send a string over the socket as raw bytes
        Parameters:
        str - The string to send
        Throws:
        java.io.IOException
      • writeWord

        protected void writeWord​(short word)
                          throws java.io.IOException
        Write a little endian word
        Parameters:
        word - A word to write
        Throws:
        java.io.IOException
      • sendFlapSignon

        protected void sendFlapSignon()
                               throws java.io.IOException
        Send a FLAP signon packet
        Throws:
        java.io.IOException
      • sendFlap

        protected void sendFlap​(int type,
                                java.lang.String str)
                         throws java.io.IOException
        Send a FLAP packet
        Parameters:
        type - The type DATA or SIGNON
        str - The string message to send
        Throws:
        java.io.IOException
      • getFlap

        protected java.lang.String getFlap()
                                    throws java.io.IOException
        Get a FLAP packet
        Returns:
        The data as a string
        Throws:
        java.io.IOException
      • send

        public 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
      • normalize

        protected 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
      • encode

        protected java.lang.String encode​(java.lang.String str)
        Called to encode a message. Convert carige returns to
        Parameters:
        str - The string to be encoded
        Returns:
        The string encoded
      • getError

        public java.lang.String getError()
        Getter for error
        Returns:
        Returns error.
      • isLoggedin

        public boolean isLoggedin()
        Getter for loggedin
        Returns:
        Returns loggedin.