public.javadoc.org.spincast.plugins.formsprotection.doublesubmit.SpincastFormsDoubleSubmitProtectionFilterDefault.html Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of spincast-website Show documentation
Show all versions of spincast-website Show documentation
Source code for the https://www.spincast.org website.
SpincastFormsDoubleSubmitProtectionFilterDefault (org.spincast:spincast-framework 1.0.0 API)
org.spincast.plugins.formsprotection.doublesubmit
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
Modifier and Type
Field and Description
protected org.slf4j.Logger
logger
-
Constructor Summary
Constructors
Constructor and Description
SpincastFormsDoubleSubmitProtectionFilterDefault(SpincastFormsProtectionConfig spincastFormsProtectionConfig,
FlashMessageFactory flashMessageFactory,
Dictionary dictionary,
SpincastCryptoUtils cryptoUtils,
SpincastFormsDoubleSubmitProtectionRepository spincastFormsDoubleSubmitProtectionRepository)
-
Method Summary
All Methods Instance Methods Concrete Methods
Modifier and Type
Method and Description
String
createNewFormDoubleSubmitProtectionId()
Creates an id to use in a form that needs to be
protected.
protected SpincastCryptoUtils
getCryptoUtils()
protected Dictionary
getDictionary()
protected FlashMessageFactory
getFlashMessageFactory()
protected String
getFormDoubleSubmitPrivateKey()
protected SpincastFormsDoubleSubmitProtectionRepository
getSpincastFormsDoubleSubmitProtectionRepository()
protected SpincastFormsProtectionConfig
getSpincastFormsProtectionConfig()
protected org.spincast.shaded.org.apache.commons.lang3.tuple.Pair<Instant,String>
getSubmittedFormInfo(String payloadEncrypted)
Returns the Date/ProtectionId or null
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).
-
-
Constructor Detail
-
SpincastFormsDoubleSubmitProtectionFilterDefault
@Inject
public SpincastFormsDoubleSubmitProtectionFilterDefault(SpincastFormsProtectionConfig spincastFormsProtectionConfig,
FlashMessageFactory flashMessageFactory,
Dictionary dictionary,
SpincastCryptoUtils cryptoUtils,
SpincastFormsDoubleSubmitProtectionRepository spincastFormsDoubleSubmitProtectionRepository)
-
Method Detail
-
getSpincastFormsProtectionConfig
protected SpincastFormsProtectionConfig getSpincastFormsProtectionConfig()
-
getFlashMessageFactory
protected FlashMessageFactory getFlashMessageFactory()
-
getDictionary
protected Dictionary getDictionary()
-
getCryptoUtils
protected SpincastCryptoUtils 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 interface SpincastFormsDoubleSubmitProtectionFilter
- Throws:
FormAlreadySubmittedException
- if the form was already submitted. This
exception, by default, implements PublicException
and contains a
message from the Dictionary
to be displayed to the user.
FormTooOldException
- if the submitted form is too old. This
exception, by default, implements PublicException
and contains a
message from the Dictionary
to be displayed to the user.
-
createNewFormDoubleSubmitProtectionId
public String createNewFormDoubleSubmitProtectionId()
Description copied from interface: SpincastFormsDoubleSubmitProtectionFilter
Creates an id to use in a form that needs to be
protected.
- Specified by:
createNewFormDoubleSubmitProtectionId
in interface SpincastFormsDoubleSubmitProtectionFilter
-
getSubmittedFormInfo
protected org.spincast.shaded.org.apache.commons.lang3.tuple.Pair<Instant,String> getSubmittedFormInfo(String payloadEncrypted)
Returns the Date/ProtectionId or null
if invalid.
-
invalidFormMatchAction
protected void invalidFormMatchAction(RequestContext<?> context,
String message)
throws Exception
What to do when the submitted form is not valid
(already submitted for example).
By default, throw a PublicException
with
an HTTP status code of HttpStatus.SC_BAD_REQUEST
and
a public message.
- Throws:
Exception
-
getFormDoubleSubmitPrivateKey
protected String getFormDoubleSubmitPrivateKey()
Copyright © 2019. All rights reserved.