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 AuthenticationExceptionstatic @NonNull AuthenticationExceptionexception(@NonNull AuthenticationFailureReason reason) static @NonNull AuthenticationExceptionstatic @NonNull AuthenticationResponsefailure()static @NonNull AuthenticationResponsefailure(@NonNull AuthenticationFailureReason reason) static @NonNull AuthenticationResponsedefault booleanIf true, it is expected thegetAuthentication()method will return a non empty optional.static @NonNull AuthenticationResponsestatic @NonNull AuthenticationResponsesuccess(@NonNull String username, @NonNull Collection<String> roles) static @NonNull AuthenticationResponsesuccess(@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
-