Search in sources :

Example 1 with InvalidTestPrincipal

use of org.apache.jackrabbit.oak.security.authorization.accesscontrol.InvalidTestPrincipal in project jackrabbit-oak by apache.

the class L5_AccessControlListImplTest method testAddEntryWithInvalidPrincipals.

public void testAddEntryWithInvalidPrincipals() throws Exception {
    // EXERCISE: explain for each principal in the list why using it for an ACE fails
    List<Principal> invalidPrincipals = ImmutableList.of(new InvalidTestPrincipal("unknown"), null, new PrincipalImpl(""), new Principal() {

        @Override
        public String getName() {
            return "unknown";
        }
    });
    for (Principal principal : invalidPrincipals) {
        try {
            acl.addAccessControlEntry(principal, testPrivileges);
            fail("Adding an ACE with an invalid principal should fail");
        } catch (AccessControlException e) {
        // success
        }
    }
}
Also used : AccessControlException(javax.jcr.security.AccessControlException) PrincipalImpl(org.apache.jackrabbit.oak.spi.security.principal.PrincipalImpl) InvalidTestPrincipal(org.apache.jackrabbit.oak.security.authorization.accesscontrol.InvalidTestPrincipal) Principal(java.security.Principal) InvalidTestPrincipal(org.apache.jackrabbit.oak.security.authorization.accesscontrol.InvalidTestPrincipal)

Aggregations

Principal (java.security.Principal)1 AccessControlException (javax.jcr.security.AccessControlException)1 InvalidTestPrincipal (org.apache.jackrabbit.oak.security.authorization.accesscontrol.InvalidTestPrincipal)1 PrincipalImpl (org.apache.jackrabbit.oak.spi.security.principal.PrincipalImpl)1