Package org.ametys.core.captcha
Class CaptchaHelper
java.lang.Object
org.ametys.core.captcha.CaptchaHelper
- All Implemented Interfaces:
Disposable
,Initializable
,Serviceable
Helper for generating a captcha regardless of its implementation
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
checkAndInvalidate
(String key, String value) Check a captchavoid
dispose()
static Captcha
Retrieve the used captchastatic String
Retrieve the type of captcha usedstatic String
Get the catalog to use for the message to display when captcha verification has failedstatic String
Get the i18n key to use for the message to display when captcha verification has failedstatic String
Get the catalog to use for the message to display when too many connection attempts have been madestatic String
Get the i18n key to use for the message to display when too many connection attempts have been madestatic Collection<Pattern>
Get the minimal url patterns used by the captcha implementation.void
static boolean
Determine if the captcha provider requires user interaction If not, no visible rendering should be donevoid
service
(ServiceManager manager) static void
Dispose the CaptchaHelper
-
Field Details
-
ROLE
The avalon role
-
-
Constructor Details
-
CaptchaHelper
public CaptchaHelper()
-
-
Method Details
-
initialize
- Specified by:
initialize
in interfaceInitializable
- Throws:
Exception
-
service
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
getCaptchaType
Retrieve the type of captcha used- Returns:
- The type of captcha.
-
getCaptcha
Retrieve the used captcha- Returns:
- The captcha.
-
checkAndInvalidate
Check a captcha- Parameters:
key
- The captcha key. Can be empty or null when using reCaptcha.value
- The value to check- Returns:
true
if the captcha is valid, false otherwise.
-
getFailedI18NKey
Get the i18n key to use for the message to display when captcha verification has failed- Returns:
- The i18n key.
-
getFailedI18NCatalog
Get the catalog to use for the message to display when captcha verification has failed- Returns:
- The catalog.
-
getTooManyAttemptI18NKey
Get the i18n key to use for the message to display when too many connection attempts have been made- Returns:
- The key.
-
getTooManyAttemptI18NCatalog
Get the catalog to use for the message to display when too many connection attempts have been made- Returns:
- The catalog.
-
getUsedUrlPatterns
Get the minimal url patterns used by the captcha implementation. This is necessary to grant those url even when the user is not authentified (in particular to set a catpcha on the login page). Do no put a too wide range (such as ^.*$) since it may introduce security issues.- Returns:
- The minimal url patterns used by the captcha implementation.
-
requiresUserInteraction
Determine if the captcha provider requires user interaction If not, no visible rendering should be done- Returns:
- true if user interaction are needed
-
dispose
- Specified by:
dispose
in interfaceDisposable
-
staticDispose
Dispose the CaptchaHelper
-