Interface AuthenticationResponse
- All Superinterfaces:
Serializable
- All Known Implementing Classes:
AuthenticationFailed
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
The response of an authentication attempt.
- Since:
- 1.0
- Author:
- Sergio del Amo
-
Method Summary
Modifier and TypeMethodDescriptionstatic AuthenticationException
static AuthenticationException
exception
(AuthenticationFailureReason reason) static AuthenticationException
static AuthenticationResponse
failure()
static AuthenticationResponse
failure
(AuthenticationFailureReason reason) static AuthenticationResponse
default boolean
If true, it is expected thegetAuthentication()
method will return a non empty optional.static AuthenticationResponse
static AuthenticationResponse
success
(String username, Collection<String> roles) static AuthenticationResponse
static AuthenticationResponse
-
Method Details
-
isAuthenticated
default boolean isAuthenticated()If true, it is expected thegetAuthentication()
method will return a non empty optional.- Returns:
- true or false depending on whether the user is authenticated
-
getAuthentication
Optional<Authentication> getAuthentication()- Returns:
- The user details if the response is authenticated
-
getMessage
- Returns:
- A message if the response chose to include one
-
success
- Parameters:
username
- User's name- Returns:
- A successful
AuthenticationResponse
-
success
@NonNull static AuthenticationResponse success(@NonNull String username, @NonNull Collection<String> roles) - Parameters:
username
- User's nameroles
- Users's roles- Returns:
- A successful
AuthenticationResponse
-
success
@NonNull static AuthenticationResponse success(@NonNull String username, @NonNull Map<String, Object> attributes) - Parameters:
username
- User's nameattributes
- User's attributes- Returns:
- A successful
AuthenticationResponse
-
success
@NonNull static AuthenticationResponse success(@NonNull String username, @NonNull Collection<String> roles, @NonNull Map<String, Object> attributes) - Parameters:
username
- User's nameroles
- Users's rolesattributes
- User's attributes- Returns:
- A successful
AuthenticationResponse
-
failure
-
failure
-
failure
-
exception
-
exception
-
exception
-