Compare commits

...

10 Commits

Author SHA1 Message Date
duhui 3f7a2cf13b 疯体登陆sdk 2023-05-08 11:49:25 +08:00
duhui 02e3087c84 疯体登陆sdk 2023-05-08 11:48:14 +08:00
duhui 7d15eee93f 悠谷渠道小七专服 2022-12-28 14:25:01 +08:00
duhui d875e2c443 安久和疯体混服 2022-08-29 20:15:34 +08:00
duhui 4411ef41b1 安久登陆 2022-08-12 15:33:04 +08:00
duhui 2bdc94d016 安久登陆 2022-08-12 15:16:22 +08:00
duhui 87feb2b057 安久登陆 2022-08-12 15:02:41 +08:00
duhui f54cfccd6a 安久登陆 2022-08-12 14:41:42 +08:00
duhui a02edca3bd 安久登录 2022-08-08 11:24:17 +08:00
duhui 7dd9ac2238 ohayoo增加安卓登陆 2022-07-28 13:52:27 +08:00
7 changed files with 316 additions and 67 deletions

View File

@ -164,7 +164,7 @@ public class GetServerListController extends HttpServlet {
List<String> myServerList = new ArrayList<>();
long time = 0;
for (Map.Entry<String, UserRecentLoginInfo> entry : userServerInfoMap.entrySet()) {
if(!serverInfosCache.keySet().contains(entry.getKey())){
if(!serverInfosCache.containsKey(entry.getKey())){
//服务器已清除
continue;
}
@ -175,12 +175,7 @@ public class GetServerListController extends HttpServlet {
}
}
Collections.sort(serverList, new Comparator<DBObject>() {
@Override
public int compare(DBObject dbObject1, DBObject dbObject2) {
return Integer.compare((int) dbObject1.get("sort"), (int) dbObject2.get("sort"));
}
});
serverList.sort(Comparator.comparingInt(dbObject -> (int) dbObject.get("sort")));
DBObject resp = new BasicDBObject();
resp.put("serverList", serverList);
resp.put("myServerList", myServerList);

View File

@ -6,7 +6,6 @@ import com.ljsd.redis.RedisKey;
import com.ljsd.service.*;
import com.ljsd.util.AppConstans;
import com.ljsd.util.BaseGlobal;
import com.ljsd.util.MD5Util;
import com.mongodb.BasicDBObject;
import com.mongodb.DBObject;
import org.slf4j.Logger;
@ -27,12 +26,11 @@ public class GetUserController extends HttpServlet {
private final static String _COLLECTION_NAME = "user_info";
private static final Logger LOGGER = LoggerFactory.getLogger(GetUserController.class);
private static Map<String, VerifyService> serviceMap = new HashMap<>();
public static Map<String, VerifyService> serviceMap = new HashMap<>();
public static void initHandler(){
//初始化所有需要的验证方式
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"));
@ -41,9 +39,12 @@ public class GetUserController extends HttpServlet {
serviceMap.put("QUICK2", new QuickVerifyService2("QUICK2"));
serviceMap.put("QUICK3", new QuickVerifyService3("QUICK3"));
serviceMap.put("YOUGU", new YouGuVerifyService("YG"));
serviceMap.put("YGXQ", new YouGuVerifyService("YGXQ"));
serviceMap.put("DUOYOU", new DuoYouVerifyService("DUOYOU"));
serviceMap.put("AIWAN", new AiWanVerifyService("AIWAN"));
serviceMap.put("HF", new HFVerifyService("HF"));
// serviceMap.put("ANJIU", new AnJiuVerifyService("ANJIU"));
serviceMap.put("FENGTI", new FengTiVerifyService("FENGTI"));
}

View File

@ -28,8 +28,7 @@ public abstract class AbstractVerifyService implements VerifyService {
public static String caohua_app_id;
public static String caohua_secret_key;
private String sign;
public String sign;
public AbstractVerifyService(String sign) {
this.sign = sign;

View File

@ -0,0 +1,112 @@
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;
/**
* ,
*/
@Deprecated
public class AnJiuVerifyService extends AbstractVerifyService {
private static final Logger LOGGER = LoggerFactory.getLogger(AnJiuVerifyService.class);
public static int isTestLan=0;
private final static String appId = "220422817754";
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 ("4".equals(platform) ) {
//正式服appId
VerifyParams params = new VerifyParams();
params.setProductCode(appId);
VerifyParams formatParam = getFormatParam(params, request, pid, 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());
LOGGER.info("安久请求参数url{}param{}",url,params);
boolean result = false;
try {
String r = HttpUtils.doPost(url, parms);
LOGGER.info("anjiu请求结果:{}",r);
JSONObject jsonObject = JSON.parseObject(r);
int code = jsonObject.getIntValue("code");
if(code == 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;
}
}

View File

@ -0,0 +1,114 @@
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 FengTiVerifyService extends AbstractVerifyService {
private static final Logger LOGGER = LoggerFactory.getLogger(FengTiVerifyService.class);
public static int isTestLan=0;
public FengTiVerifyService(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) ) {//正式 切不是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 {
//正式服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 url = "http://47.95.231.223/webapi/checkUserInfo";
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(url, parms);
LOGGER.info("疯体登录结果:{}",r);
JSONObject jsonObject = JSON.parseObject(r);
result = jsonObject.getBoolean("status");
}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;
}
}

View File

@ -2,10 +2,10 @@ package com.ljsd.service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.ljsd.controller.GetUserController;
import com.ljsd.pojo.VerifyParams;
import com.ljsd.util.AppConstans;
import com.ljsd.util.HttpUtils;
import com.ljsd.util.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -16,14 +16,17 @@ import java.util.HashMap;
import java.util.Map;
/**
*
* ohayoo
*/
public class QuickVerifyService3 extends AbstractVerifyService {
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractVerifyService.class);
public static int isTestLan=0;
private final static String product_code = "59089882210126220068309806520046";
private final static String quick_appId = "59089882210126220068309806520046";
private final static String iosAppId = "6485653972429833";
private final static String android_appId = "6485653971822594";
private final static String ios_appId = "6485653972429833";
private final static String anJiu_appId = "220422817754";
public QuickVerifyService3(String sign) {
super(sign);
@ -41,58 +44,60 @@ public class QuickVerifyService3 extends AbstractVerifyService {
if (!result) {
response.sendError(400, "verify fail");
LOGGER.error("test verify fail");
return false;
}
return true;
return result;
}
// 正式 安卓
if ("1".equals(platform) ) {
String sub_channel = request.getParameter("sub_channel");
boolean result = false;
if (sub_channel != null && !sub_channel.equals("")) {
if (sub_channel.equals("1000")) {
//测试服构建参数
// 疯体quick渠道登录
if ("1".equals(platform)) {
VerifyParams params = new VerifyParams();
params.setProductCode(product_code);
VerifyParams testParam = getTestParam(params,request, openId, token);
result = verifyTest(testParam);
} else {
//正式服appId
VerifyParams params = new VerifyParams();
params.setProductCode(product_code);
VerifyParams formatParam = getFormatParam(params,request, openId, token);
result = verifyFormat(formatParam);
}
}
params.setProductCode(quick_appId);
VerifyParams testParam = getFormatParam(params,request, openId, token);
boolean result = doVerify(testParam);
if (!result) {
response.sendError(400, "verify fail");
LOGGER.error("verify fail");
response.sendError(400, "quick verify fail");
LOGGER.error("quick verify fail");
return false;
}
}
// 正式 ios
if ("2".equals(platform) ) {
// ohayoo登录
if ("2".equals(platform) || "3".equals(platform)) {
String sub_channel = request.getParameter("sub_channel");
boolean result = false;
if (sub_channel != null && !sub_channel.equals("")) {
VerifyParams params = new VerifyParams();
params.setProductCode(iosAppId);
if ("2".equals(platform)){
params.setProductCode(ios_appId);
}
if ("3".equals(platform)){
params.setProductCode(android_appId);
}
VerifyParams param;
// 1000是测试服
param = getFormatParam(params, request, openId, token);
if (sub_channel.equals("1000")) {
param = getTestParam(params,request, openId, token);
result = verifyTestIos(param);
} else {
param = getFormatParam(params,request, openId, token);
result = verifyFormatIos(param);
}
}
if (!result) {
response.sendError(400, "ios verify fail");
LOGGER.error("ios verify fail");
response.sendError(400, "ohayoo verify fail");
LOGGER.error("ohayoo verify fail");
return false;
}
}
// 安久登录
if ("4".equals(platform)) {
VerifyParams params = new VerifyParams();
params.setProductCode(anJiu_appId);
VerifyParams formatParam = getFormatParam(params, request, pid, token);
boolean result = doVerifyAnJiu(formatParam);
if (!result) {
response.sendError(400, "anjiu verify fail");
LOGGER.error("anjiu verify fail");
return false;
}
}
@ -105,19 +110,23 @@ public class QuickVerifyService3 extends AbstractVerifyService {
@Override
public boolean verifyTest(VerifyParams params) {
return doVerify(params);
return false;
}
@Override
public boolean verifyFormat(VerifyParams params) {
return doVerify(params);
return false;
}
@Override
protected VerifyParams getTestParam(VerifyParams params, HttpServletRequest request, String openId, String token) {
return null;
}
public boolean verifyTestIos(VerifyParams params) {
String url = "https://sandbox-sdk.ohayoo.cn/game_sdk/light_game/account/partner/check";
return doVerifyIos(params,url);
}
public boolean verifyFormatIos(VerifyParams params) {
String url = "https://ohayoo.cn/game_sdk/light_game/account/partner/check";
return doVerifyIos(params,url);
@ -125,7 +134,7 @@ public class QuickVerifyService3 extends AbstractVerifyService {
@Override
boolean doVerify(VerifyParams params) {
LOGGER.info("quick登录验证-->{}",params.getOpenId());
LOGGER.info("疯体 quick登录验证-->{}",params.getOpenId());
String url = "http://checkuser.quickapi.net/v2/checkUserInfo";
Map<String,String> parms = new HashMap<>();
parms.put("token",params.getToken());
@ -168,12 +177,27 @@ public class QuickVerifyService3 extends AbstractVerifyService {
return result;
}
@Override
protected VerifyParams getTestParam(VerifyParams params, HttpServletRequest request, String openId, String token) {
params.setChannel("QUICK");
params.setToken(token);
params.setOpenId(openId);
return params;
boolean doVerifyAnJiu(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());
LOGGER.info("安久请求参数url{}param{}",url,params);
boolean result = false;
try {
String r = HttpUtils.doPost(url, parms);
LOGGER.info("anjiu请求结果:{}",r);
JSONObject jsonObject = JSON.parseObject(r);
int code = jsonObject.getIntValue("code");
if(code == 0){
result = true;
}
}catch (IOException e){
LOGGER.error("anjiu验证失败,Exception:{}",e);
return false;
}
return result;
}
@Override

View File

@ -36,7 +36,10 @@ public class YouGuVerifyService extends AbstractVerifyService {
LOGGER.error("test verify fail");
return false;
}
} else if (!"3".equals(platform) ) {//正式 切不是pc
return true;
}
if (!"3".equals(platform) ) {//正式 切不是pc
String sub_channel = request.getParameter("sub_channel");
boolean result = false;
if (sub_channel != null && !sub_channel.equals("")) {
@ -45,10 +48,7 @@ public class YouGuVerifyService extends AbstractVerifyService {
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 {
}else {
//正式服appId
VerifyParams params = new VerifyParams();
VerifyParams formatParam = getFormatParam(params,request, openId, token);
@ -80,8 +80,14 @@ public class YouGuVerifyService extends AbstractVerifyService {
@Override
boolean doVerify(VerifyParams params) {
LOGGER.info("YouGuVerifyService登录验证-->{}",params.getOpenId());
String url = "http://smi.648sy.com/tcx/auth";
String log = "youguVerifyService";
if (sign.equals("YGXQ")){
url = "http://smi.648sy.com/tcxxqzf/auth";
log = "youguXQVerifyService";
}
LOGGER.info("{}登录验证-->{}",log,params.getOpenId());
Map<String,String> parms = new HashMap<>();
parms.put("token",params.getToken());
parms.put("uid",params.getOpenId());
@ -90,12 +96,12 @@ public class YouGuVerifyService extends AbstractVerifyService {
String r = HttpUtils.doPost(url, parms);
JSONObject jsonObject = JSON.parseObject(r);
int errno = jsonObject.getIntValue("errno");
LOGGER.info("YouGuVerifyService请求结果:{}",r);
LOGGER.info("{}请求结果:{}",log,r);
if(errno == 0){
result = true;
}
}catch (IOException e){
LOGGER.info("YouGuVerifyService验证失败,IOException");
LOGGER.info("{}验证失败,{}",log,e.getMessage());
return false;
}
return result;
@ -103,7 +109,6 @@ public class YouGuVerifyService extends AbstractVerifyService {
@Override
protected VerifyParams getTestParam(VerifyParams params, HttpServletRequest request, String openId, String token) {
params.setChannel("YouGu");
params.setToken(token);
params.setOpenId(openId);
return params;
@ -111,7 +116,6 @@ public class YouGuVerifyService extends AbstractVerifyService {
@Override
protected VerifyParams getFormatParam(VerifyParams params, HttpServletRequest request, String openId, String token) {
params.setChannel("YouGu");
params.setToken(token);
params.setOpenId(openId);
return params;