webfunds.sox
Class EncryptedReply

java.lang.Object
  |
  +--webfunds.sox.Encodable
        |
        +--webfunds.sox.BasicReply
              |
              +--webfunds.sox.EncryptedReply

public class EncryptedReply
extends BasicReply

An EncryptedReply is a "basic" reply, that encapsulates a reply to signed request. This class can be thought of as the "gateway" between the basic transport layer and the signed reply layer

See Also:
Serialized Form

Field Summary
protected  byte[] data
          The (encrypted) payload
protected  byte[] flags
          Flags (for future use)
protected  byte[] sessionKey
          A key for future use
 
Constructor Summary
EncryptedReply(byte[] data)
           
EncryptedReply(java.io.InputStream is)
           
EncryptedReply(Reply reply, byte[] sessionKey)
          Construct a null-encrypted reply (type "none").
EncryptedReply(Reply reply, byte[] sessionKey, java.security.Key key)
          Construct an encrypted request (type public).
 
Method Summary
 void decode(java.io.InputStream is)
           
 byte[] decrypt()
          Decrypt a reply (usually called by SOX clients).
 byte[] decrypt(java.security.Key key)
          Decrypt a reply (usually called by SOX clients).
 void encode(java.io.OutputStream os)
           
 java.lang.String toString()
           
 
Methods inherited from class webfunds.sox.Encodable
decode, encode, main, readByteArray, readCertificate, readProperties, readString, writeByteArray, writeCertificate, writeProperties, writeString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

data

protected byte[] data
The (encrypted) payload

flags

protected byte[] flags
Flags (for future use)

sessionKey

protected byte[] sessionKey
A key for future use
Constructor Detail

EncryptedReply

public EncryptedReply(Reply reply,
                      byte[] sessionKey)
Construct a null-encrypted reply (type "none"). No encryption is done. This may be useful for countries where clients are not allowed to encrypt their communications, although SOX servers may potentially refuse to accept unencrypted requests.
Parameters:
req - The reply to be encrypted
sessionKey - A key for clients to use for future requests

EncryptedReply

public EncryptedReply(Reply reply,
                      byte[] sessionKey,
                      java.security.Key key)
Construct an encrypted request (type public). The request body is encrypted with the provided key, and this key is then encrypted with the certificate.
Parameters:
reply - The reply to be encrypted
key - The key with which to encrypt the request data
sessionKey - A key for clients to use for future requests

EncryptedReply

public EncryptedReply(byte[] data)
               throws SOXPacketException

EncryptedReply

public EncryptedReply(java.io.InputStream is)
               throws java.io.IOException,
                      SOXPacketException
Method Detail

encode

public void encode(java.io.OutputStream os)
            throws java.io.IOException
Overrides:
encode in class Encodable

decode

public void decode(java.io.InputStream is)
            throws java.io.IOException,
                   SOXPacketException
Overrides:
decode in class Encodable

decrypt

public byte[] decrypt(java.security.Key key)
               throws SOXPacketException
Decrypt a reply (usually called by SOX clients).

decrypt

public byte[] decrypt()
               throws SOXPacketException
Decrypt a reply (usually called by SOX clients).

toString

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