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

更正GeetestLib

parent 76c3e748
...@@ -56,7 +56,6 @@ public class GeetestLib { ...@@ -56,7 +56,6 @@ public class GeetestLib {
*/ */
public boolean debugCode = true; public boolean debugCode = true;
/** /**
* 带参数构造函数 * 带参数构造函数
* *
...@@ -96,7 +95,7 @@ public class GeetestLib { ...@@ -96,7 +95,7 @@ public class GeetestLib {
private Map<String, String> getSuccessPreProcessRes(String challenge) { private Map<String, String> getSuccessPreProcessRes(String challenge) {
gtlog("challenge:" + challenge); gtlog("challenge:" + challenge);
Map<String, String> data = new HashMap<String, String>(3); Map<String, String> data = new HashMap<String, String>(3);
data.put("success", "0"); data.put("success", "1");
data.put("gt", this.captchaId); data.put("gt", this.captchaId);
data.put("challenge", challenge); data.put("challenge", challenge);
return data; return data;
......
...@@ -10,12 +10,10 @@ import org.springframework.beans.factory.annotation.Value; ...@@ -10,12 +10,10 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.logging.Logger;
/** /**
* @author xufei on 2018/1/30. * @author xufei on 2018/1/30.
...@@ -42,30 +40,22 @@ public class GeetestCaptchaServiceImpl implements IGeetestCaptchaService { ...@@ -42,30 +40,22 @@ public class GeetestCaptchaServiceImpl implements IGeetestCaptchaService {
@Value("${geetest.api.url}") @Value("${geetest.api.url}")
private String apiUrl; private String apiUrl;
private GeetestLib gtSdk;
@Override @Override
public Map<String, String> fetchGeetestCaptcha(String markId, String remoteIp, ClientType clientType) { 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); HashMap<String, String> param = getParam(markId, remoteIp, clientType);
log.info("请求极验参数:{}", param); return getGeetestSdk().getResponseStr(param);
Map<String, String> gtMap=getGeetestSdk().getResponseStr(param);
log.info("请求极验返回:{}", gtMap);
return gtMap;
} }
@Override @Override
public boolean validGeetestCaptcha(String markId, String remoteIp, ClientType clientType, String challenge, String validate, String seccode) { public boolean validGeetestCaptcha(String markId, String remoteIp, ClientType clientType, String challenge, String validate, String seccode) {
HashMap<String, String> param = getParam(markId, remoteIp, clientType); 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); 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() { 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) { 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