Class UsernameNotFoundException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
org.springframework.security.core.AuthenticationException
org.springframework.security.core.userdetails.UsernameNotFoundException
- All Implemented Interfaces:
Serializable
Thrown if an
UserDetailsService implementation cannot locate a User by
its username.- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs aUsernameNotFoundExceptionwith the specified message.UsernameNotFoundException(String msg, Throwable cause) Constructs aUsernameNotFoundExceptionwith the specified message and root cause. -
Method Summary
Modifier and TypeMethodDescriptionstatic UsernameNotFoundExceptionfromUsername(String username) Construct an exception based on a specific usernamestatic UsernameNotFoundExceptionfromUsername(String username, Throwable cause) Construct an exception based on a specific username@Nullable StringgetName()Get the username that couldn't be foundMethods inherited from class org.springframework.security.core.AuthenticationException
getAuthenticationRequest, setAuthenticationRequestMethods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Constructor Details
-
UsernameNotFoundException
Constructs aUsernameNotFoundExceptionwith the specified message.- Parameters:
msg- the detail message.
-
UsernameNotFoundException
Constructs aUsernameNotFoundExceptionwith the specified message and root cause.- Parameters:
msg- the detail message.cause- root cause
-
-
Method Details
-
fromUsername
Construct an exception based on a specific username- Parameters:
username- the invalid username- Returns:
- the
UsernameNotFoundException - Since:
- 7.0
-
fromUsername
Construct an exception based on a specific username- Parameters:
username- the invalid usernamecause- any underlying cause- Returns:
- the
UsernameNotFoundException - Since:
- 7.0
-
getName
Get the username that couldn't be found- Returns:
- the username
- Since:
- 7.0
-