Commit 3bbb4536 authored by 技术部-任文超's avatar 技术部-任文超

更正GeetestLib

parent 76c3e748
......@@ -56,7 +56,6 @@ public class GeetestLib {
*/
public boolean debugCode = true;
/**
* 带参数构造函数
*
......@@ -96,7 +95,7 @@ public class GeetestLib {
private Map<String, String> getSuccessPreProcessRes(String challenge) {
gtlog("challenge:" + challenge);
Map<String, String> data = new HashMap<String, String>(3);
data.put("success", "0");
data.put("success", "1");
data.put("gt", this.captchaId);
data.put("challenge", challenge);
return data;
......
......@@ -10,12 +10,10 @@ 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.
......@@ -42,30 +40,22 @@ 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);
log.info("请求极验参数:{}", param);
Map<String, String> gtMap=getGeetestSdk().getResponseStr(param);
log.info("请求极验返回:{}", gtMap);
return gtMap;
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);
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;
return Constants.GT_CAPTCHA_VALIDATE_SUCCESS == gtResult;
}
private GeetestLib getGeetestSdk() {
return gtSdk =new GeetestLib(captchaId, privateKey, newFailback, apiUrl);
return 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