@Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("AclImpl["); sb.append("id: ").append(this.id).append("; "); sb.append("objectIdentity: ").append(this.objectIdentity).append("; "); sb.append("owner: ").append(this.owner).append("; "); int count = 0; for (AccessControlEntry ace : aces) { count++; if (count == 1) { sb.append("\n"); } sb.append(ace).append("\n"); } if (count == 0) { sb.append("no ACEs; "); } sb.append("inheriting: ").append(this.entriesInheriting).append("; "); sb.append("parent: ").append( (this.parentAcl == null) ? "Null" : this.parentAcl.getObjectIdentity() .toString()); sb.append("; "); sb.append("aclAuthorizationStrategy: ").append(this.aclAuthorizationStrategy) .append("; "); sb.append("permissionGrantingStrategy: ").append(this.permissionGrantingStrategy); sb.append("]"); return sb.toString(); }
result.put(acl.getObjectIdentity(), acl); aclFound = true;
resultMap.put(result.getObjectIdentity(), result);
if (this.acl.getObjectIdentity() == null) { if (rhs.acl.getObjectIdentity() != null) { return false; if (!this.acl.getObjectIdentity() .equals(rhs.getAcl().getObjectIdentity())) { return false;
@Test public void testAllParentsAreRetrievedWhenChildIsLoaded() throws Exception { String query = "INSERT INTO acl_object_identity(ID,OBJECT_ID_CLASS,OBJECT_ID_IDENTITY,PARENT_OBJECT,OWNER_SID,ENTRIES_INHERITING) VALUES (6,2,103,1,1,1);"; getJdbcTemplate().execute(query); ObjectIdentity topParentOid = new ObjectIdentityImpl(TARGET_CLASS, Long.valueOf(100)); ObjectIdentity middleParentOid = new ObjectIdentityImpl(TARGET_CLASS, Long.valueOf(101)); ObjectIdentity childOid = new ObjectIdentityImpl(TARGET_CLASS, Long.valueOf(102)); ObjectIdentity middleParent2Oid = new ObjectIdentityImpl(TARGET_CLASS, Long.valueOf(103)); // Retrieve the child Map<ObjectIdentity, Acl> map = this.strategy.readAclsById(Arrays.asList(childOid), null); // Check that the child and all its parents were retrieved assertThat(map.get(childOid)).isNotNull(); assertThat(map.get(childOid).getObjectIdentity()).isEqualTo(childOid); assertThat(map.get(middleParentOid)).isNotNull(); assertThat(map.get(middleParentOid).getObjectIdentity()).isEqualTo(middleParentOid); assertThat(map.get(topParentOid)).isNotNull(); assertThat(map.get(topParentOid).getObjectIdentity()).isEqualTo(topParentOid); // The second parent shouldn't have been retrieved assertThat(map.get(middleParent2Oid)).isNull(); }
/** * Updates an existing acl_object_identity row, with new information presented in the * passed MutableAcl object. Also will create an acl_sid entry if needed for the Sid * that owns the MutableAcl. * * @param acl to modify (a row must already exist in acl_object_identity) * * @throws NotFoundException if the ACL could not be found to update. */ protected void updateObjectIdentity(MutableAcl acl) { Long parentId = null; if (acl.getParentAcl() != null) { Assert.isInstanceOf(ObjectIdentityImpl.class, acl.getParentAcl() .getObjectIdentity(), "Implementation only supports ObjectIdentityImpl"); ObjectIdentityImpl oii = (ObjectIdentityImpl) acl.getParentAcl() .getObjectIdentity(); parentId = retrieveObjectIdentityPrimaryKey(oii); } Assert.notNull(acl.getOwner(), "Owner is required in this implementation"); Long ownerSid = createOrRetrieveSidPrimaryKey(acl.getOwner(), true); int count = jdbcOperations.update(updateObjectIdentity, parentId, ownerSid, Boolean.valueOf(acl.isEntriesInheriting()), acl.getId()); if (count != 1) { throw new NotFoundException("Unable to locate ACL to update"); } }
final ObjectIdentity oid = mock(ObjectIdentity.class); when(mockAcl.getObjectIdentity()).thenReturn(oid); Sid sid = new PrincipalSid("johndoe");
assertThat(middleParent.getParentAcl().getObjectIdentity()).isEqualTo(topParentOid); assertThat(child.getParentAcl().getObjectIdentity()).isEqualTo(middleParentOid);
assertThat(middleParent.getParentAcl().getObjectIdentity()).isEqualTo(getTopParentOid()); assertThat(child.getParentAcl().getObjectIdentity()).isEqualTo(getMiddleParentOid());
assertThat(childAcl.getParentAcl().getObjectIdentity()).isEqualTo(getMiddleParentOid());
sb.append("parent: ").append((this.parentAcl == null) ? "Null" : this.parentAcl.getObjectIdentity().toString()); sb.append("; "); sb.append("aclAuthorizationStrategy: ").append(this.aclAuthorizationStrategy).append("; ");
@Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("AclImpl["); sb.append("id: ").append(this.id).append("; "); sb.append("objectIdentity: ").append(this.objectIdentity).append("; "); sb.append("owner: ").append(this.owner).append("; "); int count = 0; for (AccessControlEntry ace : aces) { count++; if (count == 1) { sb.append("\n"); } sb.append(ace).append("\n"); } if (count == 0) { sb.append("no ACEs; "); } sb.append("inheriting: ").append(this.entriesInheriting).append("; "); sb.append("parent: ").append( (this.parentAcl == null) ? "Null" : this.parentAcl.getObjectIdentity() .toString()); sb.append("; "); sb.append("aclAuthorizationStrategy: ").append(this.aclAuthorizationStrategy) .append("; "); sb.append("permissionGrantingStrategy: ").append(this.permissionGrantingStrategy); sb.append("]"); return sb.toString(); }
result.put(acl.getObjectIdentity(), acl); aclFound = true;
resultMap.put(result.getObjectIdentity(), result);
@Transactional @Override public void changeAclParent( MutableAcl acl, ObjectIdentity parent ) { if ( acl != null ) { Acl parentAcl = acl.getParentAcl(); if ( parent == null && parentAcl != null ) { acl.setParent( null ); updateAcl( acl ); } else if ( parent != null ) { Acl newParentAcl = getAcl( parent ); if ( newParentAcl == null ) { newParentAcl = createAcl( parent ); } if ( parentAcl == null || !parentAcl.getObjectIdentity().equals( newParentAcl.getObjectIdentity() ) ) { acl.setParent( newParentAcl ); updateAcl( acl ); } } } }
if (this.acl.getObjectIdentity() == null) { if (rhs.acl.getObjectIdentity() != null) { return false; if (!this.acl.getObjectIdentity() .equals(rhs.getAcl().getObjectIdentity())) { return false;
/** * Updates an existing acl_object_identity row, with new information presented in the * passed MutableAcl object. Also will create an acl_sid entry if needed for the Sid * that owns the MutableAcl. * * @param acl to modify (a row must already exist in acl_object_identity) * * @throws NotFoundException if the ACL could not be found to update. */ protected void updateObjectIdentity(MutableAcl acl) { Long parentId = null; if (acl.getParentAcl() != null) { Assert.isInstanceOf(ObjectIdentityImpl.class, acl.getParentAcl() .getObjectIdentity(), "Implementation only supports ObjectIdentityImpl"); ObjectIdentityImpl oii = (ObjectIdentityImpl) acl.getParentAcl() .getObjectIdentity(); parentId = retrieveObjectIdentityPrimaryKey(oii); } Assert.notNull(acl.getOwner(), "Owner is required in this implementation"); Long ownerSid = createOrRetrieveSidPrimaryKey(acl.getOwner(), true); int count = jdbcTemplate.update(updateObjectIdentity, parentId, ownerSid, Boolean.valueOf(acl.isEntriesInheriting()), acl.getId()); if (count != 1) { throw new NotFoundException("Unable to locate ACL to update"); } }
final String ownerTenantId = getTenantFromSid(ownerSid); if(ownerTenantId == MultiTenancySupport.NO_TENANT) { throw new RuntimeException("Can not retrieve tenant from acl owner: acl.objectIdentity=" + acl.getObjectIdentity().getIdentifier());
public Builder from(Acl aclData) { if(aclData instanceof MutableAcl) { this.setId((Long)((MutableAcl) aclData).getId()); } final List<AccessControlEntry> srcEntries = aclData.getEntries(); if(srcEntries != null) { final int size = srcEntries.size(); final List<AceData> aceDatas = new ArrayList<>(size); for(int i = 0; i < size; ++i) { AccessControlEntry entry = srcEntries.get(i); AceData aceData = AceDataImpl.builder().from(entry).build(); aceDatas.add(aceData); } this.setEntries(aceDatas); } this.setObjectIdentity(aclData.getObjectIdentity()); this.setOwner(aclData.getOwner()); Acl parentAcl = aclData.getParentAcl(); if(parentAcl != null) { this.setParentAclData(AclDataImpl.builder().from(parentAcl).build()); } this.setEntriesInheriting(aclData.isEntriesInheriting()); return this; }
private AclSecuredObjectIdentityData updateAclObjectIdentity(MutableAcl acl) { AclSecuredObjectIdentityData aclo = getAclSecuredObjectIdentity(acl.getObjectIdentity()); if (acl.getParentAcl() != null) { AclSecuredObjectIdentityData parentObjectIdentity = getAclSecuredObjectIdentity(acl.getParentAcl().getObjectIdentity()); aclo.setParentObject(parentObjectIdentity); } else if (aclo.getParentObject() != null) { aclo.setParentObject(null); } aclObjectIdentityDao.merge(aclo); return aclo; }