com.realtime.xmpp.util
Class HandshakeRequest

java.lang.Object
  |
  +--com.realtime.xmpp.util.HandshakeRequest
All Implemented Interfaces:
XmppQuery, XmppStanza

public class HandshakeRequest
extends java.lang.Object
implements XmppQuery

Simple class to represent the Handshake XMPP packet for Jabber accept components. An init() method has been included to allow a server to check if a handshake can be created before initiating communications with the Jabber server.

Version:
1.0 Copyright © 2002 Real Time Entertainment Group, LLC - All rights reserved.
Author:
Mike Prince

Field Summary
protected static java.lang.String[] HEX_CHARS
          Simple hex table lookup for converting nybbles to characters.
protected static java.security.MessageDigest m_messageDigest
          Our SHA1 encoder.
protected  java.lang.String m_sPacket
          Our SHA1 hashed handshake.
 
Constructor Summary
HandshakeRequest(java.lang.String sSessionId, java.lang.String sSecret)
          Create a handshake for a given session id and secret.
 
Method Summary
 java.lang.String asXML()
          Provide a string representation of the XMPP packet.
 java.lang.String getId()
          Handshake packets do not have an id field.
 java.lang.String hash(java.lang.String sIn)
          Generate a SHA1 hash of the string.
static void init()
          Initialize the handshake generator.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HEX_CHARS

protected static java.lang.String[] HEX_CHARS
Simple hex table lookup for converting nybbles to characters.


m_sPacket

protected java.lang.String m_sPacket
Our SHA1 hashed handshake.


m_messageDigest

protected static java.security.MessageDigest m_messageDigest
Our SHA1 encoder.

Constructor Detail

HandshakeRequest

public HandshakeRequest(java.lang.String sSessionId,
                        java.lang.String sSecret)

Create a handshake for a given session id and secret. Note that you should call verify() at some point to make sure the hash encoder is available.

If the message digest algorithm is not available, and an instance of this class is created, then the handshake packet will contain an error message.

Parameters:
sSessionId - The streams session id that was provided with the opening <stream:stream> element. * @param sSecret The secret used to validate with the server.
Method Detail

init

public static void init()
                 throws java.security.NoSuchAlgorithmException

Initialize the handshake generator.

Throws:
java.security.NoSuchAlgorithmException - Generated when the SHA1 digest is unavailable.

getId

public java.lang.String getId()

Handshake packets do not have an id field.

Specified by:
getId in interface XmppQuery
Returns:
Null because handshake packets do not have an id.

asXML

public java.lang.String asXML()

Provide a string representation of the XMPP packet.

Specified by:
asXML in interface XmppStanza
Returns:
The XML fragment representing this packet.

hash

public java.lang.String hash(java.lang.String sIn)

Generate a SHA1 hash of the string.

Parameters:
sIn - The string to hash.
Returns:
The hash of the input string.


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