generated from root/miduo_server
登录sdk
parent
2881b838d1
commit
a02f9b950f
|
|
@ -1,7 +1,6 @@
|
||||||
package com.ljsd.controller;
|
package com.ljsd.controller;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.ljsd.pojo.SuJieAccount;
|
|
||||||
import com.ljsd.redis.RedisKey;
|
import com.ljsd.redis.RedisKey;
|
||||||
import com.ljsd.util.BaseGlobal;
|
import com.ljsd.util.BaseGlobal;
|
||||||
import com.ljsd.util.EncryptUtils;
|
import com.ljsd.util.EncryptUtils;
|
||||||
|
|
@ -56,8 +55,8 @@ public class GetUserController extends HttpServlet {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(!"3".equals(platform)){
|
if(!"3".equals(platform)){
|
||||||
SuJieAccount suJieAccount = loginVerfify(platform, openId, token);
|
boolean result = loginVerfify(platform, openId, token);
|
||||||
if(suJieAccount == null){
|
if(!result){
|
||||||
response.sendError(400, "verify fail");
|
response.sendError(400, "verify fail");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -99,7 +98,7 @@ public class GetUserController extends HttpServlet {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static SuJieAccount loginVerfify(String platForm,String openId,String token){
|
public static boolean loginVerfify(String platForm,String openId,String token){
|
||||||
try{
|
try{
|
||||||
String loginUrl = "";
|
String loginUrl = "";
|
||||||
if("1".equals(platForm)){
|
if("1".equals(platForm)){
|
||||||
|
|
@ -108,40 +107,38 @@ public class GetUserController extends HttpServlet {
|
||||||
loginUrl = KTSDKConstans.iosVerify;
|
loginUrl = KTSDKConstans.iosVerify;
|
||||||
}
|
}
|
||||||
Map<String, String> params = new HashMap<String, String>();
|
Map<String, String> params = new HashMap<String, String>();
|
||||||
params.put("userID", openId);
|
params.put("userid", openId);
|
||||||
params.put("token", token);
|
params.put("token", token);
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.append("userID=").append(openId)
|
sb.append("userid=").append(openId)
|
||||||
.append("token=").append(token)
|
.append("token=").append(token).append(KTSDKConstans.appid).append(KTSDKConstans.appkey);
|
||||||
.append(KTSDKConstans.appid);
|
|
||||||
|
|
||||||
String sign = EncryptUtils.createMD5String(sb.toString());
|
String sign = EncryptUtils.createMD5String(sb.toString());
|
||||||
params.put("sign", sign);
|
params.put("sign", sign);
|
||||||
|
params.put("appid", KTSDKConstans.appid);
|
||||||
String loginResult = HttpUtils.doPost(loginUrl,params);
|
String loginResult = HttpUtils.doPost(loginUrl,params);
|
||||||
if(loginResult == null || loginResult.isEmpty()){
|
if(loginResult == null || loginResult.isEmpty()){
|
||||||
return null;
|
return false;
|
||||||
}
|
}
|
||||||
return parseLoginResult(loginResult);
|
return parseLoginResult(loginResult);
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
return null;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static SuJieAccount parseLoginResult(String orderResult){
|
private static boolean parseLoginResult(String orderResult){
|
||||||
try {
|
try {
|
||||||
SuJieAccount suJieAccount = (SuJieAccount)JSONObject.parse(orderResult);
|
JSONObject jsonObject = JSONObject.parseObject(orderResult);
|
||||||
int state = suJieAccount.getState();
|
int state = jsonObject.getIntValue("state");
|
||||||
if(state != 0){
|
if(state != 1){
|
||||||
return null;
|
return false;
|
||||||
}
|
}
|
||||||
return suJieAccount;
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,33 +0,0 @@
|
||||||
package com.ljsd.pojo;
|
|
||||||
|
|
||||||
public class SuJieAccount {
|
|
||||||
private String accountID;
|
|
||||||
private String accountName;
|
|
||||||
private int state;
|
|
||||||
|
|
||||||
public SuJieAccount() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public SuJieAccount(String accountID, String accountName){
|
|
||||||
this.accountID = accountID;
|
|
||||||
this.accountName = accountName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getState() {
|
|
||||||
return state;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getAccountID() {
|
|
||||||
return accountID;
|
|
||||||
}
|
|
||||||
public void setAccountID(String accountID) {
|
|
||||||
this.accountID = accountID;
|
|
||||||
}
|
|
||||||
public String getAccountName() {
|
|
||||||
return accountName;
|
|
||||||
}
|
|
||||||
public void setAccountName(String accountName) {
|
|
||||||
this.accountName = accountName;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue