
Apache Neethi:

This is an implementation of WS-Policy Specification (September, 2007) which 
can be located at:  https://www.w3.org/TR/2007/REC-ws-policy-20070904/

It provides a convenient model and an API to process policy information at 
runtime and an extension model for serailization and de-serialization of 
domain specific Assertions. 

Please visit : https://ws.apache.org/neethi/ for further infomation.

Security

Neethi enforces parser and normalization budgets to reduce the risk of
algorithmic-complexity and resource-exhaustion attacks when processing
untrusted policy documents.

The following system properties can be used to tune the parser limits. If a
property is unset, blank, zero, negative, or otherwise invalid, Neethi falls
back to the default shown below.

- `org.apache.neethi.parser.maxDepth` - maximum policy nesting depth.
  Default: `256`.
- `org.apache.neethi.parser.maxElements` - maximum number of parsed elements.
  Default: `100000`.
- `org.apache.neethi.parser.maxAttributes` - maximum number of parsed
  attributes.
  Default: `10000`.
- `org.apache.neethi.remote.maxPolicyBytes` - maximum size of a remotely
  referenced policy document fetched through `PolicyReference`.
  Default: `67108864` bytes (`64 MiB`).
- `org.apache.neethi.remote.maxFetchMillis` - maximum total time allowed to
  fetch a remote policy document through `PolicyReference`.
  Default: `30000` milliseconds (`30 seconds`).

Policy normalization also enforces several hard caps:

- `MAX_ALTERNATIVES` - maximum number of normalized policy alternatives
  produced by policy normalization and intersection.
  Default: `10000`. Helps prevent crafted policies from triggering exponential
  expansion through Cartesian cross-products.

- `MAX_REFERENCE_EXPANSIONS` - maximum number of PolicyReference expansions a
  single normalization pass may perform.
  Default: `100000`. Prevents exponential work from reference-DAG re-expansion:
  a DAG with sibling references can materialize 2^d work from O(d) parsed
  elements when the on-path cycle token is removed and siblings re-expand.

- `MAX_NORMALIZED_COMPONENTS` - maximum total number of component references
  normalization may materialize while building cross-product alternatives.
  Default: `5000000`. The alternative-count cap alone cannot bound memory
  consumption: every cross-product alternative copies the component lists of
  both parents, so a policy staying under all parse budgets and under
  MAX_ALTERNATIVES can still materialize hundreds of millions of references
  (alternatives × parent widths). This cap ensures a fast RuntimeException
  instead of OutOfMemoryError.

`PolicyComparator` also enforces a comparison budget:

- `MAX_COMPARISONS` - maximum number of pairwise component comparisons a
  single top-level `compare(...)` call may perform.
  Default: `10000000`. `PolicyComparator`'s list matching is unordered and
  unmemoized, so mismatched operand orderings cost O(n1 * n2) comparisons.
  This cap turns an engineered quadratic comparison into a fast, predictable
  RuntimeException instead of pinned CPU.

`PolicyIntersector` also enforces an intersection work budget:

- `MAX_INTERSECT_STEPS` - maximum number of assertion-pair intersection
  attempts a single top-level `intersect(...)` or `compatiblePolicies(...)`
  call may perform, including recursion into nested policies of
  `PolicyContainingAssertion` values.
  Default: `1000000`. The alternatives-output cap bounds what is emitted, but
  not all candidate-search work; recursive same-QName fan-out can otherwise
  trigger algorithmic-complexity DoS through exponential search effort.
  This cap turns that engineered search into a fast, predictable
  RuntimeException instead of pinned CPU.
