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

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

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

A codec that will add a digital signature to the flowstate when encoding, and check the validity of the signature (and strip it) upon decoding. If the signature is not valid, it will throw a FlowStateStorageException. It is highly recommended to use this codec with ClientSideFlowStateStorage as it prevents the client from tampering the state.

Version:
$Id: IntegrityCodec.java 10 2006-05-16 09:49:48Z szegedia $
Author:
Attila Szegedi

Constructor Summary
IntegrityCodec()
           
 
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 setKeyPair(java.security.KeyPair keyPair)
          Sets the pair of a matching private and public key used to sign the serialized webflow states and to check the signature validity.
 void setSignatureAlgorithmName(java.lang.String signatureAlgorithmName)
          Sets the name of the signature algorithm.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IntegrityCodec

public IntegrityCodec()
Method Detail

setKeyPair

public void setKeyPair(java.security.KeyPair keyPair)
Sets the pair of a matching private and public key used to sign the serialized webflow states and to check the signature validity. You can use a GeneratedKeyPairFactory, or even better a KeyStoreKeyPairFactory to obtain a key pair.

Parameters:
keyPair - the signing/verifying keypair.

setSignatureAlgorithmName

public void setSignatureAlgorithmName(java.lang.String signatureAlgorithmName)
Sets the name of the signature algorithm. Defaults to "SHA1With" + the key algorithm name, i.e. "SHA1WithRSA".

Parameters:
signatureAlgorithmName - the signature algorithm name

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