Class SpincastFormsDoubleSubmitProtectionFilterDefault
java.lang.Object
org.spincast.plugins.formsprotection.doublesubmit.SpincastFormsDoubleSubmitProtectionFilterDefault
- All Implemented Interfaces:
SpincastFormsDoubleSubmitProtectionFilter
public class SpincastFormsDoubleSubmitProtectionFilterDefault
extends Object
implements SpincastFormsDoubleSubmitProtectionFilter
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionSpincastFormsDoubleSubmitProtectionFilterDefault
(SpincastFormsProtectionConfig spincastFormsProtectionConfig, FlashMessageFactory flashMessageFactory, Dictionary dictionary, SpincastCryptoUtils cryptoUtils, SpincastFormsDoubleSubmitProtectionRepository spincastFormsDoubleSubmitProtectionRepository) -
Method Summary
Modifier and TypeMethodDescriptionCreates an id to use in a form that needs to be protected.protected SpincastCryptoUtils
protected Dictionary
protected FlashMessageFactory
protected String
protected SpincastFormsProtectionConfig
getSubmittedFormInfo
(String payloadEncrypted) Returns the Date/ProtectionId ornull
if invalid.void
handle
(RequestContext<?> context) Filter's handle main method.protected void
invalidFormMatchAction
(RequestContext<?> context, String message) What to do when the submitted form is not valid (already submitted for example).
-
Field Details
-
logger
protected static final org.slf4j.Logger logger
-
-
Constructor Details
-
SpincastFormsDoubleSubmitProtectionFilterDefault
@Inject public SpincastFormsDoubleSubmitProtectionFilterDefault(SpincastFormsProtectionConfig spincastFormsProtectionConfig, FlashMessageFactory flashMessageFactory, Dictionary dictionary, SpincastCryptoUtils cryptoUtils, SpincastFormsDoubleSubmitProtectionRepository spincastFormsDoubleSubmitProtectionRepository)
-
-
Method Details
-
getSpincastFormsProtectionConfig
-
getFlashMessageFactory
-
getDictionary
-
getCryptoUtils
-
getSpincastFormsDoubleSubmitProtectionRepository
protected SpincastFormsDoubleSubmitProtectionRepository getSpincastFormsDoubleSubmitProtectionRepository() -
handle
public void handle(RequestContext<?> context) throws FormAlreadySubmittedException, FormTooOldException Description copied from interface:SpincastFormsDoubleSubmitProtectionFilter
Filter's handle main method.- Specified by:
handle
in interfaceSpincastFormsDoubleSubmitProtectionFilter
- Throws:
FormAlreadySubmittedException
- if the form was already submitted. This exception, by default, implementsPublicException
and contains a message from theDictionary
to be displayed to the user.FormTooOldException
- if the submitted form is too old. This exception, by default, implementsPublicException
and contains a message from theDictionary
to be displayed to the user.
-
createNewFormDoubleSubmitProtectionId
Description copied from interface:SpincastFormsDoubleSubmitProtectionFilter
Creates an id to use in a form that needs to be protected.- Specified by:
createNewFormDoubleSubmitProtectionId
in interfaceSpincastFormsDoubleSubmitProtectionFilter
-
getSubmittedFormInfo
protected org.spincast.shaded.org.apache.commons.lang3.tuple.Pair<Instant,String> getSubmittedFormInfo(String payloadEncrypted) Returns the Date/ProtectionId ornull
if invalid. -
invalidFormMatchAction
What to do when the submitted form is not valid (already submitted for example). By default, throw aPublicException
with an HTTP status code ofHttpStatus.SC_BAD_REQUEST
and a public message.- Throws:
Exception
-
getFormDoubleSubmitPrivateKey
-