@@ -0,0 +1,2729 @@
+package de.terrestris.shogun2.security.acl;%0A%0Aimport javax.sql.DataSource;%0A%0Aimport org.springframework.security.acls.domain.PrincipalSid;%0Aimport org.springframework.security.acls.jdbc.JdbcMutableAclService;%0Aimport org.springframework.security.acls.jdbc.LookupStrategy;%0Aimport org.springframework.security.acls.model.Acl;%0Aimport org.springframework.security.acls.model.AclCache;%0Aimport org.springframework.security.acls.model.AlreadyExistsException;%0Aimport org.springframework.security.acls.model.MutableAcl;%0Aimport org.springframework.security.acls.model.ObjectIdentity;%0Aimport org.springframework.security.core.Authentication;%0Aimport org.springframework.security.core.context.SecurityContextHolder;%0Aimport org.springframework.util.Assert;%0A%0Aimport de.terrestris.shogun2.model.User;%0A%0A/**%0A * @author Nils B%C3%BChner%0A * %0A */%0Apublic class Shogun2JdbcMutableAclService extends JdbcMutableAclService %7B%0A%0A%09/**%0A%09 * Just call the parent constructor.%0A%09 * %0A%09 * @param dataSource%0A%09 * @param lookupStrategy%0A%09 * @param aclCache%0A%09 */%0A%09public Shogun2JdbcMutableAclService(DataSource dataSource,%0A%09%09%09LookupStrategy lookupStrategy, AclCache aclCache) %7B%0A%09%09super(dataSource, lookupStrategy, aclCache);%0A%09%7D%0A%0A%09/**%0A%09 * Almost the same implementation as in parent class, except that we take%0A%09 * care in case that the principal object of the authentication object is a%0A%09 * SHOGun2 user object.%0A%09 * %0A%09 * Behaves like the parent class if the principal is not of type%0A%09 * %7B@link User%7D.%0A%09 */%0A%09@Override%0A%09public MutableAcl createAcl(ObjectIdentity objectIdentity)%0A%09%09%09throws AlreadyExistsException %7B%0A%09%09Assert.notNull(objectIdentity, %22Object Identity required%22);%0A%0A%09%09// Check this object identity hasn't already been persisted%0A%09%09if (retrieveObjectIdentityPrimaryKey(objectIdentity) != null) %7B%0A%09%09%09throw new AlreadyExistsException(%22Object identity '%22%0A%09%09%09%09%09+ objectIdentity + %22' already exists%22);%0A%09%09%7D%0A%0A%09%09// Need to retrieve the current principal, in order to know who %22owns%22%0A%09%09// this ACL (can be changed later on)%0A%09%09Authentication auth = SecurityContextHolder.getContext()%0A%09%09%09%09.getAuthentication();%0A%09%09Object principal = auth.getPrincipal();%0A%0A%09%09PrincipalSid sid;%0A%09%09// check if principal is a SHOGun2 user%0A%09%09if (principal instanceof User) %7B%0A%09%09%09// User the accountName to create the PrincipalSid%0A%09%09%09sid = new PrincipalSid(((User) principal).getAccountName());%0A%09%09%7D else %7B%0A%09%09%09// default behaviour%0A%09%09%09sid = new PrincipalSid(auth);%0A%09%09%7D%0A%0A%09%09// Create the acl_object_identity row%0A%09%09createObjectIdentity(objectIdentity, sid);%0A%0A%09%09// Retrieve the ACL via superclass (ensures cache registration, proper%0A%09%09// retrieval etc)%0A%09%09Acl acl = readAclById(objectIdentity);%0A%09%09Assert.isInstanceOf(MutableAcl.class, acl,%0A%09%09%09%09%22MutableAcl should be been returned%22);%0A%0A%09%09return (MutableAcl) acl;%0A%09%7D%0A%0A%7D%0A

Add custom ACL service.