Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
xml
xml
borderStylesolid
	<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>

A WordGenerator create a text to be read, it can be random, be a common implementation take words from a list, and can make composition to create a text easier to read for human being. In the example the WordGenerator need a Dictionnary to get real words from.

Code Block
xml
xml
borderStylesolid

<bean id="wordgen" class= "com.octo.captcha.component.wordgenerator.ComposeDictionaryWordGenerator" >
		<constructor-arg><ref bean="filedict"/></constructor-arg>
	</bean>

A Dictionary provides words, this one read words from disk.

Code Block
xml
xml
borderStylesolid

<bean id="filedict" class="com.octo.captcha.component.wordgenerator.FileDictionnary" >
		<constructor-arg index="0"><value>toddlist</value></constructor-arg>
	</bean>

After to other important part to creat a factory, is the WordToImage component, which is mainly created with three others components:

  • A font generator
  • A background generator
  • A Text paster

This example is a bit more complex one; it takes the usual main three components, but also three deformations, to increase the power of captchas. All three are set to none, a component which create no deformation, see below, and Examples to have more examples of deformations.

Code Block
xml
xml
borderStylesolid

<bean id="wordtoimage" class="com.octo.captcha.component.image.wordtoimage.DeformedComposedWordToImage" >
		<constructor-arg index="0"><ref bean="fontGenRandom"/></constructor-arg>
		<constructor-arg index="1"><ref bean="backGenUni"/></constructor-arg>
		<constructor-arg index="2"><ref bean="simpleWhitePaster"/></constructor-arg>
		<constructor-arg index="3"><ref bean="none"/></constructor-arg>
		<constructor-arg index="4"><ref bean="none"/></constructor-arg>
		<constructor-arg index="5"><ref bean="none"/></constructor-arg>
	</bean>