@ComponentSpecification public interface CsrfTokenManager extends Security
CsrfTokens.| Modifier and Type | Method and Description |
|---|---|
CsrfToken |
generateInitialToken()
This method generates a new
CsrfToken for the initial "log-in" of a user. |
CsrfToken |
generateUpdateToken(CsrfToken currentToken)
|
boolean |
isValidToken(CsrfToken token)
Checks if the given
CsrfToken that has been sent from the client is valid. |
void |
validateToken(CsrfToken token) |
boolean isValidToken(CsrfToken token)
CsrfToken that has been sent from the client is valid. This method has to
correspond to generateInitialToken() and generateUpdateToken(CsrfToken). In case a
remote invocation is invoked that is secured (requires authentication and typically also authorization),
the CsrfToken has to be checked. A value of null is never valid and will always
fail. Only in case of a secured invocation and the presence of CsrfToken this method is invoked.token - is the CsrfToken send from the client. Will not be null.true if the given token is valid, false otherwise (in case
of an CSRF attack or some technical bug).void validateToken(CsrfToken token) throws SecurityException
token - is the token to validate.SecurityException - if the token is not valid.isValidToken(CsrfToken)CsrfToken generateInitialToken()
CsrfToken for the initial "log-in" of a user. Here are some examples
of possible implementation strategies:
UUID.
The token is also stored in the server-side HTTP session so it can be compared for
validation.validation can decrypt the token, split the aspects and verify them.
Security.Random to generate security tokens as this is too weak.CsrfToken. Shall not be null.CsrfToken generateUpdateToken(CsrfToken currentToken)
currentToken - is the current CsrfToken that has previously been generated and may be
updated.currentToken (same instance) to keep the token or a new instance of
CsrfToken to replace the current token and expect the next request from the client to
provide that new token (e.g. to implement one-time tokens for highest level of protection).generateInitialToken()Copyright © 2001–2016 mmm-Team. All rights reserved.