org.jabber.jabberbeans.serverside
Class Launcher

java.lang.Object
  |
  +--org.jabber.jabberbeans.serverside.Launcher

public class Launcher
extends java.lang.Object

Launcher is some simple code to negotiate a connection with a Jabber server as a component. After negotiation, it launches a component. Important: a base_exec connection uses stdin/stdout for communication. It is very important that System.err is used over System.out, as System.out will be considered outgoing data to the server.

Version:
$Revision: 1.1.1.1 $
Author:
David Waite <dwaite@jabber.com>, $Author: lucky $

Inner Class Summary
private  class Launcher.HandshakeValidator
          HandshakeValidator does validation of a key sent incoming, for instance on a base_connect.
 
Field Summary
(package private)  boolean bAccept
          true if we are running a 'base_accept' connection
private static java.lang.String BASE_ACCEPT_XMLNS
           
private static java.lang.String BASE_EXEC_XMLNS
           
(package private)  boolean bConnect
          true if we are running a 'base_connect' connection
(package private)  boolean bExec
          true if we are running a 'base_exec' connection
(package private)  ConnectionBean cb
          connection object
private static java.lang.String HANDSHAKE_TIMEOUT
           
(package private)  java.lang.String host
          local component name
(package private)  int port
          port on server that we connect to with base_accept, or port we listen on with base_connect
(package private)  java.lang.String secret
          secret known between this component and the server
(package private)  java.lang.String servermodule
          class name of the ServerModule to launch
(package private)  java.lang.String servername
          hostname of the server we connect to with base_accept (not an IP)
(package private)  java.lang.String sessionID
          session id used for seeding with the server (this should be a random #
(package private)  XMLStreamHeaderBuilder xsbuilder
          builder for initial XML stream
 
Constructor Summary
Launcher()
           
 
Method Summary
protected  void AcceptHandler()
          Support routine for base_accept.
protected  void ConnectHandler()
          Support routine for base_connect.
protected  void ExecHandler()
          Support routine for base_exec.
static void main(java.lang.String[] args)
           
 void ServerConnect()
          final steps - we have a connection, now we launch the serverside module on it.
 void start()
           
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

xsbuilder

XMLStreamHeaderBuilder xsbuilder
builder for initial XML stream

bAccept

boolean bAccept
true if we are running a 'base_accept' connection

bConnect

boolean bConnect
true if we are running a 'base_connect' connection

bExec

boolean bExec
true if we are running a 'base_exec' connection

servername

java.lang.String servername
hostname of the server we connect to with base_accept (not an IP)

port

int port
port on server that we connect to with base_accept, or port we listen on with base_connect

host

java.lang.String host
local component name

sessionID

java.lang.String sessionID
session id used for seeding with the server (this should be a random #

secret

java.lang.String secret
secret known between this component and the server

servermodule

java.lang.String servermodule
class name of the ServerModule to launch

cb

ConnectionBean cb
connection object

HANDSHAKE_TIMEOUT

private static final java.lang.String HANDSHAKE_TIMEOUT

BASE_ACCEPT_XMLNS

private static final java.lang.String BASE_ACCEPT_XMLNS

BASE_EXEC_XMLNS

private static final java.lang.String BASE_EXEC_XMLNS
Constructor Detail

Launcher

public Launcher()
Method Detail

main

public static final void main(java.lang.String[] args)

start

public final void start()

AcceptHandler

protected void AcceptHandler()
Support routine for base_accept. base_accept will cause the server to listen in on a port, waiting for connections. After a connection is established, there is a limited amount of time to complete authenication. Steps: 1. set-up protocol handler (done previous) 2. connect to server 3. send header 4. wait for response 5. read in session ID from stream header. 6. hash based on id + secret 7. send handshake with hash 8. wait for response: - if , resend hash (step 7) - if disconnect/timeout, go back to step 2. - if , continue 9. connection established, start custom logic.

ConnectHandler

protected void ConnectHandler()
Support routine for base_connect. base_connect will cause the server to connect to a port on a remote machine. After a connection is established, the server actually authenticates with us. There is a limited amount of time to complete authenication. Steps: 1. set-up protocol handler (done previous) 2. open for connections 3. wait for header 4. send response with Session ID 5. compute handshake based on secret and session ID sent. 6. for ten seconds: 6a. wait for handshake to come in 6b. verify handshake - if valid, return empty handshake and exit loop - if invalid, return stream:error 6c. if time expires without a valid handshake coming in, disconnect. and go back to 3. 7. connection established, start custom logic.

ExecHandler

protected void ExecHandler()
Support routine for base_exec. base_exec will cause the client to be launched on the local machine - the client will then do its I/O on stdin/stdout.. We do not authenticate since we are local. Spoofing is the least of our problems in that case. Steps: 1. set-up protocol handler (done previous) 2. set up connection on stdin/stdout 3. send response 4. wait for header 5. connection established, start custom logic.

ServerConnect

public void ServerConnect()
final steps - we have a connection, now we launch the serverside module on it.