public ObjectIdentityImpl(ObjectIdentity oid) { this(oid.getType(), String.valueOf(oid.getIdentifier())); }
if ((this.objectIdentity == null && rhs.objectIdentity == null) || (this.objectIdentity != null && this.objectIdentity .equals(rhs.objectIdentity))) { if ((this.id == null && rhs.id == null) || (this.id != null && this.id.equals(rhs.id))) {
@Override public int hashCode() { int result = this.parentAcl != null ? this.parentAcl.hashCode() : 0; result = 31 * result + this.aclAuthorizationStrategy.hashCode(); result = 31 * result + (this.permissionGrantingStrategy != null ? this.permissionGrantingStrategy.hashCode() : 0); result = 31 * result + (this.aces != null ? this.aces.hashCode() : 0); result = 31 * result + this.objectIdentity.hashCode(); result = 31 * result + this.id.hashCode(); result = 31 * result + (this.owner != null ? this.owner.hashCode() : 0); result = 31 * result + (this.loadedSids != null ? this.loadedSids.hashCode() : 0); result = 31 * result + (this.entriesInheriting ? 1 : 0); return result; }
private static String objID(ObjectIdentity domainObjId) { return String.valueOf(domainObjId.getIdentifier()); }
@Test public void findOneChildren() { List<ObjectIdentity> result = new ArrayList<>(); result.add(new ObjectIdentityImpl(Object.class, "5577")); Object[] args = {"1", "org.springframework.security.acls.jdbc.JdbcAclServiceTests$MockLongIdDomainObject"}; when( jdbcOperations.query(anyString(), aryEq(args), any(RowMapper.class))).thenReturn(result); ObjectIdentity objectIdentity = new ObjectIdentityImpl(MockLongIdDomainObject.class, 1L); List<ObjectIdentity> objectIdentities = aclService.findChildren(objectIdentity); assertThat(objectIdentities.size()).isEqualTo(1); assertThat(objectIdentities.get(0).getIdentifier()).isEqualTo("5577"); }
/** * Make id fot type of identity (ignore object.identifier). * @param object * @return */ public static String toTypeId(ObjectIdentity object) { Assert.notNull(object, "ObjectIdentity is null"); String type = object.getType(); return toTypeId(type); }
public void setValues(PreparedStatement ps) throws SQLException { int i = 0; for (ObjectIdentity oid : objectIdentities) { // Determine prepared statement values for this iteration String type = oid.getType(); // No need to check for nulls, as guaranteed non-null by // ObjectIdentity.getIdentifier() interface contract String identifier = oid.getIdentifier().toString(); // Inject values ps.setString((2 * i) + 1, identifier); ps.setString((2 * i) + 2, type); i++; } } }, new ProcessResultSet(acls, sids));
public void deleteAcl(ObjectIdentity objectIdentity, boolean deleteChildren) throws ChildrenExistException { Assert.notNull(objectIdentity, "Object Identity required"); Assert.notNull(objectIdentity.getIdentifier(), "Object Identity doesn't provide an identifier");
private boolean isAdminFor(ObjectIdentity o) { final String role = Authorities.adminOf(o.getType()); final String objectTenant = MultiTenancySupport.getTenant(o); for(Sid sid: sids) { if(!(sid instanceof TenantGrantedAuthoritySid)) { continue; } TenantGrantedAuthoritySid authoritySid = (TenantGrantedAuthoritySid) sid; //TODO we need retrieve tenant hierarchy // String sidTenant = authoritySid.getTenant(); // if(sidTenant != null && !Objects.equals(sidTenant, objectTenant)) { // continue; // } String authority = authoritySid.getGrantedAuthority(); if(Authorities.ADMIN_ROLE.equals(authority)) { //grant by admin authority return true; } if(role.equals(authority)) { //grant by type admin authority return true; } } return false; }
.equals(rhs.getAcl().getObjectIdentity())) { return false;
@Test public void longAndIntegerIdsWithSameValueAreEqualAndHaveSameHashcode() { ObjectIdentity obj = new ObjectIdentityImpl(Object.class, new Long(5)); ObjectIdentity obj2 = new ObjectIdentityImpl(Object.class, Integer.valueOf(5)); assertThat(obj2).isEqualTo(obj); assertThat(obj2.hashCode()).isEqualTo(obj.hashCode()); }
public List<ObjectIdentity> findChildren(ObjectIdentity parentIdentity) { Object[] args = { parentIdentity.getIdentifier().toString(), parentIdentity.getType() }; List<ObjectIdentity> objects = jdbcOperations.query(findChildrenSql, args, new RowMapper<ObjectIdentity>() { public ObjectIdentity mapRow(ResultSet rs, int rowNum) throws SQLException { String javaType = rs.getString("class"); Serializable identifier = (Serializable) rs.getObject("obj_id"); identifier = aclClassIdUtils.identifierFrom(identifier, rs); return new ObjectIdentityImpl(javaType, identifier); } }); if (objects.size() == 0) { return null; } return objects; }
private Multimap<String, String> getPermissions(Map<ObjectIdentity, Acl> acls, Sid sid) { Multimap<String, String> result = LinkedHashMultimap.create(); acls.forEach( (objectIdentity, acl) -> { String id = objectIdentity.getIdentifier().toString(); acl.getEntries() .stream() .filter(ace -> ace.getSid().equals(sid)) .map(this::getPermissionString) .forEach(permission -> result.put(id, permission)); }); return result; }
@Transactional @Override public MutableAcl createAcl( ObjectIdentity objectIdentity ) { val parentIdentity = objectIdentity( defaultParent ); return createAclWithParent( objectIdentity, !objectIdentity.equals( parentIdentity ) ? parentIdentity : null ); }
@Test public void equalStringIdsAreEqualAndHaveSameHashcode() throws Exception { ObjectIdentity obj = new ObjectIdentityImpl(Object.class, "1000"); ObjectIdentity obj2 = new ObjectIdentityImpl(Object.class, "1000"); assertThat(obj2).isEqualTo(obj); assertThat(obj2.hashCode()).isEqualTo(obj.hashCode()); }
/** * Important so caching operates properly. * <p> * Considers an object of the same class equal if it has the same * <code>classname</code> and <code>id</code> properties. * <p> * Numeric identities (Integer and Long values) are considered equal if they are * numerically equal. Other serializable types are evaluated using a simple equality. * * @param arg0 object to compare * * @return <code>true</code> if the presented object matches this object */ public boolean equals(Object arg0) { if (arg0 == null || !(arg0 instanceof ObjectIdentity)) { return false; } ObjectIdentity other = (ObjectIdentity) arg0; if (!identifier.equals(other.getIdentifier())) { return false; } return type.equals(other.getType()); }
private MutableAcl getOrCreateParentAcl(ISecuredObject<?> securedParent, Sid sid, sk.seges.acris.security.shared.user_management.domain.Permission[] permissions, ObjectIdentity identity) { try { MutableAcl parentAcl = (MutableAcl) aclService.readAclById(identity); return parentAcl; } catch (NotFoundException e) { logger.info("No parent with aclId: " + identity.getIdentifier().toString() + " and class: " + identity.getClass().getName() + " not exist, it will be created! "); setAclRecords(securedParent, sid, permissions); return getOrCreateParentAcl(securedParent, sid, permissions, identity); } }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (!(o instanceof AclDataImpl)) { return false; } AclDataImpl aclData = (AclDataImpl) o; if (entriesInheriting != aclData.entriesInheriting) { return false; } if (entries != null ? !entries.equals(aclData.entries) : aclData.entries != null) { return false; } if (objectIdentity != null ? !objectIdentity.equals(aclData.objectIdentity) : aclData.objectIdentity != null) { return false; } if (owner != null ? !owner.equals(aclData.owner) : aclData.owner != null) { return false; } if (parentAclData != null ? !parentAclData.equals(aclData.parentAclData) : aclData.parentAclData != null) { return false; } return true; }