Search in sources :

Example 21 with AuthorizableExistsException

use of org.apache.jackrabbit.api.security.user.AuthorizableExistsException in project jackrabbit-oak by apache.

the class UserManagerTest method testCreateGroupWithExistingGroupID.

@Test
public void testCreateGroupWithExistingGroupID() throws RepositoryException, NotExecutableException {
    Group g = null;
    try {
        String id = createGroupId();
        // create a user with the given ID
        g = userMgr.createGroup(id);
        superuser.save();
        // assert AuthorizableExistsException for id that is already in use
        Group gr = null;
        try {
            gr = userMgr.createGroup(id);
            fail("ID " + id + " is already in use -> must throw AuthorizableExistsException.");
        } catch (AuthorizableExistsException aee) {
        // expected this
        } finally {
            if (gr != null) {
                gr.remove();
                superuser.save();
            }
        }
    } finally {
        if (g != null) {
            g.remove();
            superuser.save();
        }
    }
}
Also used : Group(org.apache.jackrabbit.api.security.user.Group) AuthorizableExistsException(org.apache.jackrabbit.api.security.user.AuthorizableExistsException) Test(org.junit.Test)

Aggregations

AuthorizableExistsException (org.apache.jackrabbit.api.security.user.AuthorizableExistsException)21 User (org.apache.jackrabbit.api.security.user.User)14 Principal (java.security.Principal)13 Group (org.apache.jackrabbit.api.security.user.Group)13 Test (org.junit.Test)8 TestPrincipal (org.apache.jackrabbit.core.security.TestPrincipal)7 EveryonePrincipal (org.apache.jackrabbit.core.security.principal.EveryonePrincipal)6 RepositoryException (javax.jcr.RepositoryException)3 Authorizable (org.apache.jackrabbit.api.security.user.Authorizable)3 EveryonePrincipal (org.apache.jackrabbit.oak.spi.security.principal.EveryonePrincipal)3 HashMap (java.util.HashMap)1 ConstraintViolationException (javax.jcr.nodetype.ConstraintViolationException)1 ListOrderedMap (org.apache.commons.collections.map.ListOrderedMap)1 PrincipalImpl (org.apache.jackrabbit.oak.spi.security.principal.PrincipalImpl)1