修改密码RSA

master
hwf453 2 years ago
parent b6c38729d3
commit 15f478d592

@ -985,7 +985,7 @@ public interface Api {
* @return * @return
*/ */
@POST("PubFile/Data/aboutme/UpdateUserPwd.ashx") @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 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 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="; 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 manid;
private String newpwd; private String newpwd;
private String pwded;
private String type; private String type;
public String getManid() { public String getManid() {
@ -67,5 +68,13 @@ public class UpdatePwd {
public void setType(String type) { public void setType(String type) {
this.type = 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; 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.view.View;
import android.widget.Toast; import android.widget.Toast;
import com.rehome.zhdcoa.Contans;
import com.rehome.zhdcoa.R; import com.rehome.zhdcoa.R;
import com.rehome.zhdcoa.base.BaseActivity; import com.rehome.zhdcoa.base.BaseActivity;
import com.rehome.zhdcoa.base.BaseCallBack; import com.rehome.zhdcoa.base.BaseCallBack;
import com.rehome.zhdcoa.bean.BaseResultBean;
import com.rehome.zhdcoa.bean.ResultBean; import com.rehome.zhdcoa.bean.ResultBean;
import com.rehome.zhdcoa.bean.UpdatePhone; import com.rehome.zhdcoa.bean.UpdatePhone;
import com.rehome.zhdcoa.ui.toastview.toastviewbymyself; import com.rehome.zhdcoa.ui.toastview.toastviewbymyself;
import com.rehome.zhdcoa.utils.GsonUtils; import com.rehome.zhdcoa.utils.GsonUtils;
import com.rehome.zhdcoa.utils.HttpListener;
import com.rehome.zhdcoa.utils.HttpUtils; 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.AuditDialog;
import com.rehome.zhdcoa.weiget.ClearEditText; 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.ArrayList;
import java.util.List; import java.util.List;
@ -71,42 +84,92 @@ public class ChangeMyPhoneActivity extends BaseActivity {
private void updatePhone() { private void updatePhone() {
RequestBody body = RequestBody.create(MediaType.parse("application/json"), createJson()); String json = createJson();
HttpUtils.getApi().updataPwd(body).enqueue(new BaseCallBack<ResultBean>(context) { showLog(json);
@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
ResultBean bean = response.body(); // public void onSuccess(Call<String> call, Response<String> response) {
if (bean != null) { //
if (!bean.getTotal().equals("0")) { // showLog("--------------------");
if (bean.getRows().get(0).getResult().equals("1")) { // String result = response.body();
toastviewbymyself.makeText(context, bean.getRows().get(0).getMsg(), Toast.LENGTH_LONG).show(); // String jsonDecode = RSAUtils.decryptBASE64StrClient(result);
// showLog(result);
userInfo.setTelephone(etMyphone.getText().toString()); // showLog(jsonDecode);
userInfo.setAddresstel(etZJphone.getText().toString()); // 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>() {
finish(); @Override
public void onSucceed(int what, com.yolanda.nohttp.rest.Response<String> response) {
} else {
toastviewbymyself.makeText(context, bean.getRows().get(0).getMsg(), Toast.LENGTH_LONG).show(); 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")) {
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 @Override
public void onError(Call<ResultBean> call, Throwable t) { public void onFailed(int what, com.yolanda.nohttp.rest.Response<String> response) {
} }
}); });
} }
private String createJson() { private String createJson() {
UpdatePhone updatePhone = new UpdatePhone(); UpdatePhone updatePhone = new UpdatePhone();
List<UpdatePhone.RowsBean> list = new ArrayList<>(); List<UpdatePhone.RowsBean> list = new ArrayList<>();
UpdatePhone.RowsBean phBean = new UpdatePhone.RowsBean(); UpdatePhone.RowsBean phBean = new UpdatePhone.RowsBean();
@ -117,6 +180,7 @@ public class ChangeMyPhoneActivity extends BaseActivity {
list.add(phBean); list.add(phBean);
updatePhone.setRows(list); updatePhone.setRows(list);
String json = GsonUtils.GsonString(updatePhone); 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?> { NohttpUtils.getInstance().add(this, 0, request, object : HttpListener<String?> {
override fun onSucceed(what: Int, response: Response<String?>?) { override fun onSucceed(what: Int, response: Response<String?>?) {
val jsonResult = response?.get() val jsonResult = response?.get()
//val jsonResult = "DkILG4j4BV1qx0wCwhxCgNvjs3Yob6hXsnfKN75UHAcL3sWRm7hOxWzonSLO74c8FMo+DeaIkSD8w+rNFD6Wg1pU3YqbvKhTYOFc73JPsKxO6YF44M6GWQVABb6mYhxYqZDms6cKdvnYdt7P4CT2p4EncXWXfP5f87M2SF9ZFIirr7S3++OrFSSa04x/C5POuCQNyn28HDHZzDaQ7w1kN4Y2EWPok48i09aKcgSic/1ZLTOvAPo0IoF6ahfNh/lRxtnp5HWcpR6+SdxHPnrKkw26t416RKDAxtQB3EHFHJwzA9ZYXFCg9ADrDSDukMudRpFHquf7JbC1vaMSQWxBzg=="
// showLog("-----login------") // showLog("-----login------")
// showLog(jsonResult) // showLog(jsonResult)

@ -3,8 +3,10 @@ package com.rehome.zhdcoa.ui.activity;
import android.text.Editable; import android.text.Editable;
import android.text.TextUtils; import android.text.TextUtils;
import android.text.TextWatcher; import android.text.TextWatcher;
import android.util.Log;
import android.view.View; import android.view.View;
import android.widget.Toast; import android.widget.Toast;
import com.rehome.zhdcoa.Contans; import com.rehome.zhdcoa.Contans;
import com.rehome.zhdcoa.R; import com.rehome.zhdcoa.R;
import com.rehome.zhdcoa.base.BaseActivity; 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.bean.UpdatePwd;
import com.rehome.zhdcoa.ui.toastview.toastviewbymyself; import com.rehome.zhdcoa.ui.toastview.toastviewbymyself;
import com.rehome.zhdcoa.utils.GsonUtils; import com.rehome.zhdcoa.utils.GsonUtils;
import com.rehome.zhdcoa.utils.HttpListener;
import com.rehome.zhdcoa.utils.HttpUtils; import com.rehome.zhdcoa.utils.HttpUtils;
import com.rehome.zhdcoa.utils.NohttpUtils;
import com.rehome.zhdcoa.utils.RSAUtils; import com.rehome.zhdcoa.utils.RSAUtils;
import com.rehome.zhdcoa.utils.SPUtils; import com.rehome.zhdcoa.utils.SPUtils;
import com.rehome.zhdcoa.utils.UiUtlis;
import com.rehome.zhdcoa.weiget.AuditDialog; import com.rehome.zhdcoa.weiget.AuditDialog;
import com.rehome.zhdcoa.weiget.ClearEditText; 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.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
@ -50,7 +59,9 @@ public class UpdatePwdActivity extends BaseActivity {
public void initView() { public void initView() {
findView(); 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() { initToolbar("修改密码", "修改", new View.OnClickListener() {
@Override @Override
@ -107,38 +118,88 @@ public class UpdatePwdActivity extends BaseActivity {
private void updatePwd() { private void updatePwd() {
String json = createJson(); String json = createJson();
showLog(json); showLog(json);
RequestBody body = RequestBody.create(MediaType.parse("application/json"),json); // RequestBody body = RequestBody.create(MediaType.parse("application/json"), json);
HttpUtils.getApi().updataPwd(body).enqueue(new BaseCallBack<ResultBean>(context) { // 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>() {
@Override @Override
public void onSuccess(Call<ResultBean> call, Response<ResultBean> response) { public void onSucceed(int what, com.yolanda.nohttp.rest.Response<String> response) {
showLog("----------------");
ResultBean bean = response.body(); String result = response.get();
if (bean != null) { String jsonDecode = RSAUtils.decryptBASE64StrClient(result);
if (!bean.getTotal().equals("0")) { showLog(result);
if (bean.getRows().get(0).getResult().equals("1")) { // showLog(jsonDecode);
toastviewbymyself.makeText(context, bean.getRows().get(0).getMsg(), Toast.LENGTH_LONG).show(); if (TextUtils.isEmpty(jsonDecode)) {
SPUtils.put(context, Contans.SP.PASS_WORD, RSAUtils.encryptBASE64StrLocal(Objects.requireNonNull(etNewPwd.getText()).toString())); showToast(UiUtlis.getString(context, R.string.data_error));
SPUtils.put(context, Contans.SP.OLD_PWD, RSAUtils.encryptBASE64StrLocal(Objects.requireNonNull(etNewPwd.getText()).toString())); } else {
SPUtils.put( ResultBean bean = GsonUtils.GsonToBean(jsonDecode, ResultBean.class);
context, if (bean != null) {
Contans.SP.AF_PASS_WORD, if (!bean.getTotal().equals("0")) {
RSAUtils.encryptBASE64StrLocal(Objects.requireNonNull(etNewPwd.getText()).toString()) if (bean.getRows().get(0).getResult().equals("1")) {
); toastviewbymyself.makeText(context, bean.getRows().get(0).getMsg(), Toast.LENGTH_LONG).show();
finish(); SPUtils.put(context, Contans.SP.PASS_WORD, RSAUtils.encryptBASE64StrLocal(Objects.requireNonNull(etNewPwd.getText()).toString()));
} else { SPUtils.put(context, Contans.SP.OLD_PWD, RSAUtils.encryptBASE64StrLocal(Objects.requireNonNull(etNewPwd.getText()).toString()));
toastviewbymyself.makeText(context, bean.getRows().get(0).getMsg(), Toast.LENGTH_LONG).show(); 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 @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() { private String createJson() {
UpdatePwd updatePwd = new UpdatePwd(); UpdatePwd updatePwd = new UpdatePwd();
List<UpdatePwd.RowsBean> list = new ArrayList<>(); List<UpdatePwd.RowsBean> list = new ArrayList<>();
UpdatePwd.RowsBean rowsBean = new UpdatePwd.RowsBean(); UpdatePwd.RowsBean rowsBean = new UpdatePwd.RowsBean();
rowsBean.setManid(userInfo.getManid()); rowsBean.setManid(userInfo.getManid());
rowsBean.setNewpwd(etNewPwd.getText().toString()); rowsBean.setNewpwd(etNewPwd.getText().toString());
rowsBean.setPwded(etFormerPwd.getText().toString());
rowsBean.setType("0"); rowsBean.setType("0");
list.add(rowsBean); list.add(rowsBean);
updatePwd.setRows(list); updatePwd.setRows(list);
String json = GsonUtils.GsonString(updatePwd); String json = GsonUtils.GsonString(updatePwd);
return json; String jsonEncrypt = RSAUtils.encryptBASE64Str(json);
return jsonEncrypt;
} }
private boolean validaData() { private boolean validaData() {
@ -188,7 +250,7 @@ public class UpdatePwdActivity extends BaseActivity {
} }
if (!newPwd.equals(newPwdSure)) { if (!newPwd.equals(newPwdSure)) {
toastviewbymyself.makeText(context,"两次密码不一致", Toast.LENGTH_LONG).show(); toastviewbymyself.makeText(context, "两次密码不一致", Toast.LENGTH_LONG).show();
return false; return false;
} }

@ -76,7 +76,9 @@ public class YXCZCWInfoActivity extends BaseActivity {
} }
public void GetData() { 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) { HttpUtils.getYXApi().Getczcwhisdatas(body).enqueue(new BaseCallBack<YxczcwindohisBean>(context) {
@Override @Override
public void onSuccess(Call<YxczcwindohisBean> call, Response<YxczcwindohisBean> response) { public void onSuccess(Call<YxczcwindohisBean> call, Response<YxczcwindohisBean> response) {

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

Loading…
Cancel
Save