Example usage for org.springframework.security.acls.domain AclImpl getObjectIdentity

List of usage examples for org.springframework.security.acls.domain AclImpl getObjectIdentity

Introduction

In this page you can find the example usage for org.springframework.security.acls.domain AclImpl getObjectIdentity.

Prototype

@Override
    public ObjectIdentity getObjectIdentity() 

Source Link

Usage

From source file:eu.europeana.aas.acl.CassandraAclService.java

/**
 * Request Acls from the {@link AclRepository} and convert results.
 *
 * @param objects a list of {@link ObjectIdentity} objects to lookup.
 * @return a map with {@link ObjectIdentity} instances as keys and
 * {@link Acl} instances as values./* w ww .ja  va2  s  .c o m*/
 */
private Map<ObjectIdentity, Acl> doLookup(List<ObjectIdentity> objects) {
    Map<ObjectIdentity, Acl> result = new HashMap<>();

    if (objects != null && !objects.isEmpty()) {
        List<AclObjectIdentity> objectIds = new ArrayList<>();

        for (ObjectIdentity objId : objects) {
            objectIds.add(new AclObjectIdentity(objId));
        }

        Map<AclObjectIdentity, Set<AclEntry>> aeList = aclRepository.findAcls(objectIds);
        Map<ObjectIdentity, Acl> parentAcls = lookupParents(aeList.keySet());

        for (Entry<AclObjectIdentity, Set<AclEntry>> entry : aeList.entrySet()) {
            Acl parentAcl = parentAcls.get(entry.getKey().getParentObjectIdentity());
            AclImpl loadedAcl = convert(entry.getKey(), entry.getValue(), parentAcl);
            result.put(loadedAcl.getObjectIdentity(), loadedAcl);
        }
    }
    return result;
}

From source file:org.bremersee.common.security.acls.jdbc.BasicLookupStrategy.java

/**
 * The final phase of converting the <code>Map</code> of <code>AclImpl</code>
 * instances which contain <code>StubAclParent</code>s into proper, valid
 * <code>AclImpl</code>s with correct ACL parents.
 *
 * @param inputMap the unconverted <code>AclImpl</code>s
 * @param currentIdentity the current<code>Acl</code> that we wish to convert (this
 * may be//from   ww w  .  j  a  va 2 s . co  m
 *
 */
private AclImpl convert(Map<Serializable, Acl> inputMap, Long currentIdentity) {
    Assert.notEmpty(inputMap, "InputMap required");
    Assert.notNull(currentIdentity, "CurrentIdentity required");

    // Retrieve this Acl from the InputMap
    Acl uncastAcl = inputMap.get(currentIdentity);
    Assert.isInstanceOf(AclImpl.class, uncastAcl, "The inputMap contained a non-AclImpl");

    AclImpl inputAcl = (AclImpl) uncastAcl;

    Acl parent = inputAcl.getParentAcl();

    if ((parent != null) && parent instanceof StubAclParent) {
        // Lookup the parent
        StubAclParent stubAclParent = (StubAclParent) parent;
        parent = convert(inputMap, stubAclParent.getId());
    }

    // Now we have the parent (if there is one), create the true AclImpl
    AclImpl result = new AclImpl(inputAcl.getObjectIdentity(), inputAcl.getId(), aclAuthorizationStrategy,
            grantingStrategy, parent, null, inputAcl.isEntriesInheriting(), inputAcl.getOwner());

    // Copy the "aces" from the input to the destination

    // Obtain the "aces" from the input ACL
    List<AccessControlEntryImpl> aces = readAces(inputAcl);

    // Create a list in which to store the "aces" for the "result" AclImpl instance
    List<AccessControlEntryImpl> acesNew = new ArrayList<>();

    // Iterate over the "aces" input and replace each nested
    // AccessControlEntryImpl.getAcl() with the new "result" AclImpl instance
    // This ensures StubAclParent instances are removed, as per SEC-951
    for (AccessControlEntryImpl ace : aces) {
        setAclOnAce(ace, result);
        acesNew.add(ace);
    }

    // Finally, now that the "aces" have been converted to have the "result" AclImpl
    // instance, modify the "result" AclImpl instance
    setAces(result, acesNew);

    return result;
}

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

/**
 * Request Acls from the {@link CassandraAclRepository} and convert results.
 * /*  w  ww.j  a va 2 s  .  c  om*/
 * @param objects a list of {@link ObjectIdentity} objects to lookup.
 * @return a map with {@link ObjectIdentity} instances as keys and {@link Acl} instances as values.
 */
private Map<ObjectIdentity, Acl> doLookup(List<ObjectIdentity> objects) {
    Map<ObjectIdentity, Acl> result = new HashMap<ObjectIdentity, Acl>();

    if (objects != null && !objects.isEmpty()) {
        List<AclObjectIdentity> objectIds = new ArrayList<AclObjectIdentity>();

        for (ObjectIdentity objId : objects) {
            objectIds.add(new AclObjectIdentity(objId));
        }

        Map<AclObjectIdentity, Set<AclEntry>> aeList = aclRepository.findAcls(objectIds);
        Map<ObjectIdentity, Acl> parentAcls = lookupParents(aeList.keySet());

        for (Entry<AclObjectIdentity, Set<AclEntry>> entry : aeList.entrySet()) {
            Acl parentAcl = parentAcls.get(entry.getKey().getParentObjectIdentity());
            AclImpl loadedAcl = convert(entry.getKey(), entry.getValue(), parentAcl);
            result.put(loadedAcl.getObjectIdentity(), loadedAcl);
        }
    }
    return result;
}