org.apache.myfaces.application
Class StateCache<K,V>

java.lang.Object
  extended by org.apache.myfaces.application.StateCache<K,V>

public abstract class StateCache<K,V>
extends Object

This class provides an interface to separate the state caching operations (saving/restoring) from the renderkit specific stuff that HtmlResponseStateManager should do.

Author:
Leonardo Uribe

Field Summary
static String RANDOM_KEY_IN_CSRF_SESSION_TOKEN_LENGTH_PARAM
          Set the default length of the random key used for the csrf session token.
static int RANDOM_KEY_IN_CSRF_SESSION_TOKEN_LENGTH_PARAM_DEFAULT
           
static String RANDOM_KEY_IN_CSRF_SESSION_TOKEN_PARAM
          Defines how to generate the csrf session token.
static String RANDOM_KEY_IN_CSRF_SESSION_TOKEN_PARAM_DEFAULT
           
static String RANDOM_KEY_IN_CSRF_SESSION_TOKEN_RANDOM
           
static String RANDOM_KEY_IN_CSRF_SESSION_TOKEN_SECURE_RANDOM
           
static String RANDOM_KEY_IN_CSRF_SESSION_TOKEN_SECURE_RANDOM_ALGORITM_PARAM
          Sets the random algorithm to initialize the secure random id generator.
static String RANDOM_KEY_IN_CSRF_SESSION_TOKEN_SECURE_RANDOM_CLASS_PARAM
          Sets the random class to initialize the secure random id generator.
static String RANDOM_KEY_IN_CSRF_SESSION_TOKEN_SECURE_RANDOM_PROVIDER_PARAM
          Sets the random provider to initialize the secure random id generator.
 
Constructor Summary
StateCache()
           
 
Method Summary
abstract  String createCryptographicallyStrongTokenFromSession(FacesContext context)
           
abstract  K encodeSerializedState(FacesContext facesContext, Object serializedView)
          Calculate the token to be used if server side state saving, or encode the view and return the viewState that can be used by the underlying ResponseStateManager to write the state.
abstract  boolean isWriteStateAfterRenderViewRequired(FacesContext facesContext)
          Indicates if the call to ResponseStateManager.writeState should be done after the view is fully rendered.
abstract  V restoreSerializedView(FacesContext facesContext, String viewId, K viewState)
          Get the state from the cache is server side state saving is used, or decode it from the passed viewState param if client side is used.
abstract  K saveSerializedView(FacesContext facesContext, V serializedView)
          Put the state on the cache, to can be restored later.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RANDOM_KEY_IN_CSRF_SESSION_TOKEN_PARAM

@JSFWebConfigParam(since="2.2.0",
                   expectedValues="secureRandom, random",
                   defaultValue="none",
                   group="state")
public static final String RANDOM_KEY_IN_CSRF_SESSION_TOKEN_PARAM
Defines how to generate the csrf session token.

See Also:
Constant Field Values

RANDOM_KEY_IN_CSRF_SESSION_TOKEN_PARAM_DEFAULT

public static final String RANDOM_KEY_IN_CSRF_SESSION_TOKEN_PARAM_DEFAULT
See Also:
Constant Field Values

RANDOM_KEY_IN_CSRF_SESSION_TOKEN_SECURE_RANDOM

public static final String RANDOM_KEY_IN_CSRF_SESSION_TOKEN_SECURE_RANDOM
See Also:
Constant Field Values

RANDOM_KEY_IN_CSRF_SESSION_TOKEN_RANDOM

public static final String RANDOM_KEY_IN_CSRF_SESSION_TOKEN_RANDOM
See Also:
Constant Field Values

RANDOM_KEY_IN_CSRF_SESSION_TOKEN_LENGTH_PARAM

@JSFWebConfigParam(since="2.2.0",
                   defaultValue="16",
                   group="state")
public static final String RANDOM_KEY_IN_CSRF_SESSION_TOKEN_LENGTH_PARAM
Set the default length of the random key used for the csrf session token. By default is 16.

See Also:
Constant Field Values

RANDOM_KEY_IN_CSRF_SESSION_TOKEN_LENGTH_PARAM_DEFAULT

public static final int RANDOM_KEY_IN_CSRF_SESSION_TOKEN_LENGTH_PARAM_DEFAULT
See Also:
Constant Field Values

RANDOM_KEY_IN_CSRF_SESSION_TOKEN_SECURE_RANDOM_CLASS_PARAM

@JSFWebConfigParam(since="2.2.0",
                   group="state")
public static final String RANDOM_KEY_IN_CSRF_SESSION_TOKEN_SECURE_RANDOM_CLASS_PARAM
Sets the random class to initialize the secure random id generator. By default it uses java.security.SecureRandom

See Also:
Constant Field Values

RANDOM_KEY_IN_CSRF_SESSION_TOKEN_SECURE_RANDOM_PROVIDER_PARAM

@JSFWebConfigParam(since="2.2.0",
                   group="state")
public static final String RANDOM_KEY_IN_CSRF_SESSION_TOKEN_SECURE_RANDOM_PROVIDER_PARAM
Sets the random provider to initialize the secure random id generator.

See Also:
Constant Field Values

RANDOM_KEY_IN_CSRF_SESSION_TOKEN_SECURE_RANDOM_ALGORITM_PARAM

@JSFWebConfigParam(since="2.2.0",
                   defaultValue="SHA1PRNG",
                   group="state")
public static final String RANDOM_KEY_IN_CSRF_SESSION_TOKEN_SECURE_RANDOM_ALGORITM_PARAM
Sets the random algorithm to initialize the secure random id generator. By default is SHA1PRNG

See Also:
Constant Field Values
Constructor Detail

StateCache

public StateCache()
Method Detail

saveSerializedView

public abstract K saveSerializedView(FacesContext facesContext,
                                     V serializedView)
Put the state on the cache, to can be restored later.

Parameters:
facesContext -
serializedView -

restoreSerializedView

public abstract V restoreSerializedView(FacesContext facesContext,
                                        String viewId,
                                        K viewState)
Get the state from the cache is server side state saving is used, or decode it from the passed viewState param if client side is used.

Parameters:
facesContext -
viewId - The viewId of the view to be restored
viewState - A token usually retrieved from a call to ResponseStateManager.getState that will be used to identify or restore the state.
Returns:

encodeSerializedState

public abstract K encodeSerializedState(FacesContext facesContext,
                                        Object serializedView)
Calculate the token to be used if server side state saving, or encode the view and return the viewState that can be used by the underlying ResponseStateManager to write the state.

Parameters:
facesContext -
state - The state that will be used to derive the token returned.
Returns:
A token (usually encoded on javax.faces.ViewState input hidden field) that will be passed to ResponseStateManager.writeState or ResponseStateManager.getViewState to be output to the client.

isWriteStateAfterRenderViewRequired

public abstract boolean isWriteStateAfterRenderViewRequired(FacesContext facesContext)
Indicates if the call to ResponseStateManager.writeState should be done after the view is fully rendered. Usually this is required for client side state saving, but it is not for server side state saving, because ResponseStateManager.writeState could render a just a marker and then StateManager.saveState could be called, preventing use an additional buffer.

Parameters:
facesContext -
Returns:

createCryptographicallyStrongTokenFromSession

public abstract String createCryptographicallyStrongTokenFromSession(FacesContext context)
Parameters:
context -
Returns:
Since:
2.2


Copyright © 2015 The Apache Software Foundation. All rights reserved.