From fade99da94325e13e5dc70fd781e5021d2a56f5d Mon Sep 17 00:00:00 2001
From: wjli <591616088@qq.com>
Date: 星期五, 12 四月 2024 15:26:46 +0800
Subject: [PATCH] 图片链接显示方法封装和使用。 解决烟草后台本机无法查看图片的问题。

---
 xboot-core/src/main/java/cn/exrick/xboot/core/config/security/DaoAuthenticationProvider.java |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/xboot-core/src/main/java/cn/exrick/xboot/core/config/security/DaoAuthenticationProvider.java b/xboot-core/src/main/java/cn/exrick/xboot/core/config/security/DaoAuthenticationProvider.java
index 68ba9f5..ff23b5b 100644
--- a/xboot-core/src/main/java/cn/exrick/xboot/core/config/security/DaoAuthenticationProvider.java
+++ b/xboot-core/src/main/java/cn/exrick/xboot/core/config/security/DaoAuthenticationProvider.java
@@ -1,13 +1,16 @@
 package cn.exrick.xboot.core.config.security;
 
+import cn.exrick.xboot.core.common.utils.ResultUtil;
 import cn.hutool.extra.spring.SpringUtil;
 import jodd.util.Base64;
 import org.springframework.context.annotation.Configuration;
+import org.springframework.security.authentication.BadCredentialsException;
 import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
 import org.springframework.security.authentication.dao.AbstractUserDetailsAuthenticationProvider;
 import org.springframework.security.core.AuthenticationException;
 import org.springframework.security.core.userdetails.UserDetails;
 import org.springframework.security.core.userdetails.UserDetailsService;
+import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
 import org.springframework.stereotype.Component;
 
 /**
@@ -17,8 +20,18 @@
 public class DaoAuthenticationProvider extends AbstractUserDetailsAuthenticationProvider {
     @Override
     protected void additionalAuthenticationChecks(UserDetails userDetails, UsernamePasswordAuthenticationToken authentication) throws AuthenticationException {
+        if (authentication.getCredentials()==null){
+            throw new BadCredentialsException("瀵嗙爜涓虹┖");
+        }
         String password= authentication.getCredentials().toString();
+        password = password.replace("\n","");
         password = Base64.decodeToString(password);
+        boolean isPass = new BCryptPasswordEncoder().matches(password, userDetails.getPassword());
+        if (!isPass) {
+            throw new BadCredentialsException("瀵嗙爜閿欒");
+        }
+
+
         UsernamePasswordAuthenticationToken newAuthentication = new UsernamePasswordAuthenticationToken(authentication.getPrincipal(), password);
         newAuthentication.setDetails(authentication.getDetails());
     }

--
Gitblit v1.9.1