Class AuthenticationResponse


  • public final class AuthenticationResponse
    extends SecurityResponse
    Response as returned from an authentication provider. Provider should return a response even for failed authentications. Only throw an exception if an error has occurred (e.g. misconfiguration). Do not throw exception for bad credentials...
    See Also:
    failed(String), success(Subject)
    • Method Detail

      • failed

        public static AuthenticationResponse failed​(String message,
                                                    Throwable cause)
        Construct a failed response with a throwable as a cause.
        Parameters:
        message - Descriptive message of what happened. This message is propagated to public API!
        cause - Throwable causing the failed authentication. This will be logged. It may reach user only in case of debug.
        Returns:
        AuthenticationResponse with information filled
      • failed

        public static AuthenticationResponse failed​(String message)
        Construct a failed response with an explanatory message.
        Parameters:
        message - Descriptive message of what happened. This message is propagated to public API!
        Returns:
        AuthenticationResponse with information filled
      • abstain

        public static AuthenticationResponse abstain()
        Provider returning this response is not capable to make a decision (e.g. the user format is not supported).
        Returns:
        AuthenticationResponse with information filled
      • success

        public static AuthenticationResponse success​(Subject subject)
        Provider has authenticated the request and created a user Subject.
        Parameters:
        subject - Subject of the current user
        Returns:
        AuthenticationResponse with information filled
      • success

        public static AuthenticationResponse success​(Subject user,
                                                     Subject service)
        Provider has authenticated the request and created a user and service Subject.
        Parameters:
        user - Subject of the current user
        service - Subject of the current service
        Returns:
        AuthenticationResponse with information filled
      • successService

        public static AuthenticationResponse successService​(Subject service)
        Provider has authenticated the request and created a service Subject.
        Parameters:
        service - Subject of requesting service (or client)
        Returns:
        AuthenticationResponse with information filled
      • service

        public Optional<Subject> service()
        Service (or client) subject.
        Returns:
        Subject of the service (or client), if one was authenticated