Java Code Examples for org.springframework.security.acls.model.MutableAcl#setOwner()

The following examples show how to use org.springframework.security.acls.model.MutableAcl#setOwner() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultCalendarService.java    From Spring-Security-Third-Edition with MIT License 6 votes vote down vote up
@Transactional
@Override
public int createEvent(Event event) {

    int result = eventDao.createEvent(event);
    event.setId(result);

    // Add new ACL Entry:
    MutableAcl acl = aclService.createAcl(new ObjectIdentityImpl(event));
    PrincipalSid sid = new PrincipalSid(userContext.getCurrentUser().getEmail());
    acl.setOwner(sid);
    acl.insertAce(0,  BasePermission.READ, sid, true);
    aclService.updateAcl(acl);

    return result;
}
 
Example 2
Source File: OwnershipDecorator.java    From molgenis with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void assignToOwner(Entity entity) {
  EntityIdentity entityIdentity = new EntityIdentity(entity);
  String ownerName = entity.getString(ownerAttributeName);
  LOG.debug("Assigning entity {} to owner {}...", entityIdentity, ownerName);
  Sid ownerSid = createUserSid(ownerName);
  MutableAcl acl = (MutableAcl) mutableAclService.readAclById(entityIdentity);
  acl.setOwner(ownerSid);
  removeAllEntries(acl);
  acl.insertAce(0, WRITE, ownerSid, true);

  mutableAclService.updateAcl(acl);
  LOG.info("Assigned entity {} to owner {}.", entityIdentity, ownerName);
}