Interface OAuth2Service

  • All Known Implementing Classes:
    DefaultOAuth2Service

    public interface OAuth2Service
    Contract for managing OAuth 2.0 token generation
    Since:
    8.3.0
    • Method Detail

      • getConfiguredOAuth2Providers

        List<OAuth2Service.OAuth2Provider> getConfiguredOAuth2Providers()
        Returns a List of the configured OAuth Providers.
        Returns:
        configured OAuth 2.0 Providers.
      • initialiseOAuth2Flow

        OAuth2Service.OAuth2Result initialiseOAuth2Flow​(javax.servlet.http.HttpSession session,
                                                        String oAuth2ProviderId,
                                                        UnaryOperator<String> buildRedirect)
                                                 throws IllegalArgumentException
        Initialises the OAuth flow for the given Provider.
        Parameters:
        session - the current HttpSession which will be associated with the OAuth 2.0 flow
        oAuth2ProviderId - the configured OAuth 2.0 Provider id
        buildRedirect - a function which constructs the OAuth 2.0 redirect
        Returns:
        the OAuth Provider FlowResult which contains the Flow identifier and redirect URL.
        Throws:
        IllegalArgumentException
      • completeOAuth2Flow

        String completeOAuth2Flow​(javax.servlet.http.HttpSession session,
                                  String oAuthProviderId)
                           throws OAuth2Exception
        Completes the OAuth flow for the specified Provider and generates a token if successful.
        Parameters:
        session - the HttpSession which initialised the OAuth 2.0 flow through initialiseOAuth2Flow(HttpSession, String, UnaryOperator)
        oAuthProviderId - the configured OAuth 2.0 Provider ID
        Returns:
        the OAuth token identifier.
        Throws:
        OAuth2Exception - if the flow has not been initialised for the given Provider within the current session.