Browse Source

两个登录 账号加密2

dev
jianjun 3 years ago
parent
commit
632344f83b
  1. 6
      epmet-auth/src/main/java/com/epmet/controller/GovWebController.java
  2. 6
      epmet-auth/src/main/java/com/epmet/controller/LoginController.java

6
epmet-auth/src/main/java/com/epmet/controller/GovWebController.java

@ -1,6 +1,7 @@
package com.epmet.controller; package com.epmet.controller;
import com.epmet.auth.dto.result.BlockChainStaffAuthResultDTO; import com.epmet.auth.dto.result.BlockChainStaffAuthResultDTO;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.utils.RSASignature; import com.epmet.commons.tools.utils.RSASignature;
import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.commons.tools.validator.ValidatorUtils;
@ -9,6 +10,7 @@ import com.epmet.dto.form.GovWebLoginFormDTO;
import com.epmet.dto.result.UserTokenResultDTO; import com.epmet.dto.result.UserTokenResultDTO;
import com.epmet.service.GovWebService; import com.epmet.service.GovWebService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
@ -44,11 +46,11 @@ public class GovWebController {
ValidatorUtils.validateEntity(formDTO); ValidatorUtils.validateEntity(formDTO);
try { try {
if (formDTO.getPassword().length() > 50) { if (StringUtils.isNotBlank(formDTO.getPassword())&&formDTO.getPassword().length() > NumConstant.FIFTY) {
String newPassword = RSASignature.decryptByPrivateKey(formDTO.getPassword(), privateKey); String newPassword = RSASignature.decryptByPrivateKey(formDTO.getPassword(), privateKey);
formDTO.setPassword(newPassword); formDTO.setPassword(newPassword);
} }
if (formDTO.getPhone().length() > 50) { if (StringUtils.isNotBlank(formDTO.getPhone())&&formDTO.getPhone().length() > NumConstant.FIFTY) {
String phone = RSASignature.decryptByPrivateKey(formDTO.getPhone(), privateKey); String phone = RSASignature.decryptByPrivateKey(formDTO.getPhone(), privateKey);
formDTO.setPhone(phone); formDTO.setPhone(phone);
} }

6
epmet-auth/src/main/java/com/epmet/controller/LoginController.java

@ -99,15 +99,15 @@ public class LoginController {
//效验数据 //效验数据
ValidatorUtils.validateEntity(formDTO); ValidatorUtils.validateEntity(formDTO);
//解密密码 //解密密码
if (formDTO.getPhone().length() > NumConstant.FIFTY) { if (StringUtils.isNotBlank(formDTO.getPhone())&&formDTO.getPhone().length() > NumConstant.FIFTY) {
String phone = RSASignature.decryptByPrivateKey(formDTO.getPhone(), privateKey); String phone = RSASignature.decryptByPrivateKey(formDTO.getPhone(), privateKey);
formDTO.setPhone(phone); formDTO.setPhone(phone);
} }
if (formDTO.getMobile().length() > NumConstant.FIFTY) { if (StringUtils.isNotBlank(formDTO.getMobile())&&formDTO.getMobile().length() > NumConstant.FIFTY) {
String phone = RSASignature.decryptByPrivateKey(formDTO.getMobile(), privateKey); String phone = RSASignature.decryptByPrivateKey(formDTO.getMobile(), privateKey);
formDTO.setMobile(phone); formDTO.setMobile(phone);
} }
if (formDTO.getPassword().length() > NumConstant.FIFTY) { if (StringUtils.isNotBlank(formDTO.getPassword())&&formDTO.getPassword().length() > NumConstant.FIFTY) {
String confirmNewPassWord = RSASignature.decryptByPrivateKey(formDTO.getPassword(), privateKey); String confirmNewPassWord = RSASignature.decryptByPrivateKey(formDTO.getPassword(), privateKey);
formDTO.setPassword(confirmNewPassWord); formDTO.setPassword(confirmNewPassWord);
} }

Loading…
Cancel
Save