Przeglądaj źródła

Include UsernameNotFoundException in BadCredentialsException

Closes gh-16496

Signed-off-by: dae won <eodnjs01477@gmail.com>
dae won 2 miesięcy temu
rodzic
commit
9654e51bd4

+ 3 - 2
core/src/main/java/org/springframework/security/authentication/dao/AbstractUserDetailsAuthenticationProvider.java

@@ -137,11 +137,12 @@ public abstract class AbstractUserDetailsAuthenticationProvider
 			}
 			catch (UsernameNotFoundException ex) {
 				this.logger.debug(LogMessage.format("Failed to find user '%s'", username));
+				String message = this.messages.getMessage("AbstractUserDetailsAuthenticationProvider.badCredentials",
+						"Bad credentials");
 				if (!this.hideUserNotFoundExceptions) {
 					throw ex;
 				}
-				throw new BadCredentialsException(this.messages
-					.getMessage("AbstractUserDetailsAuthenticationProvider.badCredentials", "Bad credentials"));
+				throw new BadCredentialsException(message, ex);
 			}
 			Assert.notNull(user, "retrieveUser returned null - a violation of the interface contract");
 		}