Class ParametersInterceptor
java.lang.Object
com.opensymphony.xwork2.interceptor.AbstractInterceptor
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor
org.apache.struts2.interceptor.parameter.ParametersInterceptor
- All Implemented Interfaces:
ConditionalInterceptor
,Interceptor
,Serializable
- Direct Known Subclasses:
ActionMappingParametersInterceptor
,ParametersInterceptor
This interceptor sets all parameters on the value stack.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected boolean
protected static final int
Fields inherited from class com.opensymphony.xwork2.interceptor.MethodFilterInterceptor
excludeMethods, includeMethods
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
acceptableName
(String name) Deprecated.protected boolean
acceptableValue
(String name, String value) Deprecated.since 6.4.0, useisAcceptableValue(java.lang.String, java.lang.String)
protected void
addParametersToContext
(ActionContext ac, Map<String, ?> newParams) Adds the parameters into context's ParameterMapprotected void
protected void
applyParameters
(Object action, ValueStack stack, HttpParameters parameters) protected void
applyParametersOnStack
(ValueStack stack, Map<String, Parameter> parameters, Object action) protected void
batchApplyReflectionContextState
(Map<String, Object> context, boolean value) doIntercept
(ActionInvocation invocation) Subclasses must override to implement the interceptor logic.protected Comparator<String>
Gets an instance of the comparator to use for the ordered sorting.protected String
getParameterLogMap
(HttpParameters parameters) protected HttpParameters
initNewHttpParameters
(HttpParameters parameters) protected boolean
isAcceptableName
(String name) Validates the name passed is: * Within the max length of a parameter name * Is not excluded * Is acceptedprotected boolean
isAcceptableParameter
(String name, Object action) Checks if name of parameter can be accepted or thrown awayprotected boolean
isAcceptableParameterNameAware
(String name, Object action) protected boolean
isAcceptableParameterValue
(Parameter param, Object action) Checks if parameter value can be accepted or thrown awayprotected boolean
isAcceptableParameterValueAware
(Parameter param, Object action) protected boolean
isAcceptableValue
(String name, String value) Validates: * Value is null/blank * Value is not excluded * Value is acceptedprotected boolean
isAccepted
(String paramName) protected boolean
isExcluded
(String paramName) boolean
Whether to order the parameters or notprotected boolean
isParamValueAccepted
(String value) protected boolean
isParamValueExcluded
(String value) protected boolean
isWithinLengthLimit
(String name) protected void
notifyDeveloperParameterException
(Object action, String property, String message) protected HttpParameters
retrieveParameters
(ActionContext actionContext) Gets the parameter map to apply from wherever appropriatevoid
setAcceptedPatterns
(AcceptedPatternsChecker acceptedPatterns) void
setAcceptedValuePatterns
(String commaDelimitedPatterns) Sets a comma-delimited list of regular expressions to match values of parameters that should be accepted and included in the parameter map.void
setAcceptParamNames
(String commaDelim) Sets a comma-delimited list of regular expressions to match parameters that are allowed in the parameter map (aka whitelist).void
setDevMode
(String mode) protected void
setDynamicMethodInvocation
(String dmiEnabled) void
setExcludedPatterns
(ExcludedPatternsChecker excludedPatterns) void
setExcludedValuePatterns
(String commaDelimitedPatterns) Sets a comma-delimited list of regular expressions to match values of parameters that should be removed from the parameter map.void
setExcludeParams
(String commaDelim) Sets a comma-delimited list of regular expressions to match parameters that should be removed from the parameter map.void
setOrdered
(boolean ordered) Set whether to order the parameters by object depth or notprotected void
setParameters
(Object action, ValueStack stack, HttpParameters parameters) void
setParamNameMaxLength
(int paramNameMaxLength) If the param name exceeds the configured maximum length it will not be accepted.void
setValueStackFactory
(ValueStackFactory valueStackFactory) toAcceptableParameters
(HttpParameters parameters, Object action) protected ValueStack
toNewStack
(ValueStack stack) Methods inherited from class com.opensymphony.xwork2.interceptor.MethodFilterInterceptor
applyInterceptor, getExcludeMethodsSet, getIncludeMethodsSet, intercept, setExcludeMethods, setIncludeMethods
Methods inherited from class com.opensymphony.xwork2.interceptor.AbstractInterceptor
destroy, init, setDisabled, shouldIntercept
-
Field Details
-
PARAM_NAME_MAX_LENGTH
protected static final int PARAM_NAME_MAX_LENGTH- See Also:
-
ordered
protected boolean ordered
-
-
Constructor Details
-
ParametersInterceptor
public ParametersInterceptor()
-
-
Method Details
-
setValueStackFactory
-
setDevMode
-
setExcludedPatterns
-
setAcceptedPatterns
-
setDynamicMethodInvocation
-
setParamNameMaxLength
public void setParamNameMaxLength(int paramNameMaxLength) If the param name exceeds the configured maximum length it will not be accepted.- Parameters:
paramNameMaxLength
- Maximum length of param names
-
doIntercept
Description copied from class:MethodFilterInterceptor
Subclasses must override to implement the interceptor logic.- Specified by:
doIntercept
in classMethodFilterInterceptor
- Parameters:
invocation
- the action invocation- Returns:
- the result of invocation
- Throws:
Exception
- in case of any errors
-
retrieveParameters
Gets the parameter map to apply from wherever appropriate- Parameters:
actionContext
- The action context- Returns:
- The parameter map to apply
-
addParametersToContext
Adds the parameters into context's ParameterMapIn this class this is a no-op, since the parameters were fetched from the same location. In subclasses both this and
retrieveParameters(com.opensymphony.xwork2.ActionContext)
should be overridden.- Parameters:
ac
- The action contextnewParams
- The parameter map to apply
-
setParameters
@Deprecated protected void setParameters(Object action, ValueStack stack, HttpParameters parameters) -
applyParameters
-
batchApplyReflectionContextState
-
toNewStack
-
applyMemberAccessProperties
-
toAcceptableParameters
-
initParameterMap
-
initNewHttpParameters
-
applyParametersOnStack
protected void applyParametersOnStack(ValueStack stack, Map<String, Parameter> parameters, Object action) -
notifyDeveloperParameterException
-
isAcceptableParameter
Checks if name of parameter can be accepted or thrown away- Parameters:
name
- parameter nameaction
- current action- Returns:
- true if parameter is accepted
-
isAcceptableParameterNameAware
-
isAcceptableParameterValue
Checks if parameter value can be accepted or thrown away- Parameters:
param
- the parameteraction
- current action- Returns:
- true if parameter is accepted
-
isAcceptableParameterValueAware
-
getOrderedComparator
Gets an instance of the comparator to use for the ordered sorting. Override this method to customize the ordering of the parameters as they are set to the action.- Returns:
- A comparator to sort the parameters
-
getParameterLogMap
-
acceptableName
Deprecated.since 6.4.0, useisAcceptableName(java.lang.String)
-
isAcceptableName
Validates the name passed is: * Within the max length of a parameter name * Is not excluded * Is accepted- Parameters:
name
- - Name to check- Returns:
- true if accepted
-
acceptableValue
Deprecated.since 6.4.0, useisAcceptableValue(java.lang.String, java.lang.String)
-
isAcceptableValue
Validates: * Value is null/blank * Value is not excluded * Value is accepted- Parameters:
name
- - Param name (for logging)value
- - value to check- Returns:
- true if accepted
-
isWithinLengthLimit
-
isAccepted
-
isExcluded
-
isParamValueExcluded
-
isParamValueAccepted
-
isOrdered
public boolean isOrdered()Whether to order the parameters or not- Returns:
- True to order
-
setOrdered
public void setOrdered(boolean ordered) Set whether to order the parameters by object depth or not- Parameters:
ordered
- True to order them
-
setAcceptParamNames
Sets a comma-delimited list of regular expressions to match parameters that are allowed in the parameter map (aka whitelist).Don't change the default unless you know what you are doing in terms of security implications.
- Parameters:
commaDelim
- A comma-delimited list of regular expressions
-
setExcludeParams
Sets a comma-delimited list of regular expressions to match parameters that should be removed from the parameter map.- Parameters:
commaDelim
- A comma-delimited list of regular expressions
-
setAcceptedValuePatterns
Sets a comma-delimited list of regular expressions to match values of parameters that should be accepted and included in the parameter map.- Parameters:
commaDelimitedPatterns
- A comma-delimited set of regular expressions
-
setExcludedValuePatterns
Sets a comma-delimited list of regular expressions to match values of parameters that should be removed from the parameter map.- Parameters:
commaDelimitedPatterns
- A comma-delimited set of regular expressions
-
isAcceptableName(java.lang.String)