Class OAuth2ClientServiceImpl
- java.lang.Object
-
- org.nuxeo.runtime.model.DefaultComponent
-
- org.nuxeo.ecm.platform.oauth2.clients.OAuth2ClientServiceImpl
-
- All Implemented Interfaces:
OAuth2ClientService,Adaptable,Component,Extensible,TimestampedService
public class OAuth2ClientServiceImpl extends DefaultComponent implements OAuth2ClientService
OAuth2 Client service- Since:
- 9.2
-
-
Field Summary
-
Fields inherited from class org.nuxeo.runtime.model.DefaultComponent
lastModified, name
-
Fields inherited from interface org.nuxeo.ecm.platform.oauth2.clients.OAuth2ClientService
OAUTH2CLIENT_DIRECTORY_NAME, OAUTH2CLIENT_SCHEMA
-
-
Constructor Summary
Constructors Constructor Description OAuth2ClientServiceImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcheckPermission(NuxeoPrincipal principal)protected voidcheckUnicity(String clientId)Checks if a client with theclientIdis unique.OAuth2Clientcreate(OAuth2Client oAuth2Client, NuxeoPrincipal principal)Registers a new oAuth2 client as the given principal.voiddelete(String clientId, NuxeoPrincipal principal)Deletes an oAuth2 client as the given principal.protected <T> Texecute(Function<Session,T> function)protected <T> Texecute(Function<Session,T> function, NuxeoPrincipal principal)OAuth2ClientgetClient(String clientId)Gets the oAuth2 client with the given client id.protected DocumentModelgetClientModel(String clientId)List<OAuth2Client>getClients()Gets all the oAuth2 clients.protected DocumentModelgetDocument(String clientId)Gets the document model from a givenclientIdbooleanhasClient(String clientId)Checks if an oAuth2 client with the given client id exists.booleanisValidClient(String clientId, String clientSecret)Checks if the oAuth2 client with the given client id is valid regarding the given client secret.protected List<DocumentModel>queryClients()OAuth2Clientupdate(String clientId, OAuth2Client oAuth2Client, NuxeoPrincipal principal)Updates an exiting oAuth2 client as the given principal.protected voidvalidate(OAuth2Client oAuth2Client)Validates theOAuth2Client.-
Methods inherited from class org.nuxeo.runtime.model.DefaultComponent
activate, addRuntimeMessage, addRuntimeMessage, deactivate, getAdapter, getDescriptor, getDescriptors, getLastModified, getRegistry, register, registerContribution, registerExtension, setLastModified, setModifiedNow, setName, start, stop, unregister, unregisterContribution, unregisterExtension
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.nuxeo.runtime.model.Component
applicationStarted, getApplicationStartedOrder
-
-
-
-
Method Detail
-
hasClient
public boolean hasClient(String clientId)
Description copied from interface:OAuth2ClientServiceChecks if an oAuth2 client with the given client id exists.Done as a privileged user.
- Specified by:
hasClientin interfaceOAuth2ClientService- Parameters:
clientId- the client id of the oAuth2 client whose existence to check- Returns:
trueif an oAuth2 client with the given client id exists,falseotherwise
-
isValidClient
public boolean isValidClient(String clientId, String clientSecret)
Description copied from interface:OAuth2ClientServiceChecks if the oAuth2 client with the given client id is valid regarding the given client secret.Done as a privileged user.
- Specified by:
isValidClientin interfaceOAuth2ClientService- Parameters:
clientId- the client id of the oAuth2 client to validateclientSecret- the client secret used for validation- Returns:
trueif the oAuth2 client with the given client id is valid regarding the given client secret,falseotherwise
-
getClient
public OAuth2Client getClient(String clientId)
Description copied from interface:OAuth2ClientServiceGets the oAuth2 client with the given client id.Done as a privileged user.
- Specified by:
getClientin interfaceOAuth2ClientService- Parameters:
clientId- the client id of the oAuth2 client to get- Returns:
- the oAuth2 client with the given client id if it exists,
nullotherwise
-
getClients
public List<OAuth2Client> getClients()
Description copied from interface:OAuth2ClientServiceGets all the oAuth2 clients.Done as a privileged user.
- Specified by:
getClientsin interfaceOAuth2ClientService- Returns:
- the oAuth2 clients
-
create
public OAuth2Client create(OAuth2Client oAuth2Client, NuxeoPrincipal principal)
Description copied from interface:OAuth2ClientServiceRegisters a new oAuth2 client as the given principal.- Specified by:
createin interfaceOAuth2ClientService- Parameters:
oAuth2Client- theOAuth2Clientto registerprincipal- the current user- Returns:
- the newly registered client
-
update
public OAuth2Client update(String clientId, OAuth2Client oAuth2Client, NuxeoPrincipal principal)
Description copied from interface:OAuth2ClientServiceUpdates an exiting oAuth2 client as the given principal.- Specified by:
updatein interfaceOAuth2ClientService- Parameters:
clientId- the client id of oAuth2Client to updateoAuth2Client- the newOAuth2Clientdataprincipal- the current user- Returns:
- the updated oAuth2Client
-
delete
public void delete(String clientId, NuxeoPrincipal principal)
Description copied from interface:OAuth2ClientServiceDeletes an oAuth2 client as the given principal.- Specified by:
deletein interfaceOAuth2ClientService- Parameters:
clientId- the client id of the oAuth2Client to deleteprincipal- the current user
-
getClientModel
protected DocumentModel getClientModel(String clientId)
-
queryClients
protected List<DocumentModel> queryClients()
-
execute
protected <T> T execute(Function<Session,T> function, NuxeoPrincipal principal)
- Since:
- 11.1
-
checkPermission
protected void checkPermission(NuxeoPrincipal principal)
-
validate
protected void validate(OAuth2Client oAuth2Client)
Validates theOAuth2Client. AnOAuth2Clientis valid if and only if- It is not
null - The required fields are filled in:
OAuth2Client.getId(),OAuth2Client.getName(),OAuth2Client.getRedirectURIs() - The
OAuth2Client.getRedirectURIs()is a valid URI,OAuth2Client.isRedirectURIValid(String)
- Parameters:
oAuth2Client- thenot nulloAuth2Client to validate- Throws:
NullPointerException- if the oAuth2Client isnullNuxeoException- if oAuth2Client is not valid- Since:
- 11.1
- It is not
-
checkUnicity
protected void checkUnicity(String clientId)
Checks if a client with theclientIdis unique.- Parameters:
clientId- the client id to check- Throws:
NuxeoException- if an oAuth2 client with the givenclientIdalready exists- Since:
- 11.1
-
getDocument
protected DocumentModel getDocument(String clientId)
Gets the document model from a givenclientId- Parameters:
clientId- the oAuth client id- Throws:
NuxeoException- if there is no document model for the givenclientId- Since:
- 11.1
-
-