com.opensymphony.xwork2.interceptor

## Class ParametersInterceptor

- java.lang.Object
- - com.opensymphony.xwork2.interceptor.AbstractInterceptor
  - - com.opensymphony.xwork2.interceptor.MethodFilterInterceptor
    - - com.opensymphony.xwork2.interceptor.ParametersInterceptor

- All Implemented Interfaces:
    Interceptor, Serializable
  Direct Known Subclasses:
    ActionMappingParametersInterceptor

      public class ParametersInterceptor
      extends MethodFilterInterceptor

  This interceptor sets all parameters on the value stack.
  See Also:
    Serialized Form

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected boolean` | `ordered`
    `protected static int` | `PARAM_NAME_MAX_LENGTH`

    - ### Fields inherited from class com.opensymphony.xwork2.interceptor.MethodFilterInterceptor

      `excludeMethods, includeMethods`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ParametersInterceptor()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected boolean` | `acceptableName(String name)`
    `protected void` | `addParametersToContext(ActionContext ac, Map<String,?> newParams)` Adds the parameters into context's ParameterMap
    `String` | `doIntercept(ActionInvocation invocation)` Subclasses must override to implement the interceptor logic.
    `protected Comparator<String>` | `getOrderedComparator()` Gets an instance of the comparator to use for the ordered sorting.
    `protected String` | `getParameterLogMap(HttpParameters parameters)`
    `protected boolean` | `isAcceptableParameter(String name, Object action)` Checks if name of parameter can be accepted or thrown away
    `protected boolean` | `isAccepted(String paramName)`
    `protected boolean` | `isExcluded(String paramName)`
    `boolean` | `isOrdered()` Whether to order the parameters or not
    `protected boolean` | `isWithinLengthLimit(String name)`
    `protected void` | `notifyDeveloperParameterException(Object action, String property, String message)`
    `protected HttpParameters` | `retrieveParameters(ActionContext ac)` Gets the parameter map to apply from wherever appropriate
    `void` | `setAcceptedPatterns(AcceptedPatternsChecker acceptedPatterns)`
    `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)`
    `void` | `setExcludedPatterns(ExcludedPatternsChecker excludedPatterns)`
    `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 not
    `protected 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)`

    - ### 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`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### PARAM_NAME_MAX_LENGTH

          protected static final int PARAM_NAME_MAX_LENGTH

      See Also:
        Constant Field Values

    - #### ordered

          protected boolean ordered

  - ### Constructor Detail

    - #### ParametersInterceptor

          public ParametersInterceptor()

  - ### Method Detail

    - #### setValueStackFactory

          public void setValueStackFactory(ValueStackFactory valueStackFactory)

    - #### setDevMode

          public void setDevMode(String mode)

    - #### setExcludedPatterns

          public void setExcludedPatterns(ExcludedPatternsChecker excludedPatterns)

    - #### setAcceptedPatterns

          public void setAcceptedPatterns(AcceptedPatternsChecker acceptedPatterns)

    - #### 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

          public String doIntercept(ActionInvocation invocation)
                             throws Exception

      Description copied from class: `MethodFilterInterceptor`
      Subclasses must override to implement the interceptor logic.
      Specified by:
        `doIntercept` in class `MethodFilterInterceptor`
      Parameters:
        `invocation` - the action invocation
      Returns:
        the result of invocation
      Throws:
        `Exception` - in case of any errors

    - #### retrieveParameters

          protected HttpParameters retrieveParameters(ActionContext ac)

      Gets the parameter map to apply from wherever appropriate
      Parameters:
        `ac` - The action context
      Returns:
        The parameter map to apply

    - #### addParametersToContext

          protected void addParametersToContext(ActionContext ac,
                                                Map<String,?> newParams)

      Adds the parameters into context's ParameterMap
      Parameters:
        `ac` - The action context
        `newParams` - The parameter map to apply

        In this class this is a no-op, since the parameters were fetched from the same location. In subclasses both retrieveParameters() and addParametersToContext() should be overridden.

    - #### setParameters

          protected void setParameters(Object action,
                                       ValueStack stack,
                                       HttpParameters parameters)

    - #### notifyDeveloperParameterException

          protected void notifyDeveloperParameterException(Object action,
                                                           String property,
                                                           String message)

    - #### isAcceptableParameter

          protected boolean isAcceptableParameter(String name,
                                                  Object action)

      Checks if name of parameter can be accepted or thrown away
      Parameters:
        `name` - parameter name
        `action` - current action
      Returns:
        true if parameter is accepted

    - #### getOrderedComparator

          protected Comparator<String> 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

          protected String getParameterLogMap(HttpParameters parameters)

    - #### acceptableName

          protected boolean acceptableName(String name)

    - #### isWithinLengthLimit

          protected boolean isWithinLengthLimit(String name)

    - #### isAccepted

          protected boolean isAccepted(String paramName)

    - #### isExcluded

          protected boolean isExcluded(String paramName)

    - #### 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

          public void setAcceptParamNames(String commaDelim)

      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

          public void setExcludeParams(String commaDelim)

      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

Copyright © 2000–2023 Apache Software Foundation. All rights reserved.