org.apache.myfaces.util
Class StateUtils

java.lang.Object
  extended by org.apache.myfaces.util.StateUtils

public final class StateUtils
extends java.lang.Object

This Class exposes a handful of methods related to encryption, compression and serialization.

To enable encryption, a secret must be provided. StateUtils looks first for the org.apache.myfaces.secret init param, then system properties. If a secret cannot be located, encryption is not used.

All parameters are interpretted as base 64 encoded keys. In other words, if your secret is "76543210", you would put "NzY1NDMyMTA=" in the deployment descriptor. This is needed so that key values are not limited to just values composed of printable characters.

If you are using CBC mode encryption, you must specify an initialization vector. StateUtils will throw an exception otherwise.

If you are using the AES algorithm and getting a SecurityException complaining about keysize, you most likely need to get the unlimited strength jurisdiction policy files from a place like http://java.sun.com/j2se/1.4.2/download.html .

Author:
Dennis C. Byrne, ich

Field Summary
static java.lang.String INIT_ALGORITHM
           
static java.lang.String INIT_ALGORITHM_IV
           
static java.lang.String INIT_ALGORITHM_PARAM
           
static java.lang.String INIT_PREFIX
           
static java.lang.String INIT_SECRET
           
static java.lang.String ZIP_CHARSET
           
 
Method Summary
static byte[] compress(byte[] bytes)
           
static java.lang.String construct(java.lang.Object object)
          This fires during the Render Response phase.
static byte[] decode(byte[] bytes)
           
static byte[] decompress(byte[] bytes)
           
static byte[] decrypt(byte[] secure)
           
static byte[] encode(byte[] bytes)
           
static java.lang.String encode64(java.lang.Object obj)
           
static byte[] encrypt(byte[] insecure)
           
static java.lang.String getAlgorithm()
           
static java.lang.String getAlgorithmParams()
           
static byte[] getAsByteArray(java.lang.Object object)
           
static java.lang.Object getAsObject(byte[] bytes)
           
static byte[] getIv()
           
static byte[] getSecret()
           
static boolean isSecure()
           
static void main(java.lang.String[] args)
           
static java.lang.Object reconstruct(java.lang.String string)
          This fires during the Restore View phase.
static void setAlgorithm(java.lang.String algorithm)
           
static void setAlgorithmParams(java.lang.String algorithmParams)
           
static void setIv(byte[] iv)
           
static void setIv(java.lang.String _iv)
           
static void setSecret(byte[] secret)
           
static void setSecret(java.lang.String _secret)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ZIP_CHARSET

public static final java.lang.String ZIP_CHARSET
See Also:
Constant Field Values

INIT_PREFIX

public static final java.lang.String INIT_PREFIX
See Also:
Constant Field Values

INIT_SECRET

public static final java.lang.String INIT_SECRET
See Also:
Constant Field Values

INIT_ALGORITHM

public static final java.lang.String INIT_ALGORITHM
See Also:
Constant Field Values

INIT_ALGORITHM_IV

public static final java.lang.String INIT_ALGORITHM_IV
See Also:
Constant Field Values

INIT_ALGORITHM_PARAM

public static final java.lang.String INIT_ALGORITHM_PARAM
See Also:
Constant Field Values
Method Detail

isSecure

public static boolean isSecure()

construct

public static final java.lang.String construct(java.lang.Object object)
This fires during the Render Response phase.


getAsByteArray

public static final byte[] getAsByteArray(java.lang.Object object)

encrypt

public static byte[] encrypt(byte[] insecure)

compress

public static final byte[] compress(byte[] bytes)

encode

public static final byte[] encode(byte[] bytes)

reconstruct

public static final java.lang.Object reconstruct(java.lang.String string)
This fires during the Restore View phase.


decode

public static final byte[] decode(byte[] bytes)

decompress

public static final byte[] decompress(byte[] bytes)

decrypt

public static byte[] decrypt(byte[] secure)

getAsObject

public static final java.lang.Object getAsObject(byte[] bytes)

encode64

public static java.lang.String encode64(java.lang.Object obj)

getSecret

public static byte[] getSecret()

setSecret

public static void setSecret(java.lang.String _secret)

setSecret

public static void setSecret(byte[] secret)

getAlgorithm

public static java.lang.String getAlgorithm()

setAlgorithm

public static void setAlgorithm(java.lang.String algorithm)

getAlgorithmParams

public static java.lang.String getAlgorithmParams()

setAlgorithmParams

public static void setAlgorithmParams(java.lang.String algorithmParams)

getIv

public static byte[] getIv()

setIv

public static void setIv(java.lang.String _iv)

setIv

public static void setIv(byte[] iv)

main

public static void main(java.lang.String[] args)
                 throws java.io.UnsupportedEncodingException
Throws:
java.io.UnsupportedEncodingException


Copyright 2006 Apache Software Foundation. All Rights Reserved.