org.szegedi.spring.web.jsflow.codec
Class ConfidentialityCodec

java.lang.Object
  extended by org.szegedi.spring.web.jsflow.codec.ConfidentialityCodec
All Implemented Interfaces:
org.springframework.beans.factory.InitializingBean, BinaryStateCodec

public class ConfidentialityCodec
extends java.lang.Object
implements BinaryStateCodec, org.springframework.beans.factory.InitializingBean

A codec that will encrypt the flowstate when encoding, and decrypt it upon decoding. It can be used with ClientSideFlowStateStorage when there is a concern that confidential information might be contained in the flow state. If you use it, then it is recommended to put it into a CompositeCodec and precede it with a CompressionCodec, as compression improves the security of encryption. You might also want to consider enclosing it (or the composite codec) into a PooledCodec to improve performance, especially when using some sort of password-based encryption as it has high cipher initialization time requirements. Note however that if you are not concerned about secrecy, but just want to prevent the client from tampering with or forging a false flowstate, then you should use an IntegrityCodec instead.

Version:
$Id: ConfidentialityCodec.java 76 2007-04-02 09:37:23Z szegedia $
Author:
Attila Szegedi

Constructor Summary
ConfidentialityCodec()
           
 
Method Summary
 void afterPropertiesSet()
           
 OneWayCodec createDecoder()
          Create a one-way single-threaded, nonshared codec instance able to decode a state as received from the client or from an upstream codec.
 OneWayCodec createEncoder()
          Create a one-way single-threaded, nonshared codec instance able to encode a state as should be sent to a client or a downstream codec.
 void setAlgorithmParameters(java.security.AlgorithmParameters algorithmParameters)
          Sets any optional algorithm parameters
 void setChainingAndPadding(java.lang.String chainingAndPadding)
          Sets the block chaining and padding mode, i.e.
 void setProvider(java.lang.String provider)
          Sets the name of the security provider to use.
 void setSecretKey(java.security.Key secretKey)
          Sets the secret key used for encryption and decryption.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConfidentialityCodec

public ConfidentialityCodec()
Method Detail

setSecretKey

public void setSecretKey(java.security.Key secretKey)
Sets the secret key used for encryption and decryption. You can obtain a key using a GeneratedSecretKeyFactory or better yet a KeySpecSecretKeyFactory

Parameters:
secretKey - the secret key

setAlgorithmParameters

public void setAlgorithmParameters(java.security.AlgorithmParameters algorithmParameters)
Sets any optional algorithm parameters

Parameters:
algorithmParameters - the algorithm parameters

setProvider

public void setProvider(java.lang.String provider)
Sets the name of the security provider to use. If not set, the default provider is used.

Parameters:
provider - the name of the security provider to use or null.

setChainingAndPadding

public void setChainingAndPadding(java.lang.String chainingAndPadding)
Sets the block chaining and padding mode, i.e. "CBC/PKCS5Padding". If not set, the key's algorithm defaults are used.

Parameters:
chainingAndPadding - the block chaining and padding mode, or null for algorithm defaults.

afterPropertiesSet

public void afterPropertiesSet()
                        throws java.lang.Exception
Specified by:
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
Throws:
java.lang.Exception

createDecoder

public OneWayCodec createDecoder()
                          throws java.lang.Exception
Description copied from interface: BinaryStateCodec
Create a one-way single-threaded, nonshared codec instance able to decode a state as received from the client or from an upstream codec.

Specified by:
createDecoder in interface BinaryStateCodec
Returns:
the codec for decoding
Throws:
java.lang.Exception

createEncoder

public OneWayCodec createEncoder()
                          throws java.lang.Exception
Description copied from interface: BinaryStateCodec
Create a one-way single-threaded, nonshared codec instance able to encode a state as should be sent to a client or a downstream codec.

Specified by:
createEncoder in interface BinaryStateCodec
Returns:
the codec for encoding
Throws:
java.lang.Exception