The ACLService service displays various operations you can perform on ACLs:
-
getretrieves all ACLs in the scope. -
createcreates a list ofsecurityObjects. The list of objects must be supplied as input, before they can be created in the application. -
getForComponentretrieves a component's ACL from the component's category and identifier. -
getByIdretrieves ACLs from the list of their identifiers. -
updateByIdupdates ACLs using their identifiers. -
deleteByIddeletes ACLs based on their identifiers.
ACL recovery
The examples below show how to retrieve ACLs using the various operations of get.
GET:
- REST
- JAVA
# <CORE_HOST> FlowerDocs Core base URL
# <TOKEN> authentication token
curl -X GET "<CORE_HOST>/rest/acl/" \
-H "token: <TOKEN>"
@Autowired
private ACLService service;
public List<SecurityObject> getAllAcl() throws TechnicalException, FunctionalException
{
return service.getAll();
}
GET FOR COMPONENT:
- REST
- JAVA
# <CORE_HOST> FlowerDocs Core base URL
# <TOKEN> authentication token
# <CATEGORY> component category
# <IDS> component identifier
curl -X GET "<CORE_HOST>/rest/acl/<CATEGORY>/<IDS>" \
-H "token: <TOKEN>"
@Autowired
private ACLService service;
public SecurityObject getForComponentAcl() throws FunctionalException, TechnicalException
{
ComponentReference component = new ComponentReference();
component.setId(new Id("c1ec8407-c1ba-4802-bc03-a99c9cfb5b9e"));
component.setCategory(Category.DOCUMENT);
return service.getForComponent(component);
}
GET BY ID:
- REST
- JAVA
# <CORE_HOST> FlowerDocs Core base URL
# <TOKEN> authentication token
# <IDS> identifiers of ACLs to retrieve
curl -X GET "<CORE_HOST>/rest/acl/<IDS>" \
-H "token: <TOKEN>"
@Autowired
private ACLService service;
public List<SecurityObject> get() throws FunctionalException, TechnicalException
{
List<Id> ids = Lists.newArrayList(new Id("acl-admin"));
return service.get(ids);
}
ACL creation
The examples below show how to create ACLs using the operation of create.
- REST
- JAVA
# <CORE_HOST> FlowerDocs Core base URL
# <TOKEN> authentication token
curl -X POST "<CORE_HOST>/rest/acl/" \
-H "token: <TOKEN>" \
-H "Content-Type: application/json" \
-d '[
{
"entries": [
{
"principal": "*",
"permission": "UPDATE_CONTENT",
"grant": "ALLOW"
}],
"id": "acl_test",
"name": "ACL test"
}
]'
@Autowired
private ACLService service;
public List<SecurityObject> create() throws FunctionalException, TechnicalException
{
AccessControlEntry ace = new AccessControlEntry(Lists.newArrayList("*"),
Lists.newArrayList(Permission.UPDATE_CONTENT), GrantType.ALLOW);
SecurityObject acl = new AccessControlList(new Id("acl_test"), "ACL Test", Lists.newArrayList(ace));
List<SecurityObject> acls = Lists.newArrayList(acl);
return service.create(acls);
}
ACL modification
The examples below show how to update ACLs using the operation ofupdate.
- REST
- JAVA
# <CORE_HOST> FlowerDocs Core base URL
# <TOKEN> authentication token
# <IDS> identifiers of ACLs to be modified
curl -X POST "<CORE_HOST>/rest/acl/<IDS>" \
-H "token: <TOKEN>" \
-H "Content-Type: application/json" \
-d '[
{
"entries": [
{
"principal": "*",
"permission": "UPDATE_CONTENT",
"grant": "DENY"
}],
"id": "acl_test",
"name": "ACL test"
}
]'
@Autowired
private ACLService service;
public List<SecurityObject> update() throws FunctionalException, TechnicalException
{
AccessControlEntry ace = new AccessControlEntry(Lists.newArrayList("*"),
Lists.newArrayList(Permission.UPDATE_CONTENT), GrantType.DENY);
SecurityObject acl = new AccessControlList(new Id("acl-courrier-outgoing"), "Outgoing mail security",
Lists.newArrayList(ace));
List<SecurityObject> acls = Lists.newArrayList(acl);
return service.update(acls);
}
Deleting ACL
The examples below show how to delete ACLs using the operation of delete.
- REST
- JAVA
# <CORE_HOST> FlowerDocs Core base URL
# <TOKEN> authentication token
# <IDS> identifiers of ACLs to be deleted
curl -X DELETE "<CORE_HOST>/rest/acl/<IDS>" \
-H "token: <TOKEN>"
@Autowired
private ACLService service;
public void delete() throws FunctionalException, TechnicalException
{
List<Id> ids = Lists.newArrayList(new Id("acl_test"));
service.delete(ids);
}