public class SpincastFormsCsrfProtectionFilterDefault extends Object implements SpincastFormsCsrfProtectionFilter
| Modifier and Type | Field and Description |
|---|---|
protected org.slf4j.Logger |
logger |
| Constructor and Description |
|---|
SpincastFormsCsrfProtectionFilterDefault(SpincastFormsProtectionConfig spincastFormsProtectionConfig,
SpincastCryptoUtils spincastCryptoUtils,
SpincastSessionManager spincastSessionManager,
SpincastConfig spincastConfig,
Dictionary dictionary) |
| Modifier and Type | Method and Description |
|---|---|
protected SpincastCsrfToken |
createCsrfToken() |
protected void |
csrfDoesntMatchAction(RequestContext<?> context,
String message)
What to do when the CSRF is not there or not valid?
By default, throw a
PublicException with
an HTTP status code of HttpStatus.SC_BAD_REQUEST and
a public message. |
SpincastCsrfToken |
getCurrentCsrfToken()
Returns the current CSRF token to use
Will be taken from the user session by default.
|
SpincastCsrfToken |
getCurrentCsrfToken(boolean createItIfNoneExists) |
protected Dictionary |
getDictionary() |
protected SpincastConfig |
getSpincastConfig() |
protected SpincastCryptoUtils |
getSpincastCryptoUtils() |
protected SpincastFormsProtectionConfig |
getSpincastFormsProtectionConfig() |
protected SpincastSessionManager |
getSpincastSessionManager() |
void |
handle(RequestContext<?> context)
Filter's handle main method.
|
@Inject public SpincastFormsCsrfProtectionFilterDefault(SpincastFormsProtectionConfig spincastFormsProtectionConfig, SpincastCryptoUtils spincastCryptoUtils, SpincastSessionManager spincastSessionManager, SpincastConfig spincastConfig, Dictionary dictionary)
protected SpincastFormsProtectionConfig getSpincastFormsProtectionConfig()
protected SpincastCryptoUtils getSpincastCryptoUtils()
protected SpincastSessionManager getSpincastSessionManager()
protected SpincastConfig getSpincastConfig()
protected Dictionary getDictionary()
public void handle(RequestContext<?> context) throws FormInvalidOriginException, FormInvalidCsrfTokenException
SpincastFormsCsrfProtectionFilterhandle in interface SpincastFormsCsrfProtectionFilterFormInvalidOriginException - if the form was submitted
from an invalid orgine.FormInvalidCsrfTokenException - if the form was submitted
with an invalid CRSF token.public SpincastCsrfToken getCurrentCsrfToken()
SpincastFormsCsrfProtectionFilterIf there is none, a new one is created and save in the user's session! This will make the session being dirty and saved to the database.
getCurrentCsrfToken in interface SpincastFormsCsrfProtectionFilterpublic SpincastCsrfToken getCurrentCsrfToken(boolean createItIfNoneExists)
protected SpincastCsrfToken createCsrfToken()
protected void csrfDoesntMatchAction(RequestContext<?> context, String message) throws Exception
PublicException with
an HTTP status code of HttpStatus.SC_BAD_REQUEST and
a public message.ExceptionCopyright © 2019. All rights reserved.