com.echomine.jabber
Class JabberContext

java.lang.Object
  extended by com.echomine.jabber.JabberContext

public class JabberContext
extends java.lang.Object

The session context. It contains information such as login, password, and other session specific information.

Because the context contains session information, it also stores the session ID. The session ID is the ID sent by the server after connection is established.

If you set the username and password both to null, Jabber User Service will create an anonymous resource if the server supports it. If you don't know what it is, don't worry about it.

Also, this is the place to set whether to use SSL to connect to the jabber server for better security


Field Summary
static int DEFAULT_PORT
           
static java.lang.String DEFAULT_SERVER
           
static int DEFAULT_SSL_PORT
           
 
Constructor Summary
JabberContext(java.lang.String username, java.lang.String password, java.lang.String serverName)
          the default required parameters used by Jabber.
 
Method Summary
 java.lang.String getPassword()
           
 java.lang.String getResource()
           
 java.lang.String getServerName()
          normally, this information can be obtained from the connection model.
 JID getServerNameJID()
           
 java.lang.String getSessionID()
           
 java.lang.String getUsername()
           
 boolean isSSL()
          replies true if this is a SSL connection
 void setPassword(java.lang.String password)
           
 void setResource(java.lang.String resource)
          sets the resource name associated with this session.
 void setServerName(java.lang.String serverName)
          sets the server name that this session will connect to.
 void setSessionID(java.lang.String sessionID)
          sets the session ID (normally used only during handshake) and should not be changed
 void setSSL(boolean secure)
          switches the connection between secure and in-secure (default) connection
 void setUsername(java.lang.String username)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_SERVER

public static final java.lang.String DEFAULT_SERVER
See Also:
Constant Field Values

DEFAULT_PORT

public static final int DEFAULT_PORT
See Also:
Constant Field Values

DEFAULT_SSL_PORT

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

JabberContext

public JabberContext(java.lang.String username,
                     java.lang.String password,
                     java.lang.String serverName)
the default required parameters used by Jabber. The server name here is the canonical name for the server you're connecting to. Note that this should be the same as the hostname you're connecting to. However, if you happen to use an IP rather than the server name, you will not be able to login. This is a security check done by Jabber server itself. Thus, for instance, if you want to connect to jabber.org, then you would set the serverName as jabber.org. If you use www.jabber.org (or a different name that maps to the same IP as jabber.org, and you used www.jabber.org as the server name, then you will not be able to login to the Jabber server itself. Thus, in a way the server name is tied to the hostname you're connecting to but it may be totally different as well.

Parameters:
username - the username
password - the password for the user
serverName - the canonical name of the server name as specificied by the Jabber server itself.
Method Detail

getPassword

public java.lang.String getPassword()

setPassword

public void setPassword(java.lang.String password)

getUsername

public java.lang.String getUsername()

setUsername

public void setUsername(java.lang.String username)

setSSL

public void setSSL(boolean secure)
switches the connection between secure and in-secure (default) connection


isSSL

public boolean isSSL()
replies true if this is a SSL connection


getServerNameJID

public JID getServerNameJID()
Returns:
the server name's JID. null if the server name has not been set

getServerName

public java.lang.String getServerName()
normally, this information can be obtained from the connection model. however, a canonical name (not an IP or reverse-lookup name) is needed by the Session Service, so the host information is kept here.

Returns:
the name of the server to connect to

setServerName

public void setServerName(java.lang.String serverName)
                   throws ParseException
sets the server name that this session will connect to. If the server name cannot be properly parse, an exception will be thrown.

Throws:
ParseException

getSessionID

public java.lang.String getSessionID()
Returns:
the session id sent by the server, null if session hasn't been established yet

setSessionID

public void setSessionID(java.lang.String sessionID)
sets the session ID (normally used only during handshake) and should not be changed


getResource

public java.lang.String getResource()
Returns:
the resource name associated with this session

setResource

public void setResource(java.lang.String resource)
sets the resource name associated with this session. You can think of resource as a location or some sort of information describing your session. Examples are Home, Office, Laptop, etc.



Copyright © 2001-2005 Echomine. All Rights Reserved.