Class OAuth2Object
- java.lang.Object
-
- org.nuxeo.ecm.webengine.model.impl.AbstractResource<ResourceTypeImpl>
-
- org.nuxeo.ecm.restapi.server.jaxrs.OAuth2Object
-
public class OAuth2Object extends AbstractResource<ResourceTypeImpl>
Endpoint to retrieve OAuth2 authentication data- Since:
- 8.4
-
-
Field Summary
Fields Modifier and Type Field Description protected static String
ACCESS_DENIED_MESSAGE
static String
TOKEN_DIR
Deprecated, for removal: This API element is subject to removal in a future version.since 11.1.
-
Constructor Summary
Constructors Constructor Description OAuth2Object()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description javax.ws.rs.core.Response
addProvider(javax.servlet.http.HttpServletRequest request, NuxeoOAuth2ServiceProvider provider)
Creates a new OAuth2 service provider.protected javax.ws.rs.core.Response
buildResponse(javax.ws.rs.core.Response.StatusType status, Object obj)
protected void
checkNotAnonymousUser()
protected void
checkPermission()
protected void
checkPermission(String nxuser)
javax.ws.rs.core.Response
createClient(OAuth2Client client)
Creates a new oauth2 client.javax.ws.rs.core.Response
deleteClient(String clientId)
Deletes the oauth2 client.javax.ws.rs.core.Response
deleteClientToken(String clientId, String nxuser, javax.servlet.http.HttpServletRequest request)
Deletes a oauth2 client token.javax.ws.rs.core.Response
deleteProvider(String providerId, javax.servlet.http.HttpServletRequest request)
Deletes an OAuth2 service provider.javax.ws.rs.core.Response
deleteProviderToken(String providerId, String nxuser, javax.servlet.http.HttpServletRequest request)
Deletes an OAuth2 provider token.javax.ws.rs.core.Response
deleteToken(String providerId, String nxuser, javax.servlet.http.HttpServletRequest request)
Deprecated.since 10.2 UsedeleteProviderToken(String, String, HttpServletRequest)
instead.protected void
deleteToken(DocumentModel token)
protected OAuth2Client
getClient(String clientId)
javax.ws.rs.core.Response
getClient(String clientId, javax.servlet.http.HttpServletRequest request)
Retrieves a oauth2 client.List<OAuth2Client>
getClients(javax.servlet.http.HttpServletRequest request)
Retrieves oauth2 clients.javax.ws.rs.core.Response
getClientToken(String clientId, String nxuser, javax.servlet.http.HttpServletRequest request)
Retrieves a oauth2 client token.List<NuxeoOAuth2Token>
getClientUserTokens(javax.servlet.http.HttpServletRequest request)
Retrieves all oauth2 client tokens for the current user.protected com.google.api.client.auth.oauth2.Credential
getCredential(NuxeoOAuth2ServiceProvider provider, NuxeoOAuth2Token token)
protected NuxeoPrincipal
getPrincipal()
protected NuxeoOAuth2ServiceProvider
getProvider(String providerId)
javax.ws.rs.core.Response
getProvider(String providerId, javax.servlet.http.HttpServletRequest request)
Retrieves oauth2 data for a given provider.protected List<NuxeoOAuth2ServiceProvider>
getProviders()
List<NuxeoOAuth2ServiceProvider>
getProviders(javax.servlet.http.HttpServletRequest request)
Lists all oauth2 service providers.javax.ws.rs.core.Response
getProviderToken(String providerId, String nxuser, javax.servlet.http.HttpServletRequest request)
Retrieves an OAuth2 provider token.List<NuxeoOAuth2Token>
getProviderUserTokens(javax.servlet.http.HttpServletRequest request)
Retrieves all oauth2 provider tokens for the current user.javax.ws.rs.core.Response
getToken(String providerId, String nxuser, javax.servlet.http.HttpServletRequest request)
Deprecated.since 10.2 UsegetProviderToken(String, String, HttpServletRequest)
instead.javax.ws.rs.core.Response
getToken(String providerId, javax.servlet.http.HttpServletRequest request)
Retrieves a valid access token for a given provider and the current user.protected NuxeoOAuth2Token
getToken(OAuth2Client client, String nxuser)
protected NuxeoOAuth2Token
getToken(NuxeoOAuth2ServiceProvider provider, String nxuser)
protected DocumentModel
getTokenDoc(OAuth2Client client, String nxuser)
protected DocumentModel
getTokenDoc(NuxeoOAuth2ServiceProvider provider, String nxuser)
protected List<NuxeoOAuth2Token>
getTokens()
Deprecated, for removal: This API element is subject to removal in a future version.since 11.1.protected List<NuxeoOAuth2Token>
getTokens(String nxuser)
Deprecated, for removal: This API element is subject to removal in a future version.since 11.1.List<NuxeoOAuth2Token>
getTokens(javax.servlet.http.HttpServletRequest request)
Retrieves all OAuth2 tokens.List<NuxeoOAuth2Token>
getTokens(NuxeoOAuth2TokenType type)
Retrieves all oAuth2 tokens byNuxeoOAuth2TokenType
.List<NuxeoOAuth2Token>
searchTokens(String query)
Search all oAuth2 tokens that match the query.javax.ws.rs.core.Response
updateClient(String clientId, OAuth2Client client)
Updates the oauth2 client.javax.ws.rs.core.Response
updateClientToken(String clientId, String nxuser, javax.servlet.http.HttpServletRequest request, NuxeoOAuth2Token token)
Updates an OAuth2 client token.javax.ws.rs.core.Response
updateProvider(String providerId, javax.servlet.http.HttpServletRequest request, NuxeoOAuth2ServiceProvider provider)
Updates an OAuth2 service provider.javax.ws.rs.core.Response
updateProviderToken(String providerId, String nxuser, javax.servlet.http.HttpServletRequest request, NuxeoOAuth2Token token)
Updates an OAuth2 provider token.javax.ws.rs.core.Response
updateToken(String providerId, String nxuser, javax.servlet.http.HttpServletRequest request, NuxeoOAuth2Token token)
Deprecated.since 10.2 UseupdateProviderToken(String, String, HttpServletRequest, NuxeoOAuth2Token)
instead.protected NuxeoOAuth2Token
updateToken(OAuth2Client client, String nxuser, NuxeoOAuth2Token token)
protected NuxeoOAuth2Token
updateToken(NuxeoOAuth2ServiceProvider provider, String nxuser, NuxeoOAuth2Token token)
protected void
updateTokenDoc(NuxeoOAuth2Token token, DocumentModel entry)
-
Methods inherited from class org.nuxeo.ecm.webengine.model.impl.AbstractResource
checkGuard, dispose, getActiveAdapter, getAdapter, getContext, getFacets, getLinks, getModule, getName, getNext, getNextSegment, getPath, getPrevious, getTemplate, getTrailingPath, getType, getURL, getView, hasFacet, initialize, initialize, isAdapter, isInstanceOf, isRoot, newAdapter, newObject, redirect, setNext, setPrevious, setRoot, toString
-
-
-
-
Field Detail
-
ACCESS_DENIED_MESSAGE
protected static final String ACCESS_DENIED_MESSAGE
- See Also:
- Constant Field Values
-
TOKEN_DIR
@Deprecated(since="11.1", forRemoval=true) public static final String TOKEN_DIR
Deprecated, for removal: This API element is subject to removal in a future version.since 11.1. UseOAuth2TokenServiceImpl.TOKEN_DIR
instead.- See Also:
- Constant Field Values
-
-
Method Detail
-
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 byNuxeoOAuth2TokenType
.- Parameters:
type
- , the value ofNuxeoOAuth2TokenType
- Returns:
- if
type
isNuxeoOAuth2TokenType.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.since 10.2 UsegetProviderToken(String, String, HttpServletRequest)
instead.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)
Deprecated.since 10.2 UseupdateProviderToken(String, String, HttpServletRequest, NuxeoOAuth2Token)
instead.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.since 10.2 UsedeleteProviderToken(String, String, HttpServletRequest)
instead.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 updateclient
- 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.since 11.1. UseOAuth2TokenService.getTokens(NuxeoPrincipal)
instead.
-
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. UseOAuth2TokenService.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()
-
-