How to change JCaptcha generation configuration?

I installed Jcaptcha as an example from the Jcaptcha website, but I need to configure jcaptcha by default with colors and fonts.

I managed to find the Jcaptcha configuration with Spring , however this is using Spring. I am new to Java and not using Spring, can I learn how to create a new captcha configuration for my jcaptcha image?

Thanks in advance.

+3
source share
2 answers

The example you are pointing to is really for the Spring Framework. But it does not really matter. I can imagine the difficulties that may arise, who does not know how dependency injection works. So this is the same programmatically. Notice, I will shorten it for brevity.

  • You need to create an ImageCaptchaFactory from your given URL, com.octo.captcha.image.gimpy.GimpyFactory
  • Put this in ImageCaptchaEngine, creating an instance of your captcha engine, namely com.octo.captcha.engine.GenericCaptchaEngine
  • And then pass this to your captcha service, com.octo.captcha.service.multitype.GenericManageableCaptchaService

Now about colors and fonts. You will need to provide color and font information in your captcha factory. How? There he is,

  • factory receives object type arguments generator words and word-image composer that are respectively com.octo.captcha.component.wordgenerator.DictionaryWordGeneratorandcom.octo.captcha.component.image.wordtoimage.ComposedWordToImage
  • , . , , , , .
  • , , . , , com.octo.captcha.component.image.fontgenerator.RandomFontGenerator factory
  • , com.octo.captcha.component.image.backgroundgenerator.UniColorBackgroundGenerator com.octo.captcha.component.image.color.SingleColorGenerator
  • , com.octo.captcha.component.image.color.RandomRangeColorGenerator
+2

Source: https://habr.com/ru/post/1732125/


All Articles