Package com.shapesecurity.salvation2
Class Policy
java.lang.Object
com.shapesecurity.salvation2.Policy
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static enum
private static class
static interface
static interface
static enum
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate SourceExpressionDirective
private boolean
private List
<Policy.NamedDirective> private final Map
<FetchDirectiveKind, SourceExpressionDirective> private SourceExpressionDirective
private FrameAncestorsDirective
private SourceExpressionDirective
private PluginTypesDirective
private RFC7230Token
private ReportUriDirective
private SandboxDirective
private boolean
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionadd
(String name, List<String> values, Directive.DirectiveErrorConsumer directiveErrorConsumer) boolean
allowsApplicationManifest
(Optional<URLWithScheme> source, Optional<URLWithScheme> origin) boolean
allowsConnection
(Optional<URLWithScheme> source, Optional<URLWithScheme> origin) boolean
boolean
allowsExternalScript
(Optional<String> nonce, Optional<String> integrity, Optional<URLWithScheme> scriptUrl, Optional<Boolean> parserInserted, Optional<URLWithScheme> origin) boolean
allowsExternalStyle
(Optional<String> nonce, Optional<URLWithScheme> styleUrl, Optional<URLWithScheme> origin) boolean
allowsFont
(Optional<URLWithScheme> source, Optional<URLWithScheme> origin) boolean
allowsFormAction
(Optional<URLWithScheme> to, Optional<Boolean> redirected, Optional<URLWithScheme> redirectedTo, Optional<URLWithScheme> origin) boolean
allowsFrame
(Optional<URLWithScheme> source, Optional<URLWithScheme> origin) boolean
allowsFrameAncestor
(Optional<URLWithScheme> source, Optional<URLWithScheme> origin) boolean
allowsImage
(Optional<URLWithScheme> source, Optional<URLWithScheme> origin) boolean
allowsInlineScript
(Optional<String> nonce, Optional<String> source, Optional<Boolean> parserInserted) boolean
allowsInlineStyle
(Optional<String> nonce, Optional<String> source) boolean
allowsJavascriptUrlNavigation
(Optional<String> source, Optional<URLWithScheme> origin) boolean
allowsMedia
(Optional<URLWithScheme> source, Optional<URLWithScheme> origin) boolean
allowsNavigation
(Optional<URLWithScheme> to, Optional<Boolean> redirected, Optional<URLWithScheme> redirectedTo, Optional<URLWithScheme> origin) boolean
allowsObject
(Optional<URLWithScheme> source, Optional<URLWithScheme> origin) boolean
allowsPlugin
(Optional<MediaType> mediaType) boolean
allowsPrefetch
(Optional<URLWithScheme> source, Optional<URLWithScheme> origin) boolean
allowsScriptAsAttribute
(Optional<String> source) boolean
allowsStyleAsAttribute
(Optional<String> source) boolean
allowsWorker
(Optional<URLWithScheme> source, Optional<URLWithScheme> origin) baseUri()
boolean
private static String
private boolean
doesElementMatchSourceListForTypeAndSource
(Policy.InlineType type, Optional<String> nonce, Optional<String> source, Optional<Boolean> parserInserted) static boolean
doesUrlMatchSourceListInOrigin
(URLWithScheme url, HostSourceDirective list, Optional<URLWithScheme> origin) (package private) static void
private static boolean
hostPartMatches
(String A, String B) private static String
normalizeBase64Url
(String input) static Policy
parseSerializedCSP
(String serialized, Policy.PolicyErrorConsumer policyErrorConsumer) static PolicyList
parseSerializedCSPList
(String serialized, Policy.PolicyListErrorConsumer policyListErrorConsumer) private static boolean
pathPartMatches
(String pathA, String pathB) private static boolean
portPartMatches
(int A, int portB, String schemeB) boolean
reportTo()
sandbox()
private static boolean
schemePartMatches
(String A, String B) void
setBlockAllMixedContent
(boolean value) void
setReportTo
(RFC7230Token token) void
setUpgradeInsecureRequests
(boolean value) private static String
stripLeadingWhitespace
(String string) private static String
stripTrailingWhitespace
(String string) toString()
boolean
-
Field Details
-
directives
-
baseUri
-
blockAllMixedContent
private boolean blockAllMixedContent -
formAction
-
frameAncestors
-
pluginTypes
-
reportTo
-
reportUri
-
sandbox
-
upgradeInsecureRequests
private boolean upgradeInsecureRequests -
fetchDirectives
-
-
Constructor Details
-
Policy
private Policy()
-
-
Method Details
-
parseSerializedCSPList
@Nonnull public static PolicyList parseSerializedCSPList(String serialized, Policy.PolicyListErrorConsumer policyListErrorConsumer) -
parseSerializedCSP
@Nonnull public static Policy parseSerializedCSP(String serialized, Policy.PolicyErrorConsumer policyErrorConsumer) -
add
public Directive add(String name, List<String> values, Directive.DirectiveErrorConsumer directiveErrorConsumer) -
remove
-
toString
-
baseUri
-
blockAllMixedContent
public boolean blockAllMixedContent() -
setBlockAllMixedContent
public void setBlockAllMixedContent(boolean value) -
formAction
-
frameAncestors
-
pluginTypes
-
reportTo
-
setReportTo
-
reportUri
-
sandbox
-
upgradeInsecureRequests
public boolean upgradeInsecureRequests() -
setUpgradeInsecureRequests
public void setUpgradeInsecureRequests(boolean value) -
getFetchDirective
-
allowsExternalScript
public boolean allowsExternalScript(Optional<String> nonce, Optional<String> integrity, Optional<URLWithScheme> scriptUrl, Optional<Boolean> parserInserted, Optional<URLWithScheme> origin) -
allowsInlineScript
-
allowsScriptAsAttribute
-
allowsEval
public boolean allowsEval() -
allowsFormAction
public boolean allowsFormAction(Optional<URLWithScheme> to, Optional<Boolean> redirected, Optional<URLWithScheme> redirectedTo, Optional<URLWithScheme> origin) -
allowsExternalStyle
public boolean allowsExternalStyle(Optional<String> nonce, Optional<URLWithScheme> styleUrl, Optional<URLWithScheme> origin) -
allowsInlineStyle
-
allowsStyleAsAttribute
-
allowsFrame
-
allowsFrameAncestor
-
allowsConnection
-
allowsFont
-
allowsImage
-
allowsApplicationManifest
public boolean allowsApplicationManifest(Optional<URLWithScheme> source, Optional<URLWithScheme> origin) -
allowsMedia
-
allowsObject
-
allowsPrefetch
-
allowsWorker
-
allowsPlugin
-
getGoverningDirectiveForEffectiveDirective
public Optional<SourceExpressionDirective> getGoverningDirectiveForEffectiveDirective(FetchDirectiveKind kind) -
doesElementMatchSourceListForTypeAndSource
-
normalizeBase64Url
-
doesUrlMatchSourceListInOrigin
public static boolean doesUrlMatchSourceListInOrigin(URLWithScheme url, HostSourceDirective list, Optional<URLWithScheme> origin) -
schemePartMatches
-
hostPartMatches
-
portPartMatches
-
pathPartMatches
-
enforceAscii
-
stripLeadingWhitespace
-
stripTrailingWhitespace
-
collect
-