com.octo.captcha.service.multitype
Class GenericManageableCaptchaService

java.lang.Object
  extended by com.octo.captcha.service.AbstractCaptchaService
      extended by com.octo.captcha.service.AbstractManageableCaptchaService
          extended by com.octo.captcha.service.multitype.GenericManageableCaptchaService
All Implemented Interfaces:
AbstractManageableCaptchaServiceMBean, CaptchaService, ImageCaptchaService, ManageableCaptchaService, MultiTypeCaptchaService, SoundCaptchaService, TextCaptchaService

public class GenericManageableCaptchaService
extends AbstractManageableCaptchaService
implements MultiTypeCaptchaService

Generic and new default captchaService implementation. Can accept and serve any captcha type.
beware of class cast exception if you call the wrong typed getChallenge method!


Field Summary
 
Fields inherited from class com.octo.captcha.service.AbstractCaptchaService
engine, logger, store
 
Constructor Summary
GenericManageableCaptchaService(CaptchaEngine captchaEngine, int minGuarantedStorageDelayInSeconds, int maxCaptchaStoreSize, int captchaStoreLoadBeforeGarbageCollection)
          Constructor with FastHashMapCaptchaStore
GenericManageableCaptchaService(CaptchaStore captchaStore, CaptchaEngine captchaEngine, int minGuarantedStorageDelayInSeconds, int maxCaptchaStoreSize, int captchaStoreLoadBeforeGarbageCollection)
           
 
Method Summary
protected  java.lang.Object getChallengeClone(Captcha captcha)
          This method : Retrieve the challenge from the captcha Make and return a clone of the challenge Return the clone It has be design in order to let the service dipose the challenge of the captcha after rendering.
 java.awt.image.BufferedImage getImageChallengeForID(java.lang.String ID)
          Method to retrive the image challenge corresponding to the given ticket.
 java.awt.image.BufferedImage getImageChallengeForID(java.lang.String ID, java.util.Locale locale)
          Method to retrive the image challenge corresponding to the given ticket.
 javax.sound.sampled.AudioInputStream getSoundChallengeForID(java.lang.String ID)
          Method to retrive the sound challenge corresponding to the given ticket.
 javax.sound.sampled.AudioInputStream getSoundChallengeForID(java.lang.String ID, java.util.Locale locale)
          Method to retrive the sound challenge corresponding to the given ticket.
 java.lang.String getTextChallengeForID(java.lang.String ID)
          Method to retrive the text challenge corresponding to the given ticket.
 java.lang.String getTextChallengeForID(java.lang.String ID, java.util.Locale locale)
          Method to retrieve the text challenge corresponding to the given ticket.
 
Methods inherited from class com.octo.captcha.service.AbstractManageableCaptchaService
emptyCaptchaStore, garbageCollectCaptchaStore, garbageCollectCaptchaStore, generateAndStoreCaptcha, getCaptchaEngineClass, getCaptchaStoreMaxSize, getCaptchaStoreSize, getCaptchaStoreSizeBeforeGarbageCollection, getEngine, getMinGuarantedStorageDelayInSeconds, getNumberOfCorrectResponses, getNumberOfGarbageCollectableCaptchas, getNumberOfGarbageCollectedCaptcha, getNumberOfGeneratedCaptchas, getNumberOfUncorrectResponses, isCaptchaStoreFull, isCaptchaStoreQuotaReached, setCaptchaEngine, setCaptchaEngineClass, setCaptchaStoreMaxSize, setCaptchaStoreSizeBeforeGarbageCollection, setMinGuarantedStorageDelayInSeconds, validateResponseForID
 
Methods inherited from class com.octo.captcha.service.AbstractCaptchaService
getChallengeForID, getChallengeForID, getQuestionForID, getQuestionForID
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.octo.captcha.service.CaptchaService
getChallengeForID, getChallengeForID, getQuestionForID, getQuestionForID, validateResponseForID
 

Constructor Detail

GenericManageableCaptchaService

public GenericManageableCaptchaService(CaptchaEngine captchaEngine,
                                       int minGuarantedStorageDelayInSeconds,
                                       int maxCaptchaStoreSize,
                                       int captchaStoreLoadBeforeGarbageCollection)
Constructor with FastHashMapCaptchaStore

Parameters:
captchaEngine - the used engine. Use the BufferedEngineContainer to enable buffered captcha generation

GenericManageableCaptchaService

public GenericManageableCaptchaService(CaptchaStore captchaStore,
                                       CaptchaEngine captchaEngine,
                                       int minGuarantedStorageDelayInSeconds,
                                       int maxCaptchaStoreSize,
                                       int captchaStoreLoadBeforeGarbageCollection)
Method Detail

getImageChallengeForID

public java.awt.image.BufferedImage getImageChallengeForID(java.lang.String ID)
                                                    throws CaptchaServiceException
Method to retrive the image challenge corresponding to the given ticket.

Specified by:
getImageChallengeForID in interface ImageCaptchaService
Parameters:
ID - the ticket
Returns:
the challenge
Throws:
CaptchaServiceException - if the ticket is invalid

getImageChallengeForID

public java.awt.image.BufferedImage getImageChallengeForID(java.lang.String ID,
                                                           java.util.Locale locale)
                                                    throws CaptchaServiceException
Method to retrive the image challenge corresponding to the given ticket.

Specified by:
getImageChallengeForID in interface ImageCaptchaService
Parameters:
ID - the ticket
Returns:
the challenge
Throws:
CaptchaServiceException - if the ticket is invalid

getSoundChallengeForID

public javax.sound.sampled.AudioInputStream getSoundChallengeForID(java.lang.String ID)
                                                            throws CaptchaServiceException
Method to retrive the sound challenge corresponding to the given ticket.

Specified by:
getSoundChallengeForID in interface SoundCaptchaService
Parameters:
ID - the ticket
Returns:
the challenge
Throws:
CaptchaServiceException - if the ticket is invalid

getSoundChallengeForID

public javax.sound.sampled.AudioInputStream getSoundChallengeForID(java.lang.String ID,
                                                                   java.util.Locale locale)
                                                            throws CaptchaServiceException
Method to retrive the sound challenge corresponding to the given ticket.

Specified by:
getSoundChallengeForID in interface SoundCaptchaService
Parameters:
ID - the ticket
Returns:
the challenge
Throws:
CaptchaServiceException - if the ticket is invalid

getTextChallengeForID

public java.lang.String getTextChallengeForID(java.lang.String ID)
                                       throws CaptchaServiceException
Method to retrive the text challenge corresponding to the given ticket.

Specified by:
getTextChallengeForID in interface TextCaptchaService
Parameters:
ID - the ticket
Returns:
the challenge
Throws:
CaptchaServiceException - if the ticket is invalid

getTextChallengeForID

public java.lang.String getTextChallengeForID(java.lang.String ID,
                                              java.util.Locale locale)
                                       throws CaptchaServiceException
Method to retrieve the text challenge corresponding to the given ticket.

Specified by:
getTextChallengeForID in interface TextCaptchaService
Parameters:
ID - the ticket
Returns:
the challenge
Throws:
CaptchaServiceException - if the ticket is invalid

getChallengeClone

protected java.lang.Object getChallengeClone(Captcha captcha)
This method : Retrieve the challenge from the captcha Make and return a clone of the challenge Return the clone It has be design in order to let the service dipose the challenge of the captcha after rendering. It should be implemented for all captcha type (@see ImageCaptchaService implementations for exemple)

Specified by:
getChallengeClone in class AbstractCaptchaService
Returns:
a Challenge Clone


Copyright 2003-2009 JCaptcha. All Rights Reserved.