Skip to content

Commit 4f97217

Browse files
therepanicjzheaux
authored andcommitted
Refine upgradeEncoding condition in DaoAuthenticationProvider
After adding jspecify support in the module that contains the DaoAuthenticationProvider class, we actually changed the contract logic, which is a good thing, and this commit fixes it. Closes: gh-18781 Signed-off-by: Andrey Litvitski <andrey1010102008@gmail.com>
1 parent fdaa883 commit 4f97217

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

core/src/main/java/org/springframework/security/authentication/dao/DaoAuthenticationProvider.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package org.springframework.security.authentication.dao;
1818

19+
import java.util.Objects;
1920
import java.util.function.Supplier;
2021

2122
import org.jspecify.annotations.Nullable;
@@ -43,6 +44,7 @@
4344
*
4445
* @author Ben Alex
4546
* @author Rob Winch
47+
* @author Andrey Litvitski
4648
*/
4749
public class DaoAuthenticationProvider extends AbstractUserDetailsAuthenticationProvider {
4850

@@ -131,7 +133,8 @@ protected Authentication createSuccessAuthentication(Object principal, Authentic
131133
throw new CompromisedPasswordException("The provided password is compromised, please change your password");
132134
}
133135
String existingEncodedPassword = user.getPassword();
134-
boolean upgradeEncoding = existingEncodedPassword != null && this.userDetailsPasswordService != null
136+
boolean upgradeEncoding = existingEncodedPassword != null
137+
&& !Objects.equals(this.userDetailsPasswordService, UserDetailsPasswordService.NOOP)
135138
&& this.passwordEncoder.get().upgradeEncoding(existingEncodedPassword);
136139
if (upgradeEncoding) {
137140
String newPassword = this.passwordEncoder.get().encode(presentedPassword);

0 commit comments

Comments
 (0)