com.realtime.xmpp.dom
Class DomAcceptComponent

java.lang.Object
  |
  +--com.realtime.xmpp.util.RestartingEndpoint
        |
        +--com.realtime.xmpp.dom.DomComponent
              |
              +--com.realtime.xmpp.dom.DomAcceptComponent
All Implemented Interfaces:
XmppEndpoint
Direct Known Subclasses:
EchoComponent, GatewayComponent, TestComponent

public class DomAcceptComponent
extends DomComponent

Provide a Jabber accept component that authenticates using the handshake protocol.

Version:
1.0
Author:
Mike Prince

Nested Class Summary
 class DomAcceptComponent.AuthenticationManager
          Listener to authenticate whenever a new session is started.
 
Field Summary
protected  java.lang.Object m_authenticationMonitor
          An authentication monitor.
protected  boolean m_bAuthenticated
          True when the session has been authenticated.
protected  java.lang.String m_sSecret
          The secret key used for validation with the Jabber server.
 
Fields inherited from class com.realtime.xmpp.dom.DomComponent
m_transformer
 
Fields inherited from class com.realtime.xmpp.util.RestartingEndpoint
m_session, m_sessionRestarter, XMPP_REQUEST_TIMEOUT
 
Constructor Summary
DomAcceptComponent(java.lang.String sHost, int nPort, java.lang.String sSecret)
          Create an ACCEPT namespaced component that generates DOM packets on incoming messages.
DomAcceptComponent(XmlStreamFactory streamFactory, java.lang.String sSecret)
          Create an ACCEPT namespaced component that generates DOM packets on incoming messages.
 
Method Summary
protected  void init(java.lang.String sSecret)
          * @throws NoSuchAlgorithmException
 void start()
          Starts the component.
 void waitForAuthentication(long timeout)
          Wait for authentication to occur on the session.
 
Methods inherited from class com.realtime.xmpp.dom.DomComponent
getDomTransformer, query, send
 
Methods inherited from class com.realtime.xmpp.util.RestartingEndpoint
fastStart, getComponentName, getSession, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_sSecret

protected java.lang.String m_sSecret
The secret key used for validation with the Jabber server.


m_authenticationMonitor

protected java.lang.Object m_authenticationMonitor
An authentication monitor.


m_bAuthenticated

protected boolean m_bAuthenticated
True when the session has been authenticated.

Constructor Detail

DomAcceptComponent

public DomAcceptComponent(java.lang.String sHost,
                          int nPort,
                          java.lang.String sSecret)
                   throws java.security.NoSuchAlgorithmException

Create an ACCEPT namespaced component that generates DOM packets on incoming messages. Uses the secret to handshake with the Jabber server.

* @param sHost The host name to connect to.

Parameters:
nPort - The server port to connect to.
sSecret - The secret to validate us with the Jabber server.
Throws:
java.security.NoSuchAlgorithmException - Generated when the SHA1 digest is unavailable.

DomAcceptComponent

public DomAcceptComponent(XmlStreamFactory streamFactory,
                          java.lang.String sSecret)
                   throws java.security.NoSuchAlgorithmException

Create an ACCEPT namespaced component that generates DOM packets on incoming messages. Uses the secret to handshake with the Jabber server.

Parameters:
streamFactory - An XML connection factory.
sSecret - The secret to validate us with the Jabber server.
Throws:
java.security.NoSuchAlgorithmException - Generated when the SHA1 digest is unavailable.
Method Detail

init

protected void init(java.lang.String sSecret)
             throws java.security.NoSuchAlgorithmException
* @throws NoSuchAlgorithmException

java.security.NoSuchAlgorithmException

start

public void start()
           throws java.io.IOException

Starts the component. Opens the socket, starts XMPP streaming, and authenticates. This is a blocking call and calls waitForAuthentication() before returning. If you do not want to wait for the connection to open, call fastStart() instead.

If you are interested in the XMPP session lifecycle events, then register using getSession().addListener().

Specified by:
start in interface XmppEndpoint
Overrides:
start in class RestartingEndpoint
Throws:
java.io.IOException - Generated when the component could not start.

waitForAuthentication

public void waitForAuthentication(long timeout)
                           throws java.io.IOException

Wait for authentication to occur on the session.

Start is a NON-blocking call and will LIKELY return before session authentication has occured. If you would like to be sure authentication has occured, call this method.

Parameters:
timeout - The timeout in milliseconds before an exception is thrown.
Throws:
java.io.IOException - Generated when the authentication does not occur before the timeout expires.


Copyright © 2002,2003 Real Time Entertainment Group, LLC. All Rights Reserved.