Skip to content

Commit 9654e51

Browse files
big-cirjzheaux
authored andcommitted
Include UsernameNotFoundException in BadCredentialsException
Closes gh-16496 Signed-off-by: dae won <[email protected]>
1 parent d52e0b6 commit 9654e51

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,12 @@ public Authentication authenticate(Authentication authentication) throws Authent
137137
}
138138
catch (UsernameNotFoundException ex) {
139139
this.logger.debug(LogMessage.format("Failed to find user '%s'", username));
140+
String message = this.messages.getMessage("AbstractUserDetailsAuthenticationProvider.badCredentials",
141+
"Bad credentials");
140142
if (!this.hideUserNotFoundExceptions) {
141143
throw ex;
142144
}
143-
throw new BadCredentialsException(this.messages
144-
.getMessage("AbstractUserDetailsAuthenticationProvider.badCredentials", "Bad credentials"));
145+
throw new BadCredentialsException(message, ex);
145146
}
146147
Assert.notNull(user, "retrieveUser returned null - a violation of the interface contract");
147148
}

0 commit comments

Comments
 (0)