Package com.volantis.shared.security.acl.mutable

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


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

        // =====================================================================
        //   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

     *
     * @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

TOP

Related Classes of com.volantis.shared.security.acl.mutable.MutableACL

Copyright © 2018 www.massapicom. 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.