Search in sources :

Example 21 with PrincipalSid

use of org.springframework.security.acls.domain.PrincipalSid in project spring-security by spring-projects.

the class SecureDocumentDaoImpl method create.

public void create(AbstractElement element) {
    super.create(element);
    // Create an ACL identity for this element
    ObjectIdentity identity = new ObjectIdentityImpl(element);
    MutableAcl acl = mutableAclService.createAcl(identity);
    // already exist)
    if (element.getParent() != null) {
        ObjectIdentity parentIdentity = new ObjectIdentityImpl(element.getParent());
        MutableAcl aclParent = (MutableAcl) mutableAclService.readAclById(parentIdentity);
        acl.setParent(aclParent);
    }
    acl.insertAce(acl.getEntries().size(), BasePermission.ADMINISTRATION, new PrincipalSid(SecurityContextHolder.getContext().getAuthentication()), true);
    mutableAclService.updateAcl(acl);
}
Also used : ObjectIdentity(org.springframework.security.acls.model.ObjectIdentity) ObjectIdentityImpl(org.springframework.security.acls.domain.ObjectIdentityImpl) MutableAcl(org.springframework.security.acls.model.MutableAcl) PrincipalSid(org.springframework.security.acls.domain.PrincipalSid)

Aggregations

PrincipalSid (org.springframework.security.acls.domain.PrincipalSid)21 Test (org.junit.Test)13 GrantedAuthoritySid (org.springframework.security.acls.domain.GrantedAuthoritySid)9 Sid (org.springframework.security.acls.model.Sid)9 ObjectIdentityImpl (org.springframework.security.acls.domain.ObjectIdentityImpl)8 MutableAcl (org.springframework.security.acls.model.MutableAcl)8 Authentication (org.springframework.security.core.Authentication)8 TestingAuthenticationToken (org.springframework.security.authentication.TestingAuthenticationToken)7 ObjectIdentity (org.springframework.security.acls.model.ObjectIdentity)6 BasePermission (org.springframework.security.acls.domain.BasePermission)5 Permission (org.springframework.security.acls.model.Permission)5 Transactional (org.springframework.transaction.annotation.Transactional)5 Acl (org.springframework.security.acls.model.Acl)3 HashMap (java.util.HashMap)2 AclImpl (org.springframework.security.acls.domain.AclImpl)2 CumulativePermission (org.springframework.security.acls.domain.CumulativePermission)2 SidRetrievalStrategyImpl (org.springframework.security.acls.domain.SidRetrievalStrategyImpl)2 NotFoundException (org.springframework.security.acls.model.NotFoundException)2 SidRetrievalStrategy (org.springframework.security.acls.model.SidRetrievalStrategy)2 CustomSid (org.springframework.security.acls.sid.CustomSid)2