public final class StateUtils extends 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. 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 .
org.apache.myfaces.webapp.StartupServletContextListener
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_ALGORITHM |
static String |
DEFAULT_ALGORITHM_PARAMS |
static String |
INIT_ALGORITHM |
static String |
INIT_ALGORITHM_IV |
static String |
INIT_ALGORITHM_PARAM |
static String |
INIT_PREFIX |
static String |
INIT_SECRET |
static String |
INIT_SECRET_KEY_CACHE |
static String |
SERIAL_FACTORY |
static String |
ZIP_CHARSET |
Modifier and Type | Method and Description |
---|---|
static byte[] |
compress(byte[] bytes) |
static String |
construct(Object object,
javax.faces.context.ExternalContext ctx)
This fires during the Render Response phase.
|
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 String |
encode64(Object obj) |
static byte[] |
encrypt(byte[] insecure,
javax.faces.context.ExternalContext ctx) |
static byte[] |
getAsByteArray(Object object,
javax.faces.context.ExternalContext ctx) |
static Object |
getAsObject(byte[] bytes,
javax.faces.context.ExternalContext ctx) |
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(String[] args) |
static Object |
reconstruct(String string,
javax.faces.context.ExternalContext ctx)
This fires during the Restore View phase.
|
public static final String ZIP_CHARSET
public static final String DEFAULT_ALGORITHM
public static final String DEFAULT_ALGORITHM_PARAMS
public static final String INIT_PREFIX
public static final String INIT_SECRET
public static final String INIT_ALGORITHM
public static final String INIT_SECRET_KEY_CACHE
public static final String INIT_ALGORITHM_IV
public static final String INIT_ALGORITHM_PARAM
public static final String SERIAL_FACTORY
public static boolean enableCompression(javax.faces.context.ExternalContext ctx)
public static boolean isSecure(javax.faces.context.ExternalContext ctx)
public static String construct(Object object, javax.faces.context.ExternalContext ctx)
public static byte[] getAsByteArray(Object object, javax.faces.context.ExternalContext ctx)
public static byte[] encrypt(byte[] insecure, javax.faces.context.ExternalContext ctx)
public static byte[] compress(byte[] bytes)
public static byte[] encode(byte[] bytes)
public static Object reconstruct(String string, javax.faces.context.ExternalContext ctx)
public static byte[] decode(byte[] bytes)
public static byte[] decompress(byte[] bytes)
public static byte[] decrypt(byte[] secure, javax.faces.context.ExternalContext ctx)
public static Object getAsObject(byte[] bytes, javax.faces.context.ExternalContext ctx)
public static void main(String[] args) throws UnsupportedEncodingException
UnsupportedEncodingException
public static void initSecret(javax.servlet.ServletContext ctx)
Copyright © 2013 Apache Software Foundation. All Rights Reserved.