安久登录

master
duhui 2022-08-08 11:24:17 +08:00
parent 7dd9ac2238
commit a02edca3bd
2 changed files with 108 additions and 1 deletions

View File

@ -32,7 +32,6 @@ public class GetUserController extends HttpServlet {
//初始化所有需要的验证方式
serviceMap.put("MHT", new LdVerifyService("MHT"));
serviceMap.put("XP", new XPVerifyService("XP"));
//草花
serviceMap.put("CH",new CaohuaVerifyService("CH"));
serviceMap.put("QUICK", new QuickVerifyService("QUICK"));
serviceMap.put("QIANYOU", new QiYouVerifyService("huangjiayl&qypay"));
@ -44,6 +43,7 @@ public class GetUserController extends HttpServlet {
serviceMap.put("DUOYOU", new DuoYouVerifyService("DUOYOU"));
serviceMap.put("AIWAN", new AiWanVerifyService("AIWAN"));
serviceMap.put("HF", new HFVerifyService("HF"));
serviceMap.put("ANJIU", new HFVerifyService("ANJIU"));
}

View File

@ -0,0 +1,107 @@
package com.ljsd.service;
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 AnJiuVerifyService extends AbstractVerifyService {
private static final Logger LOGGER = LoggerFactory.getLogger(AnJiuVerifyService.class);
public static int isTestLan=0;
private final static String appId = "29423";
public AnJiuVerifyService(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 ("1".equals(platform) ) {
//正式服appId
VerifyParams params = new VerifyParams();
params.setProductCode(appId);
VerifyParams formatParam = getFormatParam(params, request, openId, token);
boolean 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 false;
}
@Override
public boolean verifyFormat(VerifyParams params) {
return doVerify(params);
}
@Override
boolean doVerify(VerifyParams params) {
String url = "http://release.anjiu.cn/cp/checktoken";
Map<String,String> parms = new HashMap<>();
parms.put("sessionId",params.getToken());
parms.put("appId",params.getProductCode());
parms.put("platformId",params.getOpenId());
boolean result = false;
try {
String r = HttpUtils.doPost(url, parms);
LOGGER.info("anjiu请求结果:{}",r);
if(r.equals("0")){
result = true;
}
}catch (IOException e){
LOGGER.error("anjiu验证失败,Exception:{}",e);
return false;
}
return result;
}
@Override
protected VerifyParams getTestParam(VerifyParams params, HttpServletRequest request, String openId, String token) {
return null;
}
@Override
protected VerifyParams getFormatParam(VerifyParams params, HttpServletRequest request, String openId, String token) {
params.setProductCode(appId);
params.setToken(token);
params.setOpenId(openId);
return params;
}
}