mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-06-01 09:42:13 +00:00
DelegatingPasswordEncoder handles null encodedPassword
Fixes: gh-4872
This commit is contained in:
parent
e377dcf81b
commit
f558b5016c
@ -200,6 +200,9 @@ public class DelegatingPasswordEncoder implements PasswordEncoder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String extractId(String prefixEncodedPassword) {
|
private String extractId(String prefixEncodedPassword) {
|
||||||
|
if (prefixEncodedPassword == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
int start = prefixEncodedPassword.indexOf(PREFIX);
|
int start = prefixEncodedPassword.indexOf(PREFIX);
|
||||||
if(start != 0) {
|
if(start != 0) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -177,4 +177,9 @@ public class DelegatingPasswordEncoderTests {
|
|||||||
verify(this.invalidId).matches(this.rawPassword, this.encodedPassword);
|
verify(this.invalidId).matches(this.rawPassword, this.encodedPassword);
|
||||||
verifyZeroInteractions(this.bcrypt, this.noop);
|
verifyZeroInteractions(this.bcrypt, this.noop);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test(expected = IllegalStateException.class)
|
||||||
|
public void matchesWhenRawPasswordNotNullAndEncodedPasswordNullThenThrowsIllegalStateException() {
|
||||||
|
this.passwordEncoder.matches(this.rawPassword, null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user