generated from root/miduo_server
浩凡sdk
parent
aba44e47f7
commit
75429c3812
|
|
@ -43,6 +43,7 @@ public class GetUserController extends HttpServlet {
|
|||
serviceMap.put("YOUGU", new YouGuVerifyService("YG"));
|
||||
serviceMap.put("DUOYOU", new DuoYouVerifyService("DUOYOU"));
|
||||
serviceMap.put("AIWAN", new AiWanVerifyService("AIWAN"));
|
||||
serviceMap.put("HF", new HFVerifyService("HF"));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,128 @@
|
|||
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 HFVerifyService extends AbstractVerifyService {
|
||||
|
||||
public static final String app_key = "FKzLkGPIyMwYjXhRYfMWBsqikOfSPLkX";
|
||||
public static final String app_id = "30397";
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(HFVerifyService.class);
|
||||
public static int isTestLan = 0;
|
||||
|
||||
public HFVerifyService(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) {
|
||||
boolean result = loginVerfifyByTestLan(openId, token);
|
||||
if (!result) {
|
||||
response.sendError(400, "verify fail");
|
||||
LOGGER.error("test verify fail");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
//正式 切不是pc
|
||||
else if (!"3".equals(platform)) {
|
||||
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);
|
||||
// }
|
||||
//正式服appId
|
||||
else {
|
||||
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("hao fan 登录验证-->{}", params.getOpenId());
|
||||
String url = "http://unionsdk.haofangame.com/api/checkToken.jhtml";
|
||||
Map<String, String> parms = new HashMap<>();
|
||||
parms.put("token", params.getToken());
|
||||
parms.put("gamePid", app_id);
|
||||
parms.put("userNo", params.getOpenId());
|
||||
boolean result = false;
|
||||
try {
|
||||
String r = HttpUtils.doPost(url, parms);
|
||||
JSONObject jsonObject = JSON.parseObject(r);
|
||||
int errno = jsonObject.getIntValue("code");
|
||||
LOGGER.info("hao fan 请求结果:{}", r);
|
||||
if (errno >=100) {
|
||||
result = true;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
LOGGER.info("hao fan 验证失败,IOException");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected VerifyParams getTestParam(VerifyParams params, HttpServletRequest request, String openId, String token) {
|
||||
return getFormatParam(params, request, openId, token);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getServiceSign() {
|
||||
return super.getServiceSign();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected VerifyParams getFormatParam(VerifyParams params, HttpServletRequest request, String openId, String token) {
|
||||
params.setToken(token);
|
||||
params.setAppId(app_id);
|
||||
params.setOpenId(openId);
|
||||
return params;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue