Interface OAuthProvider

All Known Implementing Classes:
DefaultOauthProvider

public interface OAuthProvider
Represent an OAuth authorization server
  • Method Summary

    Modifier and Type
    Method
    Description
    Optional<com.nimbusds.oauth2.sdk.token.AccessToken>
    Try to get the currently stored access token for the given provider.
    Get the authorization endpoint for the provider
    com.nimbusds.oauth2.sdk.auth.ClientAuthentication
    Get the client authentication to use for new token request
    com.nimbusds.oauth2.sdk.id.ClientID
    Get the client id provided by the authorization server.
    Get the list of custom parameters returned with the access token.
    Get the extension id
    com.nimbusds.oauth2.sdk.Scope
    Get the scope to request to the provider.
    Optional<com.nimbusds.oauth2.sdk.token.AccessToken>
    Get the stored access token if it exist.
    <T> Optional<T>
    Retrieve the stored value for a custom parameter
    Get the token endpoint for the provider
    boolean
    isKnownState(com.nimbusds.oauth2.sdk.id.State state)
    Indicate that the provider is expecting an authorization response for the provided state.
    com.nimbusds.oauth2.sdk.token.AccessToken
    requestAccessToken(com.nimbusds.oauth2.sdk.AuthorizationGrant authorizationGrant)
    Request a token to an authorization server using an authorization code previously provided by the authorization server.
  • Method Details

    • getId

      Get the extension id
      Returns:
      the id
    • getClientID

      com.nimbusds.oauth2.sdk.id.ClientID getClientID()
      Get the client id provided by the authorization server.
      Returns:
      the client id
    • getClientAuthentication

      com.nimbusds.oauth2.sdk.auth.ClientAuthentication getClientAuthentication()
      Get the client authentication to use for new token request
      Returns:
      the authentication
    • getAuthorizationEndpointURI

      Get the authorization endpoint for the provider
      Returns:
      the uri
    • getTokenEndpointURI

      Get the token endpoint for the provider
      Returns:
      the uri
    • getCustomParametersName

      Get the list of custom parameters returned with the access token. The listed parameters are stored with the access token for later use.
      Returns:
      the list of parameter names
    • getScope

      com.nimbusds.oauth2.sdk.Scope getScope()
      Get the scope to request to the provider. null if no scope should be use.
      Returns:
      the scope or null
    • getStoredAccessToken

      Optional<com.nimbusds.oauth2.sdk.token.AccessToken> getStoredAccessToken()
      Get the stored access token if it exist. If a token exists, but is expired, this method will silently try to refresh it.
      Returns:
      the access token or empty
    • getAccessToken

      Optional<com.nimbusds.oauth2.sdk.token.AccessToken> getAccessToken(Redirector redirector) throws ProcessingException, IOException
      Try to get the currently stored access token for the given provider. If no valid token is available, the method should return Optional.empty() and try to redirect to the authorization protocol.
      Parameters:
      redirector - the redirector to use if no token are available.
      Returns:
      the token or Optional.empty()
      Throws:
      ProcessingException - if an error occurred while redirecting
      IOException - if an error occurred while redirecting
      See Also:
    • isKnownState

      boolean isKnownState(com.nimbusds.oauth2.sdk.id.State state)
      Indicate that the provider is expecting an authorization response for the provided state.
      Parameters:
      state - the state
      Returns:
      true if the provider has initiated a authorization process with this state and the process is not complete yet.
    • getStoredCustomParameter

      Retrieve the stored value for a custom parameter
      Type Parameters:
      T - the type of the value to retrieve. This must be a valid JSON type
      Parameters:
      parameter - the name of the parameter
      Returns:
      the value of the parameter if it exists
    • requestAccessToken

      com.nimbusds.oauth2.sdk.token.AccessToken requestAccessToken(com.nimbusds.oauth2.sdk.AuthorizationGrant authorizationGrant) throws IOException
      Request a token to an authorization server using an authorization code previously provided by the authorization server. This method will store the result of the token request in session. See getStoredAccessToken() and getAccessToken(Redirector) for how to use the requested token.
      Parameters:
      authorizationGrant - the grant to use to request the token
      Returns:
      the new access token
      Throws:
      IOException - if an error occurred while communicating with the token endpoint
      AccessDeniedException - if the response contains error
      See Also: