org.jboss.seam.captcha
Class Captcha

java.lang.Object
  extended by org.jboss.seam.captcha.Captcha
All Implemented Interfaces:
Serializable

@Name(value="org.jboss.seam.captcha.captcha")
@Scope(value=SESSION)
@Install(precedence=0)
@BypassInterceptors
public class Captcha
extends Object
implements Serializable

Default CAPTCHA algorithm, a simple addition problem. May be extended and customized.

Author:
Gavin King
See Also:
Serialized Form

Constructor Summary
Captcha()
           
 
Method Summary
protected  String getChallenge()
          Get the challenge question
protected  Color getChallengeBackgroundColor()
          May be overridden by subclasses
protected  int getChallengeImageWidth()
          May be overridden by subclasses
protected  Color getChallengeTextColor()
          May be overridden by subclasses
 String getResponse()
           
 void init()
          Initialize the challenge and correct response.
static Captcha instance()
           
 BufferedImage renderChallenge()
          Render the challenge question as an image.
protected  void setCorrectResponse(String correctResponse)
          Set the correct response
protected  void setChallenge(String challenge)
          Set the challenge question
 void setResponse(String input)
           
 boolean validateResponse(String response)
          Validate that the entered response is the correct response
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Captcha

public Captcha()
Method Detail

init

@Create
public void init()
Initialize the challenge and correct response. May be overridden and customized by a subclass.


setChallenge

protected void setChallenge(String challenge)
Set the challenge question


getChallenge

protected String getChallenge()
Get the challenge question


setCorrectResponse

protected void setCorrectResponse(String correctResponse)
Set the correct response


validateResponse

public boolean validateResponse(String response)
Validate that the entered response is the correct response


getResponse

@CaptchaResponse
public String getResponse()

setResponse

public void setResponse(String input)

renderChallenge

public BufferedImage renderChallenge()
Render the challenge question as an image. May be overridden by subclasses to achieve a stronger CAPTCHA.


getChallengeImageWidth

protected int getChallengeImageWidth()
May be overridden by subclasses

Returns:
the width, in pixels, of the challenge question

getChallengeBackgroundColor

protected Color getChallengeBackgroundColor()
May be overridden by subclasses

Returns:
the background color of the challenge image

getChallengeTextColor

protected Color getChallengeTextColor()
May be overridden by subclasses

Returns:
@return the foreground color of the challenge image

instance

public static Captcha instance()