com.jabberwookie
Class Client2Server

java.lang.Object
  |
  +--com.jabberwookie.Stream
        |
        +--com.jabberwookie.Client2Server

public class Client2Server
extends Stream

This implements the most common form of Jabber stream. That of a client (user) connecting to the server (usually for IM).

Author:
smeiners

Field Summary
static int LOGIN_BAD_PASS
           
static int LOGIN_BAD_UID
           
static int LOGIN_FAILED
           
static int LOGIN_OK
           
static int LOGIN_PASS_EXP
           
 
Fields inherited from class com.jabberwookie.Stream
chunkProcessor, chunkQueue, connected, connectionId, DEBUG, in, iqListener, mListener, ns, out, outWriter, parserT, pListener, processor, PROCESSOR_WAIT_TIME, unListener, waitingIds
 
Constructor Summary
Client2Server(java.io.InputStream in, java.io.OutputStream out)
          Creates a new instance of Client2Server.
Client2Server(java.io.InputStream in, java.io.OutputStream out, Processor processor)
          Creates a new instance of Client2Server.
 
Method Summary
 void close()
          Closes down the stream.
 void docStart(java.lang.String tag, java.util.Hashtable attrs)
          Overrides the docStart from Stream in order to catch the server name.
 java.lang.String getServerName()
          Gets the name of the server as returned by the server.
 int login(java.lang.String userName, java.lang.String resource, java.lang.String password, int minLevel, int maxLevel, int timeOut)
          Will login with the specified authentication mechanisms.
 int loginAny(java.lang.String userName, java.lang.String resource, java.lang.String password, int timeOut)
          Logs in useing any suppored authentication mechanism, in the order of most to least secure.
 int loginDigest(java.lang.String userName, java.lang.String resource, java.lang.String password, int timeOut)
          Attempts to login via digest authentication or stronger only.
 int loginZeroK(java.lang.String userName, java.lang.String resource, java.lang.String password, int timeOut)
          Attempts to login with Zero Knowledge authentication only.
 boolean open(java.lang.String serverName, int timeoutMillis)
          Opens the stream, but does not login.
 
Methods inherited from class com.jabberwookie.Stream
cData, chunkStart, chunkStop, docStop, dtdData, elementStart, elementStop, getConnectionId, isConnected, processChunk, processingInstruction, send, send, setAllListeners, setIQListener, setMessageListener, setNamespaces, setPresenceListener, setProcessor, setUnrecogizedChunkListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOGIN_BAD_PASS

public static final int LOGIN_BAD_PASS
See Also:
Constant Field Values

LOGIN_BAD_UID

public static final int LOGIN_BAD_UID
See Also:
Constant Field Values

LOGIN_FAILED

public static final int LOGIN_FAILED
See Also:
Constant Field Values

LOGIN_OK

public static final int LOGIN_OK
See Also:
Constant Field Values

LOGIN_PASS_EXP

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

Client2Server

public Client2Server(java.io.InputStream in,
                     java.io.OutputStream out)
Creates a new instance of Client2Server. Since this class doesn't understand what a Socket is you'll have to open one youself and then pass in the input and output stream.


Client2Server

public Client2Server(java.io.InputStream in,
                     java.io.OutputStream out,
                     Processor processor)
Creates a new instance of Client2Server. Since this class doesn't understand what a Socket is you'll have to open one youself and then pass in the input and output stream. Please see the documentation for Stream.Stream(InputStream,OutputStream,Processor) and Stream.setProcessor(Processor) for more information about the Processor.

Method Detail

getServerName

public java.lang.String getServerName()
Gets the name of the server as returned by the server.


open

public boolean open(java.lang.String serverName,
                    int timeoutMillis)
             throws java.io.IOException
Opens the stream, but does not login. Use login(java.lang.String, java.lang.String, java.lang.String, int, int, int) to do that.

Specified by:
open in class Stream
Parameters:
serverName -
timeoutMillis -
Returns:
Throws:
java.io.IOException
See Also:
Stream.open(java.lang.String, int)

close

public void close()
Closes down the stream. And effectivly logs out.

Specified by:
close in class Stream

docStart

public void docStart(java.lang.String tag,
                     java.util.Hashtable attrs)
Overrides the docStart from Stream in order to catch the server name.

Overrides:
docStart in class Stream

loginAny

public int loginAny(java.lang.String userName,
                    java.lang.String resource,
                    java.lang.String password,
                    int timeOut)
Logs in useing any suppored authentication mechanism, in the order of most to least secure.

Parameters:
userName - Full JID (minus the resource)
resource -
password -
timeOut - How long to wait before giving up.
Returns:
One of the following: LOGIN_BAD_PASS, LOGIN_BAD_UID, LOGIN_FAILED, LOGIN_PASS_EXP, or LOGIN_OK.

loginDigest

public int loginDigest(java.lang.String userName,
                       java.lang.String resource,
                       java.lang.String password,
                       int timeOut)
Attempts to login via digest authentication or stronger only.

Parameters:
userName - Full JID (minus the resource)
resource -
password -
timeOut - How long to wait before giving up.
Returns:
One of the following: LOGIN_BAD_PASS, LOGIN_BAD_UID, LOGIN_FAILED, LOGIN_PASS_EXP, or LOGIN_OK.

loginZeroK

public int loginZeroK(java.lang.String userName,
                      java.lang.String resource,
                      java.lang.String password,
                      int timeOut)
Attempts to login with Zero Knowledge authentication only.

Parameters:
userName - Full JID (minus the resource)
resource -
password -
timeOut - How long to wait before giving up.
Returns:
One of the following: LOGIN_BAD_PASS, LOGIN_BAD_UID, LOGIN_FAILED, LOGIN_PASS_EXP, or LOGIN_OK.

login

public int login(java.lang.String userName,
                 java.lang.String resource,
                 java.lang.String password,
                 int minLevel,
                 int maxLevel,
                 int timeOut)
Will login with the specified authentication mechanisms.

Parameters:
userName - Full JID (minus the resource)
resource -
password -
minLevel - The minimum requested authentication level. One of IQAuth.LEVEL_PLAINTEXT, IQAuth.LEVEL_DIGEST, or IQAuth.LEVEL_ZERO_K.
maxLevel - The maximum requested authentication level. One of IQAuth.LEVEL_PLAINTEXT, IQAuth.LEVEL_DIGEST, or IQAuth.LEVEL_ZERO_K.
timeOut - How long to wait before giving up.
Returns:
One of the following: LOGIN_BAD_PASS, LOGIN_BAD_UID, LOGIN_FAILED, LOGIN_PASS_EXP, or LOGIN_OK.