Class JCaptcha
java.lang.Object
org.ametys.runtime.plugin.component.AbstractLogEnabled
org.ametys.core.captcha.AbstractCaptcha
org.ametys.plugins.core.impl.captcha.jcaptcha.JCaptcha
- All Implemented Interfaces:
Captcha
,LogEnabled
,PluginAware
,Configurable
Captcha implementation with images
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected class
Bean for a captcha and a validity date -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static Map<String,
JCaptcha.ValidableCaptcha> Map of dynamic captchasprotected static Map<String,
List<JCaptcha.ValidableCaptcha>> Map of static captchasprotected static final String
Prefix for dynamic captchasprotected static final String
Prefix for static captchas -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
checkAndInvalidateCaptcha
(String key, String value) Check if the Captcha is correctvoid
Clean the outdated captchasgenerateImageCaptcha
(String key, Integer color, boolean addNoise, boolean fisheye, int width, int height) Generate an image captcha to PNG format.getLabel()
Get the Captcha type labelGet the label to display when login has failed with this captchaGet the label to display when too many attempt have been doneGet the minimal url patterns used by the captcha implementation.void
removeCaptcha
(String key) Remove a captchaMethods inherited from class org.ametys.core.captcha.AbstractCaptcha
configure, getConfigParameters, getId, getLoginSCSSURL, getXSLHelperURL, setPluginInfo
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.ametys.core.captcha.Captcha
requireUserInteraction
-
Field Details
-
STATIC_PREFIX_KEY
Prefix for static captchas- See Also:
-
DYNAMIC_PREFIX_KEY
Prefix for dynamic captchas- See Also:
-
_mapStaticCaptcha
Map of static captchas -
_mapDynamicCaptcha
Map of dynamic captchas
-
-
Constructor Details
-
JCaptcha
public JCaptcha()
-
-
Method Details
-
checkAndInvalidateCaptcha
Description copied from interface:Captcha
Check if the Captcha is correct- Parameters:
key
- the keyvalue
- the value- Returns:
- true if correct
-
getLabel
Description copied from interface:Captcha
Get the Captcha type label- Returns:
- the label
-
getLoginFailedBecauseCaptchaFailedLabel
Description copied from interface:Captcha
Get the label to display when login has failed with this captcha- Returns:
- the label
-
getLoginFailedBecauseTooManyAttemptLabel
Description copied from interface:Captcha
Get the label to display when too many attempt have been done- Returns:
- the label
-
getUsedUrlPatterns
Description copied from interface:Captcha
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.
-
generateImageCaptcha
public BufferedImage generateImageCaptcha(String key, Integer color, boolean addNoise, boolean fisheye, int width, int height) Generate an image captcha to PNG format. The key has to be unique, if you cannot generate a key use the other form of the method.- Parameters:
key
- the wanted key. Can not be null. You can use RandomStringUtils.randomAlphanumeric(10) to generates onecolor
- The color for fontaddNoise
- true to add noise to captcha imagefisheye
- true to add fish eye background to captcha imagewidth
- The image widthheight
- The image height- Returns:
- The corresponding image
-
removeCaptcha
Remove a captcha- Parameters:
key
- the key value
-
cleanOldCaptchas
Clean the outdated captchas
-