修改密码RSA

master
hwf453 2 years ago
parent b6c38729d3
commit 15f478d592

@ -985,7 +985,7 @@ public interface Api {
* @return
*/
@POST("PubFile/Data/aboutme/UpdateUserPwd.ashx")
Call<ResultBean> updataPwd(@Body RequestBody body);
Call<String> updataPwd(@Body RequestBody body);
/**

@ -505,6 +505,9 @@ public class Contans {
//厂内人员信息,每个常维队伍人数, 实时查询常维队伍人员明细
public final static String REGULAR_MAINTENANCE_STAFF = "api/real_time_data/regular_maintenance_staff";
//修改手机号或者密码
public static String UPLOAD_PHONE_OR_PWD_URL="PubFile/Data/aboutme/UpdateUserPwd.ashx";
/**
*
*/
@ -535,6 +538,7 @@ public class Contans {
//保存生产岗位考试数据(交卷)
public static String UPLOAD_PRODUCE_EXAM_URL="ZHYXB/Api/ZXKS/Save_Data.ashx";
//管理
//安防-危化品入厂申请
public static String DAGER_ENTER_APPLY_GETLIST_URL="CBS/WHP/Api/GetWHPSQList.ashx?Login_User_ID=";

@ -42,6 +42,7 @@ public class UpdatePwd {
private String manid;
private String newpwd;
private String pwded;
private String type;
public String getManid() {
@ -67,5 +68,13 @@ public class UpdatePwd {
public void setType(String type) {
this.type = type;
}
public String getPwded() {
return pwded;
}
public void setPwded(String pwded) {
this.pwded = pwded;
}
}
}

@ -1,18 +1,31 @@
package com.rehome.zhdcoa.ui.activity;
import static com.rehome.zhdcoa.utils.GsonUtils.GsonToBean;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.Toast;
import com.rehome.zhdcoa.Contans;
import com.rehome.zhdcoa.R;
import com.rehome.zhdcoa.base.BaseActivity;
import com.rehome.zhdcoa.base.BaseCallBack;
import com.rehome.zhdcoa.bean.BaseResultBean;
import com.rehome.zhdcoa.bean.ResultBean;
import com.rehome.zhdcoa.bean.UpdatePhone;
import com.rehome.zhdcoa.ui.toastview.toastviewbymyself;
import com.rehome.zhdcoa.utils.GsonUtils;
import com.rehome.zhdcoa.utils.HttpListener;
import com.rehome.zhdcoa.utils.HttpUtils;
import com.rehome.zhdcoa.utils.NohttpUtils;
import com.rehome.zhdcoa.utils.RSAUtils;
import com.rehome.zhdcoa.utils.UiUtlis;
import com.rehome.zhdcoa.weiget.AuditDialog;
import com.rehome.zhdcoa.weiget.ClearEditText;
import com.yolanda.nohttp.NoHttp;
import com.yolanda.nohttp.RequestMethod;
import com.yolanda.nohttp.rest.Request;
import java.util.ArrayList;
import java.util.List;
@ -71,13 +84,65 @@ public class ChangeMyPhoneActivity extends BaseActivity {
private void updatePhone() {
RequestBody body = RequestBody.create(MediaType.parse("application/json"), createJson());
HttpUtils.getApi().updataPwd(body).enqueue(new BaseCallBack<ResultBean>(context) {
@Override
public void onSuccess(Call<ResultBean> call, Response<ResultBean> response) {
String json = createJson();
showLog(json);
// RequestBody body = RequestBody.create(MediaType.parse("application/json"), json);
// HttpUtils.getApi().updataPwd(body).enqueue(new BaseCallBack<String>(context) {
// @Override
// public void onSuccess(Call<String> call, Response<String> response) {
//
// showLog("--------------------");
// String result = response.body();
// String jsonDecode = RSAUtils.decryptBASE64StrClient(result);
// showLog(result);
// showLog(jsonDecode);
// if (TextUtils.isEmpty(jsonDecode)) {
// showToast(UiUtlis.getString(context, R.string.data_error));
// } else {
// ResultBean bean = GsonUtils.GsonToBean(jsonDecode, ResultBean.class);
// if (bean != null) {
// if (!bean.getTotal().equals("0")) {
// if (bean.getRows().get(0).getResult().equals("1")) {
// toastviewbymyself.makeText(context, bean.getRows().get(0).getMsg(), Toast.LENGTH_LONG).show();
//
// userInfo.setTelephone(etMyphone.getText().toString());
// userInfo.setAddresstel(etZJphone.getText().toString());
//
// finish();
//
// } else {
// toastviewbymyself.makeText(context, bean.getRows().get(0).getMsg(), Toast.LENGTH_LONG).show();
// }
// }
// }
// }
// }
//
// @Override
// public void onError(Call<String> call, Throwable t) {
//
// }
// });
String url = Contans.BASE_URL + Contans.UPLOAD_PHONE_OR_PWD_URL;
Request<String> request = NoHttp.createStringRequest(url, RequestMethod.POST);
request.setDefineRequestBodyForJson(json);
NohttpUtils.getInstance().add(this, 0, "正在提交数据...", request, new HttpListener<String>() {
ResultBean bean = response.body();
@Override
public void onSucceed(int what, com.yolanda.nohttp.rest.Response<String> response) {
showLog("----------------");
String result = response.get();
String jsonDecode = RSAUtils.decryptBASE64StrClient(result);
showLog(result);
//showLog(jsonDecode);
if (TextUtils.isEmpty(jsonDecode)) {
showToast(UiUtlis.getString(context, R.string.data_error));
} else {
ResultBean bean = GsonUtils.GsonToBean(jsonDecode, ResultBean.class);
if (bean != null) {
if (!bean.getTotal().equals("0")) {
if (bean.getRows().get(0).getResult().equals("1")) {
@ -93,20 +158,18 @@ public class ChangeMyPhoneActivity extends BaseActivity {
}
}
}
}
}
@Override
public void onError(Call<ResultBean> call, Throwable t) {
public void onFailed(int what, com.yolanda.nohttp.rest.Response<String> response) {
}
});
}
private String createJson() {
UpdatePhone updatePhone = new UpdatePhone();
List<UpdatePhone.RowsBean> list = new ArrayList<>();
UpdatePhone.RowsBean phBean = new UpdatePhone.RowsBean();
@ -117,6 +180,7 @@ public class ChangeMyPhoneActivity extends BaseActivity {
list.add(phBean);
updatePhone.setRows(list);
String json = GsonUtils.GsonString(updatePhone);
return json;
String jsonEncrypt = RSAUtils.encryptBASE64Str(json);
return jsonEncrypt;
}
}

@ -209,8 +209,6 @@ class LoginActivity : BaseActivityOaToolbarViewBinding<ActivityLoginBinding>() {
NohttpUtils.getInstance().add(this, 0, request, object : HttpListener<String?> {
override fun onSucceed(what: Int, response: Response<String?>?) {
val jsonResult = response?.get()
//val jsonResult = "DkILG4j4BV1qx0wCwhxCgNvjs3Yob6hXsnfKN75UHAcL3sWRm7hOxWzonSLO74c8FMo+DeaIkSD8w+rNFD6Wg1pU3YqbvKhTYOFc73JPsKxO6YF44M6GWQVABb6mYhxYqZDms6cKdvnYdt7P4CT2p4EncXWXfP5f87M2SF9ZFIirr7S3++OrFSSa04x/C5POuCQNyn28HDHZzDaQ7w1kN4Y2EWPok48i09aKcgSic/1ZLTOvAPo0IoF6ahfNh/lRxtnp5HWcpR6+SdxHPnrKkw26t416RKDAxtQB3EHFHJwzA9ZYXFCg9ADrDSDukMudRpFHquf7JbC1vaMSQWxBzg=="
// showLog("-----login------")
// showLog(jsonResult)

@ -3,8 +3,10 @@ package com.rehome.zhdcoa.ui.activity;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.util.Log;
import android.view.View;
import android.widget.Toast;
import com.rehome.zhdcoa.Contans;
import com.rehome.zhdcoa.R;
import com.rehome.zhdcoa.base.BaseActivity;
@ -13,11 +15,18 @@ import com.rehome.zhdcoa.bean.ResultBean;
import com.rehome.zhdcoa.bean.UpdatePwd;
import com.rehome.zhdcoa.ui.toastview.toastviewbymyself;
import com.rehome.zhdcoa.utils.GsonUtils;
import com.rehome.zhdcoa.utils.HttpListener;
import com.rehome.zhdcoa.utils.HttpUtils;
import com.rehome.zhdcoa.utils.NohttpUtils;
import com.rehome.zhdcoa.utils.RSAUtils;
import com.rehome.zhdcoa.utils.SPUtils;
import com.rehome.zhdcoa.utils.UiUtlis;
import com.rehome.zhdcoa.weiget.AuditDialog;
import com.rehome.zhdcoa.weiget.ClearEditText;
import com.yolanda.nohttp.NoHttp;
import com.yolanda.nohttp.RequestMethod;
import com.yolanda.nohttp.rest.Request;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
@ -50,7 +59,9 @@ public class UpdatePwdActivity extends BaseActivity {
public void initView() {
findView();
etFormerPwd.setText("Rehome.zhps@996");
// etFormerPwd.setText("Rehome.zhps@2020");
// etNewPwd.setText("Rehome.zhps@996");
// etNewPwdSure.setText("Rehome.zhps@996");
initToolbar("修改密码", "修改", new View.OnClickListener() {
@Override
@ -107,16 +118,66 @@ public class UpdatePwdActivity extends BaseActivity {
private void updatePwd() {
String json = createJson();
showLog(json);
RequestBody body = RequestBody.create(MediaType.parse("application/json"),json);
HttpUtils.getApi().updataPwd(body).enqueue(new BaseCallBack<ResultBean>(context) {
@Override
public void onSuccess(Call<ResultBean> call, Response<ResultBean> response) {
// RequestBody body = RequestBody.create(MediaType.parse("application/json"), json);
// HttpUtils.getApi().updataPwd(body).enqueue(new BaseCallBack<String>(context) {
// @Override
// public void onSuccess(Call<String> call, Response<String> response) {
//
// showLog("--------------------");
// String result = response.body();
// String jsonDecode = RSAUtils.decryptBASE64StrClient(result);
// showLog(result);
// showLog(jsonDecode);
// if (TextUtils.isEmpty(jsonDecode)) {
// showToast(UiUtlis.getString(context, R.string.data_error));
// } else {
// ResultBean bean = GsonUtils.GsonToBean(jsonDecode, ResultBean.class);
// if (bean != null) {
// if (!bean.getTotal().equals("0")) {
// if (bean.getRows().get(0).getResult().equals("1")) {
// toastviewbymyself.makeText(context, bean.getRows().get(0).getMsg(), Toast.LENGTH_LONG).show();
// SPUtils.put(context, Contans.SP.PASS_WORD, RSAUtils.encryptBASE64StrLocal(Objects.requireNonNull(etNewPwd.getText()).toString()));
// SPUtils.put(context, Contans.SP.OLD_PWD, RSAUtils.encryptBASE64StrLocal(Objects.requireNonNull(etNewPwd.getText()).toString()));
// SPUtils.put(
// context,
// Contans.SP.AF_PASS_WORD,
// RSAUtils.encryptBASE64StrLocal(Objects.requireNonNull(etNewPwd.getText()).toString())
// );
// finish();
// } else {
// toastviewbymyself.makeText(context, bean.getRows().get(0).getMsg(), Toast.LENGTH_LONG).show();
// }
// }
// }
// }
// }
//
// @Override
// public void onError(Call<String> call, Throwable t) {
//
// }
// });
String url = Contans.BASE_URL + Contans.UPLOAD_PHONE_OR_PWD_URL;
Request<String> request = NoHttp.createStringRequest(url, RequestMethod.POST);
request.setDefineRequestBodyForJson(json);
NohttpUtils.getInstance().add(this, 0, "正在提交数据...", request, new HttpListener<String>() {
ResultBean bean = response.body();
@Override
public void onSucceed(int what, com.yolanda.nohttp.rest.Response<String> response) {
showLog("----------------");
String result = response.get();
String jsonDecode = RSAUtils.decryptBASE64StrClient(result);
showLog(result);
// showLog(jsonDecode);
if (TextUtils.isEmpty(jsonDecode)) {
showToast(UiUtlis.getString(context, R.string.data_error));
} else {
ResultBean bean = GsonUtils.GsonToBean(jsonDecode, ResultBean.class);
if (bean != null) {
if (!bean.getTotal().equals("0")) {
if (bean.getRows().get(0).getResult().equals("1")) {
@ -134,11 +195,11 @@ public class UpdatePwdActivity extends BaseActivity {
}
}
}
}
}
@Override
public void onError(Call<ResultBean> call, Throwable t) {
public void onFailed(int what, com.yolanda.nohttp.rest.Response<String> response) {
}
});
@ -147,17 +208,18 @@ public class UpdatePwdActivity extends BaseActivity {
}
private String createJson() {
UpdatePwd updatePwd = new UpdatePwd();
List<UpdatePwd.RowsBean> list = new ArrayList<>();
UpdatePwd.RowsBean rowsBean = new UpdatePwd.RowsBean();
rowsBean.setManid(userInfo.getManid());
rowsBean.setNewpwd(etNewPwd.getText().toString());
rowsBean.setPwded(etFormerPwd.getText().toString());
rowsBean.setType("0");
list.add(rowsBean);
updatePwd.setRows(list);
String json = GsonUtils.GsonString(updatePwd);
return json;
String jsonEncrypt = RSAUtils.encryptBASE64Str(json);
return jsonEncrypt;
}
private boolean validaData() {
@ -188,7 +250,7 @@ public class UpdatePwdActivity extends BaseActivity {
}
if (!newPwd.equals(newPwdSure)) {
toastviewbymyself.makeText(context,"两次密码不一致", Toast.LENGTH_LONG).show();
toastviewbymyself.makeText(context, "两次密码不一致", Toast.LENGTH_LONG).show();
return false;
}

@ -76,7 +76,9 @@ public class YXCZCWInfoActivity extends BaseActivity {
}
public void GetData() {
RequestBody body = RequestBody.create(MediaType.parse("application/json"), GetJson());
String json = GetJson();
showLog(json);
RequestBody body = RequestBody.create(MediaType.parse("application/json"),json);
HttpUtils.getYXApi().Getczcwhisdatas(body).enqueue(new BaseCallBack<YxczcwindohisBean>(context) {
@Override
public void onSuccess(Call<YxczcwindohisBean> call, Response<YxczcwindohisBean> response) {

@ -121,12 +121,15 @@ public class HttpUtils {
@NonNull
@Override
public Response intercept(@NonNull Chain chain) throws IOException {
Request originalRequest = chain.request();
if(App.getInstance().getUserInfo()!=null&&App.getInstance().getUserInfo().getToken()!=null){
String token = App.getInstance().getUserInfo().getToken();
String credential = "Bearer " + token;
Request originalRequest = chain.request();
Request updateRequest = originalRequest.newBuilder().header("Authorization", credential).build();
return chain.proceed(updateRequest);
}
return chain.proceed(originalRequest);
}
}
public static class TokenHeaderInterceptorAuthenticator implements Interceptor {

Loading…
Cancel
Save