messageProcessor
Class Recoder

java.lang.Object
  extended by messageProcessor.Recoder

final class Recoder
extends java.lang.Object

Recodes (decrypts/encrypts) messages. Prevents linkability of (incoming and outgoing) messages due to their appearance.

This class is thread-safe (but parallel execution of a single instance's methods won't increase performance. For parallel processing, several Recoders are needed).

Author:
Karl-Peter Fuchs

Constructor Summary
protected Recoder()
          Constructor used to generate a Recoder used to encrypt replies.
protected Recoder(java.security.KeyPair keyPair)
          Constructor used to generate a Recoder used to decrypt requests.
 
Method Summary
protected  byte[] decrypt(byte[] data, java.lang.String transformation)
          Decrypts the bypassed data using the internal asymmetric cipher (and private key) and the specified transformation.
protected  java.security.Key getPublicKey()
          Returns the public key of this Recoder.
protected  Message recode(BasicMessage message)
          Recodes (decrypts/encrypts) the bypassed message according to its type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Recoder

protected Recoder(java.security.KeyPair keyPair)
Constructor used to generate a Recoder used to decrypt requests.

Creates a new Recoder which will use the bypassed KeyPair to decrypt messages.

Instantiates Cipher objects for later use as specified in the property file.

Parameters:
keyPair - Public and private key of the asymmetric crypto system.

Recoder

protected Recoder()
Constructor used to generate a Recoder used to encrypt replies.

Method Detail

getPublicKey

protected java.security.Key getPublicKey()
Returns the public key of this Recoder.

Returns:
The public key of this Recoder.

recode

protected Message recode(BasicMessage message)
Recodes (decrypts/encrypts) the bypassed message according to its type.

Parameters:
message - The message to be recoded.
Returns:
The recoded message (same reference as previously bypassed). "Null", if recoding failed.

decrypt

protected byte[] decrypt(byte[] data,
                         java.lang.String transformation)
                  throws java.lang.Exception
Decrypts the bypassed data using the internal asymmetric cipher (and private key) and the specified transformation.

Parameters:
data - Data to be decrypted.
transformation - Transformation that shall be used for decryption.
Returns:
Decrypted data.
Throws:
java.lang.Exception - Any type of error preventing the data from being decrypted.