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 @NonNull AuthenticationException
static @NonNull AuthenticationException
exception
(@NonNull AuthenticationFailureReason reason) static @NonNull AuthenticationException
static @NonNull AuthenticationResponse
failure()
static @NonNull AuthenticationResponse
failure
(@NonNull AuthenticationFailureReason reason) static @NonNull AuthenticationResponse
default boolean
If true, it is expected thegetAuthentication()
method will return a non empty optional.static @NonNull AuthenticationResponse
static @NonNull AuthenticationResponse
success
(@NonNull String username, @NonNull Collection<String> roles) static @NonNull AuthenticationResponse
success
(@NonNull String username, @NonNull Collection<String> roles, @NonNull Map<String, Object> attributes) static @NonNull 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 @NonNull AuthenticationResponse success(@NonNull @NonNull String username, @NonNull @NonNull Collection<String> roles) - Parameters:
username
- User's nameroles
- Users's roles- Returns:
- A successful
AuthenticationResponse
-
success
@NonNull static @NonNull AuthenticationResponse success(@NonNull @NonNull String username, @NonNull @NonNull Map<String, Object> attributes) - Parameters:
username
- User's nameattributes
- User's attributes- Returns:
- A successful
AuthenticationResponse
-
success
@NonNull static @NonNull AuthenticationResponse success(@NonNull @NonNull String username, @NonNull @NonNull Collection<String> roles, @NonNull @NonNull Map<String, Object> attributes) - Parameters:
username
- User's nameroles
- Users's rolesattributes
- User's attributes- Returns:
- A successful
AuthenticationResponse
-
failure
-
failure
@NonNull static @NonNull AuthenticationResponse failure(@NonNull @NonNull AuthenticationFailureReason reason) -
failure
-
exception
-
exception
@NonNull static @NonNull AuthenticationException exception(@NonNull @NonNull AuthenticationFailureReason reason) -
exception
-