Class RequireTrustedTypesForDirective

java.lang.Object
org.htmlunit.csp.Directive
org.htmlunit.csp.directive.RequireTrustedTypesForDirective

public class RequireTrustedTypesForDirective extends Directive
Represents the require-trusted-types-for CSP directive.

This directive instructs the user agent to require Trusted Types for certain DOM sinks. Currently the only defined keyword is 'script', which enforces Trusted Types for all script-related injection sinks.

Author:
Michael Smith, Salvation Team
See Also:
  • Constructor Details

    • RequireTrustedTypesForDirective

      public RequireTrustedTypesForDirective(List<String> values, Directive.DirectiveErrorConsumer errors)
      Parses a require-trusted-types-for directive from the given list of values.

      The only currently recognised keyword is 'script' (case-insensitive). An empty directive, duplicate keywords, and unrecognised tokens are reported through the supplied errors consumer.

      Parameters:
      values - the raw string values for this directive
      errors - consumer that receives parsing errors and warnings
  • Method Details

    • script

      public boolean script()
      Returns whether the 'script' keyword is present.

      When true, Trusted Types are required for all script-related DOM injection sinks.

      Returns:
      true if the 'script' keyword is present
    • setScript

      public void setScript(boolean script)
      Sets whether the 'script' keyword is present.

      Setting to true adds 'script' to the directive values; setting to false removes it.

      Parameters:
      script - true to add 'script', false to remove it