org.xlattice.protocol.stun
Class SecretServer

java.lang.Object
  extended by java.lang.Thread
      extended by org.xlattice.protocol.stun.SecretServer
All Implemented Interfaces:
java.lang.Runnable, StunConst

public class SecretServer
extends java.lang.Thread
implements StunConst

Author:
Jim Dixon

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
static int BUFSIZE
           
protected  org.xlattice.util.NonBlockingLog serverLog
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Fields inherited from interface org.xlattice.protocol.stun.StunConst
BINDING_ERROR_RESPONSE, BINDING_REQUEST, BINDING_RESPONSE, CHANGE_IP, CHANGE_PORT, CHANGE_REQUEST, CHANGED_ADDRESS, ERROR_CODE, HEADER_LENGTH, MAPPED_ADDRESS, MESSAGE_INTEGRITY, MSG_ID_LENGTH, PASSWORD, REFLECTED_FROM, RESPONSE_ADDRESS, SECONDARY_ADDRESS, SERVER_NAME, SHARED_SECRET_ERROR_RESPONSE, SHARED_SECRET_REQUEST, SHARED_SECRET_RESPONSE, SOURCE_ADDRESS, STUN_SERVER_PORT, UNKNOWN_ATTRIBUTES, USERNAME, XOR_MAPPED_ADDRESS, XOR_ONLY
 
Constructor Summary
SecretServer(java.net.Inet4Address host, int port, java.lang.String ksName, java.lang.String passwd, javax.crypto.SecretKey secret1, javax.crypto.SecretKey secret2, boolean verbose)
           
SecretServer(java.net.Inet4Address host, int port, java.lang.String ksName, java.lang.String passwd, javax.crypto.SecretKey secret1, javax.crypto.SecretKey secret2, java.lang.String logDir, boolean verbose)
          Creates a server which provides username/password pairs over a secure TLS connection.
 
Method Summary
protected  void badArg(java.lang.String msg)
           
 void close()
          Closes the Acceptor and then blocks until this thread stops running.
 boolean isRunning()
           
protected  void LOG_MSG(java.lang.String s)
           
protected  SharedSecretErrorResponse malformed(StunMsg msg)
           
 void run()
           
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

BUFSIZE

public static final int BUFSIZE
See Also:
Constant Field Values

serverLog

protected final org.xlattice.util.NonBlockingLog serverLog
Constructor Detail

SecretServer

public SecretServer(java.net.Inet4Address host,
                    int port,
                    java.lang.String ksName,
                    java.lang.String passwd,
                    javax.crypto.SecretKey secret1,
                    javax.crypto.SecretKey secret2,
                    java.lang.String logDir,
                    boolean verbose)
             throws java.security.GeneralSecurityException,
                    java.io.IOException
Creates a server which provides username/password pairs over a secure TLS connection. The caller must provide two crypto-grade secret keys for generating HMACs.

Parameters:
host - server IPv4 address
port - IP port number
ksName - key store file name
passwd - key store passphrase
secret1 - used for HMACs on usernames
secret2 - used for creating passwords
logDir - where we write our logs
verbose - whether we are verbose when we log
Throws:
java.security.GeneralSecurityException
java.io.IOException

SecretServer

public SecretServer(java.net.Inet4Address host,
                    int port,
                    java.lang.String ksName,
                    java.lang.String passwd,
                    javax.crypto.SecretKey secret1,
                    javax.crypto.SecretKey secret2,
                    boolean verbose)
             throws java.security.GeneralSecurityException,
                    java.io.IOException
Throws:
java.security.GeneralSecurityException
java.io.IOException
Method Detail

LOG_MSG

protected void LOG_MSG(java.lang.String s)

badArg

protected final void badArg(java.lang.String msg)
                     throws java.lang.IllegalArgumentException
Throws:
java.lang.IllegalArgumentException

malformed

protected final SharedSecretErrorResponse malformed(StunMsg msg)

run

public void run()
Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

close

public void close()
           throws java.lang.Exception
Closes the Acceptor and then blocks until this thread stops running.

Throws:
java.lang.Exception

isRunning

public boolean isRunning()