|
@@ -3,6 +3,7 @@ package com.jiayue.ssi.aspectj;
|
|
import cn.hutool.crypto.SmUtil;
|
|
import cn.hutool.crypto.SmUtil;
|
|
import com.jiayue.ssi.annotation.AgainVerify;
|
|
import com.jiayue.ssi.annotation.AgainVerify;
|
|
import com.jiayue.ssi.constant.SecretKeyConstants;
|
|
import com.jiayue.ssi.constant.SecretKeyConstants;
|
|
|
|
+import com.jiayue.ssi.entity.SysUser;
|
|
import com.jiayue.ssi.util.ResponseVO;
|
|
import com.jiayue.ssi.util.ResponseVO;
|
|
import com.jiayue.ssi.util.SM2CryptUtils;
|
|
import com.jiayue.ssi.util.SM2CryptUtils;
|
|
import com.jiayue.ssi.util.SecurityContextUtil;
|
|
import com.jiayue.ssi.util.SecurityContextUtil;
|
|
@@ -12,6 +13,7 @@ import org.aspectj.lang.annotation.Around;
|
|
import org.aspectj.lang.annotation.Aspect;
|
|
import org.aspectj.lang.annotation.Aspect;
|
|
import org.aspectj.lang.annotation.Pointcut;
|
|
import org.aspectj.lang.annotation.Pointcut;
|
|
import org.springframework.core.annotation.Order;
|
|
import org.springframework.core.annotation.Order;
|
|
|
|
+import org.springframework.security.authentication.BadCredentialsException;
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.web.context.request.RequestAttributes;
|
|
import org.springframework.web.context.request.RequestAttributes;
|
|
import org.springframework.web.context.request.RequestContextHolder;
|
|
import org.springframework.web.context.request.RequestContextHolder;
|
|
@@ -49,10 +51,26 @@ public class AgainVerifyAspect {
|
|
try {
|
|
try {
|
|
decryptPassword= SmUtil.sm3(againPwd).toUpperCase();
|
|
decryptPassword= SmUtil.sm3(againPwd).toUpperCase();
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
- log.error("鉴别操作加密密码失败",e);
|
|
|
|
|
|
+// log.error("鉴别操作加密密码失败",e);
|
|
return ResponseVO.fail("鉴别失败,不能操作");
|
|
return ResponseVO.fail("鉴别失败,不能操作");
|
|
}
|
|
}
|
|
- if (!decryptPassword.equals(SM2CryptUtils.decrypt(SecurityContextUtil.getSysUser().getPassword(), SecretKeyConstants.SERVER_PRIVATE_KEY))) {
|
|
|
|
|
|
+
|
|
|
|
+ // 先检测存储密码的完整性
|
|
|
|
+ String dbpwd = "";
|
|
|
|
+ SysUser sysUser = SecurityContextUtil.getSysUser();
|
|
|
|
+ try {
|
|
|
|
+ dbpwd = SM2CryptUtils.decrypt(sysUser.getPassword(), SecretKeyConstants.SERVER_PRIVATE_KEY);
|
|
|
|
+ }
|
|
|
|
+ catch (Exception e1){
|
|
|
|
+ log.error("账号:"+sysUser.getUsername()+",数据库密码被破坏!");
|
|
|
|
+ return ResponseVO.fail("鉴别失败,不能操作");
|
|
|
|
+ }
|
|
|
|
+ if (!dbpwd.equals(sysUser.getCheckPassword())){
|
|
|
|
+ log.error("账号:"+sysUser.getUsername()+",数据库密码完整性校验失败!");
|
|
|
|
+ return ResponseVO.fail("鉴别失败,不能操作");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!decryptPassword.equals(dbpwd)) {
|
|
// log.error("鉴别失败,不能操作");
|
|
// log.error("鉴别失败,不能操作");
|
|
return ResponseVO.fail("鉴别失败,不能操作");
|
|
return ResponseVO.fail("鉴别失败,不能操作");
|
|
}
|
|
}
|