Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring security Spring安全性:在自定义身份验证中使用BCryptPasswordEncoder提供_Spring Security - Fatal编程技术网

Spring security Spring安全性:在自定义身份验证中使用BCryptPasswordEncoder提供

Spring security Spring安全性:在自定义身份验证中使用BCryptPasswordEncoder提供,spring-security,Spring Security,我对密码进行了如下哈希处理: BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder(); String hashedPassword = passwordEncoder.encode(password); 现在,我将如何使用自定义spring身份验证来验证登录用户名和密码 public Authentication authenticate(Authentication authentication)

我对密码进行了如下哈希处理:

    BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
    String hashedPassword = passwordEncoder.encode(password);
现在,我将如何使用自定义spring身份验证来验证登录用户名和密码

public Authentication authenticate(Authentication authentication) throws AuthenticationException{        
}


在本文中,我如何使用BCryptPasswordEncoder匹配登录密码是否正确

您的身份验证方法的核心可能如下所示:

String rawPassword=Stringauthentication.getCredentials; 如果passwordEncoder.matchesrawPassword,hashedPassword{ 抛出新的BadCredentialsException错误的密码; }
我选择了用户服务