|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.myfaces.shared_tomahawk.util.StateUtils
public final class StateUtils
This Class exposes a handful of methods related to encryption, compression and serialization.
The secret is interpretted as base 64 encoded. 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.
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 .
org.apache.myfaces.webapp.StartupServletContextListener
Field Summary | |
---|---|
static java.lang.String |
COMPRESS_STATE_IN_CLIENT
Indicate if the view state should be compressed before encrypted(optional) and encoded |
static java.lang.String |
DEFAULT_ALGORITHM
|
static java.lang.String |
DEFAULT_ALGORITHM_PARAMS
|
static java.lang.String |
DEFAULT_MAC_ALGORITHM
|
static java.lang.String |
INIT_ALGORITHM
Indicate the encryption algorithm used for encrypt the view state. |
static java.lang.String |
INIT_ALGORITHM_IV
Defines the initialization vector (Base64 encoded) used for the encryption algorithm |
static java.lang.String |
INIT_ALGORITHM_PARAM
Defines the default mode and padding used for the encryption algorithm |
static java.lang.String |
INIT_MAC_ALGORITHM
Indicate the algorithm used to calculate the Message Authentication Code that is added to the view state. |
static java.lang.String |
INIT_MAC_SECRET
Define the initialization code that are used to initialize the secret key used on the Message Authentication Code algorithm |
static java.lang.String |
INIT_MAC_SECRET_KEY_CACHE
If is set to "false", the secret key used for MAC algorithm is not cached. |
static java.lang.String |
INIT_PREFIX
|
static java.lang.String |
INIT_SECRET
Defines the secret (Base64 encoded) used to initialize the secret key for encryption algorithm. |
static java.lang.String |
INIT_SECRET_KEY_CACHE
If is set to "false", the secret key used for encryption algorithm is not cached. |
static java.lang.String |
SERIAL_FACTORY
Defines the factory class name using for serialize/deserialize the view state returned by state manager into a byte array. |
static java.lang.String |
USE_ENCRYPTION
Indicate if the view state is encrypted or not. |
static java.lang.String |
ZIP_CHARSET
|
Method Summary | |
---|---|
static byte[] |
compress(byte[] bytes)
|
static java.lang.String |
construct(java.lang.Object object,
javax.faces.context.ExternalContext ctx)
This fires during the Render Response phase, saving state. |
static byte[] |
decode(byte[] bytes)
|
static byte[] |
decompress(byte[] bytes)
|
static byte[] |
decrypt(byte[] secure,
javax.faces.context.ExternalContext ctx)
|
static boolean |
enableCompression(javax.faces.context.ExternalContext ctx)
|
static byte[] |
encode(byte[] bytes)
|
static byte[] |
encrypt(byte[] insecure,
javax.faces.context.ExternalContext ctx)
|
static byte[] |
getAsByteArray(java.lang.Object object,
javax.faces.context.ExternalContext ctx)
Performs serialization with the serialization provider created by the SerialFactory. |
static java.lang.Object |
getAsObject(byte[] bytes,
javax.faces.context.ExternalContext ctx)
Performs deserialization with the serialization provider created from the SerialFactory. |
static void |
initSecret(javax.servlet.ServletContext ctx)
Does nothing if the user has disabled the SecretKey cache. |
static boolean |
isSecure(javax.faces.context.ExternalContext ctx)
|
static void |
main(java.lang.String[] args)
Utility method for generating base 64 encoded strings. |
static java.lang.Object |
reconstruct(java.lang.String string,
javax.faces.context.ExternalContext ctx)
This fires during the Restore View phase, restoring state. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String ZIP_CHARSET
public static final java.lang.String DEFAULT_ALGORITHM
public static final java.lang.String DEFAULT_ALGORITHM_PARAMS
public static final java.lang.String INIT_PREFIX
public static final java.lang.String USE_ENCRYPTION
public static final java.lang.String INIT_SECRET
public static final java.lang.String INIT_ALGORITHM
public static final java.lang.String INIT_SECRET_KEY_CACHE
public static final java.lang.String INIT_ALGORITHM_IV
public static final java.lang.String INIT_ALGORITHM_PARAM
public static final java.lang.String SERIAL_FACTORY
public static final java.lang.String COMPRESS_STATE_IN_CLIENT
public static final java.lang.String DEFAULT_MAC_ALGORITHM
public static final java.lang.String INIT_MAC_ALGORITHM
public static final java.lang.String INIT_MAC_SECRET
public static final java.lang.String INIT_MAC_SECRET_KEY_CACHE
Method Detail |
---|
public static boolean enableCompression(javax.faces.context.ExternalContext ctx)
public static boolean isSecure(javax.faces.context.ExternalContext ctx)
public static final java.lang.String construct(java.lang.Object object, javax.faces.context.ExternalContext ctx)
public static final byte[] getAsByteArray(java.lang.Object object, javax.faces.context.ExternalContext ctx)
object
- ctx
-
public static byte[] encrypt(byte[] insecure, javax.faces.context.ExternalContext ctx)
public static final byte[] compress(byte[] bytes)
public static final byte[] encode(byte[] bytes)
public static final java.lang.Object reconstruct(java.lang.String string, javax.faces.context.ExternalContext ctx)
public static final byte[] decode(byte[] bytes)
public static final byte[] decompress(byte[] bytes)
public static byte[] decrypt(byte[] secure, javax.faces.context.ExternalContext ctx)
public static final java.lang.Object getAsObject(byte[] bytes, javax.faces.context.ExternalContext ctx)
bytes
- ctx
-
public static void main(java.lang.String[] args) throws java.io.UnsupportedEncodingException
args
-
java.io.UnsupportedEncodingException
public static void initSecret(javax.servlet.ServletContext ctx)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |