List of usage examples for org.springframework.security.acls.model MutableAcl getObjectIdentity
ObjectIdentity getObjectIdentity();
From source file:net.projectmonkey.spring.acl.hbase.repository.TestingInMemoryCache.java
@Override public void putInCache(final MutableAcl acl) { cache.put(acl.getObjectIdentity().getIdentifier(), acl); }
From source file:net.projectmonkey.spring.acl.service.SimpleACLService.java
private void verifyAclExists(final MutableAcl acl) { ObjectIdentity identity = acl.getObjectIdentity(); if (!aclRepository.isThereAnAclFor(identity)) { throw new NotFoundException("Acl does not exist for object identity " + identity); }//from w ww . j a v a2 s . c o m }
From source file:eu.europeana.aas.acl.CassandraMutableAclService.java
@Override public MutableAcl updateAcl(MutableAcl acl) throws NotFoundException { Assert.notNull(acl, "MutableAcl required"); Assert.notNull(acl.getObjectIdentity(), "Object Identity required"); Assert.notNull(acl.getObjectIdentity().getIdentifier(), "Object Identity doesn't provide an identifier"); if (LOG.isDebugEnabled()) { LOG.debug("BEGIN updateAcl: acl: " + acl); }//from ww w .j ava 2 s. c o m try { aclRepository.updateAcl(new AclObjectIdentity(acl), convertToAclEntries(acl)); } catch (AclNotFoundException e) { throw new NotFoundException(e.getMessage(), e); } // Clear the cache, including children clearCacheIncludingChildren(acl.getObjectIdentity()); // Retrieve the ACL via superclass (ensures cache registration, proper retrieval etc) MutableAcl result = (MutableAcl) readAclById(acl.getObjectIdentity()); if (LOG.isDebugEnabled()) { LOG.debug("END updateAcl: acl: " + result); } return result; }
From source file:com.cedac.security.acls.mongo.MongoMutableAclServiceTests.java
@Test @ShouldMatchDataSet// w w w . j a v a 2 s. com public void creatingAcl_withNoAcl() { MutableAcl acl = fixture .createAcl(new ObjectIdentityImpl("com.cedac.smartresidence.profile.domain.Home", "2")); assertNotNull(acl); assertEquals("com.cedac.smartresidence.profile.domain.Home", acl.getObjectIdentity().getType()); assertEquals("2", acl.getObjectIdentity().getIdentifier()); assertEquals(new PrincipalSid("admin@cedac.com"), acl.getOwner()); assertEquals(true, acl.isEntriesInheriting()); assertEquals(0, acl.getEntries().size()); }
From source file:com.cedac.security.acls.mongo.MongoMutableAclService.java
@Override public MutableAcl updateAcl(MutableAcl acl) throws NotFoundException { Assert.notNull(acl.getId(), "Object Identity doesn't provide an identifier"); DBObject persistedAcl = getAclCollection().findOne(queryByObjectIdentity(acl.getObjectIdentity())); if (persistedAcl == null) { LOG.trace(ACL, "No ACL found for object identity {}", acl.getObjectIdentity()); throw new NotFoundException("No acl found for object identity " + acl.getObjectIdentity()); }//from w ww . j a v a 2s . co m LOG.debug(ACL, "Updating persisted ACL object"); if (acl.getParentAcl() != null) { ObjectIdentity parentOid = acl.getParentAcl().getObjectIdentity(); persistedAcl.put(parentObjectFieldName, toDBObject(parentOid)); } persistedAcl.put(ownerFieldName, toDBObject(acl.getOwner())); persistedAcl.put(entriesInheritingFieldName, acl.isEntriesInheriting()); BasicDBList list = new BasicDBList(); for (AccessControlEntry entry : acl.getEntries()) { list.add(toDBObject(entry)); } persistedAcl.put(entriesFieldName, list); getAclCollection().save(persistedAcl, writeConcern); LOG.trace(ACL, "Clearing cache including children for object identity {}", acl.getObjectIdentity()); clearCacheIncludingChildren(acl.getObjectIdentity()); LOG.trace(ACL, "Retrieve ACL via superclass."); return (MutableAcl) super.readAclById(acl.getObjectIdentity()); }
From source file:com.kylinolap.rest.service.AclService.java
@Override public MutableAcl updateAcl(MutableAcl acl) throws NotFoundException { try {// w ww. ja v a2s .c o m readAclById(acl.getObjectIdentity()); } catch (NotFoundException e) { throw e; } HTableInterface htable = null; try { htable = HBaseConnection.get(hbaseUrl).getTable(aclTableName); Delete delete = new Delete(Bytes.toBytes(String.valueOf(acl.getObjectIdentity().getIdentifier()))); delete.deleteFamily(Bytes.toBytes(ACL_ACES_FAMILY)); htable.delete(delete); Put put = new Put(Bytes.toBytes(String.valueOf(acl.getObjectIdentity().getIdentifier()))); if (null != acl.getParentAcl()) { put.add(Bytes.toBytes(ACL_INFO_FAMILY), Bytes.toBytes(ACL_INFO_FAMILY_PARENT_COLUMN), domainObjSerializer .serialize(new DomainObjectInfo(acl.getParentAcl().getObjectIdentity()))); } for (AccessControlEntry ace : acl.getEntries()) { AceInfo aceInfo = new AceInfo(ace); put.add(Bytes.toBytes(ACL_ACES_FAMILY), Bytes.toBytes(aceInfo.getSidInfo().getSid()), aceSerializer.serialize(aceInfo)); } if (!put.isEmpty()) { htable.put(put); htable.flushCommits(); logger.debug("ACL of " + acl.getObjectIdentity() + " updated successfully."); } } catch (IOException e) { logger.error(e.getLocalizedMessage(), e); } finally { IOUtils.closeQuietly(htable); } return (MutableAcl) readAclById(acl.getObjectIdentity()); }
From source file:net.projectmonkey.spring.acl.hbase.repository.HBaseACLRepository.java
/** * Updates an existing acl. This deletes the existing acl and completely * replaces the row with the new acl./*from ww w . ja v a2s . c om*/ * * @param acl which must not be null. * @throws AuthorizationServiceException if some mandatory aspect of * the supplied acl is null or if an unexpected exception * occurred */ @Override public void update(final MutableAcl acl) { Assert.notNull(acl, "acl must not be null"); HTableInterface table = getTable(); try { ObjectIdentity identity = acl.getObjectIdentity(); AclRecord aclRecord = new AclRecord(identity, acl.getOwner(), resolveConverter(identity)); deleteInternal(aclRecord, table); save(acl, table, aclRecord); } catch (IOException e) { throw new AuthorizationServiceException("An unexpected exception occurred", e); } finally { close(table); } }
From source file:com.trailmagic.image.security.SpringSecurityImageSecurityService.java
public void effectPermissions(MutableAcl acl, Sid recipient, Set<Permission> newPermissions, boolean additive) { Set<Permission> existingPermissions = findExistingPermissions(acl, recipient); if (!additive) { Set<Permission> permsToRemove = new HashSet<Permission>(); permsToRemove.addAll(existingPermissions); permsToRemove.removeAll(newPermissions); for (Permission perm : permsToRemove) { acl.deleteAce(indexOf(recipient, perm, acl)); if (log.isDebugEnabled()) { log.debug("Removed ACE for permission " + perm + ", recipient " + recipient + ", on object " + acl.getObjectIdentity()); }/*www .jav a2 s.com*/ } } Set<Permission> permsToAdd = new HashSet<Permission>(); permsToAdd.addAll(newPermissions); permsToAdd.removeAll(existingPermissions); for (Permission perm : permsToAdd) { acl.insertAce(acl.getEntries().size(), perm, recipient, true); if (log.isDebugEnabled()) { log.debug("Added ACE for permission " + perm + ", recipient " + recipient + ", on object " + acl.getObjectIdentity()); } } aclService.updateAcl(acl); }
From source file:org.apache.kylin.rest.service.AclService.java
@Override public MutableAcl updateAcl(MutableAcl acl) throws NotFoundException { try {/*from ww w . java 2s .c om*/ readAclById(acl.getObjectIdentity()); } catch (NotFoundException e) { throw e; } HTableInterface htable = null; try { htable = aclHBaseStorage.getTable(aclTableName); Delete delete = new Delete(Bytes.toBytes(String.valueOf(acl.getObjectIdentity().getIdentifier()))); delete.deleteFamily(Bytes.toBytes(AclHBaseStorage.ACL_ACES_FAMILY)); htable.delete(delete); Put put = new Put(Bytes.toBytes(String.valueOf(acl.getObjectIdentity().getIdentifier()))); if (null != acl.getParentAcl()) { put.add(Bytes.toBytes(AclHBaseStorage.ACL_INFO_FAMILY), Bytes.toBytes(ACL_INFO_FAMILY_PARENT_COLUMN), domainObjSerializer .serialize(new DomainObjectInfo(acl.getParentAcl().getObjectIdentity()))); } for (AccessControlEntry ace : acl.getEntries()) { AceInfo aceInfo = new AceInfo(ace); put.add(Bytes.toBytes(AclHBaseStorage.ACL_ACES_FAMILY), Bytes.toBytes(aceInfo.getSidInfo().getSid()), aceSerializer.serialize(aceInfo)); } if (!put.isEmpty()) { htable.put(put); htable.flushCommits(); logger.debug("ACL of " + acl.getObjectIdentity() + " updated successfully."); } } catch (IOException e) { throw new RuntimeException(e.getMessage(), e); } finally { IOUtils.closeQuietly(htable); } return (MutableAcl) readAclById(acl.getObjectIdentity()); }
From source file:org.apache.kylin.rest.service.LegacyAclService.java
@Override public MutableAcl updateAcl(MutableAcl acl) throws NotFoundException { try {/* w w w .j a v a 2 s .c om*/ readAclById(acl.getObjectIdentity()); } catch (NotFoundException e) { throw e; } Table htable = null; try { htable = aclHBaseStorage.getTable(aclTableName); Delete delete = new Delete(Bytes.toBytes(String.valueOf(acl.getObjectIdentity().getIdentifier()))); delete.deleteFamily(Bytes.toBytes(AclHBaseStorage.ACL_ACES_FAMILY)); htable.delete(delete); Put put = new Put(Bytes.toBytes(String.valueOf(acl.getObjectIdentity().getIdentifier()))); if (null != acl.getParentAcl()) { put.addColumn(Bytes.toBytes(AclHBaseStorage.ACL_INFO_FAMILY), Bytes.toBytes(ACL_INFO_FAMILY_PARENT_COLUMN), domainObjSerializer .serialize(new DomainObjectInfo(acl.getParentAcl().getObjectIdentity()))); } for (AccessControlEntry ace : acl.getEntries()) { AceInfo aceInfo = new AceInfo(ace); put.addColumn(Bytes.toBytes(AclHBaseStorage.ACL_ACES_FAMILY), Bytes.toBytes(aceInfo.getSidInfo().getSid()), aceSerializer.serialize(aceInfo)); } if (!put.isEmpty()) { htable.put(put); logger.debug("ACL of " + acl.getObjectIdentity() + " updated successfully."); } } catch (IOException e) { throw new RuntimeException(e.getMessage(), e); } finally { IOUtils.closeQuietly(htable); } return (MutableAcl) readAclById(acl.getObjectIdentity()); }