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

完善log,修复参数

parent 99bfb717
......@@ -78,7 +78,7 @@ public class CaptchaNewValidateAdvisor {
String seccode = request.getParameter(Constants.FN_GEETEST_SECCODE);
String phoneNo = request.getParameter("phoneNo");
String clientType = request.getParameter("clientType");
log.info("使用极验二次验证,phoneNo:{}", phoneNo);
log.info("使用极验二次验证,phoneNo:{}, clientType:{}, challenge:{}, validate:{}, seccode:{}", phoneNo, clientType, challenge, validate, seccode);
return geetestCaptchaService.validGeetestCaptcha(PasswordUtil.MD5(phoneNo), IPUtil.getRemoteIP(request), ClientType.valueByName(clientType), challenge, validate, seccode);
}
......
......@@ -245,23 +245,16 @@ public class GeetestLib {
* @return 验证结果, 1表示验证成功0表示验证失败
*/
public int enhencedValidateRequest(String challenge, String validate, String seccode, HashMap<String, String> data) {
if (!resquestIsLegal(challenge, validate, seccode)) {
return 0;
}
gtlog("request legitimate");
String userId = data.get("user_id");
String clientType = data.get("client_type");
String ipAddress = data.get("ip_address");
String postUrl = this.apiUrl + this.validateUrl;
String param = String.format("challenge=%s&validate=%s&seccode=%s&json_format=%s",
challenge, validate, seccode, this.json_format);
if (userId != null) {
param = param + "&user_id=" + userId;
}
......@@ -271,62 +264,35 @@ public class GeetestLib {
if (ipAddress != null) {
param = param + "&ip_address=" + ipAddress;
}
gtlog("param:" + param);
String response = "";
try {
if (validate.length() <= 0) {
return 0;
}
if (!checkResultByPrivate(challenge, validate)) {
return 0;
}
gtlog("checkResultByPrivate");
response = readContentFromPost(postUrl, param);
gtlog("response: " + response);
} catch (Exception e) {
e.printStackTrace();
}
String return_seccode = "";
try {
JSONObject return_map = new JSONObject(response);
return_seccode = return_map.getString("seccode");
gtlog("md5: " + md5Encode(return_seccode));
if (return_seccode.equals(md5Encode(seccode))) {
return 1;
} else {
return 0;
}
} catch (JSONException e) {
gtlog("json load error");
return 0;
}
}
/**
......
......@@ -60,9 +60,9 @@ public class GeetestCaptchaServiceImpl implements IGeetestCaptchaService {
HashMap<String, String> param = new HashMap<>();
param.put("user_id", markId);
if (Objects.isNull(clientType)) {
param.put("client_type", ClientType.APP.name());
param.put("client_type", ClientType.APP.name().toLowerCase());
}else{
param.put("client_type", clientType.name());
param.put("client_type", clientType.name().toLowerCase());
}
param.put("ip_address", remoteIp);
return param;
......
......@@ -23,8 +23,8 @@ public class GeetestCaptchaServiceTest {
@Resource
private IGeetestCaptchaService geetestCaptchaService;
private String phoneNo = "18010043006";
private String remoteIp = "127.0.0.1";
private String phoneNo = "18953309449";
private String remoteIp = "192.168.12.24";
private ClientType clientType = ClientType.H5;
private Map<String, String> data = null;
......@@ -32,7 +32,6 @@ public class GeetestCaptchaServiceTest {
public void testFetchGeetestCaptcha(){
data = geetestCaptchaService.fetchGeetestCaptcha(PasswordUtil.MD5(phoneNo), remoteIp, clientType);
Assert.assertNotNull(data);
Assert.assertTrue(data.containsKey(Constants.VERIFY_PARAM));
Assert.assertTrue(data.containsKey("gt"));
Assert.assertTrue(data.containsKey("challenge"));
}
......
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