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 void
checkPermission(NuxeoPrincipal principal)
protected void
checkUnicity(String clientId)
Checks if a client with theclientId
is unique.OAuth2Client
create(OAuth2Client oAuth2Client, NuxeoPrincipal principal)
Registers a new oAuth2 client as the given principal.void
delete(String clientId, NuxeoPrincipal principal)
Deletes an oAuth2 client as the given principal.protected <T> T
execute(Function<Session,T> function)
protected <T> T
execute(Function<Session,T> function, NuxeoPrincipal principal)
OAuth2Client
getClient(String clientId)
Gets the oAuth2 client with the given client id.protected DocumentModel
getClientModel(String clientId)
List<OAuth2Client>
getClients()
Gets all the oAuth2 clients.protected DocumentModel
getDocument(String clientId)
Gets the document model from a givenclientId
boolean
hasClient(String clientId)
Checks if an oAuth2 client with the given client id exists.boolean
isValidClient(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()
OAuth2Client
update(String clientId, OAuth2Client oAuth2Client, NuxeoPrincipal principal)
Updates an exiting oAuth2 client as the given principal.protected void
validate(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:OAuth2ClientService
Checks if an oAuth2 client with the given client id exists.Done as a privileged user.
- Specified by:
hasClient
in interfaceOAuth2ClientService
- Parameters:
clientId
- the client id of the oAuth2 client whose existence to check- Returns:
true
if an oAuth2 client with the given client id exists,false
otherwise
-
isValidClient
public boolean isValidClient(String clientId, String clientSecret)
Description copied from interface:OAuth2ClientService
Checks if the oAuth2 client with the given client id is valid regarding the given client secret.Done as a privileged user.
- Specified by:
isValidClient
in interfaceOAuth2ClientService
- Parameters:
clientId
- the client id of the oAuth2 client to validateclientSecret
- the client secret used for validation- Returns:
true
if the oAuth2 client with the given client id is valid regarding the given client secret,false
otherwise
-
getClient
public OAuth2Client getClient(String clientId)
Description copied from interface:OAuth2ClientService
Gets the oAuth2 client with the given client id.Done as a privileged user.
- Specified by:
getClient
in interfaceOAuth2ClientService
- Parameters:
clientId
- the client id of the oAuth2 client to get- Returns:
- the oAuth2 client with the given client id if it exists,
null
otherwise
-
getClients
public List<OAuth2Client> getClients()
Description copied from interface:OAuth2ClientService
Gets all the oAuth2 clients.Done as a privileged user.
- Specified by:
getClients
in interfaceOAuth2ClientService
- Returns:
- the oAuth2 clients
-
create
public OAuth2Client create(OAuth2Client oAuth2Client, NuxeoPrincipal principal)
Description copied from interface:OAuth2ClientService
Registers a new oAuth2 client as the given principal.- Specified by:
create
in interfaceOAuth2ClientService
- Parameters:
oAuth2Client
- theOAuth2Client
to registerprincipal
- the current user- Returns:
- the newly registered client
-
update
public OAuth2Client update(String clientId, OAuth2Client oAuth2Client, NuxeoPrincipal principal)
Description copied from interface:OAuth2ClientService
Updates an exiting oAuth2 client as the given principal.- Specified by:
update
in interfaceOAuth2ClientService
- Parameters:
clientId
- the client id of oAuth2Client to updateoAuth2Client
- the newOAuth2Client
dataprincipal
- the current user- Returns:
- the updated oAuth2Client
-
delete
public void delete(String clientId, NuxeoPrincipal principal)
Description copied from interface:OAuth2ClientService
Deletes an oAuth2 client as the given principal.- Specified by:
delete
in 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
. AnOAuth2Client
is 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 null
oAuth2Client to validate- Throws:
NullPointerException
- if the oAuth2Client isnull
NuxeoException
- if oAuth2Client is not valid- Since:
- 11.1
- It is not
-
checkUnicity
protected void checkUnicity(String clientId)
Checks if a client with theclientId
is unique.- Parameters:
clientId
- the client id to check- Throws:
NuxeoException
- if an oAuth2 client with the givenclientId
already 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
-
-