org.xlattice.protocol.stun
Class UserName

java.lang.Object
  extended by org.xlattice.protocol.stun.UserName

public class UserName
extends java.lang.Object

Serialized, a UserName looks like 4B 4B 2B 6B 20B +---+---+---+---+---+---+---+---+---+- - -+---+ | t | addr |port| salt | HMAC-SHA1 | +---+---+---+---+---+---+---+---+---+- - -+---+ where t is the time rounded down to the nearest ten minutes, addr is the IPv4 address, and port is the port number; all three quantities are in big-endian form. salt is a 6-byte random number and HMAC-SHA1 is computed over these four fields (16 bytes in total) using the usernameSecret. A STUN UserName formatted like this is suitable for use in a stateless server.

Author:
Jim Dixon

Field Summary
 java.net.Inet4Address addr
           
static int BODY_LENGTH
           
static int HMAC_LENGTH
           
 long ms
           
 int port
           
 
Constructor Summary
UserName(java.net.Inet4Address addr, int port)
           
 
Method Summary
static UserName decode(javax.crypto.SecretKey key, byte[] msg, int offset)
           
static void encode(java.net.Inet4Address addr, int port, java.util.Random rng, javax.crypto.SecretKey key, byte[] msg, int offset)
           
 void encode(java.util.Random rng, javax.crypto.SecretKey key, byte[] msg, int offset)
           
static byte[] generate(java.net.Inet4Address addr, int port, java.util.Random rng, javax.crypto.SecretKey key)
           
static boolean verify(javax.crypto.SecretKey key, byte[] msg, int offset)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BODY_LENGTH

public static final int BODY_LENGTH
See Also:
Constant Field Values

HMAC_LENGTH

public static final int HMAC_LENGTH
See Also:
Constant Field Values

ms

public final long ms

addr

public final java.net.Inet4Address addr

port

public final int port
Constructor Detail

UserName

public UserName(java.net.Inet4Address addr,
                int port)
Method Detail

decode

public static UserName decode(javax.crypto.SecretKey key,
                              byte[] msg,
                              int offset)
                       throws org.xlattice.CryptoException
Throws:
org.xlattice.CryptoException

encode

public void encode(java.util.Random rng,
                   javax.crypto.SecretKey key,
                   byte[] msg,
                   int offset)
            throws org.xlattice.CryptoException
Throws:
org.xlattice.CryptoException

encode

public static void encode(java.net.Inet4Address addr,
                          int port,
                          java.util.Random rng,
                          javax.crypto.SecretKey key,
                          byte[] msg,
                          int offset)
                   throws org.xlattice.CryptoException
Throws:
org.xlattice.CryptoException

generate

public static byte[] generate(java.net.Inet4Address addr,
                              int port,
                              java.util.Random rng,
                              javax.crypto.SecretKey key)
                       throws org.xlattice.CryptoException
Throws:
org.xlattice.CryptoException

verify

public static boolean verify(javax.crypto.SecretKey key,
                             byte[] msg,
                             int offset)
                      throws org.xlattice.CryptoException
Throws:
org.xlattice.CryptoException