Fine-tuning the display and function of the CAPTCHA default
You can enable or disable the presentation of a CAPTCHA appears to those attempting to log in. You can fine-tune the details of the CAPTCHA, including how many characters drawn from what character set and what sort of background for the image.
- In the navigation of Dev Studio, click .
- On the Security Policies landing page, find the pyGenerateCaptcha activity and save a copy with the same name into the ruleset you created for unauthenticated visitors.
- Expand step 1 to display the Java code.
- Make the adjustments you want and
- Click Save.
- Make sure that, on the Security Policies gadget, the
CAPTCHA implementation policy is set to
Default.Although you have modified the CAPTCHA, you are still using the default CAPTCHA provider.
- Some typical adjustments to the CAPTCHA presentation include:
- Modify the character set: add characters to, or remove them
from, this section of the code:
char[] DEFAULT_CHARS = new char[] { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'k', 'm', 'n', 'p', 'r', 'w', 'x', 'y', '2', '3', '4', '5', '6', '7', '8', };
- Change the number of characters displayed
by modifying the bolded number in this section of the
code:
nl.captcha.text.producer.DefaultTextProducer textProd = new nl.captcha.text.producer.DefaultTextProducer(6, DEFAULT_CHARS );
- Change the color of the font by modifying
the color specified in the bolded text in this line of the
code:
DEFAULT_COLORS.add(new java.awt.Color(0,51,102));
- For more examples of modification that are available,, visit the SimpleCaptcha website,http://simplecaptcha.sourceforge.net/custom_images.html.
- Modify the character set: add characters to, or remove them
from, this section of the code:
- You can achieve any of the effects demonstrated on the SimpleCaptcha website. However you must use fully-qualified names in Pega Platform to refer to SimpleCaptcha classes. For example, the website demonstrates creating a CAPTCHA using a complex background and Chinese characters.
- The SimpleCaptcha website provides the following code to achieve that
CAPTCHA:
Captcha captcha = new Captcha.Builder(200, 50) .addText(new ChineseTextProducer(6)) // Answer will be 6 Chinese characters .addBackground(new GradiatedBackgroundProducer()) .addNoise(new StraightLineNoiseProducer()) .gimp(new FishEyeGimpyRenderer()) .addBorder() .build(); // Required.
- To get the same effect in Pega Platform, modify the
code by using fully-qualified names, and add it to
pyGenerateCaptcha:
nl.captcha.Captcha captcha = new nl.captcha.Captcha.Builder(200, 50) .addText(new nl.captcha.text.producer.ChineseTextProducer(6)) // Answer will be 6 Chinese characters .addBackground(new nl.captcha.backgrounds.GradiatedBackgroundProducer()) .addNoise(new nl.captcha.noise.StraightLineNoiseProducer()) .gimp(new nl.captcha.gimpy.FishEyeGimpyRenderer()) .addBorder() .build(); // Required.
- Some typical adjustments to the CAPTCHA presentation include:
Previous topic Customizing CAPTCHA presentation and function Next topic Substituting another service for the default CAPTCHA