Policy with its
origin, providing simplified query methods that
automatically supply the origin to the underlying policy checks.
Each allows* method delegates to the corresponding method on
Policy, filling in Optional.of(origin_) for the origin
parameter and Optional.empty() for any parameters that are not
applicable to the simplified query (such as nonce, integrity, or
redirect information).
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanDetermines whether the policy allows a connection (e.g.booleanDetermines whether the policy allows loading a font from the given URL.booleanDetermines whether the policy allows a form submission to the given URL.booleanDetermines whether the policy allows being framed by the given ancestor URL.booleanDetermines whether the policy allows loading a frame from the given URL.booleanDetermines whether the policy allows loading an image from the given URL.booleanDetermines whether the policy allows loading an application manifest from the given URL.booleanDetermines whether the policy allows loading media (audio/video) from the given URL.booleanDetermines whether the policy allows navigation to the given URL.booleanDetermines whether the policy allows loading an object/embed/applet from the given URL.booleanDetermines whether the policy allows a prefetch from the given URL.booleanDetermines whether the policy allows loading an external script from the given URL.booleanDetermines whether the policy allows loading an external stylesheet from the given URL.booleanDetermines whether the policy allows any inline script without a nonce or hash.booleanDetermines whether the policy allows any inline style without a nonce or hash.booleanDetermines whether the policy allows loading a worker from the given URL.Returns the underlying origin.Returns the underlyingPolicy.
-
Constructor Details
-
PolicyInOrigin
Ctor.- Parameters:
policy- the Content Security Policy to query againstorigin- the origin of the protected resource
-
-
Method Details
-
getPolicy
Returns the underlyingPolicy.- Returns:
- the policy associated with this origin-bound wrapper
-
getOrigin
Returns the underlying origin.- Returns:
- the policy associated with this origin-bound wrapper
-
allowsScriptFromSource
Determines whether the policy allows loading an external script from the given URL.Delegates to
Policy.allowsExternalScript(java.util.Optional<java.lang.String>, java.util.Optional<java.lang.String>, java.util.Optional<? extends org.htmlunit.csp.url.URLWithScheme>, java.util.Optional<java.lang.Boolean>, java.util.Optional<? extends org.htmlunit.csp.url.URLWithScheme>)with no nonce, no integrity, unknown parser-inserted status, and this wrapper's origin.- Parameters:
url- the URL of the external script- Returns:
trueif the policy allows the script from the given source
-
allowsStyleFromSource
Determines whether the policy allows loading an external stylesheet from the given URL.Delegates to
Policy.allowsExternalStyle(java.util.Optional<java.lang.String>, java.util.Optional<? extends org.htmlunit.csp.url.URLWithScheme>, java.util.Optional<? extends org.htmlunit.csp.url.URLWithScheme>)with no nonce and this wrapper's origin.- Parameters:
url- the URL of the external stylesheet- Returns:
trueif the policy allows the style from the given source
-
allowsImageFromSource
Determines whether the policy allows loading an image from the given URL.Delegates to
Policy.allowsImage(java.util.Optional<? extends org.htmlunit.csp.url.URLWithScheme>, java.util.Optional<? extends org.htmlunit.csp.url.URLWithScheme>)with this wrapper's origin.- Parameters:
url- the URL of the image resource- Returns:
trueif the policy allows the image from the given source
-
allowsFrameFromSource
Determines whether the policy allows loading a frame from the given URL.Delegates to
Policy.allowsFrame(java.util.Optional<? extends org.htmlunit.csp.url.URLWithScheme>, java.util.Optional<? extends org.htmlunit.csp.url.URLWithScheme>)with this wrapper's origin.- Parameters:
url- the URL of the framed resource- Returns:
trueif the policy allows the frame from the given source
-
allowsWorkerFromSource
Determines whether the policy allows loading a worker from the given URL.Delegates to
Policy.allowsWorker(java.util.Optional<? extends org.htmlunit.csp.url.URLWithScheme>, java.util.Optional<? extends org.htmlunit.csp.url.URLWithScheme>)with this wrapper's origin.- Parameters:
url- the URL of the worker script- Returns:
trueif the policy allows the worker from the given source
-
allowsFontFromSource
Determines whether the policy allows loading a font from the given URL.Delegates to
Policy.allowsFont(java.util.Optional<? extends org.htmlunit.csp.url.URLWithScheme>, java.util.Optional<? extends org.htmlunit.csp.url.URLWithScheme>)with this wrapper's origin.- Parameters:
url- the URL of the font resource- Returns:
trueif the policy allows the font from the given source
-
allowsObjectFromSource
Determines whether the policy allows loading an object/embed/applet from the given URL.Delegates to
Policy.allowsObject(java.util.Optional<? extends org.htmlunit.csp.url.URLWithScheme>, java.util.Optional<? extends org.htmlunit.csp.url.URLWithScheme>)with this wrapper's origin.- Parameters:
url- the URL of the object resource- Returns:
trueif the policy allows the object from the given source
-
allowsMediaFromSource
Determines whether the policy allows loading media (audio/video) from the given URL.Delegates to
Policy.allowsMedia(java.util.Optional<? extends org.htmlunit.csp.url.URLWithScheme>, java.util.Optional<? extends org.htmlunit.csp.url.URLWithScheme>)with this wrapper's origin.- Parameters:
url- the URL of the media resource- Returns:
trueif the policy allows the media from the given source
-
allowsManifestFromSource
Determines whether the policy allows loading an application manifest from the given URL.Delegates to
Policy.allowsApplicationManifest(java.util.Optional<? extends org.htmlunit.csp.url.URLWithScheme>, java.util.Optional<? extends org.htmlunit.csp.url.URLWithScheme>)with this wrapper's origin.- Parameters:
url- the URL of the manifest resource- Returns:
trueif the policy allows the manifest from the given source
-
allowsPrefetchFromSource
Determines whether the policy allows a prefetch from the given URL.Delegates to
Policy.allowsPrefetch(java.util.Optional<? extends org.htmlunit.csp.url.URLWithScheme>, java.util.Optional<? extends org.htmlunit.csp.url.URLWithScheme>)with this wrapper's origin.- Parameters:
url- the URL to prefetch- Returns:
trueif the policy allows the prefetch from the given source
-
allowsUnsafeInlineScript
public boolean allowsUnsafeInlineScript()Determines whether the policy allows any inline script without a nonce or hash.Delegates to
Policy.allowsInlineScript(java.util.Optional<java.lang.String>, java.util.Optional<java.lang.String>, java.util.Optional<java.lang.Boolean>)with no nonce, no source text, and unknown parser-inserted status. This effectively checks whether'unsafe-inline'is active for scripts.- Returns:
trueif the policy allows inline scripts without specific credentials
-
allowsUnsafeInlineStyle
public boolean allowsUnsafeInlineStyle()Determines whether the policy allows any inline style without a nonce or hash.Delegates to
Policy.allowsInlineStyle(java.util.Optional<java.lang.String>, java.util.Optional<java.lang.String>)with no nonce and no source text. This effectively checks whether'unsafe-inline'is active for styles.- Returns:
trueif the policy allows inline styles without specific credentials
-
allowsConnection
Determines whether the policy allows a connection (e.g.fetch(),XMLHttpRequest,WebSocket) to the given URL.Delegates to
Policy.allowsConnection(java.util.Optional<? extends org.htmlunit.csp.url.URLWithScheme>, java.util.Optional<? extends org.htmlunit.csp.url.URLWithScheme>)with this wrapper's origin.- Parameters:
url- the URL to connect to- Returns:
trueif the policy allows the connection to the given source
-
allowsFrameAncestor
Determines whether the policy allows being framed by the given ancestor URL.Delegates to
Policy.allowsFrameAncestor(java.util.Optional<? extends org.htmlunit.csp.url.URLWithScheme>, java.util.Optional<? extends org.htmlunit.csp.url.URLWithScheme>)with this wrapper's origin.- Parameters:
url- the URL of the ancestor frame- Returns:
trueif the policy allows the frame ancestor
-
allowsFormAction
Determines whether the policy allows a form submission to the given URL.Delegates to
Policy.allowsFormAction(java.util.Optional<? extends org.htmlunit.csp.url.URLWithScheme>, java.util.Optional<java.lang.Boolean>, java.util.Optional<? extends org.htmlunit.csp.url.URLWithScheme>, java.util.Optional<? extends org.htmlunit.csp.url.URLWithScheme>)with unknown redirect status, no redirect target, and this wrapper's origin.- Parameters:
url- the form action target URL- Returns:
trueif the policy allows the form action to the given URL
-