Class CsrfTokenManager
java.lang.Object
at.porscheinformatik.tapestry.csrfprotection.internal.CsrfTokenManager
This class contains the logic to create a secure token for cross-site script request forgery protection. It is
created for a HTTP session and provides the same token throughout the whole session (per-session paradigm).
-
Constructor Summary
ConstructorsConstructorDescriptionCsrfTokenManager(CsrfTokenRepository tokenRepository, String parameterName) Initializes the secure token that will stay the same for the whole life cycle of this instance. -
Method Summary
Modifier and TypeMethodDescriptionvoidcheckToken(org.apache.tapestry5.http.services.Request request, jakarta.servlet.http.HttpServletRequest httpServletRequest) This method performs the check of the token.Returns the token stored in this instance.
-
Constructor Details
-
CsrfTokenManager
public CsrfTokenManager(CsrfTokenRepository tokenRepository, @Symbol("tapestry.csrf-token-parameter-name") String parameterName) Initializes the secure token that will stay the same for the whole life cycle of this instance.- Parameters:
tokenRepository- an implementation ofCsrfTokenRepositoryparameterName- symbolCsrfConstants.CSRF_TOKEN_PARAMETER_NAME
-
-
Method Details
-
getSessionToken
Returns the token stored in this instance.- Returns:
- the stored token or a newly generated one
-
checkToken
public void checkToken(org.apache.tapestry5.http.services.Request request, jakarta.servlet.http.HttpServletRequest httpServletRequest) throws CsrfException This method performs the check of the token. It extracts the current client token from the request and the current server-side token by accessing the CsrfTokenProvider instance assigned in this session.- Parameters:
request- .httpServletRequest- .- Throws:
CsrfException- when token not there or token does not match
-