public class SimpleXsrfTokenGenerator extends Object implements XsrfTokenGenerator
Tokens are chosen to be reasonably unique (60 bits) with reasonably short representations (base64 encoded).
Modifier and Type | Field and Description |
---|---|
static String |
TOKEN_SESSION_KEY |
Constructor and Description |
---|
SimpleXsrfTokenGenerator() |
Modifier and Type | Method and Description |
---|---|
String |
generateToken(javax.servlet.http.HttpServletRequest request)
Generate a new form token for the current request.
|
String |
getToken(javax.servlet.http.HttpServletRequest request,
boolean create)
Retrieves the token from the request.
|
String |
getXsrfTokenName()
Convenience method which will return the name to be used for a supplied XsrfToken in a request.
|
boolean |
validateToken(javax.servlet.http.HttpServletRequest request,
String token)
Validate a form token received as part of a web request
|
public static final String TOKEN_SESSION_KEY
public String getToken(javax.servlet.http.HttpServletRequest request, boolean create)
XsrfTokenGenerator
getToken
in interface XsrfTokenGenerator
request
- the request the token is retrieved fromcreate
- if true, a token will be created if it doesn't already existpublic String generateToken(javax.servlet.http.HttpServletRequest request)
XsrfTokenGenerator
generateToken
in interface XsrfTokenGenerator
request
- the request the token is being generated forpublic String getXsrfTokenName()
XsrfTokenGenerator
getXsrfTokenName
in interface XsrfTokenGenerator
public boolean validateToken(javax.servlet.http.HttpServletRequest request, String token)
XsrfTokenGenerator
validateToken
in interface XsrfTokenGenerator
request
- the request the token was received intoken
- the tokenCopyright © 2020 Atlassian. All rights reserved.