Class PolicyList

java.lang.Object
org.htmlunit.csp.PolicyList

public class PolicyList extends Object
Represents a list of Content Security Policies parsed from a comma-separated serialized CSP list.

A serialized CSP list (e.g. the value of a Content-Security-Policy HTTP header) may contain multiple policies separated by commas. Each policy is parsed independently, and a resource is blocked if any policy in the list blocks it.

Instances are created by Policy.parseSerializedCSPList(String, Policy.PolicyListErrorConsumer). Empty policies (those with no directives) are omitted during parsing.

See Also:
  • Constructor Details

    • PolicyList

      public PolicyList(List<Policy> policies)
      Ctor.
      Parameters:
      policies - the list of parsed Policy instances (empty policies excluded)
  • Method Details

    • getPolicies

      public List<Policy> getPolicies()
      Returns a copy of the policies associated with this object.

      The returned list is a defensive copy, so modifications to it do not affect the internal collection of policies.

      Returns:
      a new List containing all policies
    • toString

      public String toString()
      Serializes this policy list back to its string representation.

      Individual policies are separated by ", ". Each policy is serialized using Policy.toString().

      Overrides:
      toString in class Object
      Returns:
      the comma-separated serialized CSP list string