|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.octo.captcha.service.AbstractCaptchaService com.octo.captcha.service.AbstractManageableCaptchaService
public abstract class AbstractManageableCaptchaService
This class provides default implementation for the management interface. It uses an HashMap to store the timestamps for garbage collection.
Field Summary |
---|
Fields inherited from class com.octo.captcha.service.AbstractCaptchaService |
---|
engine, logger, store |
Constructor Summary | |
---|---|
protected |
AbstractManageableCaptchaService(CaptchaStore captchaStore,
CaptchaEngine captchaEngine,
int minGuarantedStorageDelayInSeconds,
int maxCaptchaStoreSize)
|
protected |
AbstractManageableCaptchaService(CaptchaStore captchaStore,
CaptchaEngine captchaEngine,
int minGuarantedStorageDelayInSeconds,
int maxCaptchaStoreSize,
int captchaStoreLoadBeforeGarbageCollection)
|
Method Summary | |
---|---|
void |
emptyCaptchaStore()
Empty the Store |
void |
garbageCollectCaptchaStore()
Garbage collect the captcha store, means all old capthca (captcha in the store wich has been stored more than the MinGuarantedStorageDelayInSecond |
protected void |
garbageCollectCaptchaStore(java.util.Iterator garbageCollectableCaptchaIds)
Garbage collect the captcha store, means all old captcha (captcha in the store wich has been stored more than the MinGuarantedStorageDelayInSecond |
protected Captcha |
generateAndStoreCaptcha(java.util.Locale locale,
java.lang.String ID)
|
java.lang.String |
getCaptchaEngineClass()
Get the fully qualified class name of the concrete CaptchaEngine used by the service. |
int |
getCaptchaStoreMaxSize()
|
int |
getCaptchaStoreSize()
Get the curent size of the captcha store |
int |
getCaptchaStoreSizeBeforeGarbageCollection()
|
CaptchaEngine |
getEngine()
|
int |
getMinGuarantedStorageDelayInSeconds()
Get the minimum delay (in seconds) a client can be assured that a captcha generated by the service can be retrieved and a response to its challenge tested |
long |
getNumberOfCorrectResponses()
Get the number of correct responses to captcha challenges since the service is up. |
int |
getNumberOfGarbageCollectableCaptchas()
Get the number of captchas that can be garbage collected in the captcha store |
long |
getNumberOfGarbageCollectedCaptcha()
Get the number of captcha garbage collected since the service is up WARNING : this value won't be significant if the real number is > Long.MAX_VALUE |
long |
getNumberOfGeneratedCaptchas()
Get the number of captcha generated since the service is up WARNING : this value won't be significant if the real number is > Long.MAX_VALUE |
long |
getNumberOfUncorrectResponses()
Get the number of uncorrect responses to captcha challenges since the service is up. |
protected boolean |
isCaptchaStoreFull()
|
protected boolean |
isCaptchaStoreQuotaReached()
|
void |
setCaptchaEngine(CaptchaEngine engine)
Updates the engine served by this service |
void |
setCaptchaEngineClass(java.lang.String theClassName)
Set the fully qualified class name of the concrete CaptchaEngine used by the service |
void |
setCaptchaStoreMaxSize(int size)
This max size is used by the service : it will throw a CaptchaServiceException if the store is full when a client ask for a captcha. |
void |
setCaptchaStoreSizeBeforeGarbageCollection(int captchaStoreSizeBeforeGarbageCollection)
max captchaStore size before garbage collection of the store |
void |
setMinGuarantedStorageDelayInSeconds(int theMinGuarantedStorageDelayInSeconds)
set the minimum delay (in seconds)a client can be assured that a captcha generated by the service can be retrieved and a response to its challenge tested |
java.lang.Boolean |
validateResponseForID(java.lang.String ID,
java.lang.Object response)
Method to validate a response to the challenge corresponding to the given ticket and remove the coresponding captcha from the store. |
Methods inherited from class com.octo.captcha.service.AbstractCaptchaService |
---|
getChallengeClone, 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 |
Constructor Detail |
---|
protected AbstractManageableCaptchaService(CaptchaStore captchaStore, CaptchaEngine captchaEngine, int minGuarantedStorageDelayInSeconds, int maxCaptchaStoreSize)
protected AbstractManageableCaptchaService(CaptchaStore captchaStore, CaptchaEngine captchaEngine, int minGuarantedStorageDelayInSeconds, int maxCaptchaStoreSize, int captchaStoreLoadBeforeGarbageCollection)
Method Detail |
---|
public java.lang.String getCaptchaEngineClass()
getCaptchaEngineClass
in interface ManageableCaptchaService
public void setCaptchaEngineClass(java.lang.String theClassName) throws java.lang.IllegalArgumentException
setCaptchaEngineClass
in interface ManageableCaptchaService
theClassName
- the fully qualified class name of the CaptchaEngine used by the service
java.lang.IllegalArgumentException
- if className can't be used as the service CaptchaEngine, either because it can't
be instanciated by the service or it is not a ImageCaptchaEngine concrete
class.public CaptchaEngine getEngine()
getEngine
in interface ManageableCaptchaService
public void setCaptchaEngine(CaptchaEngine engine)
setCaptchaEngine
in interface ManageableCaptchaService
public int getMinGuarantedStorageDelayInSeconds()
getMinGuarantedStorageDelayInSeconds
in interface ManageableCaptchaService
public void setMinGuarantedStorageDelayInSeconds(int theMinGuarantedStorageDelayInSeconds)
setMinGuarantedStorageDelayInSeconds
in interface ManageableCaptchaService
theMinGuarantedStorageDelayInSeconds
- the minimum guaranted delaypublic long getNumberOfGeneratedCaptchas()
getNumberOfGeneratedCaptchas
in interface ManageableCaptchaService
public long getNumberOfCorrectResponses()
getNumberOfCorrectResponses
in interface ManageableCaptchaService
public long getNumberOfUncorrectResponses()
getNumberOfUncorrectResponses
in interface ManageableCaptchaService
public int getCaptchaStoreSize()
getCaptchaStoreSize
in interface ManageableCaptchaService
public int getNumberOfGarbageCollectableCaptchas()
getNumberOfGarbageCollectableCaptchas
in interface ManageableCaptchaService
public long getNumberOfGarbageCollectedCaptcha()
getNumberOfGarbageCollectedCaptcha
in interface ManageableCaptchaService
public int getCaptchaStoreSizeBeforeGarbageCollection()
getCaptchaStoreSizeBeforeGarbageCollection
in interface ManageableCaptchaService
public void setCaptchaStoreSizeBeforeGarbageCollection(int captchaStoreSizeBeforeGarbageCollection)
setCaptchaStoreSizeBeforeGarbageCollection
in interface ManageableCaptchaService
public void setCaptchaStoreMaxSize(int size)
setCaptchaStoreMaxSize
in interface ManageableCaptchaService
public int getCaptchaStoreMaxSize()
getCaptchaStoreMaxSize
in interface ManageableCaptchaService
protected void garbageCollectCaptchaStore(java.util.Iterator garbageCollectableCaptchaIds)
public void garbageCollectCaptchaStore()
ManageableCaptchaService
garbageCollectCaptchaStore
in interface ManageableCaptchaService
public void emptyCaptchaStore()
emptyCaptchaStore
in interface ManageableCaptchaService
protected Captcha generateAndStoreCaptcha(java.util.Locale locale, java.lang.String ID)
generateAndStoreCaptcha
in class AbstractCaptchaService
protected boolean isCaptchaStoreFull()
protected boolean isCaptchaStoreQuotaReached()
public java.lang.Boolean validateResponseForID(java.lang.String ID, java.lang.Object response) throws CaptchaServiceException
validateResponseForID
in interface CaptchaService
validateResponseForID
in class AbstractCaptchaService
ID
- the ticket provided by the buildCaptchaAndGetID method
CaptchaServiceException
- if the ticket is invalid
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |