- All Known Implementing Classes:
Policy,PolicyList
public interface CspQueries
Enforcement query API shared by
Policy and PolicyList.
For a single Policy, each method applies that policy's rules.
For a PolicyList, each method returns true only if every
member policy allows the resource (an empty list is unrestricted).
Semantics of individual checks are documented on Policy.
- Since:
- 5.4.0
- Author:
- Ronald Brill, Rick Mitchell
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionbooleanallowsApplicationManifest(Optional<? extends URLWithScheme> source, Optional<? extends URLWithScheme> origin) Returns whether an application manifest is allowed.booleanallowsConnection(Optional<? extends URLWithScheme> source, Optional<? extends URLWithScheme> origin) Returns whether a connection is allowed.booleanReturns whether eval is allowed.booleanallowsExternalScript(Optional<String> nonce, Optional<String> integrity, Optional<? extends URLWithScheme> scriptUrl, Optional<Boolean> parserInserted, Optional<? extends URLWithScheme> origin) Returns whether an external script is allowed.booleanallowsExternalStyle(Optional<String> nonce, Optional<? extends URLWithScheme> styleUrl, Optional<? extends URLWithScheme> origin) Returns whether an external stylesheet is allowed.booleanallowsFont(Optional<? extends URLWithScheme> source, Optional<? extends URLWithScheme> origin) Returns whether a font is allowed.booleanallowsFormAction(Optional<? extends URLWithScheme> to, Optional<Boolean> redirected, Optional<? extends URLWithScheme> redirectedTo, Optional<? extends URLWithScheme> origin) Returns whether a form action is allowed.booleanallowsFrame(Optional<? extends URLWithScheme> source, Optional<? extends URLWithScheme> origin) Returns whether a frame is allowed.booleanallowsFrameAncestor(Optional<? extends URLWithScheme> source, Optional<? extends URLWithScheme> origin) Returns whether a frame ancestor is allowed.booleanallowsImage(Optional<? extends URLWithScheme> source, Optional<? extends URLWithScheme> origin) Returns whether an image is allowed.booleanallowsInlineScript(Optional<String> nonce, Optional<String> source, Optional<Boolean> parserInserted) Returns whether an inline script is allowed.booleanallowsInlineStyle(Optional<String> nonce, Optional<String> source) Returns whether an inline style is allowed.booleanallowsJavascriptUrlNavigation(Optional<String> source, Optional<? extends URLWithScheme> origin) Returns whether ajavascript:URL navigation is allowed.booleanallowsMedia(Optional<? extends URLWithScheme> source, Optional<? extends URLWithScheme> origin) Returns whether media is allowed.booleanallowsNavigation(Optional<? extends URLWithScheme> to, Optional<Boolean> redirected, Optional<? extends URLWithScheme> redirectedTo, Optional<? extends URLWithScheme> origin) Returns whether navigation is allowed.booleanallowsObject(Optional<? extends URLWithScheme> source, Optional<? extends URLWithScheme> origin) Returns whether an object is allowed.booleanallowsPlugin(Optional<? extends MediaType> mediaType) Returns whether a plugin type is allowed.booleanallowsPrefetch(Optional<? extends URLWithScheme> source, Optional<? extends URLWithScheme> origin) Returns whether a prefetch is allowed.booleanallowsScriptAsAttribute(Optional<String> source) Returns whether a script event-handler attribute is allowed.booleanallowsStyleAsAttribute(Optional<String> source) Returns whether a style attribute is allowed.booleanallowsWorker(Optional<? extends URLWithScheme> source, Optional<? extends URLWithScheme> origin) Returns whether a worker is allowed.
-
Method Details
-
allowsExternalScript
boolean allowsExternalScript(Optional<String> nonce, Optional<String> integrity, Optional<? extends URLWithScheme> scriptUrl, Optional<Boolean> parserInserted, Optional<? extends URLWithScheme> origin) Returns whether an external script is allowed.- Parameters:
nonce- script nonce, if anyintegrity- SRI metadata, if anyscriptUrl- script URL, if knownparserInserted- whether the script is parser-insertedorigin- protected-resource origin, if known- Returns:
trueif allowed under this query target's rules- See Also:
-
allowsInlineScript
boolean allowsInlineScript(Optional<String> nonce, Optional<String> source, Optional<Boolean> parserInserted) Returns whether an inline script is allowed.- Parameters:
nonce- script nonce, if anysource- inline script text, if knownparserInserted- whether the script is parser-inserted- Returns:
trueif allowed under this query target's rules- See Also:
-
allowsScriptAsAttribute
Returns whether a script event-handler attribute is allowed.- Parameters:
source- attribute text, if known- Returns:
trueif allowed under this query target's rules- See Also:
-
allowsEval
boolean allowsEval()Returns whether eval is allowed.- Returns:
trueif allowed under this query target's rules- See Also:
-
allowsFormAction
boolean allowsFormAction(Optional<? extends URLWithScheme> to, Optional<Boolean> redirected, Optional<? extends URLWithScheme> redirectedTo, Optional<? extends URLWithScheme> origin) Returns whether a form action is allowed.- Parameters:
to- form action URL, if knownredirected- whether the submission redirectsredirectedTo- final URL after redirect, if knownorigin- protected-resource origin, if known- Returns:
trueif allowed under this query target's rules- See Also:
-
allowsExternalStyle
boolean allowsExternalStyle(Optional<String> nonce, Optional<? extends URLWithScheme> styleUrl, Optional<? extends URLWithScheme> origin) Returns whether an external stylesheet is allowed.- Parameters:
nonce- style nonce, if anystyleUrl- stylesheet URL, if knownorigin- protected-resource origin, if known- Returns:
trueif allowed under this query target's rules- See Also:
-
allowsInlineStyle
Returns whether an inline style is allowed.- Parameters:
nonce- style nonce, if anysource- inline style text, if known- Returns:
trueif allowed under this query target's rules- See Also:
-
allowsStyleAsAttribute
Returns whether a style attribute is allowed.- Parameters:
source- attribute text, if known- Returns:
trueif allowed under this query target's rules- See Also:
-
allowsFrame
boolean allowsFrame(Optional<? extends URLWithScheme> source, Optional<? extends URLWithScheme> origin) Returns whether a frame is allowed.- Parameters:
source- framed resource URL, if knownorigin- protected-resource origin, if known- Returns:
trueif allowed under this query target's rules- See Also:
-
allowsFrameAncestor
boolean allowsFrameAncestor(Optional<? extends URLWithScheme> source, Optional<? extends URLWithScheme> origin) Returns whether a frame ancestor is allowed.- Parameters:
source- ancestor frame URL, if knownorigin- protected-resource origin, if known- Returns:
trueif allowed under this query target's rules- See Also:
-
allowsConnection
boolean allowsConnection(Optional<? extends URLWithScheme> source, Optional<? extends URLWithScheme> origin) Returns whether a connection is allowed.- Parameters:
source- connection URL, if knownorigin- protected-resource origin, if known- Returns:
trueif allowed under this query target's rules- See Also:
-
allowsFont
boolean allowsFont(Optional<? extends URLWithScheme> source, Optional<? extends URLWithScheme> origin) Returns whether a font is allowed.- Parameters:
source- font URL, if knownorigin- protected-resource origin, if known- Returns:
trueif allowed under this query target's rules- See Also:
-
allowsImage
boolean allowsImage(Optional<? extends URLWithScheme> source, Optional<? extends URLWithScheme> origin) Returns whether an image is allowed.- Parameters:
source- image URL, if knownorigin- protected-resource origin, if known- Returns:
trueif allowed under this query target's rules- See Also:
-
allowsApplicationManifest
boolean allowsApplicationManifest(Optional<? extends URLWithScheme> source, Optional<? extends URLWithScheme> origin) Returns whether an application manifest is allowed.- Parameters:
source- manifest URL, if knownorigin- protected-resource origin, if known- Returns:
trueif allowed under this query target's rules- See Also:
-
allowsMedia
boolean allowsMedia(Optional<? extends URLWithScheme> source, Optional<? extends URLWithScheme> origin) Returns whether media is allowed.- Parameters:
source- media URL, if knownorigin- protected-resource origin, if known- Returns:
trueif allowed under this query target's rules- See Also:
-
allowsObject
boolean allowsObject(Optional<? extends URLWithScheme> source, Optional<? extends URLWithScheme> origin) Returns whether an object is allowed.- Parameters:
source- object URL, if knownorigin- protected-resource origin, if known- Returns:
trueif allowed under this query target's rules- See Also:
-
allowsPrefetch
boolean allowsPrefetch(Optional<? extends URLWithScheme> source, Optional<? extends URLWithScheme> origin) Returns whether a prefetch is allowed.- Parameters:
source- prefetch URL, if knownorigin- protected-resource origin, if known- Returns:
trueif allowed under this query target's rules- See Also:
-
allowsWorker
boolean allowsWorker(Optional<? extends URLWithScheme> source, Optional<? extends URLWithScheme> origin) Returns whether a worker is allowed.- Parameters:
source- worker URL, if knownorigin- protected-resource origin, if known- Returns:
trueif allowed under this query target's rules- See Also:
-
allowsPlugin
Returns whether a plugin type is allowed.- Parameters:
mediaType- plugin media type, if known- Returns:
trueif allowed under this query target's rules- See Also:
-