|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.xwiki.csrf.internal.DefaultCSRFToken
@Component @InstantiationStrategy(value=SINGLETON) public class DefaultCSRFToken
Concrete implementation of the CSRFToken component.
This implementation uses a user => token map to store the tokens. The tokens are random BASE64
encoded bit-strings.
TODO Expire tokens every couple of hours (configurable). Expiration can be implemented using two maps, oldTokens and currentTokens, old tokens are replaced by current tokens every 1/2 period, check is performed on both and new tokens are added to the current tokens.
| Constructor Summary | |
|---|---|
DefaultCSRFToken()
|
|
| Method Summary | |
|---|---|
void |
clearToken()
Removes the anti-CSRF token associated with the current user. |
java.lang.String |
getResubmissionURL()
Get the URL where a failed request should be redirected to. |
java.lang.String |
getToken()
Returns the anti-CSRF token associated with the current user. |
void |
initialize()
Initializes the storage and random number generator. |
boolean |
isTokenValid(java.lang.String token)
Check if the given token matches the internally stored token associated with the current user. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public DefaultCSRFToken()
| Method Detail |
|---|
public void initialize()
throws org.xwiki.component.phase.InitializationException
initialize in interface org.xwiki.component.phase.Initializableorg.xwiki.component.phase.InitializationExceptionpublic java.lang.String getToken()
getToken in interface CSRFTokenCSRFToken.isTokenValid(String)public void clearToken()
CSRFToken.getToken() will generate a fresh token.
clearToken in interface CSRFTokenpublic boolean isTokenValid(java.lang.String token)
token matches the internally stored token associated with the current user.
isTokenValid in interface CSRFTokentoken - random token from the request
true if the component is disabled or the given token is correct, false otherwisepublic java.lang.String getResubmissionURL()
getResubmissionURL in interface CSRFToken
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||