修改

parent db6c31d5
......@@ -4,20 +4,24 @@ import cn.quantgroup.xyqb.Constants;
import cn.quantgroup.xyqb.model.ClientType;
import cn.quantgroup.xyqb.service.captcha.GeetestLib;
import cn.quantgroup.xyqb.service.captcha.IGeetestCaptchaService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.logging.Logger;
/**
* @author xufei on 2018/1/30.
*/
@Service
@Slf4j
public class GeetestCaptchaServiceImpl implements IGeetestCaptchaService {
@Resource
......@@ -38,22 +42,28 @@ public class GeetestCaptchaServiceImpl implements IGeetestCaptchaService {
@Value("${geetest.api.url}")
private String apiUrl;
private GeetestLib gtSdk;
@Override
public Map<String, String> fetchGeetestCaptcha(String markId, String remoteIp, ClientType clientType) {
GeetestLib gtSdk = new GeetestLib(captchaId, privateKey, newFailback, apiUrl);
HashMap<String, String> param = getParam(markId, remoteIp, clientType);
return gtSdk.getResponseStr(param);
log.info("请求极验参数:{}", param);
return getGeetestSdk().getResponseStr(param);
}
@Override
public boolean validGeetestCaptcha(String markId, String remoteIp, ClientType clientType, String challenge, String validate, String seccode) {
HashMap<String, String> param = getParam(markId, remoteIp, clientType);
return Constants.GT_CAPTCHA_VALIDATE_SUCCESS==getGeetestSdk().enhencedValidateRequest(challenge, validate, seccode, param);
log.info("二次验证参数:{},challenge:{},validate:{},seccode;{}", param,challenge,validate,seccode);
int gtResult = getGeetestSdk().enhencedValidateRequest(challenge, validate, seccode, param);
log.info("二次验证返回结果;{},版本信息:{}",gtResult);
return Constants.GT_CAPTCHA_VALIDATE_SUCCESS==gtResult;
}
private GeetestLib getGeetestSdk() {
return new GeetestLib(captchaId, privateKey, newFailback, apiUrl);
return gtSdk =new GeetestLib(captchaId, privateKey, newFailback, apiUrl);
}
private HashMap<String, String> getParam(String markId, String remoteIp, ClientType clientType) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment