![JAR search and dependency download from the Maven repository](/logo.png)
com.octo.captcha.text.math.MathCaptcha Maven / Gradle / Ivy
The newest version!
/*
* JCaptcha, the open source java framework for captcha definition and integration
* Copyright (c) 2007 jcaptcha.net. All Rights Reserved.
* See the LICENSE.txt file distributed with this package.
*/
package com.octo.captcha.text.math;
import com.octo.captcha.text.TextCaptcha;
/**
* Simple math captcha
*
* @author Marc-Antoine Garrigue
* @version 1.0
*/
public class MathCaptcha extends TextCaptcha {
private String response;
MathCaptcha(String question, String challenge, String response) {
super(question, challenge);
this.response = response;
}
/**
* Validation routine from the CAPTCHA interface. this methods verify if the response is not null and a String and
* then compares the given response to the internal string.
*
* @return true if the given response equals the internal response, false otherwise.
*/
public final Boolean validateResponse(final Object response) {
return (null != response && response instanceof String)
? validateResponse((String) response) : Boolean.FALSE;
}
/**
* Very simple validation routine that compares the given response to the internal string.
*
* @return true if the given response equals the internal response, false otherwise.
*/
private final Boolean validateResponse(final String response) {
return Boolean.valueOf(response.equals(this.response));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy