Interface AuthenticationResponse

  • All Superinterfaces:
    java.io.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.

    @FunctionalInterface
    public interface AuthenticationResponse
    extends java.io.Serializable
    The response of an authentication attempt.
    Since:
    1.0
    • Method Detail

      • isAuthenticated

        default boolean isAuthenticated()
        If true, it is expected the getAuthentication() method will return a non empty optional.
        Returns:
        true or false depending on whether the user is authenticated
      • getAuthentication

        java.util.Optional<Authentication> getAuthentication()
        Returns:
        The user details if the response is authenticated
      • getMessage

        default java.util.Optional<java.lang.String> getMessage()
        Returns:
        A message if the response chose to include one
      • success

        @NonNull
        static AuthenticationResponse success​(@NonNull
                                              java.lang.String username,
                                              @NonNull
                                              java.util.Collection<java.lang.String> roles)
        Parameters:
        username - User's name
        roles - Users's roles
        Returns:
        A successful AuthenticationResponse
      • success

        @NonNull
        static AuthenticationResponse success​(@NonNull
                                              java.lang.String username,
                                              @NonNull
                                              java.util.Map<java.lang.String,​java.lang.Object> attributes)
        Parameters:
        username - User's name
        attributes - User's attributes
        Returns:
        A successful AuthenticationResponse
      • success

        @NonNull
        static AuthenticationResponse success​(@NonNull
                                              java.lang.String username,
                                              @NonNull
                                              java.util.Collection<java.lang.String> roles,
                                              @NonNull
                                              java.util.Map<java.lang.String,​java.lang.Object> attributes)
        Parameters:
        username - User's name
        roles - Users's roles
        attributes - User's attributes
        Returns:
        A successful AuthenticationResponse