/
Authorisation Service (java)
NOTE: Trivore ID Documentation has moved to https://trivoreid.com
The content on this site IS OUT OF DATE!
This space has been archived!
Please go ahead to the new site!
Authorisation Service (java)
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());