public class XsrfTokenInterceptor extends Object implements com.opensymphony.xwork2.interceptor.Interceptor
xwork.xml
.
Configuration in xwork.xml will override any annotation-based configuration. Behaviour when a method is not configured at all depends on the SecurityLevel seeting
Requests containing the HTTP header X-Atlassian-Token: no-check
will bypass the check and always
succeed.
Modifier and Type | Class and Description |
---|---|
static class |
XsrfTokenInterceptor.SecurityLevel |
Modifier and Type | Field and Description |
---|---|
static String |
CONFIG_PARAM_NAME |
static String |
OVERRIDE_HEADER_NAME |
static String |
OVERRIDE_HEADER_VALUE |
static String |
REQUEST_PARAM_NAME |
static String |
SECURITY_TOKEN_REQUIRED_ERROR_KEY |
static String |
VALIDATION_FAILED_ERROR_KEY |
Constructor and Description |
---|
XsrfTokenInterceptor() |
XsrfTokenInterceptor(XsrfTokenGenerator tokenGenerator) |
Modifier and Type | Method and Description |
---|---|
protected void |
addInvalidTokenError(com.opensymphony.xwork2.Action action,
String errorMessageKey)
Add error to action in cases where token is required, but is missing or invalid.
|
void |
destroy() |
protected XsrfTokenInterceptor.SecurityLevel |
getSecurityLevel()
Gets the current security level.
|
void |
init() |
String |
intercept(com.opensymphony.xwork2.ActionInvocation invocation) |
protected String |
internationaliseErrorMessage(com.opensymphony.xwork2.Action action,
String messageKey)
Convert an error message key into the correct message for the current user's locale.
|
public static final String REQUEST_PARAM_NAME
public static final String CONFIG_PARAM_NAME
public static final String VALIDATION_FAILED_ERROR_KEY
public static final String SECURITY_TOKEN_REQUIRED_ERROR_KEY
public static final String OVERRIDE_HEADER_NAME
public static final String OVERRIDE_HEADER_VALUE
public XsrfTokenInterceptor()
public XsrfTokenInterceptor(XsrfTokenGenerator tokenGenerator)
public String intercept(com.opensymphony.xwork2.ActionInvocation invocation) throws Exception
intercept
in interface com.opensymphony.xwork2.interceptor.Interceptor
Exception
protected void addInvalidTokenError(com.opensymphony.xwork2.Action action, String errorMessageKey)
internationaliseErrorMessage(com.opensymphony.xwork2.Action, java.lang.String)
action
- the action to add the error message toerrorMessageKey
- the error message key that will be used to internationalise the messageprotected String internationaliseErrorMessage(com.opensymphony.xwork2.Action action, String messageKey)
action
- the current action being executedmessageKey
- the message key that needs internationalisingpublic void destroy()
destroy
in interface com.opensymphony.xwork2.interceptor.Interceptor
public void init()
init
in interface com.opensymphony.xwork2.interceptor.Interceptor
protected XsrfTokenInterceptor.SecurityLevel getSecurityLevel()
XsrfTokenInterceptor.SecurityLevel
for more information on the meanings of the different
level. Default implementation returns OPT_IN
. Implementations should override this method if they
want more control over the security level setting.Copyright © 2021 Atlassian. All rights reserved.