public final class CspInterceptor extends AbstractInterceptor
CspSettings
to add appropriate Content Security Policy header
to the response. These headers determine what the browser will consider a policy violation and the browser's behavior
when a violation occurs. A detailed explanation of CSP can be found here.Constructor and Description |
---|
CspInterceptor() |
Modifier and Type | Method and Description |
---|---|
String |
intercept(ActionInvocation invocation)
Override to handle interception
|
void |
setCspSettingsClassName(String cspSettingsClassName)
Sets the class name of the default
CspSettings implementation to use when the action does not
set its own values. |
void |
setEnforcingMode(boolean enforcingMode)
Enables enforcing mode, by default all exceptions are only reported
|
void |
setPrependServletContext(boolean prependServletContext)
Sets whether to prepend the servlet context path to the
reportUri . |
void |
setReportTo(String reportTo)
Sets the report group where csp violation reports will be sent.
|
void |
setReportUri(String reportUri) |
destroy, init, setDisabled, shouldIntercept
public String intercept(ActionInvocation invocation) throws Exception
AbstractInterceptor
intercept
in interface Interceptor
intercept
in class AbstractInterceptor
invocation
- the action invocationActionInvocation.invoke()
, or from the interceptor itself.Exception
- any system-level error, as defined in Action.execute()
.public void setReportUri(String reportUri)
public void setReportTo(String reportTo)
reportTo
- the report group where csp violation reports will be sentpublic void setEnforcingMode(boolean enforcingMode)
enforcingMode
- true
to enable enforcing mode, false
to keep reporting mode.public void setPrependServletContext(boolean prependServletContext)
reportUri
.prependServletContext
- true
to prepend the location with the servlet context path,
false
otherwise.public void setCspSettingsClassName(String cspSettingsClassName)
CspSettings
implementation to use when the action does not
set its own values. If not set, the default is DefaultCspSettings
.Copyright © 2000–2024 Apache Software Foundation. All rights reserved.