Class AuthCodeGrantImpl

java.lang.Object
org.glassfish.jersey.client.oauth2.AuthCodeGrantImpl
All Implemented Interfaces:
OAuth2CodeGrantFlow

class AuthCodeGrantImpl extends Object implements OAuth2CodeGrantFlow
Default implementation of OAuth2CodeGrantFlow.
Since:
2.3
  • Field Details

    • accessTokenUri

      private final String accessTokenUri
    • authorizationUri

      private final String authorizationUri
    • refreshTokenUri

      private final String refreshTokenUri
    • clientIdentifier

      private final ClientIdentifier clientIdentifier
    • client

      private final javax.ws.rs.client.Client client
    • authorizationProperties

      private final Map<String,String> authorizationProperties
    • accessTokenProperties

      private final Map<String,String> accessTokenProperties
    • refreshTokenProperties

      private final Map<String,String> refreshTokenProperties
    • tokenResult

      private volatile TokenResult tokenResult
  • Constructor Details

  • Method Details

    • configureClient

      private javax.ws.rs.client.Client configureClient(javax.ws.rs.client.Client client)
    • setDefaultProperty

      private void setDefaultProperty(String key, String value, Map<String,String>... properties)
    • initDefaultProperties

      private void initDefaultProperties(String redirectUri, String scope)
    • start

      public String start()
      Description copied from interface: OAuth2CodeGrantFlow
      Start the authorization process and return redirection URI on which the user should give a consent for our application to access resources.
      Specified by:
      start in interface OAuth2CodeGrantFlow
      Returns:
      URI to which user should be redirected.
    • finish

      public TokenResult finish(String authorizationCode, String state)
      Description copied from interface: OAuth2CodeGrantFlow
      Finish the authorization process and return the TokenResult. The method must be called on the same instance after the OAuth2CodeGrantFlow.start() method was called and user granted access to this application.

      The method makes a request to the Authorization Server in order to exchange code for access token.

      Specified by:
      finish in interface OAuth2CodeGrantFlow
      Parameters:
      authorizationCode - Code received from the user authorization process.
      state - State received from the user authorization response.
      Returns:
      Token result.
    • refreshAccessToken

      public TokenResult refreshAccessToken(String refreshToken)
      Description copied from interface: OAuth2CodeGrantFlow
      Refresh the access token using a refresh token. This method can be called on newly created instance or on instance on which the authorization flow was already performed.
      Specified by:
      refreshAccessToken in interface OAuth2CodeGrantFlow
      Parameters:
      refreshToken - Refresh token.
      Returns:
      Token result.
    • getAuthorizedClient

      public javax.ws.rs.client.Client getAuthorizedClient()
      Description copied from interface: OAuth2CodeGrantFlow
      Return the client configured for performing authorized requests to the Service Provider. The authorization process must be successfully finished by instance by calling methods OAuth2CodeGrantFlow.start() and OAuth2CodeGrantFlow.finish(String, String).
      Specified by:
      getAuthorizedClient in interface OAuth2CodeGrantFlow
      Returns:
      Client configured to add correct Authorization header to requests.
    • getOAuth2Feature

      public javax.ws.rs.core.Feature getOAuth2Feature()
      Description copied from interface: OAuth2CodeGrantFlow
      Return the oauth filter feature that can be used to configure client instances to perform authenticated requests to the Service Provider.

      The authorization process must be successfully finished by instance by calling methods OAuth2CodeGrantFlow.start() and OAuth2CodeGrantFlow.finish(String, String).

      Specified by:
      getOAuth2Feature in interface OAuth2CodeGrantFlow
      Returns:
      oauth filter feature configured with received AccessToken.