jcaptchaserviceproxyimpl.java
来自「anewssystem新闻发布系统集成使用了spring hibernate f」· Java 代码 · 共 67 行
JAVA
67 行
package anni.core.security.jcaptcha;
import com.octo.captcha.service.CaptchaService;
import com.octo.captcha.service.CaptchaServiceException;
import org.acegisecurity.captcha.CaptchaServiceProxy;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* 实现 CaptchaServiceProxy 用于acegi来校验,由spring注入jcaptchaService.
*
* @author sshwsfc@gmail.com
* @author Lingo
* @since 2007-04-07
* @version 1.0
*/
public class JCaptchaServiceProxyImpl implements CaptchaServiceProxy {
/**
* logger.
*/
private static Log logger = LogFactory.getLog(JCaptchaServiceProxyImpl.class);
/**
* service.
*/
private CaptchaService jcaptchaService = null;
/**
* 验证输入的验证码是否有效.
*
* @param id session中的id
* @param response 响应
* @return boolean 是否通过验证
*/
public boolean validateReponseForId(String id, Object response) {
logger.debug("validating captcha response");
try {
boolean isHuman = jcaptchaService.validateResponseForID(id,
response).booleanValue();
if (isHuman) {
logger.debug("captcha passed");
} else {
logger.warn("captcha failed");
}
return isHuman;
} catch (CaptchaServiceException cse) {
// fixes known bug in JCaptcha
logger.warn("captcha validation failed due to exception", cse);
return false;
}
}
/**
* @param jcaptchaServiceIn JCaptchaService.
*/
public void setJcaptchaService(CaptchaService jcaptchaServiceIn) {
jcaptchaService = jcaptchaServiceIn;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?