List of usage examples for org.springframework.security.acls.model ObjectIdentity getIdentifier
Serializable getIdentifier();
From source file:org.apache.kylin.rest.service.LegacyAclService.java
@Override public Map<ObjectIdentity, Acl> readAclsById(List<ObjectIdentity> oids, List<Sid> sids) throws NotFoundException { Map<ObjectIdentity, Acl> aclMaps = new HashMap<ObjectIdentity, Acl>(); Table htable = null;/*from w w w.ja va 2 s. c o m*/ Result result = null; try { htable = aclHBaseStorage.getTable(aclTableName); for (ObjectIdentity oid : oids) { result = htable.get(new Get(Bytes.toBytes(String.valueOf(oid.getIdentifier())))); if (null != result && !result.isEmpty()) { SidInfo owner = sidSerializer .deserialize(result.getValue(Bytes.toBytes(AclHBaseStorage.ACL_INFO_FAMILY), Bytes.toBytes(ACL_INFO_FAMILY_OWNER_COLUMN))); Sid ownerSid = (null == owner) ? null : (owner.isPrincipal() ? new PrincipalSid(owner.getSid()) : new GrantedAuthoritySid(owner.getSid())); boolean entriesInheriting = Bytes .toBoolean(result.getValue(Bytes.toBytes(AclHBaseStorage.ACL_INFO_FAMILY), Bytes.toBytes(ACL_INFO_FAMILY_ENTRY_INHERIT_COLUMN))); Acl parentAcl = null; DomainObjectInfo parentInfo = domainObjSerializer .deserialize(result.getValue(Bytes.toBytes(AclHBaseStorage.ACL_INFO_FAMILY), Bytes.toBytes(ACL_INFO_FAMILY_PARENT_COLUMN))); if (null != parentInfo) { ObjectIdentity parentObj = new ObjectIdentityImpl(parentInfo.getType(), parentInfo.getId()); parentAcl = readAclById(parentObj, null); } AclImpl acl = new AclImpl(oid, oid.getIdentifier(), aclAuthorizationStrategy, permissionGrantingStrategy, parentAcl, null, entriesInheriting, ownerSid); genAces(sids, result, acl); aclMaps.put(oid, acl); } else { throw new NotFoundException("Unable to find ACL information for object identity '" + oid + "'"); } } } catch (IOException e) { throw new RuntimeException(e.getMessage(), e); } finally { IOUtils.closeQuietly(htable); } return aclMaps; }
From source file:org.apache.kylin.rest.service.LegacyAclService.java
@Override public MutableAcl createAcl(ObjectIdentity objectIdentity) throws AlreadyExistsException { Acl acl = null;// w w w .j a va2 s. c o m try { acl = readAclById(objectIdentity); } catch (NotFoundException e) { //do nothing? } if (null != acl) { throw new AlreadyExistsException("ACL of " + objectIdentity + " exists!"); } Authentication auth = SecurityContextHolder.getContext().getAuthentication(); PrincipalSid sid = new PrincipalSid(auth); Table htable = null; try { htable = aclHBaseStorage.getTable(aclTableName); Put put = new Put(Bytes.toBytes(String.valueOf(objectIdentity.getIdentifier()))); put.addColumn(Bytes.toBytes(AclHBaseStorage.ACL_INFO_FAMILY), Bytes.toBytes(ACL_INFO_FAMILY_TYPE_COLUMN), Bytes.toBytes(objectIdentity.getType())); put.addColumn(Bytes.toBytes(AclHBaseStorage.ACL_INFO_FAMILY), Bytes.toBytes(ACL_INFO_FAMILY_OWNER_COLUMN), sidSerializer.serialize(new SidInfo(sid))); put.addColumn(Bytes.toBytes(AclHBaseStorage.ACL_INFO_FAMILY), Bytes.toBytes(ACL_INFO_FAMILY_ENTRY_INHERIT_COLUMN), Bytes.toBytes(true)); htable.put(put); logger.debug("ACL of " + objectIdentity + " created successfully."); } catch (IOException e) { throw new RuntimeException(e.getMessage(), e); } finally { IOUtils.closeQuietly(htable); } return (MutableAcl) readAclById(objectIdentity); }
From source file:org.apache.kylin.rest.service.LegacyAclService.java
@Override public void deleteAcl(ObjectIdentity objectIdentity, boolean deleteChildren) throws ChildrenExistException { Table htable = null;//from w w w .j a va2 s . c om try { htable = aclHBaseStorage.getTable(aclTableName); Delete delete = new Delete(Bytes.toBytes(String.valueOf(objectIdentity.getIdentifier()))); List<ObjectIdentity> children = findChildren(objectIdentity); if (!deleteChildren && children.size() > 0) { throw new ChildrenExistException("Children exists for " + objectIdentity); } for (ObjectIdentity oid : children) { deleteAcl(oid, deleteChildren); } htable.delete(delete); logger.debug("ACL of " + objectIdentity + " deleted successfully."); } catch (IOException e) { throw new RuntimeException(e.getMessage(), e); } finally { IOUtils.closeQuietly(htable); } }
From source file:org.springframework.security.acls.cassandra.CassandraMutableAclService.java
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"); if (LOG.isDebugEnabled()) { LOG.debug("BEGIN deleteAcl: objectIdentity: " + objectIdentity + ", deleteChildren: " + deleteChildren); }//from ww w. ja v a2s. c o m List<AclObjectIdentity> objIdsToDelete = new ArrayList<AclObjectIdentity>(); List<ObjectIdentity> objectsToDelete = new ArrayList<ObjectIdentity>(); objectsToDelete.add(objectIdentity); List<ObjectIdentity> children = findChildren(objectIdentity); if (deleteChildren) { for (ObjectIdentity child : children) { objectsToDelete.addAll(calculateChildrenReccursively(child)); } } else if (children != null && !children.isEmpty()) { throw new ChildrenExistException( "Cannot delete '" + objectIdentity + "' (has " + children.size() + " children)"); } for (ObjectIdentity objId : objectsToDelete) { objIdsToDelete.add(new AclObjectIdentity(objId)); } aclRepository.deleteAcls(objIdsToDelete); // Clear the cache if (aclCache != null) { for (ObjectIdentity obj : objectsToDelete) { aclCache.evictFromCache(obj); } } if (LOG.isDebugEnabled()) { LOG.debug("END deleteAcl"); } }
From source file:org.springframework.security.acls.jdbc.JdbcAclService.java
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); }/*w w w. j a v a 2 s . co m*/ }); if (objects.size() == 0) { return null; } return objects; }