Example usage for org.springframework.security.acls.model Acl getEntries

List of usage examples for org.springframework.security.acls.model Acl getEntries

Introduction

In this page you can find the example usage for org.springframework.security.acls.model Acl getEntries.

Prototype

List<AccessControlEntry> getEntries();

Source Link

Document

Returns all of the entries represented by the present Acl.

Usage

From source file:org.springframework.security.acls.cassandra.CassandraMutableAclService.java

/**
 * Converts an {@link Acl} to a list of {@link AclEntry} objects.
 * /*from   w  ww .  ja v a  2 s  .co m*/
 * @param acl the {@link Acl} to convert.
 * @return the list of derived {@link AclEntry} objects.
 */
private List<AclEntry> convertToAclEntries(Acl acl) {
    List<AclEntry> result = new ArrayList<AclEntry>();

    for (AccessControlEntry entry : acl.getEntries()) {
        result.add(new AclEntry(entry));
    }
    return result;
}

From source file:ubc.pavlab.aspiredb.server.security.authorization.acl.AclTestUtils.java

public void checkHasAces(Object f) {
    Acl a = getAcl(f);
    assertTrue(a + " doesn't have ACEs, it should", a.getEntries().size() > 0);
}

From source file:ubc.pavlab.aspiredb.server.security.authorization.acl.AclTestUtils.java

public void checkLacksAces(Object f) {
    Acl a = getAcl(f);
    assertTrue(f + " has ACEs, it shouldn't", a.getEntries().size() == 0);
}

From source file:ubic.gemma.security.authorization.acl.AclAdvice.java

/**
 * When setting the parent, we check to see if we can delete the ACEs on the 'child', if any. This is because we
 * want permissions to be managed by the parent. Check that the ACEs on the child are exactly equivalent to the ones
 * on the parent.//from w  ww .java 2 s.c  o m
 * 
 * @param parentAcl -- careful with the order!
 * @param object
 * @param acl
 * @param true if ACEs were cleared.
 */
private boolean maybeClearACEsOnChild(Securable object, MutableAcl childAcl, Acl parentAcl) {
    int aceCount = childAcl.getEntries().size();

    if (aceCount == 0) {

        if (parentAcl.getEntries().size() == 0) {
            throw new IllegalStateException("Either the child or the parent has to have ACEs");
        }
        return false;
    }

    if (parentAcl.getEntries().size() == aceCount) {

        boolean oktoClearACEs = true;

        // check for exact match of all ACEs
        for (AccessControlEntry ace : parentAcl.getEntries()) {
            boolean found = false;
            for (AccessControlEntry childAce : childAcl.getEntries()) {
                if (childAce.getPermission().equals(ace.getPermission())
                        && childAce.getSid().equals(ace.getSid())) {
                    found = true;
                    break;
                }
            }

            if (!found) {
                oktoClearACEs = false;
                break;
            }
        }

        if (oktoClearACEs) {
            if (log.isTraceEnabled())
                log.trace("Erasing ACEs from child " + object);

            while (childAcl.getEntries().size() > 0) {
                childAcl.deleteAce(0);
            }

            return true;
        }

    }
    return false;
}