|
|
|
@ -7,6 +7,8 @@ import android.content.pm.ApplicationInfo;
|
|
|
|
import android.text.TextUtils;
|
|
|
|
import android.text.TextUtils;
|
|
|
|
import android.util.Log;
|
|
|
|
import android.util.Log;
|
|
|
|
import com.rehome.zhdcoa.Contans;
|
|
|
|
import com.rehome.zhdcoa.Contans;
|
|
|
|
|
|
|
|
import com.rehome.zhdcoa.bean.DeviceAlarmLoginResultBean;
|
|
|
|
|
|
|
|
import com.rehome.zhdcoa.bean.DeviceAlarmLoginResultDataBean;
|
|
|
|
import com.rehome.zhdcoa.bean.UserAuthenticationAIBean;
|
|
|
|
import com.rehome.zhdcoa.bean.UserAuthenticationAIBean;
|
|
|
|
import com.yolanda.nohttp.NoHttp;
|
|
|
|
import com.yolanda.nohttp.NoHttp;
|
|
|
|
import com.yolanda.nohttp.RequestMethod;
|
|
|
|
import com.yolanda.nohttp.RequestMethod;
|
|
|
|
@ -338,16 +340,16 @@ public class AuthenticationLoginAIUtils {
|
|
|
|
|
|
|
|
|
|
|
|
public static void authenticationDeviceAlermInfoRsaShowProgress(Activity mActivity, String account, String password, OnAuthenticationLoginListener listener) {
|
|
|
|
public static void authenticationDeviceAlermInfoRsaShowProgress(Activity mActivity, String account, String password, OnAuthenticationLoginListener listener) {
|
|
|
|
|
|
|
|
|
|
|
|
Request<String> request = NoHttp.createStringRequest(Contans.IP + Contans.DeviceAlermInfoLoginUrl, RequestMethod.POST);
|
|
|
|
Request<String> request = NoHttp.createStringRequest(Contans.IP + Contans.DeviceAlermInfoLoginRsaUrl, RequestMethod.POST);
|
|
|
|
|
|
|
|
|
|
|
|
Map<String, String> params = new HashMap<>();
|
|
|
|
Map<String, String> params = new HashMap<>();
|
|
|
|
params.put("username", account);
|
|
|
|
params.put("username", account);
|
|
|
|
params.put("password", password);
|
|
|
|
params.put("password", password);
|
|
|
|
|
|
|
|
|
|
|
|
String json = GsonUtils.GsonString(params);
|
|
|
|
String json = GsonUtils.GsonString(params);
|
|
|
|
//showLog(json);
|
|
|
|
//showLog(json,mActivity);
|
|
|
|
String jsonEncrypt = RSAUtils.encryptBASE64Str(json);
|
|
|
|
String jsonEncrypt = RSAUtils.encryptBASE64Str(json);
|
|
|
|
//showLog(jsonEncrypt);
|
|
|
|
showLog(jsonEncrypt,mActivity);
|
|
|
|
request.setDefineRequestBodyForJson(jsonEncrypt);
|
|
|
|
request.setDefineRequestBodyForJson(jsonEncrypt);
|
|
|
|
|
|
|
|
|
|
|
|
if (Contans.IP.equals(Contans.IP_EXTRANET)) {
|
|
|
|
if (Contans.IP.equals(Contans.IP_EXTRANET)) {
|
|
|
|
@ -373,11 +375,26 @@ public class AuthenticationLoginAIUtils {
|
|
|
|
showLog(result,mActivity);
|
|
|
|
showLog(result,mActivity);
|
|
|
|
|
|
|
|
|
|
|
|
if(!TextUtils.isEmpty(result)){
|
|
|
|
if(!TextUtils.isEmpty(result)){
|
|
|
|
UserAuthenticationAIBean bean = GsonToBean(result, UserAuthenticationAIBean.class);
|
|
|
|
DeviceAlarmLoginResultBean bean = GsonToBean(result, DeviceAlarmLoginResultBean.class);
|
|
|
|
if (bean != null) {
|
|
|
|
if (bean != null) {
|
|
|
|
if (bean.isSuccess()&&bean.getCode()==20000) {//登录成功
|
|
|
|
if (bean.isSuccess()&&bean.getCode()==20000) {//登录成功
|
|
|
|
SPUtils.put(mActivity, Contans.AUTHENTICATIONLOGINTOKENAI, bean.getData().getToken());
|
|
|
|
if(!TextUtils.isEmpty(bean.getData())){
|
|
|
|
listener.onAuthenticationSuccess(true, bean.getData().getToken());
|
|
|
|
String jsonDecode = RSAUtils.decryptBASE64StrClient(bean.getData());
|
|
|
|
|
|
|
|
if (TextUtils.isEmpty(jsonDecode)) {
|
|
|
|
|
|
|
|
//解密失败
|
|
|
|
|
|
|
|
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, "");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
if (bean.getFlag() == -1) {
|
|
|
|
if (bean.getFlag() == -1) {
|
|
|
|
if (bean.getMsg() != null && bean.getMsg().equals("用户未注销")) {
|
|
|
|
if (bean.getMsg() != null && bean.getMsg().equals("用户未注销")) {
|
|
|
|
|