public ACL createACL(Resource resource) { if (resource == null) throw new IllegalArgumentException("ACLs cannot be created for null resources"); ACL acl = this.aclMap.get(resource); if (acl == null) { acl = new ACLImpl(resource); this.aclMap.put(resource, acl); } return acl; }
public ACLEntry getEntry(String identityOrRole) { if (this.entriesMap == null) this.initEntriesMap(); return this.entriesMap.get(identityOrRole); }
@SuppressWarnings("unchecked") public Collection<ACL> getACLs() { Collection<ACL> acls = null; EntityManager entityManager = this.managerFactory.createEntityManager(); try { acls = entityManager.createQuery("SELECT a FROM ACLImpl a").getResultList(); if (acls != null && this.resourceFactory != null) { for (ACL acl : acls) { ACLImpl impl = (ACLImpl) acl; String[] resourceName = impl.getResourceAsString().split(":"); impl.setResource(this.resourceFactory.instantiateResource(resourceName[0], resourceName[1])); } } } finally { entityManager.close(); } return acls; }
public void deRegisterPolicy(String contextID, String type) { if (PolicyRegistration.XACML.equalsIgnoreCase(type)) { this.contextIdToXACMLPolicy.remove(contextID); if (trace) log.trace("DeRegistered policy for contextId:" + contextID + ":type=" + type); } else if (PolicyRegistration.ACL.equalsIgnoreCase(type)) { Set<ACL> acls = this.contextIDToACLs.remove(contextID); if (acls != null) { for (ACL acl : acls) { ACLImpl impl = (ACLImpl) acl; this.configuredACLs.remove(impl.getResourceAsString()); } } if (trace) log.trace("Deregistered ACLs for contextId:" + contextID); } }
/** * <p> * Searches the database for the {@code ACL} associated with the specified resource. * </p> * * @param resource the {@code Resource} that is associated with the {@code ACL} being searched. * @param entityManager the {@code EntityManager} used to search the database. * @return the {@code ACL} retrieved from the database, or {@code null} if no {@code ACL} could be found. */ private ACLImpl findACLByResource(Resource resource, EntityManager entityManager) { ACLImpl acl = null; try { acl = (ACLImpl) entityManager.createQuery( "SELECT a FROM ACLImpl a WHERE a.resourceAsString LIKE '" + Util.getResourceAsString(resource) + "'") .getSingleResult(); acl.setResource(resource); } catch (NoResultException nre) { // ignore the exception when no ACL could be found for the given resource. } return acl; } }
public boolean updateACL(ACL acl) if (((ACLImpl) acl).getACLId() == 0) return false;
@SuppressWarnings("unchecked") public Collection<ACL> getACLs() { Collection<ACL> acls = null; EntityManager entityManager = this.managerFactory.createEntityManager(); try { acls = entityManager.createQuery("SELECT a FROM ACLImpl a").getResultList(); if (acls != null && this.resourceFactory != null) { for (ACL acl : acls) { ACLImpl impl = (ACLImpl) acl; String[] resourceName = impl.getResourceAsString().split(":"); impl.setResource(this.resourceFactory.instantiateResource(resourceName[0], resourceName[1])); } } } finally { entityManager.close(); } return acls; }
log.trace("Registering ACL for resource " + impl.getResourceAsString()); this.configuredACLs.put(impl.getResourceAsString(), acl);
/** * <p> * Searches the database for the {@code ACL} associated with the specified resource. * </p> * * @param resource the {@code Resource} that is associated with the {@code ACL} being searched. * @param entityManager the {@code EntityManager} used to search the database. * @return the {@code ACL} retrieved from the database, or {@code null} if no {@code ACL} could be found. */ private ACLImpl findACLByResource(Resource resource, EntityManager entityManager) { ACLImpl acl = null; try { acl = (ACLImpl) entityManager.createQuery( "SELECT a FROM ACLImpl a WHERE a.resourceAsString LIKE '" + Util.getResourceAsString(resource) + "'") .getSingleResult(); acl.setResource(resource); } catch (NoResultException nre) { // ignore the exception when no ACL could be found for the given resource. } return acl; } }
public boolean updateACL(ACL acl) if (((ACLImpl) acl).getACLId() == 0) return false;
/** * <p> * Creates and returns the {@code ACL} objects that correspond to the {@code acl-definition}s specified in the XML * configuration file. * </p> * * @return a {@code Set<ACL>} containing the generated {@code ACL}s. */ public Set<ACL> getConfiguredACLs() { Set<ACL> configuredACLs = new HashSet<ACL>(); for (ACLDefinition definition : this.definitions.values()) { Set<ACLEntry> entries = this.getEntries(definition, new ArrayList<String>()); ACLImpl acl = new ACLImpl(definition.getResource(), entries); configuredACLs.add(acl); } return configuredACLs; }
public ACLEntry getEntry(String identityOrRole) { if (this.entriesMap == null) this.initEntriesMap(); return this.entriesMap.get(identityOrRole); }
acl = new ACLImpl(resource, entries); entityManager.persist(acl);
public Collection<? extends ACLEntry> getEntries() { if (this.entriesMap == null) this.initEntriesMap(); return Collections.unmodifiableCollection(this.entries); }
acl = new ACLImpl(resource, entries); entityManager.persist(acl);
public Collection<? extends ACLEntry> getEntries() { if (this.entriesMap == null) this.initEntriesMap(); return Collections.unmodifiableCollection(this.entries); }
public boolean removeEntry(ACLEntry entry) { if (this.entriesMap == null) this.initEntriesMap(); this.entriesMap.remove(entry.getIdentityOrRole()); return this.entries.remove(entry); }
public ACLEntry getEntry(Identity identity) { if (this.entriesMap == null) this.initEntriesMap(); return this.entriesMap.get(identity.getName()); }
public ACLEntry getEntry(Identity identity) { if (this.entriesMap == null) this.initEntriesMap(); return this.entriesMap.get(identity.getName()); }
public boolean removeEntry(ACLEntry entry) { if (this.entriesMap == null) this.initEntriesMap(); this.entriesMap.remove(entry.getIdentityOrRole()); return this.entries.remove(entry); }