增加悠谷新的登录验证

master
DESKTOP-C3M45P4\dengdan 2025-12-09 12:25:14 +08:00
parent 763ade31c9
commit 180a9714ee
2 changed files with 118 additions and 0 deletions

View File

@ -61,6 +61,7 @@ public class GetUserController extends HttpServlet {
serviceMap.put("AQLM", new AQLMVerifyService("AQLM"));
serviceMap.put("AQLMYJ", new YgAqlmYjVerifyService("AQLMYJ"));
serviceMap.put("GOHU", new GonghuiVerifyService("GOHU"));
serviceMap.put("TCX_YG", new YouGuTcxVerifyService("TCX_YG"));
// 自在修仙西游
serviceMap.put("ZXXQ01", new Zzxxxq01VerifyService("ZXXQ01"));

View File

@ -0,0 +1,117 @@
package com.ljsd.service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.ljsd.pojo.VerifyParams;
import com.ljsd.util.AppConstans;
import com.ljsd.util.HttpUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
public class YouGuTcxVerifyService extends AbstractVerifyService {
private static final Logger LOGGER = LoggerFactory.getLogger(YouGuVerifyService.class);
public static int isTestLan=0;
public YouGuTcxVerifyService(String sign) {
super(sign);
}
@Override
public boolean verify(HttpServletResponse response, HttpServletRequest request, String admin, String platform, String pid, String openId, String token){
try {
//如果是自己人不需要验证了
if(AppConstans.appsecret.equals(admin)) {
return true;
}
if (isTestLan == 1) { //test
boolean result = loginVerfifyByTestLan(openId, token);
if (!result) {
response.sendError(400, "verify fail");
LOGGER.error("test verify fail");
return false;
}
return true;
}
if (!"3".equals(platform) ) {//正式 切不是pc
String sub_channel = request.getParameter("sub_channel");
boolean result = false;
if (sub_channel != null && !sub_channel.isEmpty()) {
if (sub_channel.equals("1000")) {
//测试服构建参数
VerifyParams params = new VerifyParams();
VerifyParams testParam = getTestParam(params,request, openId, token);
result = verifyTest(testParam);
}else {
//正式服appId
VerifyParams params = new VerifyParams();
VerifyParams formatParam = getFormatParam(params,request, openId, token);
result = verifyFormat(formatParam);
}
}
if (!result) {
response.sendError(400, "verify fail");
LOGGER.error("verify fail");
return false;
}
}
}catch (Exception e){
e.printStackTrace();
}
return true;
}
@Override
public boolean verifyTest(VerifyParams params) {
return doVerify(params);
}
@Override
public boolean verifyFormat(VerifyParams params) {
return doVerify(params);
}
@Override
boolean doVerify(VerifyParams params) {
String loginUrl = "http://smi.648sy.com/txcldyzlmzf3/auth";
LOGGER.info("悠谷渠道登录验证-->{}",params.getOpenId());
Map<String,String> parms = new HashMap<>();
parms.put("token",params.getToken());
parms.put("uid",params.getOpenId());
boolean result = false;
try {
String r = HttpUtils.doPost(loginUrl, parms);
JSONObject jsonObject = JSON.parseObject(r);
int errno = jsonObject.getIntValue("errno");
LOGGER.info("悠谷渠道登录验证请求结果:{}",r);
if(errno == 0){
result = true;
}
}catch (IOException e){
LOGGER.info("悠谷渠道登录验证验证失败,{}",e.getMessage());
return false;
}
return result;
}
@Override
protected VerifyParams getTestParam(VerifyParams params, HttpServletRequest request, String openId, String token) {
params.setToken(token);
params.setOpenId(openId);
return params;
}
@Override
protected VerifyParams getFormatParam(VerifyParams params, HttpServletRequest request, String openId, String token) {
params.setToken(token);
params.setOpenId(openId);
return params;
}
}