Interface Client<C extends Credentials>

  • All Known Implementing Classes:
    AnonymousClient, BaseClient, DirectClient, IndirectClient

    public interface Client<C extends Credentials>

    This interface is the core class of the library. It represents an authentication mechanism to validate user's credentials and retrieve his user profile.

    Clients can be "indirect": in that case, credentials are not provided with the HTTP request, but the user must be redirected to an identity provider to perform login, the original requested url being saved and restored after the authentication process is done.

    The getRedirectionAction(WebContext) method is called to get the redirection to the identity provider, the getCredentials(WebContext) method is used to retrieve the credentials provided by the remote identity provider and the getUserProfile(Credentials, WebContext) method is called to get the user profile from the identity provider and based on the provided credentials.

    Clients can be "direct": in that case, credentials are provided along with the HTTP request and validated by the application.

    The getRedirectionAction(WebContext) method is not used, the getCredentials(WebContext) method is used to retrieve and validate the credentials provided and the getUserProfile(Credentials, WebContext) method is called to get the user profile from the appropriate system.

    Since:
    1.4.0
    Author:
    Jerome Leleu
    • Method Detail

      • getName

        String getName()
        Get the name of the client.
        Returns:
        the name of the client
      • getRedirectionAction

        Optional<RedirectionAction> getRedirectionAction​(WebContext context)

        Return the redirection action to the authentication provider (indirect clients).

        Parameters:
        context - the current web context
        Returns:
        the redirection to perform (optional)
      • getCredentials

        Optional<C> getCredentials​(WebContext context)

        Get the credentials from the web context. If no validation was made remotely (direct client), credentials must be validated at this step.

        Parameters:
        context - the current web context
        Returns:
        the credentials (optional)
      • getUserProfile

        Optional<UserProfile> getUserProfile​(C credentials,
                                             WebContext context)
        Get the user profile based on the provided credentials.
        Parameters:
        credentials - credentials
        context - web context
        Returns:
        the user profile (optional)
      • renewUserProfile

        Optional<UserProfile> renewUserProfile​(UserProfile profile,
                                               WebContext context)
        Renew the user profile.
        Parameters:
        profile - the user profile
        context - the current web context
        Returns:
        the renewed user profile (optional).
      • getLogoutAction

        Optional<RedirectionAction> getLogoutAction​(WebContext context,
                                                    UserProfile currentProfile,
                                                    String targetUrl)

        Return the logout action (indirect clients).

        Parameters:
        context - the current web context
        currentProfile - the currentProfile
        targetUrl - the target url after logout
        Returns:
        the redirection to perform (optional)