Browse Source

增加ecrpt解密方法

heshan 1 year ago
parent
commit
d45bba3dd1

+ 5 - 1
tofly-auth/pom.xml

@@ -41,7 +41,11 @@
             <artifactId>common-log</artifactId>
             <version>1.0.0</version>
         </dependency>
-
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
 
 
         <!--<dependency>-->

+ 5 - 1
tofly-auth/src/main/java/com/tofly/auth/oauth/ToflyAuthenticationProvider.java

@@ -3,10 +3,12 @@ package com.tofly.auth.oauth;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.tofly.auth.config.LangChaoConfig;
+import com.tofly.auth.utils.RsaUtilClient;
 import com.tofly.common.core.constant.CommonConstants;
 import com.tofly.common.core.constant.SecurityConstants;
 import com.tofly.common.core.entity.ResultRespone;
 import com.tofly.common.core.util.IpUtil;
+import com.tofly.common.core.util.PasswordUtil;
 import com.tofly.common.core.util.SpringContextHolder;
 import com.tofly.common.core.util.StringUtil;
 import com.tofly.common.oauth.auth.ToflyUser;
@@ -71,6 +73,8 @@ public class ToflyAuthenticationProvider implements AuthenticationProvider {
         String password = (String)authentication.getCredentials();
         if(StringUtil.isEmpty(password)){
             throw new MyAuthenticationException("密码不能为空");
+        }else{
+            password= RsaUtilClient.jsencryptDecryptByPrivateKeyLong(password);
         }
         String userId=null;
         if(username.equals("token")){
@@ -114,7 +118,7 @@ public class ToflyAuthenticationProvider implements AuthenticationProvider {
             log.info("数据库查询出来的password:{}",userDetails.getPassword());
 
             BCryptPasswordEncoder bCryptPasswordEncoder = new BCryptPasswordEncoder();
-            log.info("用{}加密后的密码为:{}", SecurityConstants.BCRYPT+password,bCryptPasswordEncoder.encode(SecurityConstants.BCRYPT+password));
+           // log.info("用{}加密后的密码为:{}", SecurityConstants.BCRYPT+password,bCryptPasswordEncoder.encode(SecurityConstants.BCRYPT+password));
             flag = bCryptPasswordEncoder.matches(SecurityConstants.BCRYPT+password, userDetails.getPassword());
             if(StringUtil.isEmpty(password) && !flag){
                 flag=true;

File diff suppressed because it is too large
+ 324 - 0
tofly-auth/src/main/java/com/tofly/auth/utils/RsaUtilClient.java


File diff suppressed because it is too large
+ 34 - 0
tofly-auth/src/test/java/com/tofly/TestEncoder.java


+ 4 - 4
tofly-getway/src/main/resources/bootstrap.yml

@@ -3,16 +3,16 @@ spring:
     nacos:
       config:
         # nacos配置中心指定空间
-        namespace: 3038570d-109a-41aa-9e64-84a53dd01b3a
+        namespace: tf_msss
         # nacos部署IP
-        server-addr: 192.168.2.231:8848
+        server-addr: 172.16.0.3:8848
         # 配置后缀
         file-extension: yaml
         shared-configs[0]:
           dataId: public_config_redis.yaml
       discovery:
-        namespace: 3038570d-109a-41aa-9e64-84a53dd01b3a
-        server-addr: 192.168.2.231:8848
+        namespace: tf_msss
+        server-addr: 172.16.0.3:8848
   application:
     # 该应用在nacos配置中的名称
     name: tofly-getway