generated from root/miduo_server
101 lines
3.5 KiB
Java
101 lines
3.5 KiB
Java
package com.ljsd.controller;
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.ljsd.plat.MHTHyTestPlat;
|
|
import com.ljsd.plat.PlatProcess;
|
|
import com.ljsd.redis.RedisKey;
|
|
import com.ljsd.util.BaseGlobal;
|
|
import com.ljsd.util.HttpUtils;
|
|
import com.ljsd.util.KTSDKConstans;
|
|
import com.ljsd.util.MHTSDKConstans;
|
|
import com.mongodb.BasicDBObject;
|
|
import com.mongodb.DBObject;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
import javax.servlet.ServletException;
|
|
import javax.servlet.http.HttpServlet;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import java.io.IOException;
|
|
import java.io.PrintWriter;
|
|
import java.util.*;
|
|
|
|
public class GetUserHwController extends GetUserController {
|
|
private final static String _COLLECTION_NAME = "user_info";
|
|
private static final Logger LOGGER = LoggerFactory.getLogger(GetUserHwController.class);
|
|
public static int isTestLan=0;
|
|
|
|
public static void initLanState(){
|
|
Properties properties = BaseGlobal.getInstance().properties;
|
|
isTestLan = Integer.parseInt(properties.getProperty("isTestLan"));
|
|
}
|
|
|
|
public GetUserHwController() {
|
|
super();
|
|
}
|
|
|
|
public void destroy() {
|
|
super.destroy();
|
|
}
|
|
|
|
|
|
@Override
|
|
public boolean vertify(HttpServletResponse response, HttpServletRequest request, String admin, String platform, String pid, String openId, String token) {
|
|
try {
|
|
if(!KTSDKConstans.appsecret.equals(admin)) {
|
|
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
|
|
boolean result = false;
|
|
if(platform.equals("1")){
|
|
String sub_channel = request.getParameter("sub_channel");
|
|
if (sub_channel != null && !sub_channel.equals("")) {
|
|
PlatProcess hwios;
|
|
if (sub_channel.equals("1000")) {
|
|
hwios = BaseGlobal.getInstance().getHandlers("HWTEST");
|
|
} else {
|
|
hwios = BaseGlobal.getInstance().getHandlers("HWGP");
|
|
}
|
|
result = hwios.loginVerfify(pid, openId, token);
|
|
}
|
|
|
|
}else if(platform.equals("2")){
|
|
PlatProcess hwios = BaseGlobal.getInstance().getHandlers("HWIOS");
|
|
result = hwios.loginVerfify(pid, openId, token);
|
|
}
|
|
|
|
if (!result) {
|
|
response.sendError(400, "verify fail");
|
|
LOGGER.error("verify fail");
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}catch (Exception e){
|
|
e.printStackTrace();
|
|
}
|
|
return true;
|
|
}
|
|
|
|
|
|
public void doPost(HttpServletRequest request, HttpServletResponse response)
|
|
throws ServletException, IOException {
|
|
this.doGet(request, response);
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) {
|
|
boolean mht = new MHTHyTestPlat().loginVerfify("MHT", "31179", "ad24919ba4a748579e6adc7c1e8a1042");
|
|
System.out.println("mht = " + mht);
|
|
}
|
|
|
|
}
|