generated from root/miduo_server
多游登录
parent
a2553d5cab
commit
f827a3d5f8
|
@ -38,6 +38,7 @@ public class GetUserController extends HttpServlet {
|
||||||
serviceMap.put("DY", new V3367VerifyService("DY"));
|
serviceMap.put("DY", new V3367VerifyService("DY"));
|
||||||
serviceMap.put("QUICK2", new QuickVerifyService2("QUICK2"));
|
serviceMap.put("QUICK2", new QuickVerifyService2("QUICK2"));
|
||||||
serviceMap.put("YOUGU", new YouGuVerifyService("YG"));
|
serviceMap.put("YOUGU", new YouGuVerifyService("YG"));
|
||||||
|
serviceMap.put("DUOYOU", new DuoYouVerifyService("DUOYOU"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -73,7 +74,7 @@ public class GetUserController extends HttpServlet {
|
||||||
DBObject res = new BasicDBObject();
|
DBObject res = new BasicDBObject();
|
||||||
String openId = request.getParameter("openId");
|
String openId = request.getParameter("openId");
|
||||||
if (openId == null || openId.isEmpty()) {
|
if (openId == null || openId.isEmpty()) {
|
||||||
returnErrorToFront(res,response,"openId is empty");
|
returnErrorToFront(res,response, "openId is empty");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -0,0 +1,123 @@
|
||||||
|
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 DuoYouVerifyService extends AbstractVerifyService {
|
||||||
|
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractVerifyService.class);
|
||||||
|
public static int isTestLan=0;
|
||||||
|
|
||||||
|
public DuoYouVerifyService(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;
|
||||||
|
}
|
||||||
|
} else if (!"3".equals(platform) ) {//正式 切不是pc
|
||||||
|
String sub_channel = request.getParameter("sub_channel");
|
||||||
|
boolean result = false;
|
||||||
|
if (sub_channel != null && !sub_channel.equals("")) {
|
||||||
|
if (sub_channel.equals("1000")) {
|
||||||
|
//测试服构建参数
|
||||||
|
VerifyParams params = new VerifyParams();
|
||||||
|
VerifyParams testParam = getTestParam(params,request, openId, token);
|
||||||
|
result = verifyTest(testParam);
|
||||||
|
} else if(sub_channel.equals("20201222")){
|
||||||
|
//商务服
|
||||||
|
//result = loginVerfifyShangwu("MHT", openId, token, MHTSDKConstans.rhappIdshangwu);
|
||||||
|
} 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) {
|
||||||
|
LOGGER.info("DuoYouVerifyService-->{}",params.getOpenId());
|
||||||
|
String url = "https://api.aiduoyou.com/member/login_check?app_id="+params.getAppId()+"&uid="+params.getOpenId()+"&access_token="+params.getToken();
|
||||||
|
LOGGER.info("DuoYouVerifyService params -->{}",url);
|
||||||
|
/*Map<String,String> parms = new HashMap<>();
|
||||||
|
parms.put("app_id ",params.getAppId());
|
||||||
|
parms.put("uid",params.getOpenId());
|
||||||
|
parms.put("access_token",params.getToken());*/
|
||||||
|
boolean result = false;
|
||||||
|
try {
|
||||||
|
String r = HttpUtils.httpGetRequest(url);
|
||||||
|
JSONObject jsonObject = JSON.parseObject(r);
|
||||||
|
int errno = jsonObject.getIntValue("code");
|
||||||
|
LOGGER.info("DuoYouVerifyService请求结果:{}",r);
|
||||||
|
if(errno == 0){
|
||||||
|
result = true;
|
||||||
|
}
|
||||||
|
}catch (Exception e){
|
||||||
|
LOGGER.info("DuoYouVerifyService,IOException");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected VerifyParams getTestParam(VerifyParams params, HttpServletRequest request, String openId, String token) {
|
||||||
|
params.setChannel("YouGu");
|
||||||
|
params.setToken(token);
|
||||||
|
params.setOpenId(openId);
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected VerifyParams getFormatParam(VerifyParams params, HttpServletRequest request, String openId, String token) {
|
||||||
|
//App ID:531340CB459ACA5BD680DAF51215B56F
|
||||||
|
//App Key:31cc6cf98488f154d564153ecd93953e
|
||||||
|
params.setAppId("531340CB459ACA5BD680DAF51215B56F");
|
||||||
|
params.setToken(token);
|
||||||
|
params.setOpenId(openId);
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue