Examples of MutableAcl


Examples of com.volantis.shared.security.acl.mutable.MutableACL

                new ACLEntryMock("entryMock", expectations);

        // =====================================================================
        //   Test Expectations
        // =====================================================================
        MutableACL acl = factory.createACL(principalMock);

        try {
            acl.setName(attackerMock, "new name");
            fail("Did not detect attempt to change by a principal other " +
                    "than the owner");
        } catch (NotOwnerException expected) {
        }

        try {
            acl.addEntry(attackerMock, entryMock);
            fail("Did not detect attempt to change by a principal other " +
                    "than the owner");
        } catch (NotOwnerException expected) {
        }

        try {
            acl.removeEntry(attackerMock, entryMock);
            fail("Did not detect attempt to change by a principal other " +
                    "than the owner");
        } catch (NotOwnerException expected) {
        }

        try {
            acl.addOwner(attackerMock, principalMock);
            fail("Did not detect attempt to change by a principal other " +
                    "than the owner");
        } catch (NotOwnerException expected) {
        }

        try {
            acl.deleteOwner(attackerMock, principalMock);
            fail("Did not detect attempt to change by a principal other " +
                    "than the owner");
        } catch (NotOwnerException expected) {
        }
    }
View Full Code Here

Examples of com.volantis.shared.security.acl.mutable.MutableACL

        // =====================================================================

        // =====================================================================
        //   Test Expectations
        // =====================================================================
        MutableACL acl = factory.createACL(principalMock);

        // The principal with which the ACL is first created is an owner.
        assertTrue(acl.isOwner(principalMock));

        // Another principal is not an owner.
        assertFalse(acl.isOwner(otherMock));

        // Adding the principal again should return false.
        assertFalse(acl.addOwner(principalMock, principalMock));

        // Adding another principal should return true and it is then an owner.
        assertTrue(acl.addOwner(principalMock, otherMock));
        assertTrue(acl.isOwner(otherMock));

        // Removing the original principal should return true, removing it
        // again should return false.
        assertTrue(acl.deleteOwner(principalMock, principalMock));
        assertFalse(acl.deleteOwner(otherMock, principalMock));

        // Attempting to remove the last owner should fail.
        try {
            acl.deleteOwner(otherMock, otherMock);
            fail("Did not detect attempt to remove last owner");
        } catch (LastOwnerException expected) {
        }
    }
View Full Code Here

Examples of com.volantis.shared.security.acl.mutable.MutableACL

     *
     * @todo support Group.
     */
    public void testPermissions() throws Exception {

        MutableACL acl = factory.createACL(principalMock);

        MutableACLEntry negative = factory.createACLEntry(otherMock, true);
        negative.addPermission(permission1Mock);

        acl.addEntry(principalMock, negative);

        MutableACLEntry positive = factory.createACLEntry(otherMock, false);
        positive.addPermission(permission1Mock);
        positive.addPermission(permission2Mock);

        acl.addEntry(principalMock, positive);

        Set permissions = acl.permissions(otherMock);
        assertEquals(permissions, Collections.singleton(permission2Mock));
    }
View Full Code Here

Examples of org.acegisecurity.acls.MutableAcl

                    if (acls.containsKey(new Long(parentId))) {
                        continue; // skip this while iteration
                    }

                    // Now try to find it in the cache
                    MutableAcl cached = aclCache.getFromCache(new Long(parentId));

                    if ((cached == null) || !cached.isSidLoaded(sids)) {
                        parentIdsToLookup.add(new Long(parentId));
                    } else {
                        // Pop into the acls map, so our convert method doesn't
                        // need to deal with an unsynchronized AclCache
                        acls.put(cached.getId(), cached);
                    }
                }
            }

            // Lookup parents, adding Acls (with StubAclParents) to "acl" map
View Full Code Here

Examples of org.acegisecurity.acls.MutableAcl

    //~ Methods ========================================================================================================

    public void evictFromCache(Serializable pk) {
        Assert.notNull(pk, "Primary key (identifier) required");

        MutableAcl acl = getFromCache(pk);

        if (acl != null) {
            cache.remove(acl.getId());
            cache.remove(acl.getObjectIdentity());
        }
    }
View Full Code Here

Examples of org.acegisecurity.acls.MutableAcl

    }

    public void evictFromCache(ObjectIdentity objectIdentity) {
        Assert.notNull(objectIdentity, "ObjectIdentity required");

        MutableAcl acl = getFromCache(objectIdentity);

        if (acl != null) {
            cache.remove(acl.getId());
            cache.remove(acl.getObjectIdentity());
        }
    }
View Full Code Here

Examples of org.acegisecurity.acls.MutableAcl

    private int counter = 1000;

    //~ Methods ========================================================================================================

    public void addPermission(Contact contact, Sid recipient, Permission permission) {
        MutableAcl acl;
        ObjectIdentity oid = new ObjectIdentityImpl(Contact.class, contact.getId());

        try {
            acl = (MutableAcl) mutableAclService.readAclById(oid);
        } catch (NotFoundException nfe) {
            acl = mutableAclService.createAcl(oid);
        }

        acl.insertAce(null, permission, recipient, true);
        mutableAclService.updateAcl(acl);

        if (logger.isDebugEnabled()) {
            logger.debug("Added permission " + permission + " for Sid " + recipient + " contact " + contact);
        }
View Full Code Here

Examples of org.acegisecurity.acls.MutableAcl

        }
    }

    public void deletePermission(Contact contact, Sid recipient, Permission permission) {
        ObjectIdentity oid = new ObjectIdentityImpl(Contact.class, contact.getId());
        MutableAcl acl = (MutableAcl) mutableAclService.readAclById(oid);

        // Remove all permissions associated with this particular recipient (string equality to KISS)
        AccessControlEntry[] entries = acl.getEntries();

        for (int i = 0; i < entries.length; i++) {
            if (entries[i].getSid().equals(recipient) && entries[i].getPermission().equals(permission)) {
                acl.deleteAce(entries[i].getId());
            }
        }

        mutableAclService.updateAcl(acl);
View Full Code Here

Examples of org.acegisecurity.acls.MutableAcl

        // Create acl_object_identity rows (and also acl_class rows as needed
        for (int i = 1; i < createEntities; i++) {
            final ObjectIdentity objectIdentity = new ObjectIdentityImpl(Contact.class, new Long(i));
            tt.execute(new TransactionCallback() {
                    public Object doInTransaction(TransactionStatus arg0) {
                        MutableAcl acl = mutableAclService.createAcl(objectIdentity);

                        return null;
                    }
                });
        }
View Full Code Here

Examples of org.springframework.security.acls.model.MutableAcl

    public void create(AbstractElement element) {
        super.create(element);

        // Create an ACL identity for this element
        ObjectIdentity identity = new ObjectIdentityImpl(element);
        MutableAcl acl = mutableAclService.createAcl(identity);

        // If the AbstractElement has a parent, go and retrieve its identity (it should already exist)
        if (element.getParent() != null) {
            ObjectIdentity parentIdentity = new ObjectIdentityImpl(element.getParent());
            MutableAcl aclParent = (MutableAcl) mutableAclService.readAclById(parentIdentity);
            acl.setParent(aclParent);
        }
        acl.insertAce(acl.getEntries().size(), BasePermission.ADMINISTRATION, new PrincipalSid(SecurityContextHolder.getContext().getAuthentication()), true);

        mutableAclService.updateAcl(acl);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.