java.lang.Object
org.htmlunit.csp.Directive
org.htmlunit.csp.directive.HostSourceDirective
- Direct Known Subclasses:
FrameAncestorsDirective,SourceExpressionDirective
Abstract base class for directives whose values are host-source lists.
A host-source list can contain the keywords 'none', 'self',
and *, as well as scheme-sources (https:) and host-sources
(example.com, *.example.com:443/path). This class is extended
by SourceExpressionDirective (which adds nonces, hashes, and other
source expressions) and by FrameAncestorsDirective.
- Author:
- Salvation Team
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.htmlunit.csp.Directive
Directive.DirectiveErrorConsumer -
Field Summary
Fields inherited from class org.htmlunit.csp.Directive
IS_DIRECTIVE_NAME -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedHostSourceDirective(List<String> values) Constructs a host-source directive from the given raw values. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidAppends a value to this directive's value list.getHosts()Returns an unmodifiable list of host-sources (e.g.getNone()Returns the original'none'token if the directive was set to'none', ornullif the directive is not'none'.Returns an unmodifiable list of scheme-sources (e.g.protected voidremoveValueIgnoreCase(String value) Removes all occurrences of a value from this directive (case-insensitive comparison).booleanself()Returns whether the'self'keyword is present in this source list.booleanstar()Returns whether the wildcard (*) is present in this source list.Methods inherited from class org.htmlunit.csp.Directive
containsNonDirectiveCharacter, getValues
-
Constructor Details
-
HostSourceDirective
Constructs a host-source directive from the given raw values.- Parameters:
values- the raw string values for this directive
-
-
Method Details
-
getNone
Returns the original'none'token if the directive was set to'none', ornullif the directive is not'none'.- Returns:
- the
'none'token string, ornull
-
addValue
Description copied from class:DirectiveAppends a value to this directive's value list.The value must be a non-empty ASCII string that does not contain whitespace, commas, or semicolons.
-
removeValueIgnoreCase
Description copied from class:DirectiveRemoves all occurrences of a value from this directive (case-insensitive comparison).- Overrides:
removeValueIgnoreCasein classDirective- Parameters:
value- the value to remove (compared case-insensitively)
-
star
public boolean star()Returns whether the wildcard (*) is present in this source list.When
*is present, any URL with a network scheme (ftp,http,https) is matched, as well as URLs whose scheme matches the origin's scheme.- Returns:
trueif the wildcard source is present
-
self
public boolean self()Returns whether the'self'keyword is present in this source list.When
'self'is present, URLs that share the same origin as the protected resource are matched.- Returns:
trueif'self'is present
-
getSchemes
Returns an unmodifiable list of scheme-sources (e.g.https:,data:) present in this directive.- Returns:
- the list of parsed
Schemevalues
-
getHosts
Returns an unmodifiable list of host-sources (e.g.example.com,*.cdn.example.com:443/path) present in this directive.- Returns:
- the list of parsed
Hostvalues
-