BotDetect Java CAPTCHA Web API Reference
To make Captcha integration into Java websites easy, the BotDetect Java CAPTCHA Library exposes a public API focused on ease of use from JSP forms.
botdetect.web.Captcha
Instances of Captcha
type can be created on your forms and will take care of Captcha display and validation. Captcha
object is also implicitly created by BotDetect Captcha Custom Tag.
Captcha Class Reference | ||
---|---|---|
Captcha load (ServletRequest request) | Returns Captcha instance. Id is retreived from request . |
|
Captcha load (ServletRequest request, String captchaId) | Returns a new Captcha instance. |
|
String get/ CaptchaId | Unique identifier of the Captcha object within the application (for example, if you placed one Captcha object on the Registration page and another on the Contact Us page, they would have distinct CaptchaId values). | |
String get/ CurrentInstanceId | Globally unique identifier of the current Captcha object instance, used to ensure each page load keeps separate Captcha codes, for example when opening the same form in multiple browser tabs. | |
int get/set CodeLength | Length (number of characters) of the Captcha code rendered; the default value is between 4 and 6. | |
CodeStyle get/set CodeStyle | Code style, i.e. the algorithm used to generate Captcha codes; the default value is Alphanumeric. | |
ImageStyle /set ImageStyle | Image style, i.e. the algorithm used to render Captcha codes in images; if no image style is set, it is randomized by default. | |
void setImageStyle( List<ImageStyle> usedStyles) | Sets a List of Image styles randomly used to render Captcha image. |
|
ImageSize get/set ImageSize | Size of the Captcha image rendered; the default size is (250, 50). | |
ImageFormat get/set ImageFormat | Image format in which the Captcha image will be rendered; the default format is JPEG. | |
boolean is/set ReloadEnabled | Controls whether Captcha reloading is enabled (is the reload icon and related code added to Captcha markup). | |
boolean is/set CaptchaSoundEnabled | Controls whether Captcha sound is enabled (is the sound icon and related code added to Captcha markup). | |
boolean get/set UserInputClientId | User input textbox client-side identifier, used for Captcha validation and all client-side user input processing, e.g. automatic user input lowercasing and focusing. | |
boolean is/set HelpLinkEnabled | Is the Captcha help link enabled (depends on license). | |
HelpLinkMode is/set HelpLinkMode | Select whether help link will be Captcha image (image ) or text under Captcha image (text ). Default is text . |
|
boolean is/set IncludeClientScript | If set to false prevents renderCaptchaMarkup method to render HTML markup for BotDetect Client Script. Default is true . |
|
String getClientScriptMarkup( String contextPath) | Returns HTML markup for BotDetect Client Script. | |
boolean is/set IncludeStyle | If set to false prevents renderCaptchaMarkup method to render HTML markup for BotDetect Stylesheet. Default is true . |
|
String getStylesheetMarkup( String contextPath) | Returns HTML markup for BotDetect Stylesheet. | |
void renderCaptchaMarkup( ServletContext ctx, Writer out) | Generates the Html markup needed to add the current Captcha object instance to a form. | |
boolean validate( HttpServletRequest request, String userInput) | Validates the Captcha, comparing the user input to the Captcha code stored on the server. Each randomly generated Captcha code can only be validated once, regardless of the validation result. |
botdetect.web.jsf.JsfCaptcha
Intended to be used with JavaServer Faces. Extends add it to your form while binding with JSF managed bean's property allows more dynamic control of
Captcha
object.
JsfCaptcha Class Reference | ||
---|---|---|
JsfCaptcha() | The JsfCaptcha constructor has no parameters because id is assigned through attribute value on the page. |
|
boolean validate(String userInput) | Validates the Captcha, comparing the user input to the Captcha code stored on the server. Each randomly generated Captcha code can only be validated once, regardless of the validation result. | |
void setCodeLength(int length) | Sets length (number of characters) of the Captcha code rendered; the default value is between 4 and 6. | |
void setImageWidth(int width) | Width of the Captcha image rendered; the default width is 250 pixels. | |
void setImageHeight(int height) | Height of the Captcha image rendered; the default height is 50 pixels. | |
void setCodeStyle(CodeStyle height) | Code style, i.e. the algorithm used to generate Captcha codes; the default value is Alphanumeric. | |
void setImageStyle(ImageStyle style) | Image style, i.e. the algorithm used to render Captcha codes in images; if no image style is set, it is randomized by default. | |
void setImageStyles(String styles) | Comma delimited string of Image styles randomly used to render Captcha image. | |
void setImageFormat(ImageFormat format) | Image format in which the Captcha image will be rendered; the default format is JPEG. | |
void setHelpLinkEnabled(boolean value) | Sets whether is the Captcha help link enabled (depends on license). | |
void setHelpLinkMode(HelpLinkMode mode) | Select whether help link will be Captcha image (image ) or text under Captcha image (text ). Default is text . |
|
void setReloadEnabled(boolean value) | Sets whether Captcha reloading is enabled (is the reload icon and related code added to Captcha markup). Default is true . |
|
void setSoundEnabled(boolean value) | Sets whether Captcha sound is enabled (is the sound icon and related code added to Captcha markup). Default is true . |
|
void setUserInputClientId(String value) | User input textbox client-side identifier, used for Captcha validation and all client-side user input processing, e.g. automatic user input lowercasing and focusing. | |
void setOmitStylesheet(boolean value) | If set to true prevents JsfCaptcha rendering method to render HTML markup for BotDetect stylesheet. Default is false. |
|
void setOmitClientScript(boolean value) | If set to true prevents JsfCaptcha rendering method to render HTML markup for BotDetect Client Script. Default is false. |
Please Note
BotDetect Java Captcha Library v4.0.Beta3.7 is an in-progress port of BotDetect 4 Captcha, and we need you to guide our efforts towards a polished product. Please let us know if you encounter any bugs, implementation issues, or a usage scenario you would like to discuss.
Current BotDetect Versions
-
BotDetect ASP.NET CAPTCHA
2019-07-22v4.4.2 -
BotDetect Java CAPTCHA
2019-07-22v4.0.Beta3.7 -
BotDetect PHP CAPTCHA
2019-07-22v4.2.5