Le service ACLService expose différentes opérations que vous pouvez effectuer sur les ACL :
getpermet de récupérer toutes les ACL du scope.createcrée une liste desecurityObjects. La liste des objets doit être fournie en entrée pour ensuite être créés dans l’application.getForComponentrécupère l’ACL d’un composant à partir de la catégorie et de l’identifiant de ce composant.getByIdrécupère les ACL à partir de la liste de leurs identifiants.updateByIdmet à jour les ACL à partir de leurs identifiants.deleteByIdsupprime les ACL à partir de leurs identifiants.
Récupération d’ACL
Les exemples ci-dessous indiquent comment récupérer des ACL en utilisant les différentes opérations de get.
GET :
# <CORE_HOST> URL de base de FlowerDocs Core
# <TOKEN> jeton d'authentification
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 :
# <CORE_HOST> URL de base de FlowerDocs Core
# <TOKEN> jeton d'authentification
# <CATEGORY> categorie du composant
# <IDS> identifiant du composant
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 :
# <CORE_HOST> URL de base de FlowerDocs Core
# <TOKEN> jeton d'authentification
# <IDS> identifiants des ACL a recuperer
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);
}
Création d’ACL
Les exemples ci-dessous indiquent comment créer des ACL en utilisant l’opération de create.
# <CORE_HOST> URL de base de FlowerDocs Core
# <TOKEN> jeton d'authentification
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": "Test d'\''ACL"
}
]'
@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"), "Test d'ACL", Lists.newArrayList(ace));
List<SecurityObject> acls = Lists.newArrayList(acl);
return service.create(acls);
}
Modification d’ACL
Les exemples ci-dessous indiquent comment mettre à jour des ACL en utilisant l’opération d’update.
# <CORE_HOST> URL de base de FlowerDocs Core
# <TOKEN> jeton d'authentification
# <IDS> identifiants des ACL à modifier
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": "Test d'\''ACL"
}
]'
@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-sortant"), "Securite courrier sortant",
Lists.newArrayList(ace));
List<SecurityObject> acls = Lists.newArrayList(acl);
return service.update(acls);
}
Suppression d’ACL
Les exemples ci-dessous indiquent comment supprimer des ACL en utilisant l’opération de delete.
# <CORE_HOST> URL de base de FlowerDocs Core
# <TOKEN> jeton d'authentification
# <IDS> identifiants des ACL à supprimer
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);
}