public abstract class CspReportAction extends ActionSupport implements ServletRequestAware, ServletResponseAware
processReport(String jsonCspReport) method to customize how the action processes
the CSP report. See DefaultCspReportAction for the default implementation.
Add the action to the endpoint that is the reportUri in the CspInterceptor
to collect the reports.
<package name="csp-reports" namespace="/" extends="struts-default">
<action name="csp-reports" class="org.apache.struts2.action.DefaultCspReportAction">
<result type="httpheader">
<param name="status">204</param>
</result>
</action>
</package>
DefaultCspReportAction,
Serialized FormValidationAware.LegacyAdapter| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_MAX_REPORT_SIZE
Default upper bound, in characters, on the report body accepted by
withServletRequest(javax.servlet.http.HttpServletRequest). |
container| Constructor and Description |
|---|
CspReportAction() |
| Modifier and Type | Method and Description |
|---|---|
javax.servlet.http.HttpServletRequest |
getServletRequest() |
void |
setMaxReportSize(String maxReportSize)
Sets the upper bound, in characters, on an accepted report body.
|
void |
setServletRequest(javax.servlet.http.HttpServletRequest request) |
void |
withServletRequest(javax.servlet.http.HttpServletRequest request)
Applies the HTTP request object in implementing classes.
|
void |
withServletResponse(javax.servlet.http.HttpServletResponse response)
Applies the HTTP response object in implementing classes.
|
addActionError, addActionMessage, addFieldError, clearActionErrors, clearErrors, clearErrorsAndMessages, clearFieldErrors, clearMessages, clone, execute, getActionErrors, getActionMessages, getContainer, getFieldErrors, getFormatted, getLocale, getLocaleProvider, getText, getText, getText, getText, getText, getText, getText, getText, getText, getTextProvider, getTexts, getTexts, hasActionErrors, hasActionMessages, hasErrors, hasFieldErrors, hasKey, input, isValidLocale, isValidLocaleString, pause, setActionErrors, setActionMessages, setContainer, setFieldErrors, toLocale, validateequals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitvalidateadaptaddActionError, addActionMessage, addFieldError, getActionErrors, getActionMessages, getFieldErrors, hasActionErrors, hasActionMessages, hasErrors, hasFieldErrors, setActionErrors, setActionMessages, setFieldErrorspublic static final int DEFAULT_MAX_REPORT_SIZE
withServletRequest(javax.servlet.http.HttpServletRequest).
CSP violation reports are small JSON documents; anything larger is not treated as a report.public void setMaxReportSize(String maxReportSize)
processReport(String).
The value is injected from struts.csp.report.maxSize when the action is built, which is
before the interceptor stack runs. It is deliberately not an action property: the report body is
read by withServletRequest(HttpServletRequest), which the servletConfig
interceptor invokes ahead of staticParams and params, so a value applied by
either of those would arrive too late to have any effect.
maxReportSize - maximum accepted report size in characterspublic void withServletRequest(javax.servlet.http.HttpServletRequest request)
ServletRequestAwarewithServletRequest in interface ServletRequestAwarerequest - the HTTP request.public void withServletResponse(javax.servlet.http.HttpServletResponse response)
ServletResponseAwarewithServletResponse in interface ServletResponseAwareresponse - the HTTP response.public void setServletRequest(javax.servlet.http.HttpServletRequest request)
public javax.servlet.http.HttpServletRequest getServletRequest()
Copyright © 2000–2026 Apache Software Foundation. All rights reserved.