设备预警信息 登录接口加密

master
wenfei 4 days ago
parent 5c38dcb029
commit 16d47cc936

@ -529,7 +529,7 @@ public class Contans {
//设备状态智能监测及分析平台 登录
public final static String DeviceAlermInfoLoginUrl = "dserver/user/login";
public final static String DeviceAlermInfoLoginRsaUrl = "dserver/user/loginRsaUpAndDown";
public final static String DeviceAlermInfoLoginRsaUrl = "dserver/user/loginRsaUpAndDownRsa";
//设备预警信息列表
//http://192.168.2.28:1700/dserver/warning/page?v=1765422183414&keyword=&pageNo=1&pageSize=10
public final static String DeviceAlermInfoListUrl = "dserver/warning/page";

@ -6,6 +6,7 @@ import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.text.TextUtils;
import android.util.Log;
import com.rehome.zhdcoa.Contans;
import com.rehome.zhdcoa.bean.DeviceAlarmLoginResultBean;
import com.rehome.zhdcoa.bean.DeviceAlarmLoginResultDataBean;
@ -14,9 +15,12 @@ import com.yolanda.nohttp.NoHttp;
import com.yolanda.nohttp.RequestMethod;
import com.yolanda.nohttp.rest.Request;
import com.yolanda.nohttp.rest.Response;
import static com.rehome.zhdcoa.utils.GsonUtils.GsonToBean;
import java.util.HashMap;
import java.util.Map;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLSession;
import javax.net.ssl.SSLSocketFactory;
@ -40,7 +44,7 @@ public class AuthenticationLoginAIUtils {
params.put("password", password);
String json = GsonUtils.GsonString(params);
showLog(json,mActivity);
showLog(json, mActivity);
String jsonEncrypt = RSAUtils.encryptBASE64Str(json);
//showLog(jsonEncrypt);
request.setDefineRequestBodyForJson(jsonEncrypt);
@ -63,17 +67,17 @@ public class AuthenticationLoginAIUtils {
@Override
public void onSucceed(int what, Response<String> response) {
showLog("----------------",mActivity);
showLog("----------------", mActivity);
String result = response.get();
showLog(result,mActivity);
showLog(result, mActivity);
String jsonDecode = RSAUtils.decryptBASE64StrClient(result);
if (TextUtils.isEmpty(jsonDecode)) {
//解密失败
showLog("APP解密失败",mActivity);
showLog("APP解密失败", mActivity);
listener.onAuthenticationSuccess(false, "");
} else {
showLog(jsonDecode,mActivity);
showLog(jsonDecode, mActivity);
UserAuthenticationAIBean bean = GsonToBean(jsonDecode, UserAuthenticationAIBean.class);
if (bean != null) {
if (bean.isSuccess()) {//登录成功
@ -88,19 +92,19 @@ public class AuthenticationLoginAIUtils {
} else {
listener.onAuthenticationSuccess(false, "");
if (bean.getFlag() == -2) {
showLog("没有传参",mActivity);
showLog("没有传参", mActivity);
}
if (bean.getFlag() == -3) {
showLog("服务器解密失败",mActivity);
showLog("服务器解密失败", mActivity);
}
if (bean.getFlag() == -4) {
showLog("Json 格式不正确",mActivity);
showLog("Json 格式不正确", mActivity);
}
if (bean.getFlag() == -5) {
showLog("账号密码不能为空",mActivity);
showLog("账号密码不能为空", mActivity);
}
if (bean.getFlag() == -6) {
showLog("账号或密码错误",mActivity);
showLog("账号或密码错误", mActivity);
}
}
}
@ -136,7 +140,7 @@ public class AuthenticationLoginAIUtils {
@Override
public void onFailed(int what, Response<String> response) {
showLog("onFailed",mActivity);
showLog("onFailed", mActivity);
listener.onAuthenticationSuccess(false, "");
}
});
@ -177,17 +181,17 @@ public class AuthenticationLoginAIUtils {
@Override
public void onSucceed(int what, Response<String> response) {
showLog("----------------",mActivity);
showLog("----------------", mActivity);
String result = response.get();
showLog(result,mActivity);
showLog(result, mActivity);
String jsonDecode = RSAUtils.decryptBASE64StrClient(result);
if (TextUtils.isEmpty(jsonDecode)) {
//解密失败
showLog("APP解密失败",mActivity);
showLog("APP解密失败", mActivity);
listener.onAuthenticationSuccess(false, "");
} else {
showLog(jsonDecode,mActivity);
showLog(jsonDecode, mActivity);
UserAuthenticationAIBean bean = GsonToBean(jsonDecode, UserAuthenticationAIBean.class);
if (bean != null) {
if (bean.isSuccess()) {//登录成功
@ -202,19 +206,19 @@ public class AuthenticationLoginAIUtils {
} else {
listener.onAuthenticationSuccess(false, "");
if (bean.getFlag() == -2) {
showLog("没有传参",mActivity);
showLog("没有传参", mActivity);
}
if (bean.getFlag() == -3) {
showLog("服务器解密失败",mActivity);
showLog("服务器解密失败", mActivity);
}
if (bean.getFlag() == -4) {
showLog("Json 格式不正确",mActivity);
showLog("Json 格式不正确", mActivity);
}
if (bean.getFlag() == -5) {
showLog("账号密码不能为空",mActivity);
showLog("账号密码不能为空", mActivity);
}
if (bean.getFlag() == -6) {
showLog("账号或密码错误",mActivity);
showLog("账号或密码错误", mActivity);
}
}
}
@ -250,7 +254,7 @@ public class AuthenticationLoginAIUtils {
@Override
public void onFailed(int what, Response<String> response) {
showLog("onFailed",mActivity);
showLog("onFailed", mActivity);
listener.onAuthenticationSuccess(false, "");
}
});
@ -291,14 +295,14 @@ public class AuthenticationLoginAIUtils {
@Override
public void onSucceed(int what, Response<String> response) {
showLog("----------------",mActivity);
showLog("----------------", mActivity);
String result = response.get();
showLog(result,mActivity);
showLog(result, mActivity);
if(!TextUtils.isEmpty(result)){
if (!TextUtils.isEmpty(result)) {
UserAuthenticationAIBean bean = GsonToBean(result, UserAuthenticationAIBean.class);
if (bean != null) {
if (bean.isSuccess()&&bean.getCode()==20000) {//登录成功
if (bean.isSuccess() && bean.getCode() == 20000) {//登录成功
SPUtils.put(mActivity, Contans.AUTHENTICATIONLOGINTOKENAI, bean.getData().getToken());
listener.onAuthenticationSuccess(true, bean.getData().getToken());
} else {
@ -310,19 +314,19 @@ public class AuthenticationLoginAIUtils {
} else {
listener.onAuthenticationSuccess(false, "");
if (bean.getFlag() == -2) {
showLog("没有传参",mActivity);
showLog("没有传参", mActivity);
}
if (bean.getFlag() == -3) {
showLog("服务器解密失败",mActivity);
showLog("服务器解密失败", mActivity);
}
if (bean.getFlag() == -4) {
showLog("Json 格式不正确",mActivity);
showLog("Json 格式不正确", mActivity);
}
if (bean.getFlag() == -5) {
showLog("账号密码不能为空",mActivity);
showLog("账号密码不能为空", mActivity);
}
if (bean.getFlag() == -6) {
showLog("账号或密码错误",mActivity);
showLog("账号或密码错误", mActivity);
}
}
}
@ -332,7 +336,7 @@ public class AuthenticationLoginAIUtils {
@Override
public void onFailed(int what, Response<String> response) {
showLog("onFailed",mActivity);
showLog("onFailed", mActivity);
listener.onAuthenticationSuccess(false, "");
}
});
@ -349,7 +353,7 @@ public class AuthenticationLoginAIUtils {
String json = GsonUtils.GsonString(params);
//showLog(json,mActivity);
String jsonEncrypt = RSAUtils.encryptBASE64Str(json);
showLog(jsonEncrypt,mActivity);
showLog(jsonEncrypt, mActivity);
request.setDefineRequestBodyForJson(jsonEncrypt);
if (Contans.IP.equals(Contans.IP_EXTRANET)) {
@ -370,31 +374,23 @@ public class AuthenticationLoginAIUtils {
@Override
public void onSucceed(int what, Response<String> response) {
showLog("----------------",mActivity);
showLog("----------------", mActivity);
String result = response.get();
showLog(result,mActivity);
showLog(result, mActivity);
if(!TextUtils.isEmpty(result)){
DeviceAlarmLoginResultBean bean = GsonToBean(result, DeviceAlarmLoginResultBean.class);
if (bean != null) {
if (bean.isSuccess()&&bean.getCode()==20000) {//登录成功
if(!TextUtils.isEmpty(bean.getData())){
String jsonDecode = RSAUtils.decryptBASE64StrClient(bean.getData());
if (!TextUtils.isEmpty(result)) {
String jsonDecode = RSAUtils.decryptBASE64StrClient(result);
if (TextUtils.isEmpty(jsonDecode)) {
//解密失败
showLog("APP解密失败",mActivity);
showLog("APP解密失败", mActivity);
listener.onAuthenticationSuccess(false, "");
} else {
//showLog(jsonDecode,mActivity);
DeviceAlarmLoginResultDataBean beanDecode = GsonToBean(jsonDecode, DeviceAlarmLoginResultDataBean.class);
if(beanDecode!=null&&beanDecode.getMsg()!=null&&"登录成功".equals(beanDecode.getMsg())){
listener.onAuthenticationSuccess(true, beanDecode.getToken());
}else{
showLog("账号或密码错误",mActivity);
listener.onAuthenticationSuccess(false, "");
}
}
}
showLog(jsonDecode, mActivity);
UserAuthenticationAIBean bean = GsonToBean(jsonDecode, UserAuthenticationAIBean.class);
//DeviceAlarmLoginResultBean bean = GsonToBean(result, DeviceAlarmLoginResultBean.class);
if (bean != null) {
if (bean.isSuccess() && bean.getCode() == 20000) {//登录成功
listener.onAuthenticationSuccess(true, bean.getData().getToken());
} else {
if (bean.getFlag() == -1) {
if (bean.getMsg() != null && bean.getMsg().equals("用户未注销")) {
@ -404,19 +400,20 @@ public class AuthenticationLoginAIUtils {
} else {
listener.onAuthenticationSuccess(false, "");
if (bean.getFlag() == -2) {
showLog("没有传参",mActivity);
showLog("没有传参", mActivity);
}
if (bean.getFlag() == -3) {
showLog("服务器解密失败",mActivity);
showLog("服务器解密失败", mActivity);
}
if (bean.getFlag() == -4) {
showLog("Json 格式不正确",mActivity);
showLog("Json 格式不正确", mActivity);
}
if (bean.getFlag() == -5) {
showLog("账号密码不能为空",mActivity);
showLog("账号密码不能为空", mActivity);
}
if (bean.getFlag() == -6) {
showLog("账号或密码错误",mActivity);
showLog("账号或密码错误", mActivity);
}
}
}
}
@ -426,14 +423,14 @@ public class AuthenticationLoginAIUtils {
@Override
public void onFailed(int what, Response<String> response) {
showLog("onFailed",mActivity);
showLog("onFailed", mActivity);
listener.onAuthenticationSuccess(false, "");
}
});
}
public static void showLog(String logText,Context context) {
public static void showLog(String logText, Context context) {
if (isApkInDebug(context)) {
if (TextUtils.isEmpty(logText)) {
Log.i("app", "logText is null");

Loading…
Cancel
Save