Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

Introduction 

JCaptcha try to strictly respect Inversion of Control pattern, in order to easier creation of components for concrete applications. On the other side the Spring Framework allows to use the power of IOC combined with XML declarations.
So that, every single component of jCaptcha can be declared in XML, and instanced through Spring. The application using jCaptcha should only manipulate a CaptchaService instance.

5 secondes configuration

The most simple configuration possible is to declare the following in your Spring context

<bean
		class="com.octo.captcha.service.image.DefaultManageableImageCaptchaService" id="imageCaptchaService">
	</bean>

Now if you want to customize your engine configuration, you'll need to define your own implementation

Setting a captcha engine image configuration in Spring

In this section we will describe how to set components to create a full CaptchaEngine.

We will start with what we want, the CaptchaEngine, for each component we provide a working and common example, but every component has several implementations, see the Java doc for more details. The construction of each component in XML must respect a constructor of this component.

There are several Engines pre configured, but as we want to control configuration, we have to use the GenericCaptchaEngine, which is build with a list of captcha factories (factories are the ?real? producer of captchas)

<bean class="com.octo.captcha.engine.GenericCaptchaEngine" id="imageEngine">
		<constructor-arg index="0">
			<list>
				<ref bean="imageCaptchaFactory"/>
			</list>
		</constructor-arg>
	</bean>

Then, a CaptchaFactory needs:

  • A word generator, to create the text to read.
  • A wordToImage, to generate the captcha from the text.
    	<bean id="CaptchaFactory" class="com.octo.captcha.image.gimpy.GimpyFactory" >
    		<constructor-arg><ref bean="wordgen"/></constructor-arg>
    		<constructor-arg><ref bean="wordtoimage"/></constructor-arg>
    	</bean>
    
  • No labels