Professional Documents
Culture Documents
Available Pages
• $
• %
•
• &
'
• ( (
•
• )
• *
)
• +
• ,- -
• $%.
• /
• )
• 0 ) -
)
•
1
- 2 34
) %
30
5
• 0-
• 6
•
•
7
• 1
+
-
•
%,56% )
++
)
•
)
/$'
• 0
• /
• 8
9 6
7
9 & )
-
!
9 : ) $
9 8
*) &;
9 0
)-
-
)<
9 &
)
-
!
! "
#
5
)
*
) -
9 +*
)-
)
-
5 )
) )
-
)-
-
9 1
-' 5 )
)
)
)) ) + ) )
-
/
)
9 -
5 )
) )
7)
$
9 -
/ ) ) 5 )
)
)
&?
) )
-
-
$%%&
'" ()*+,
5
' - 454 5 0$, -
)
3
@) =
)))
4 /
'"
&-
" ,
A -'
)) -
B 5
@
')
) %1
%
9
C )
C *
)
9 +
C ,- -
9 $%.
9 /
C )
1 -' D
5
)
- )
- )
)
)
$
1
)
) ' ) )!
)
)
)!
)
)
9 )
9 *
)
5 ) )-
'
) -
)
)
-
)
)
- .
/ !
)
K):
:
) (
K):
7)
)
)!
!
.
)
- .
/ !
*
*
,
*
/ 5*
,
'
0
)
- .
/ !
6
1
5*
,
) ?'):
-
1
-
)
*
%
5*
,
) %
?'):
!
'
) $ )
-
E
*
)
'! )
)
&
'
)
)
5' 4 &
K
-)
D 8 %1
%,56% )
1 )
) - -
- -' )
- )
1 %
!
- " & &3 "
4
0 0
!
.
" . '#.
0 #
. '#.
5 (
K):
)
) ) 7
- ) 54(4D-)
) !
"
4
5 ) / - 0)5* , )
1)
4
"
"
5
-
) ')
5*
,
1
) ) *
)
*
)
'
-'
))
)!
0 #
. 2)
-
2 .
"
".
5 ) * - 5* , ?-- 5* ,
0 #
. 5 *2)
"
"
&
5
)
)
-
)
)
)
D
" % . "
% "
"
&" "
D
Comments
-
)
) '
D
D<<7<
<
<
5'
00!5!!*6
788
.
D
%F D
% D
A -)
D )-
) ;/
5 '
)
$
- -
"L (S
D
-Djava.awt.headless=true
5 )
4
5
-
! )
) )) 5 '
$
1
)
)
- * 5
' )
)
)
+*
D
/**
* Description: This Factory is used in order to switch from the
* java.awt.Toolkit component to other implementation like <a
/ D
)
jcaptcha.load.test.exclude=**/*LoadTest*.*
D
D<<-"@<<
<
< )
BO"" T
.
(7
5
)
* -
% ) D
% ) @ ) ) ) )
) - ) - ) )
1
3
5
- -
'
/
- 1
)
)
@
)
)
) @ 1(
1
) )! 5 ' ) &)
*
)
)
+ )
/
5
%
&
/ ) &?
) -
) !
K40S1=: (0%$5
!
%
- ) -
- 5
) )
))
=
' -)
K# K %
1
4
)
)) )
)
E 1
-
2 34
) %
30
5
, ) %
E ) = #
1
-
)
3
- )
-
' '
4 %.
K )
) ) )
5 '
)
'
/
4 "
-) )
=A
-)
0
)
)
*D )
-)
'
))
'
!
5
)--
K
) - )
) -
%
-
5
!
)
-
)
= D ) ) - )
% )
) )
)
)
0 &" ,
9 %
C
@
-
) )
! )
C ?
- -
9 %
D
!
77
% )
) ) *
77
)
K
)
) )
!
K
'
)
77
)) *
)
-
%1
!
* %1
/
D , - %
)*+ *"
9 %,56%
9 6 7 ) %1 ? H % & ? ) H-)
9 %,56%D8 6) %1 , $ /
H % & ? = 6
) H-)
9 &
$)
- 8)
) ) (
7 /
7
4=//! /
& ? ,1! % ? 3,1! H ? 3,1! /
0)
3,1!
0 %
D 0 K H %
)*+
4
5 -.
0 -
9 8 : 5 5
5
%
) ((/ %
' %
K / K :
& % /
( H '
% ( S
2 & ( 0
0
9 $
/ & ? + 5 A 5'
('
9 / ?E $
( 3,) 5' ) ?
%
H
4E:%
Comments
5 / ) % !
%))
3
)) 3)
! ) 3
3"
))
!
K+?31=$< - )
0#
)-
$
6&
) -
/
!
! " 0%
1
.
import com.octo.captcha.service.image.ImageCaptchaService;
import com.octo.captcha.service.image.DefaultManageableImageCaptchaService;
.
" %
import com.octo.captcha.service.CaptchaServiceException;
import com.sun.image.codec.jpeg.JPEGCodec;
import com.sun.image.codec.jpeg.JPEGImageEncoder;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
super.init(servletConfig);
// a jpeg encoder
JPEGImageEncoder jpegEncoder =
JPEGCodec.createJPEGEncoder(jpegOutputStream);
jpegEncoder.encode(challenge);
} catch (IllegalArgumentException e) {
httpServletResponse.sendError(HttpServletResponse.SC_NOT_FOUND);
return;
} catch (CaptchaServiceException e) {
httpServletResponse.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
return;
}
captchaChallengeAsJpeg = jpegOutputStream.toByteArray();
&42
<servlet>
<servlet-name>jcaptcha</servlet-name>
<servlet-class>ImageCaptchaServlet</servlet-class>
<load-on-startup>0</load-on-startup>
</servlet>
%)
<servlet-mapping>
<servlet-name>jcaptcha</servlet-name>
<url-pattern>/jcaptcha</url-pattern>
</servlet-mapping>
<img src="/jcaptcha">
<input type='text' name='j_captcha_response' value=''>
'
Comments
1 ) -) ) ) 1 )E ) B
6
1E /, ) R -R ) 1 @ D
"D )
)
-
/
B ( 1
)
-
B 1- *
-
) -
'
#D R6)
!R )
-
/,
)
B 1E
-
2 ))
5' FF
5
)) ') - -
1
)--
-
)
)
! 1
)
//
- D
1
)) *
E ) 5
)
*
)
1 )
0$1(
!
() 1 )
B K
)
' B
5 * 1- /, ) -)
5D
U OR<
RV
K
-)
D 8 %1
%,56% )
1 )
) - -
- -' )
- )
1 %
!
- " & &3 "
4
0 0
!
.
" . '#.
0 #
. '#.
5 (
K):
)
) ) 7
- ) 54(4D-)
) !
"
4
5 ) / - 0)5* , )
1)
4
"
"
5
-
) ')
5*
,
1
) ) *
)
*
)
'
-'
))
)!
0 #
. 2)
-
2 .
"
".
5 ) * - 5* , ?-- 5* ,
0 #
. 5 *2)
"
"
&
5
)
)
-
)
)
)
D
" % . "
% "
"
&" "
D
2
&
5
-
E
/ * -
/
@
-
*
/
5
/
0.
<bean id="colorGenRandomList"
class="com.octo.captcha.component.image.color.RandomListColorGenerator" >
<constructor-arg index="0">
<list>
<ref bean="yellow"/>
<ref bean=" blue "/>
<ref bean=" lightBlue "/>
</list>
</constructor-arg>
</bean>
<bean id="blue" class="java.awt.Color" >
<constructor-arg type="int" index="0"><value>0</value></constructor-arg>
<constructor-arg type="int" index="1"><value>0</value></constructor-arg>
<constructor-arg type="int" index="2"><value>255</value></constructor-arg>
</bean>
9 .
<bean id="colorGenRandomBlue"
class="com.octo.captcha.component.image.color.RandomRangeColorGenerator" >
<constructor-arg index="0">
<list>
<value>150</value>
<value>255</value>
</list>
</constructor-arg>
<constructor-arg index="1">
<list>
<bean id="java.util.Locale.FRANCE"
class="org.springframework.beans.factory.config.FieldRetrievingFactoryBean"/>
<bean id="java.util.Locale.US"
class="org.springframework.beans.factory.config.FieldRetrievingFactoryBean"/>
0
5 -.
<bean id="backGenUni"
class="com.octo.captcha.component.image.backgroundgenerator.UniColorBackgroundGenerator" >
<constructor-arg index="0"><value>300</value></constructor-arg>
<constructor-arg index="1"><value>100</value></constructor-arg>
</bean>
<bean id="backGenFunky"
class="com.octo.captcha.component.image.backgroundgenerator.FunkyBackgroundGenerator" >
<constructor-arg index="0"><value>300</value></constructor-arg>
<constructor-arg index="1"><value>100</value></constructor-arg>
<constructor-arg type="com.octo.captcha.component.image.color.ColorGenerator"
index="2"><ref bean="colorGenRandomList"/></constructor-arg>
<constructor-arg type="com.octo.captcha.component.image.color.ColorGenerator"
index="3"><ref bean="colorGenRandomList"/></constructor-arg>
<constructor-arg type="com.octo.captcha.component.image.color.ColorGenerator"
index="4"><ref bean="colorGenRandomList"/></constructor-arg>
<constructor-arg type="com.octo.captcha.component.image.color.ColorGenerator"
index="5"><ref bean="colorGenRandomList"/></constructor-arg>
<constructor-arg index="6"><value>0.2f</value></constructor-arg>
</bean>
<bean id="backGenMultiShape"
class="com.octo.captcha.component.image.backgroundgenerator.MultipleShapeBackgroundGenerator" >
<constructor-arg index="0"><value>300</value></constructor-arg>
<constructor-arg index="1"><value>100</value></constructor-arg>
<!--firstEllipseColorGenerator-->
<constructor-arg index="2"><ref bean="lightBlue"/></constructor-arg>
<!--secondEllipseColorGenerator-->
<constructor-arg index="3"><ref bean="lightRed"/></constructor-arg>
<!--spaceBetweenLine-->
<constructor-arg index="4"><value>10</value></constructor-arg>
<!--spaceBetweenCircle-->
<constructor-arg index="5"><value>5</value></constructor-arg>
<bean id="backGenPicture"
class="com.octo.captcha.component.image.backgroundgenerator.FileReaderRandomBackgroundGenerator"
>
<constructor-arg index="0"><value>300</value></constructor-arg>
<constructor-arg index="1"><value>100</value></constructor-arg>
<constructor-arg index="2"><ref bean="path"/></constructor-arg>
</bean>
<bean id="smearDef"
class="com.octo.captcha.component.image.deformation.ImageDeformationByFilters" >
<constructor-arg index="0">
<list>
<ref bean="smear"/>
</list>
</constructor-arg>
</bean>
<bean id="rippleDef"
class="com.octo.captcha.component.image.deformation.ImageDeformationByFilters" >
<constructor-arg index="0">
<list>
<ref bean="ripple"/>
</list>
</constructor-arg>
</bean>
<bean id="ripple2Def"
class="com.octo.captcha.component.image.deformation.ImageDeformationByFilters" >
<constructor-arg index="0">
<list>
<ref bean="ripple2"/>
</list>
</constructor-arg>
</bean>
<bean id="ripple3Def"
class="com.octo.captcha.component.image.deformation.ImageDeformationByFilters" >
<constructor-arg index="0">
<list>
<ref bean="ripple3"/>
</list>
</constructor-arg>
</bean>
<bean id="waterDef"
class="com.octo.captcha.component.image.deformation.ImageDeformationByFilters" >
<constructor-arg index="0">
<list>
<ref bean="water"/>
</list>
</constructor-arg>
</bean>
<bean id="embossDef"
class="com.octo.captcha.component.image.deformation.ImageDeformationByFilters" >
<constructor-arg index="0">
<list>
<ref bean="emboss"/>
</list>
</constructor-arg>
</bean>
<bean id="rippleDefBack"
class="com.octo.captcha.component.image.deformation.ImageDeformationByFilters" >
<constructor-arg index="0">
<list>
<ref bean="rippleBack"/>
</list>
</constructor-arg>
</bean>
<bean id="cristalDef"
class="com.octo.captcha.component.image.deformation.ImageDeformationByFilters" >
<constructor-arg index="0">
<list>
<ref bean="crystal"/>
</list>
</constructor-arg>
</bean>
<bean id="weavesDef"
class="com.octo.captcha.component.image.deformation.ImageDeformationByFilters" >
<constructor-arg index="0">
<list>
<ref bean="weaves"/>
</list>
</constructor-arg>
</bean>
<bean id="twirlDef"
class="com.octo.captcha.component.image.deformation.ImageDeformationByFilters" >
<constructor-arg index="0">
<list>
<ref bean="twirl"/>
</list>
</constructor-arg>
</bean>
<bean id="none"
class="com.octo.captcha.component.image.deformation.ImageDeformationByFilters" >
<constructor-arg index="0">
<null/>
</constructor-arg>
</bean>
. 2
!
.
" /
2
<bean id="imageCaptchaFactory"
class="com.octo.captcha.image.gimpy.GimpyFactory" >
<constructor-arg><ref bean="wordgen"/></constructor-arg>
<constructor-arg><ref bean="wordtoimage"/></constructor-arg>
</bean>
<!-- Constructs Font generator, with the min and max size of font,
and with a list of fonts-->
<bean id="fontGenRandom"
class="com.octo.captcha.component.image.fontgenerator.RandomFontGenerator" >
<constructor-arg
index="0"><value>40</value></constructor-arg>
<constructor-arg
index="1"><value>50</value></constructor-arg>
<constructor-arg index="2">
<list>
<ref bean="fontArial"/>
<ref
bean="fontTahoma"/>
<ref
bean="fontVerdana"/>
<ref bean="fontComic"/>
<ref
bean="fontLucida"/>
</list>
</constructor-arg>
</bean>
<!-- Constructs the paster component, a baffle one, which make holes in
characters
Parameters :
int for the min length of the word
int for the max length of the word
ColorGenerator for the color of the word
boolean to know if each character can have a different color
-->
<bean id="simpleColoredPaster"
class="com.octo.captcha.component.image.textpaster.RandomTextPaster" >
<constructor-arg type="java.lang.Integer"
index="0"><value>4</value></constructor-arg>
<constructor-arg type="java.lang.Integer"
index="1"><value>6</value></constructor-arg>
<constructor-arg
type="com.octo.captcha.component.image.color.ColorGenerator" index="2"><ref
bean="colorGenRandomDark"/></constructor-arg>
<constructor-arg
index="3"><value>true</value></constructor-arg>
</bean>
<!-- Constructs a File diconnary, which will read words from a file,
corresponding to Locle (for instance with locale France,
it will look for the file : toddlist_fr_FR.properties, if not found,
take toddlist.properties -->
<!-- Constructs a word generator, which composed words from existing words
It takes a diconnary for the existing words-->
<bean id="wordgen"
class="com.octo.captcha.component.wordgenerator.ComposeDictionaryWordGenerator" >
<constructor-arg><ref bean="filedict"/></constructor-arg>
</bean>
<!-- Constructs a color generator which generate dark color correspond to the
different ranges-->
<bean id="colorGenRandomDark"
class="com.octo.captcha.component.image.color.RandomRangeColorGenerator" >
<constructor-arg index="0">
<list>
<value>0</value>
<value>150</value>
</list>
</constructor-arg>
<constructor-arg index="1">
<list>
<value>0</value>
<value>150</value>
</list>
</constructor-arg>
<constructor-arg index="2">
<list>
<value>0</value>
<value>150</value>
</list>
</constructor-arg>
<constructor-arg index="3">
<list>
<value>255</value>
<value>255</value>
</list>
</constructor-arg>
</bean>
!
.
" 0%
2
<bean id="imageCaptchaService"
class="com.octo.captcha.service.multitype.GenericManageableCaptchaService">
<constructor-arg index="0">
<ref bean="imageEngine"/>
</constructor-arg>
<constructor-arg index="1"><value>300</value></constructor-arg>
<constructor-arg index="2"><value>200000</value></constructor-arg>
</bean>
</beans>
%
%) 0 D /
) D8 %,56%3)
) - ++ K
5 ) %,56% )) ++ )
4
- &%:!
)
%,56%
)
' -
)
H&)
5
' %,56% 5
)
D
- )
)
) )
- -
!
1 -
-
-
4
)
/ $'
- 14 )
;&H )
/
-
) ) ;&H )
)
/ %
)
/
<bean class="com.octo.captcha.service.image.DefaultManageableImageCaptchaService"
id="imageCaptchaService"/>
= - 7 - E ) )-
0.
"
%
.
. 0.
5 + 3-)
-
:
+
-
-
-
B B ) -
!
9 % -
9 % ')
9 % 5*
5 *
* W
'
)-
-
%
)-
) +*
* - )-
<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>
% $
:
) $
K)51 )--
-
)--
- '
-
5
) -
-
)
-
7 )
* 7 -
-
<bean id="fontGenRandom"
class="com.octo.captcha.component.image.fontgenerator.RandomFontGenerator" >
<constructor-arg index="0"><value>40</value></constructor-arg>
<constructor-arg index="1"><value>50</value></constructor-arg>
<constructor-arg index="2">
<list>
5 ?'
:
'
*
*
-
) 5 -
7
)
! -
<bean id="backGenUni"
class="com.octo.captcha.component.image.backgroundgenerator.UniColorBackgroundGenerator" >
<constructor-arg index="0"><value>300</value></constructor-arg>
<constructor-arg index="1"><value>100</value></constructor-arg>
</bean>
5 5*
,
)
*
') 5 )
* !
)
) ! )
*
'
-) 5*
,
)
)
)
*
5*
(
)) -
%* - *
- 5*
,
D
" &
-
*
&*
-
*
# %
*
%*
L % ?
-
) )--
!
-
*
- !
<bean id="simpleWhitePaster"
class="com.octo.captcha.component.image.textpaster.SimpleTextPaster" >
<constructor-arg type="java.lang.Integer"
index="0"><value>4</value></constructor-arg>
<constructor-arg type="java.lang.Integer"
index="1"><value>6</value></constructor-arg>
<constructor-arg type="com.octo.captcha.component.image.color.ColorGenerator"
index="2"><ref bean="colorGenRandomDark"/></constructor-arg>
<constructor-arg index="3"><value>true</value></constructor-arg>
</bean>
<bean id="imageCaptchaService"
class="com.octo.captcha.service.multitype.GenericManageableCaptchaService">
<constructor-arg index="0">
<ref bean="imageContainer"/>
</constructor-arg>
<constructor-arg index="1"><value>180</value></constructor-arg>
<constructor-arg index="2"><value>180000</value></constructor-arg>
</bean>
!
9 /
" D ,@
9 /
D
) -
9 /
# D
0
-
)=
1
>>
/ 0
)
9
K+?31=$< ) -
3 D
3 3ZXQ
9 %))
-
) -
- -
<plug-in className="com.octo.captcha.module.struts.CaptchaServicePlugin"/>
<action
path="/jcaptcha"
type="com.octo.captcha.module.struts.image.RenderImageCaptchaAction"
/>
5
E
A
-
3 ) )
)
A )
F
0 &" &
3 )7
!
9 /
" D ,@
9 /
D
) -
9 /
# D 1)
-
37) -
9 /
L D /
)
-)
9 /
D &)-
)=
9
K+?31=$< ) -
3 ) 3 D
3 3Z
9
)
K+?31=$< ) -
3 ) 3 D
3"
9 %))
- )
) -
- -
<plug-in className="com.octo.captcha.module.struts.CaptchaServicePlugin"/>
...
</form-beans>
<!-- Matches all edit actions (in this case, only user regstration) -->
<action path="/Edit*"
type="org.apache.struts.webapp.example.Edit{1}Action"
name="{1}Form"
scope="request"
validate="false">
<forward name="success" path="/{1}.jsp"/>
</action>
<!-- Matches all save actions (in this case, only user registration) -->
<action path="/Save*"
type="org.apache.struts.webapp.example.Save{1}Action"
name="{1}Form"
scope="request"
input="{1}"/>
</action-mappings>
...
0"
<!-- Matches all edit actions (in this case, only user regstration) -->
<action path="/Edit*"
type="org.apache.struts.webapp.example.Edit{1}Action"
name="{1}Form"
scope="request"
validate="false">
<action
path="/SaveRegistration"
type="com.octo.captcha.module.struts.VerifyCaptchaChallengeAction"
name="RegistrationForm"
scope="request"
input="Registration"
validate="false"
>
<forward name="success" path="/jcaptchaRegistration.do"/>
</action>
<action
path="/jcaptchaRegistration"
type="org.apache.struts.webapp.example.SaveRegistrationAction"
name="RegistrationForm"
scope="request"
input="Registration"
>
</action>
</action>
9 ))
)
9 ))
D
))
- )
9 ))
D@
))
@
9 ))
*
-
9 ))
<html:html>
<head>
<logic:equal name="RegistrationForm" property="action"
scope="request" value="Create">
<html:errors/>
<tr>
<th align="right">
<jcaptcha:question/>:
</th>
<td align="left">
<img src="jcaptcha.do"/>
<br/>
<%-- Add the input tag--%>
</td>
</tr>
<tr>
<th align="right">
<bean:message key="prompt.username"/>:
</th>
<td align="left">
<logic:equal name="RegistrationForm" property="action"
scope="request" value="Create">
<html:text property="username" size="16" maxlength="16"/>
</logic:equal>
<logic:equal name="RegistrationForm" property="action"
scope="request" value="Edit">
<%--
<bean:write name="RegistrationForm" property="username"
scope="request" filter="true"/>
--%>
<html:hidden property="username" write="true"/>
</logic:equal>
</td>
</tr>
...
9
- 4
Comments
6
1E) ' / 1 - ) ) ' -
6 1E) '
)-
1 1
U 3 =OR
)
/, R<V )
1
)
D
R
E
@)
)
)
)
)
!R
5'
,
)
"#
,
)
package mypackage;
import com.octo.captcha.engine.image.gimpy.SimpleListImageCaptchaEngine;
import com.octo.captcha.service.image.EhcacheManageableImageCaptchaService;
import com.octo.captcha.service.image.ImageCaptchaService;
implements ImageCaptchaService {
public MyOwnManageableImageCaptchaService() {
super(new SimpleListImageCaptchaEngine(), 180, 100000);
)
) / H
1
+ 1 '
!
! 3-* /, ' D
<plug-in className="com.octo.captcha.module.struts.CaptchaServicePlugin">
<set-property property="serviceClass"
value="mypackage.MyOwnManageableImageCaptchaService" />
</plug-in>
,
)
# J
6
1E
)
U
D@
<V ) U
D <V
)
1
1
1 )E
-)
)
1 -)
' -
R@
R E
:E
-
EE
6 1 )
)-
B
1E /
1
)
U 3 =OR
)
/, R<V
B
' -
+
!
1)
-
-)
)
- '
)
/ -
)
-)
D
+
6
-
-) )
)
/
9
D
5
)
)
)
9
D R- -
) R
+* - ) ) ) D
4
' & - "
7
9 .
5
))
) -
9
5
KKK
) - -
5
' -
)
-
-
' -
! /
*
D
D<<<<
9 H
5
- %,56%
*
&
)
)
)
)
5 '
) D
'
-
-
) -
+* D
'
- -
'
5 ') - - %,56% )
*
3 !
,
<) D
-
'
- )
'