List of usage examples for org.springframework.security.acls.model MutableAcl updateAce
void updateAce(int aceIndex, Permission permission) throws NotFoundException;
From source file:com.cedac.security.acls.mongo.MongoMutableAclServiceTests.java
@Test @ShouldMatchDataSet//from w w w.j av a 2 s . co m public void updateAcl_updateEntries() { MutableAcl acl = (MutableAcl) fixture .readAclById(new ObjectIdentityImpl("com.cedac.smartresidence.profile.domain.Home", "1")); acl.updateAce(2, BasePermission.DELETE); fixture.updateAcl(acl); }
From source file:org.apache.kylin.rest.service.AccessService.java
@Transactional @PreAuthorize(Constant.ACCESS_HAS_ROLE_ADMIN + " or hasPermission(#ae, 'ADMINISTRATION')") public Acl grant(AclEntity ae, Permission permission, Sid sid) { Message msg = MsgPicker.getMsg();// w ww. jav a 2 s. c o m if (ae == null) throw new BadRequestException(msg.getACL_DOMAIN_NOT_FOUND()); if (permission == null) throw new BadRequestException(msg.getACL_PERMISSION_REQUIRED()); if (sid == null) throw new BadRequestException(msg.getSID_REQUIRED()); ObjectIdentity objectIdentity = new ObjectIdentityImpl(ae.getClass(), ae.getId()); MutableAcl acl = null; try { acl = (MutableAcl) aclService.readAclById(objectIdentity); } catch (NotFoundException e) { acl = (MutableAcl) init(ae, null); } int indexOfAce = -1; for (int i = 0; i < acl.getEntries().size(); i++) { AccessControlEntry ace = acl.getEntries().get(i); if (ace.getSid().equals(sid)) { indexOfAce = i; } } if (indexOfAce != -1) { secureOwner(acl, indexOfAce); acl.updateAce(indexOfAce, permission); } else { acl.insertAce(acl.getEntries().size(), permission, sid, true); } acl = aclService.updateAcl(acl); return acl; }
From source file:org.apache.kylin.rest.service.AccessService.java
@Transactional @PreAuthorize(Constant.ACCESS_HAS_ROLE_ADMIN + " or hasPermission(#ae, 'ADMINISTRATION')") public Acl update(AclEntity ae, Long accessEntryId, Permission newPermission) { Message msg = MsgPicker.getMsg();// www. java 2 s . com if (ae == null) throw new BadRequestException(msg.getACL_DOMAIN_NOT_FOUND()); if (accessEntryId == null) throw new BadRequestException(msg.getACE_ID_REQUIRED()); if (newPermission == null) throw new BadRequestException(msg.getACL_PERMISSION_REQUIRED()); ObjectIdentity objectIdentity = new ObjectIdentityImpl(ae.getClass(), ae.getId()); MutableAcl acl = (MutableAcl) aclService.readAclById(objectIdentity); int indexOfAce = -1; for (int i = 0; i < acl.getEntries().size(); i++) { AccessControlEntry ace = acl.getEntries().get(i); if (ace.getId().equals(accessEntryId)) { indexOfAce = i; break; } } if (indexOfAce != -1) { secureOwner(acl, indexOfAce); try { acl.updateAce(indexOfAce, newPermission); acl = aclService.updateAcl(acl); } catch (NotFoundException e) { //do nothing? } } return acl; }