|
|
|
@ -262,6 +262,85 @@ public class AuthenticationLoginAIUtils {
|
|
|
|
params.put("username", account);
|
|
|
|
params.put("username", account);
|
|
|
|
params.put("password", password);
|
|
|
|
params.put("password", password);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String json = GsonUtils.GsonString(params);
|
|
|
|
|
|
|
|
//showLog(json);
|
|
|
|
|
|
|
|
//String jsonEncrypt = RSAUtils.encryptBASE64Str(json);
|
|
|
|
|
|
|
|
//showLog(jsonEncrypt);
|
|
|
|
|
|
|
|
request.setDefineRequestBodyForJson(json);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (Contans.IP.equals(Contans.IP_EXTRANET)) {
|
|
|
|
|
|
|
|
SSLSocketFactory socketFactory = NohttpUtils.getSSLSocketFactory(mActivity);
|
|
|
|
|
|
|
|
if (socketFactory != null) {
|
|
|
|
|
|
|
|
request.setSSLSocketFactory(socketFactory);
|
|
|
|
|
|
|
|
request.setHostnameVerifier(new HostnameVerifier() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public boolean verify(String s, SSLSession sslSession) {
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NohttpUtils.getInstance().add(mActivity, 0, request, new HttpListener<String>() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void onSucceed(int what, Response<String> response) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
showLog("----------------",mActivity);
|
|
|
|
|
|
|
|
String result = response.get();
|
|
|
|
|
|
|
|
showLog(result,mActivity);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(!TextUtils.isEmpty(result)){
|
|
|
|
|
|
|
|
UserAuthenticationAIBean bean = GsonToBean(result, UserAuthenticationAIBean.class);
|
|
|
|
|
|
|
|
if (bean != null) {
|
|
|
|
|
|
|
|
if (bean.isSuccess()&&bean.getCode()==20000) {//登录成功
|
|
|
|
|
|
|
|
SPUtils.put(mActivity, Contans.AUTHENTICATIONLOGINTOKENAI, bean.getData().getToken());
|
|
|
|
|
|
|
|
listener.onAuthenticationSuccess(true, bean.getData().getToken());
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
if (bean.getFlag() == -1) {
|
|
|
|
|
|
|
|
if (bean.getMsg() != null && bean.getMsg().equals("用户未注销")) {
|
|
|
|
|
|
|
|
String token = (String) SPUtils.get(mActivity, Contans.AUTHENTICATIONLOGINTOKENAI, String.valueOf(""));
|
|
|
|
|
|
|
|
listener.onAuthenticationSuccess(true, token);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
listener.onAuthenticationSuccess(false, "");
|
|
|
|
|
|
|
|
if (bean.getFlag() == -2) {
|
|
|
|
|
|
|
|
showLog("没有传参",mActivity);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bean.getFlag() == -3) {
|
|
|
|
|
|
|
|
showLog("服务器解密失败",mActivity);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bean.getFlag() == -4) {
|
|
|
|
|
|
|
|
showLog("Json 格式不正确",mActivity);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bean.getFlag() == -5) {
|
|
|
|
|
|
|
|
showLog("账号密码不能为空",mActivity);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bean.getFlag() == -6) {
|
|
|
|
|
|
|
|
showLog("账号或密码错误",mActivity);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void onFailed(int what, Response<String> response) {
|
|
|
|
|
|
|
|
showLog("onFailed",mActivity);
|
|
|
|
|
|
|
|
listener.onAuthenticationSuccess(false, "");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static void authenticationDeviceAlermInfoRsaShowProgress(Activity mActivity, String account, String password, OnAuthenticationLoginListener listener) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Request<String> request = NoHttp.createStringRequest(Contans.IP + Contans.DeviceAlermInfoLoginUrl, RequestMethod.POST);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Map<String, String> params = new HashMap<>();
|
|
|
|
|
|
|
|
params.put("username", account);
|
|
|
|
|
|
|
|
params.put("password", password);
|
|
|
|
|
|
|
|
|
|
|
|
String json = GsonUtils.GsonString(params);
|
|
|
|
String json = GsonUtils.GsonString(params);
|
|
|
|
//showLog(json);
|
|
|
|
//showLog(json);
|
|
|
|
String jsonEncrypt = RSAUtils.encryptBASE64Str(json);
|
|
|
|
String jsonEncrypt = RSAUtils.encryptBASE64Str(json);
|
|
|
|
|