net.kano.joscar.rvcmd.trillcrypt
Class AbstractTrillianCryptRvCmd

java.lang.Object
  extended byRvCommand
      extended byAbstractTrillianCryptRvCmd
Direct Known Subclasses:
TrillianCryptAcceptRvCmd, TrillianCryptBeginRvCmd, TrillianCryptCloseRvCmd, TrillianCryptMsgRvCmd, TrillianCryptReqRvCmd

public abstract class AbstractTrillianCryptRvCmd
extends RvCommand

A base class for the five Trillian Secure IM rendezvous commands provided in this package.


Field Summary
static int CMDTYPE_ACCEPT
          A command type indicating that a command is accepting a secure conversation request.
static int CMDTYPE_BEGIN
          A command type indicating that an encrypted conversation has begun.
static int CMDTYPE_CLOSE
          A command type indicating that a command is closing a secure conversation.
static int CMDTYPE_MESSAGE
          A command type indicating that a command contains an encrypted message.
static int CMDTYPE_REQUEST
          A command type indicating that a command is a request for a secure conversation.
static int VERSION_DEFAULT
          The protocol version number used by Trillian.
 
Fields inherited from class RvCommand
RVSTATUS_ACCEPT, RVSTATUS_DENY, RVSTATUS_REQUEST
 
Constructor Summary
protected AbstractTrillianCryptRvCmd(int cmdType)
          Creates a new outgoing Trillian Encryption command with the given command type and a protocol version of VERSION_DEFAULT.
protected AbstractTrillianCryptRvCmd(int encVersion, int cmdType)
          Creates a new outgoing Trillian Encryption command with the given command type and protocol version.
protected AbstractTrillianCryptRvCmd(RecvRvIcbm icbm)
          Creates a new Trillian Encryption command from the given incoming Trillian Encryption RV ICBM.
 
Method Summary
protected static java.math.BigInteger getBigIntFromHexBlock(ByteBlock block)
          Extracts a BigInteger from the given block of ASCII hexadecimal digits.
protected static byte[] getBigIntHexBlock(java.math.BigInteger num)
          Returns a 33-byte block of data containing a 32-digit hexadecimal representation of the given number followed by a null byte (0x00).
protected  int getCmdType()
          Returns the Trillian Encryption command type of this command.
protected  TlvChain getExtraTlvs()
          Returns a list of extra TLV's sent in this command that were not parsed into fields like version and cmdType.
static int getTrillianCmdType(RecvRvIcbm icbm)
          Extracts the "command type" value from the given incoming Trillian Encryption RV ICBM.
protected  int getVersion()
          Returns the protocol version being used.
protected abstract  void writeExtraTlvs(java.io.OutputStream out)
          Writes any "extra" TLV's to be sent in this command to the given stream.
 void writeRvData(java.io.OutputStream out)
          Writes this RV command's "rendezvous data block" to the given stream.
 
Methods inherited from class RvCommand
getCapabilityBlock, getRvStatus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VERSION_DEFAULT

public static final int VERSION_DEFAULT
The protocol version number used by Trillian.

See Also:
Constant Field Values

CMDTYPE_REQUEST

public static final int CMDTYPE_REQUEST
A command type indicating that a command is a request for a secure conversation.

See Also:
Constant Field Values

CMDTYPE_ACCEPT

public static final int CMDTYPE_ACCEPT
A command type indicating that a command is accepting a secure conversation request.

See Also:
Constant Field Values

CMDTYPE_BEGIN

public static final int CMDTYPE_BEGIN
A command type indicating that an encrypted conversation has begun.

See Also:
Constant Field Values

CMDTYPE_MESSAGE

public static final int CMDTYPE_MESSAGE
A command type indicating that a command contains an encrypted message.

See Also:
Constant Field Values

CMDTYPE_CLOSE

public static final int CMDTYPE_CLOSE
A command type indicating that a command is closing a secure conversation.

See Also:
Constant Field Values
Constructor Detail

AbstractTrillianCryptRvCmd

protected AbstractTrillianCryptRvCmd(RecvRvIcbm icbm)
Creates a new Trillian Encryption command from the given incoming Trillian Encryption RV ICBM.

Parameters:
icbm - an incoming Trillian Encryption RV ICBM

AbstractTrillianCryptRvCmd

protected AbstractTrillianCryptRvCmd(int cmdType)
Creates a new outgoing Trillian Encryption command with the given command type and a protocol version of VERSION_DEFAULT.

Parameters:
cmdType - a Trillian Encryption command type, like CMDTYPE_BEGIN

AbstractTrillianCryptRvCmd

protected AbstractTrillianCryptRvCmd(int encVersion,
                                     int cmdType)
Creates a new outgoing Trillian Encryption command with the given command type and protocol version.

Parameters:
encVersion - the Trillian Encryption protocol version being used (normally VERSION_DEFAULT)
cmdType - a Trillian Encryption command type, like CMDTYPE_BEGIN
Method Detail

getTrillianCmdType

public static int getTrillianCmdType(RecvRvIcbm icbm)
Extracts the "command type" value from the given incoming Trillian Encryption RV ICBM. This method will return -1 if the given command does not contain a command type value.

Parameters:
icbm - an incoming Trillian Encryption RV ICBM command
Returns:
the Trillian Encryption command type contained in the given RV ICBM, or -1 if none is present

getBigIntFromHexBlock

protected static java.math.BigInteger getBigIntFromHexBlock(ByteBlock block)
Extracts a BigInteger from the given block of ASCII hexadecimal digits.

Parameters:
block - a block of data containing only ASCII hexadecimal digits (that is, 0-9 and a-f)
Returns:
a BigInteger read from the given string of hexadecimal digits
See Also:
BigInteger.BigInteger(String, int)

getBigIntHexBlock

protected static byte[] getBigIntHexBlock(java.math.BigInteger num)
                                   throws java.io.IOException,
                                          java.lang.IllegalArgumentException
Returns a 33-byte block of data containing a 32-digit hexadecimal representation of the given number followed by a null byte (0x00).

Parameters:
num - a number smaller than 2128 (that is, a number whose hexadecimal representation is shorter than 33 digits)
Returns:
a block of data representing the number as a null-terminated hexadecimal ASCII string
Throws:
java.io.IOException - if the given number is too large to be represented in 32 hexadecimal digits
java.lang.IllegalArgumentException

getVersion

protected final int getVersion()
Returns the protocol version being used. This will normally be VERSION_DEFAULT.

Returns:
the protocol version number sent in this command

getCmdType

protected final int getCmdType()
Returns the Trillian Encryption command type of this command.

Returns:
this command's Trillian Encryption command type

getExtraTlvs

protected final TlvChain getExtraTlvs()
Returns a list of extra TLV's sent in this command that were not parsed into fields like version and cmdType.

Returns:
a list of the "extra" TLV's in this command

writeRvData

public void writeRvData(java.io.OutputStream out)
                 throws java.io.IOException
Description copied from class: RvCommand
Writes this RV command's "rendezvous data block" to the given stream.

Specified by:
writeRvData in class RvCommand
Parameters:
out - the stream to which to write
Throws:
java.io.IOException - if an I/O error occurs

writeExtraTlvs

protected abstract void writeExtraTlvs(java.io.OutputStream out)
                                throws java.io.IOException
Writes any "extra" TLV's to be sent in this command to the given stream.

Parameters:
out - the stream to which to write
Throws:
java.io.IOException