net.i2p.data.i2cp
Class SessionConfig

java.lang.Object
  extended by net.i2p.data.DataStructureImpl
      extended by net.i2p.data.i2cp.SessionConfig
All Implemented Interfaces:
DataStructure

public class SessionConfig
extends DataStructureImpl

Defines the information a client must provide to create a session

Author:
jrandom

Constructor Summary
SessionConfig()
           
SessionConfig(Destination dest)
           
 
Method Summary
 boolean equals(java.lang.Object object)
           
 java.util.Date getCreationDate()
          Determine when this session was authorized by the destination (so we can prevent replay attacks)
 Destination getDestination()
          Retrieve the destination for which this session is supposed to connect
 java.util.Properties getOptions()
          Retrieve any configuration options for the session
 Signature getSignature()
           
 void readBytes(java.io.InputStream rawConfig)
          Load up the current object with data from the given stream.
 void setCreationDate(java.util.Date date)
           
 void setOptions(java.util.Properties options)
          Configure the session with the given options
 void setSignature(Signature sig)
           
 void signSessionConfig(SigningPrivateKey signingKey)
          Sign the structure using the supplied private key
 boolean tooOld()
           
 java.lang.String toString()
           
 boolean verifySignature()
          Verify that the signature matches the destination's signing public key.
 void writeBytes(java.io.OutputStream out)
          Write out the data structure to the stream, using the format defined in the I2P data structure specification.
 
Methods inherited from class net.i2p.data.DataStructureImpl
calculateHash, fromBase64, fromByteArray, read, toBase64, toByteArray
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SessionConfig

public SessionConfig()

SessionConfig

public SessionConfig(Destination dest)
Method Detail

getDestination

public Destination getDestination()
Retrieve the destination for which this session is supposed to connect

Returns:
Destination for this session

getCreationDate

public java.util.Date getCreationDate()
Determine when this session was authorized by the destination (so we can prevent replay attacks)

Returns:
Date

setCreationDate

public void setCreationDate(java.util.Date date)

getOptions

public java.util.Properties getOptions()
Retrieve any configuration options for the session

Returns:
Properties of this session

setOptions

public void setOptions(java.util.Properties options)
Configure the session with the given options

Parameters:
options - Properties for this session

getSignature

public Signature getSignature()

setSignature

public void setSignature(Signature sig)

signSessionConfig

public void signSessionConfig(SigningPrivateKey signingKey)
                       throws DataFormatException
Sign the structure using the supplied private key

Parameters:
signingKey - SigningPrivateKey to sign with
Throws:
DataFormatException

verifySignature

public boolean verifySignature()
Verify that the signature matches the destination's signing public key.

Returns:
true only if the signature matches

tooOld

public boolean tooOld()

readBytes

public void readBytes(java.io.InputStream rawConfig)
               throws DataFormatException,
                      java.io.IOException
Description copied from interface: DataStructure
Load up the current object with data from the given stream. Data loaded this way must match the I2P data structure specification.

Parameters:
rawConfig - stream to read from
Throws:
DataFormatException - if the data is improperly formatted
java.io.IOException - if there was a problem reading the stream

writeBytes

public void writeBytes(java.io.OutputStream out)
                throws DataFormatException,
                       java.io.IOException
Description copied from interface: DataStructure
Write out the data structure to the stream, using the format defined in the I2P data structure specification.

Parameters:
out - stream to write to
Throws:
DataFormatException - if the data was incomplete or not yet ready to be written
java.io.IOException - if there was a problem writing to the stream

equals

public boolean equals(java.lang.Object object)
Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object