Authorisation Service
If you need more information on this subject, please, see Authorisations.
List of all options:
- Authorisations management
- Authorisation types management
- Authorisation sources management
- Authorisation grant right management (OIDC only)
Initialize service
TrivoreID sdk = TrivoreID.mgmtApiClient();
AuthorisationServiceImpl authorisationService = new AuthorisationServiceImpl(sdk.authorisationService());
Authorisations management
// Get list of all authorizations
Page<Authorisation> page = authorisationService.getAll();
// Apply filter
Filter filter = Filter.equal("nsCode", "exampleCode");
authorisationService.getAll(new Criteria(filter));
// Add new Authorisation
Page<AuthorisationType> types = authorisationService.getAllTypes();
Authorisation auth = new Authorisation();
auth.setNsCode(types.getResources().get(0).getNsCode());
// Authorisation type field is required
auth.setAuthType(types.getResources().get(0).getCode());
// This method returns authorisation object with the generated ID
auth = authorisationService.create(auth);
// Revoke Authorization
authorisationService.revoke(auth.getId());
// Get one, Update and Delete
auth = authorisationService.get(auth.getId());
auth.setValidFrom("2017-10-20T07:17:17.606Z");
authorisationService.update(auth);
authorisationService.delete(auth.getId());
Authorisation types management
// Get list of all authorization types
Page<AuthorisationType> page = authorisationService.getAllTypes();
// Apply filter
filter = Filter.contains("code", "example");
page = authorisationService.getAllTypes(new Criteria(filter));
// Add new Authorisation Type
AuthorisationType type = new AuthorisationType();
type.setCode("exampleType");
// This method returns authorisation type object with the generated ID
type = authorisationService.createType(type);
// Get one, Update and Delete
type = authorisationService.getType(type.getId());
type.setDescription("Example description.");
authorisationService.updateType(type);
authorisationService.deleteType(type.getId());
Authorisation sources management
// Get list of all authorization sources
Page<AuthorisationType> sources = authorisationService.getAllSources();
// Apply filter
filter = Filter.contains("code", "example");
authorisationService.getAllSources(new Criteria(filter));
// Add new Authorisation Type
AuthorisationType source = new AuthorisationType();
source.setCode("exampleSource");
// This method returns authorisation type object with the generated ID
source = authorisationService.createSource(source);
// Get one, Update and Delete
source = authorisationService.getSource(source.getId());
source.setDescription("Example source description.");
authorisationService.updateSource(source);
authorisationService.deleteSource(source.getId());
Authorization grant right management
// Get list of all authorization grant rights
Page<AuthorisationGrantRight> page = authorisationService.getAllGrantRights();
// Apply filter
filter = Filter.equal("id", "exampleId");
page = authorisationService.getAllGrantRights(new Criteria(filter));
// Add new Authorisation Type
AuthorisationGrantRight right = new AuthorisationGrantRight();
right.getPrincipal().setType("User");
right.getPrincipal().setValue(userId);
// This method returns authorisation grant right object with the generated ID
right = authorisationService.createGrantRight(right);
// Get one and revoke
right = authorisationService.getGrantRight(right.getId());
authorisationService.revokeGrantRight(right.getId());