Enum Class CspMode
- All Implemented Interfaces:
Serializable,Comparable<CspMode>,Constable
script-src policy without 'unsafe-inline'
and 'unsafe-eval'.
The mode is configured with the InitParameters.CSP configuration
parameter and read with
DeploymentConfiguration.getCspMode().
The WARN and STRICT modes act on the APIs that send
JavaScript to the browser as a string, such as
Element.executeJs(String, Object...), because the
browser has to compile it, which a strict policy blocks. This applies to the
calls that Vaadin itself makes as well, and in development mode as much as in
production mode. The STRICT mode also sends the Content Security
Policy header in production mode.
- Since:
- 25.4
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionThe default mode.Vaadin sends a nonce-based Content Security Policy, and APIs that needevalthrow aCspViolationException, whose stack trace leads from the API to its caller.The application runs unchanged, but every call that would not work under a strict Content Security Policy is logged as a warning, once per call site, with a stack trace that leads from the API to its caller. -
Method Summary
-
Enum Constant Details
-
OFF
The default mode. The application behaves as if no strict Content Security Policy is in use. -
WARN
The application runs unchanged, but every call that would not work under a strict Content Security Policy is logged as a warning, once per call site, with a stack trace that leads from the API to its caller. -
STRICT
Vaadin sends a nonce-based Content Security Policy, and APIs that needevalthrow aCspViolationException, whose stack trace leads from the API to its caller.In production mode, every index HTML response gets a new nonce that is put on every
<script>element of the page, and aContent-Security-Policyheader that allows only the scripts with that nonce and the scripts they load. Applications adjust the policy throughIndexHtmlResponse.getContentSecurityPolicy(). No header is sent in development mode, because the development server and the development tools needeval.Note: Vaadin itself still uses APIs that need
evalin some places, such as the event filters of double and single click listeners and of keyboard shortcuts. Until those are changed, they throw in this mode. Event data that is a property path, such as that of a click listener, does not needeval.
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-