org.apache.struts2.ognl

## Interface OgnlGuard

- All Known Implementing Classes:
    StrutsOgnlGuard

      public interface OgnlGuard

  Guards all expressions parsed by Struts Core. It is evaluated by `OgnlUtil` immediately after parsing any expression.
  Since:
    6.4.0

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `EXPR_BLOCKED`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Default Methods
    Modifier and Type | Method and Description
    --- | ---
    `default boolean` | `isBlocked(String expr)` Determines whether an OGNL expression should be blocked based on validation done on both the raw expression and the parsed tree.
    `boolean` | `isParsedTreeBlocked(Object tree)` Determines whether a parsed OGNL tree should be blocked based on some validation rules.
    `boolean` | `isRawExpressionBlocked(String expr)` Determines whether an OGNL expression should be blocked based on validation done on only the raw expression, without parsing the tree.
    `default Object` | `parseExpression(String expr)` Parses an OGNL expression and returns the resulting tree only if the expression is not blocked as per defined validation rules in `isRawExpressionBlocked(java.lang.String)` and `isParsedTreeBlocked(java.lang.Object)`.

- - ### Field Detail

    - #### EXPR_BLOCKED

          static final String EXPR_BLOCKED

      See Also:
        Constant Field Values

  - ### Method Detail

    - #### isBlocked

          default boolean isBlocked(String expr)
                             throws ognl.OgnlException

      Determines whether an OGNL expression should be blocked based on validation done on both the raw expression and the parsed tree.
      Parameters:
        `expr` - OGNL expression
      Returns:
        whether the expression should be blocked
      Throws:
        `ognl.OgnlException`

    - #### parseExpression

          default Object parseExpression(String expr)
                                  throws ognl.OgnlException

      Parses an OGNL expression and returns the resulting tree only if the expression is not blocked as per defined validation rules in `isRawExpressionBlocked(java.lang.String)` and `isParsedTreeBlocked(java.lang.Object)`.
      Parameters:
        `expr` - OGNL expression
      Returns:
        parsed expression or `EXPR_BLOCKED` if the expression should be blocked
      Throws:
        `ognl.OgnlException`

    - #### isRawExpressionBlocked

          boolean isRawExpressionBlocked(String expr)

      Determines whether an OGNL expression should be blocked based on validation done on only the raw expression, without parsing the tree.
      Parameters:
        `expr` - OGNL expression
      Returns:
        whether the expression should be blocked

    - #### isParsedTreeBlocked

          boolean isParsedTreeBlocked(Object tree)

      Determines whether a parsed OGNL tree should be blocked based on some validation rules.
      Parameters:
        `tree` - parsed OGNL tree
      Returns:
        whether the parsed tree should be blocked

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