Ejemplo n.º 1
0
 /**
  * Delete permissions from {@code acl} for every sid.
  *
  * @param acl provided acl
  * @param sids list of sids
  * @param permissions list of permissions
  */
 private void deletePermissionsFromAcl(
     MutableAcl acl, List<Sid> sids, List<Permission> permissions) {
   List<AccessControlEntry> entries = acl.getEntries(); // it's copy
   int i = 0;
   // search for sid-permission pair
   for (AccessControlEntry entry : entries) {
     for (Sid recipient : sids) {
       for (Permission permission : permissions) {
         if (entry.getSid().equals(recipient) && entry.getPermission().equals(permission)) {
           acl.deleteAce(i); // delete from original list
           i--; // because list item deleted in original list
         }
       }
     }
     i++;
   }
 }
Ejemplo n.º 2
0
 private String getSid(AccessControlEntry ace) {
   Sid sid = ace.getSid();
   String sidName = ((PrincipalSid) sid).getPrincipal();
   Map<String, Object> map = new HashMap<String, Object>();
   map.put("principal", 0L);
   map.put("sid", sidName);
   List<AclSid> listAclSidVos = this.findBy("getSid", map);
   if (listAclSidVos == null || listAclSidVos.isEmpty()) {
     AclSid vo = new AclSid();
     vo.setId(this.getKeyGen().getUUIDKey());
     vo.setPrincipal(0L);
     vo.setSid(sidName);
     this.create("insert2", vo);
     return vo.getId();
   }
   return listAclSidVos.get(0).getId();
 }