Class OAuth2Object

All Implemented Interfaces:
Resource, Adaptable

public class OAuth2Object extends AbstractResource<ResourceTypeImpl>
Endpoint to retrieve OAuth2 authentication data
Since:
8.4
  • Field Details

  • Constructor Details

    • OAuth2Object

      public OAuth2Object()
  • Method Details

    • getProviders

      public List<NuxeoOAuth2ServiceProvider> getProviders(@Context javax.servlet.http.HttpServletRequest request)
      Lists all oauth2 service providers.
      Since:
      9.2
    • getProvider

      public javax.ws.rs.core.Response getProvider(String providerId, @Context javax.servlet.http.HttpServletRequest request)
      Retrieves oauth2 data for a given provider.
    • addProvider

      public javax.ws.rs.core.Response addProvider(@Context javax.servlet.http.HttpServletRequest request, NuxeoOAuth2ServiceProvider provider)
      Creates a new OAuth2 service provider.
      Since:
      9.2
    • updateProvider

      public javax.ws.rs.core.Response updateProvider(String providerId, @Context javax.servlet.http.HttpServletRequest request, NuxeoOAuth2ServiceProvider provider)
      Updates an OAuth2 service provider.
      Since:
      9.2
    • deleteProvider

      public javax.ws.rs.core.Response deleteProvider(String providerId, @Context javax.servlet.http.HttpServletRequest request)
      Deletes an OAuth2 service provider.
      Since:
      9.2
    • getToken

      public javax.ws.rs.core.Response getToken(String providerId, @Context javax.servlet.http.HttpServletRequest request) throws IOException
      Retrieves a valid access token for a given provider and the current user. If expired, the token will be refreshed.
      Throws:
      IOException
    • getTokens

      public List<NuxeoOAuth2Token> getTokens(@Context javax.servlet.http.HttpServletRequest request)
      Retrieves all OAuth2 tokens.
      Since:
      9.2
    • getTokens

      public List<NuxeoOAuth2Token> getTokens(NuxeoOAuth2TokenType type)
      Retrieves all oAuth2 tokens by NuxeoOAuth2TokenType.
      Parameters:
      type - , the value of NuxeoOAuth2TokenType
      Returns:
      if type is NuxeoOAuth2TokenType.AS_PROVIDER, then we retrieve tokens that are provided by Nuxeo, otherwise those used by Nuxeo to connect to others applications
      Since:
      11.1
    • searchTokens

      public List<NuxeoOAuth2Token> searchTokens(String query)
      Search all oAuth2 tokens that match the query.
      Parameters:
      query - the query to match
      Since:
      11.1
    • getProviderToken

      public javax.ws.rs.core.Response getProviderToken(String providerId, String nxuser, @Context javax.servlet.http.HttpServletRequest request)
      Retrieves an OAuth2 provider token.
      Since:
      10.2
    • getToken

      @Deprecated public javax.ws.rs.core.Response getToken(String providerId, String nxuser, @Context javax.servlet.http.HttpServletRequest request)
      Deprecated.
      Retrieves an OAuth2 Token.
      Since:
      9.2
    • updateProviderToken

      public javax.ws.rs.core.Response updateProviderToken(String providerId, String nxuser, @Context javax.servlet.http.HttpServletRequest request, NuxeoOAuth2Token token)
      Updates an OAuth2 provider token.
      Since:
      10.2
    • updateToken

      @Deprecated public javax.ws.rs.core.Response updateToken(String providerId, String nxuser, @Context javax.servlet.http.HttpServletRequest request, NuxeoOAuth2Token token)
      Updates an OAuth2 Token.
      Since:
      9.2
    • deleteProviderToken

      public javax.ws.rs.core.Response deleteProviderToken(String providerId, String nxuser, @Context javax.servlet.http.HttpServletRequest request)
      Deletes an OAuth2 provider token.
      Since:
      10.2
    • deleteToken

      @Deprecated public javax.ws.rs.core.Response deleteToken(String providerId, String nxuser, @Context javax.servlet.http.HttpServletRequest request)
      Deprecated.
      Deletes an OAuth2 Token.
      Since:
      9.2
    • getProviderUserTokens

      public List<NuxeoOAuth2Token> getProviderUserTokens(@Context javax.servlet.http.HttpServletRequest request)
      Retrieves all oauth2 provider tokens for the current user.
      Since:
      10.2
    • getClientUserTokens

      public List<NuxeoOAuth2Token> getClientUserTokens(@Context javax.servlet.http.HttpServletRequest request)
      Retrieves all oauth2 client tokens for the current user.
      Since:
      10.2
    • getClientToken

      public javax.ws.rs.core.Response getClientToken(String clientId, String nxuser, @Context javax.servlet.http.HttpServletRequest request)
      Retrieves a oauth2 client token.
      Since:
      10.2
    • updateClientToken

      public javax.ws.rs.core.Response updateClientToken(String clientId, String nxuser, @Context javax.servlet.http.HttpServletRequest request, NuxeoOAuth2Token token)
      Updates an OAuth2 client token.
      Since:
      10.2
    • deleteClientToken

      public javax.ws.rs.core.Response deleteClientToken(String clientId, String nxuser, @Context javax.servlet.http.HttpServletRequest request)
      Deletes a oauth2 client token.
      Since:
      10.2
    • getClients

      public List<OAuth2Client> getClients(@Context javax.servlet.http.HttpServletRequest request)
      Retrieves oauth2 clients.
      Since:
      10.2
    • getClient

      public javax.ws.rs.core.Response getClient(String clientId, @Context javax.servlet.http.HttpServletRequest request)
      Retrieves a oauth2 client.
      Since:
      10.2
    • createClient

      public javax.ws.rs.core.Response createClient(OAuth2Client client)
      Creates a new oauth2 client.
      Parameters:
      client - the oAuth2Client to create
      Returns:
      the Response
      Since:
      11.1
    • updateClient

      public javax.ws.rs.core.Response updateClient(String clientId, OAuth2Client client)
      Updates the oauth2 client.
      Parameters:
      clientId - the oAuth2 client id to update
      client - the oAuth2Client to update
      Returns:
      the Response
      Since:
      11.1
    • deleteClient

      public javax.ws.rs.core.Response deleteClient(String clientId)
      Deletes the oauth2 client.
      Parameters:
      clientId - the oAuth2 client id to delete
      Returns:
      the Response
      Since:
      11.1
    • getProviders

      protected List<NuxeoOAuth2ServiceProvider> getProviders()
    • getProvider

      protected NuxeoOAuth2ServiceProvider getProvider(String providerId)
    • getTokens

      @Deprecated(since="11.1", forRemoval=true) protected List<NuxeoOAuth2Token> getTokens()
      Deprecated, for removal: This API element is subject to removal in a future version.
    • getTokens

      @Deprecated(since="11.1", forRemoval=true) protected List<NuxeoOAuth2Token> getTokens(String nxuser)
      Deprecated, for removal: This API element is subject to removal in a future version.
      since 11.1. Use OAuth2TokenService.getTokens(String) instead.
    • getClient

      protected OAuth2Client getClient(String clientId)
    • getTokenDoc

      protected DocumentModel getTokenDoc(NuxeoOAuth2ServiceProvider provider, String nxuser)
    • getTokenDoc

      protected DocumentModel getTokenDoc(OAuth2Client client, String nxuser)
    • getToken

      protected NuxeoOAuth2Token getToken(NuxeoOAuth2ServiceProvider provider, String nxuser)
    • getToken

      protected NuxeoOAuth2Token getToken(OAuth2Client client, String nxuser)
    • updateToken

      protected NuxeoOAuth2Token updateToken(NuxeoOAuth2ServiceProvider provider, String nxuser, NuxeoOAuth2Token token)
    • updateToken

      protected NuxeoOAuth2Token updateToken(OAuth2Client client, String nxuser, NuxeoOAuth2Token token)
    • updateTokenDoc

      protected void updateTokenDoc(NuxeoOAuth2Token token, DocumentModel entry)
    • deleteToken

      protected void deleteToken(DocumentModel token)
    • getCredential

      protected com.google.api.client.auth.oauth2.Credential getCredential(NuxeoOAuth2ServiceProvider provider, NuxeoOAuth2Token token)
    • buildResponse

      protected javax.ws.rs.core.Response buildResponse(javax.ws.rs.core.Response.StatusType status, Object obj) throws IOException
      Throws:
      IOException
    • checkPermission

      protected void checkPermission()
    • checkPermission

      protected void checkPermission(String nxuser)
    • checkNotAnonymousUser

      protected void checkNotAnonymousUser()
    • getPrincipal

      protected NuxeoPrincipal getPrincipal()