Package org.apache.jackrabbit.core.security

Examples of org.apache.jackrabbit.core.security.TestPrincipal


    protected void setUp() throws Exception {
        super.setUp();

        UserManager uMgr = getUserManager(superuser);
        // create the testUser
        Principal principal = new TestPrincipal("testUser" + UUID.randomUUID());
        String uid = principal.getName();
        String pw = principal.getName();
        creds = new SimpleCredentials(uid, pw.toCharArray());
        testUser = uMgr.createUser(uid, pw);

        // create some nodes below the test root in order to apply ac-stuff
        Node node = testRootNode.addNode(nodeName1, testNodeType);
View Full Code Here


    }

    protected Group getTestGroup() throws RepositoryException, NotExecutableException {
        if (testGroup == null) {
            // create the testGroup
            Principal principal = new TestPrincipal("testGroup" + UUID.randomUUID());
            testGroup = getUserManager(superuser).createGroup(principal);
            testGroup.addMember(testUser);
        }
        return testGroup;
    }
View Full Code Here

    }

    public void testAddInvalidEntry() throws RepositoryException, NotExecutableException {
        Principal unknownPrincipal;
        if (!pMgr.hasPrincipal("an unknown principal")) {
            unknownPrincipal = new TestPrincipal("an unknown principal");
        } else {
            throw new NotExecutableException();
        }
        JackrabbitAccessControlList pt = (JackrabbitAccessControlList) createEmptyTemplate(getTestPath());
        try {
View Full Code Here

        try {
            UserManager uMgr = getUserManager(superuser);

            u = uMgr.createUser("t", "t");
            u2 = uMgr.createUser("tt", "tt", new TestPrincipal("tt"), "t/tt");

            Principal p = u.getPrincipal();
            Principal p2 = u2.getPrincipal();

            if (p instanceof ItemBasedPrincipal && p2 instanceof ItemBasedPrincipal &&
View Full Code Here

    }

    public void testAddInvalidEntry() throws RepositoryException, NotExecutableException {
        Principal unknownPrincipal;
        if (!pMgr.hasPrincipal("an unknown principal")) {
            unknownPrincipal = new TestPrincipal("an unknown principal");
        } else {
            throw new NotExecutableException();
        }
        JackrabbitAccessControlList pt = createEmptyTemplate(getTestPath());
        try {
View Full Code Here

    }

    protected Group getTestGroup() throws RepositoryException, NotExecutableException {
        if (testGroup == null) {
            // create the testGroup
            Principal principal = new TestPrincipal("testGroup" + UUID.randomUUID());
            testGroup = getUserManager(superuser).createGroup(principal);
            testGroup.addMember(testUser);
        }
        return testGroup;
    }
View Full Code Here

        String pn = "any_principal" + UUID.randomUUID();
        return getTestPrincipal(pn);
    }

    protected Principal getTestPrincipal(String name) throws RepositoryException {
        Principal p = new TestPrincipal(name);
        return p;
    }
View Full Code Here

        User u = null;
        Group gr = null;
        try {
            u = userMgr.createUser(uid, buildPassword(uid, true), p, null);
            gr = userMgr.createGroup(new TestPrincipal(uid));

            String msg = "Creating a Group with a principal-name that exists as UserID -> must create new GroupID but keep PrincipalName.";
            assertFalse(msg, gr.getID().equals(gr.getPrincipal().getName()));
            assertFalse(msg, gr.getID().equals(uid));
            assertFalse(msg, gr.getID().equals(u.getID()));
View Full Code Here

            assertNotNull("User with id " + uid + " must exist.", ath);
            assertFalse("User with id " + uid + " must not be a group.", ath.isGroup());
        }

        // test for groups as well
        GroupImpl gr = (GroupImpl) uMgr.createGroup(new TestPrincipal("z[x]"));
        // remember the z-folder for later removal
        toRemove.add((NodeImpl) gr.getNode().getParent().getParent());

        assertEquals("z[x]", gr.getID());
        String expectedPath = UserConstants.GROUPS_PATH + "/z/" + Text.escapeIllegalJcrChars("z[") + "/" + Text.escapeIllegalJcrChars("z[x]");
        assertEquals(expectedPath, gr.getNode().getPath());

        Authorizable ath = uMgr.getAuthorizable(gr.getID());
        assertNotNull(ath);
        assertTrue(ath.isGroup());

        // test if conflicting authorizables are detected.
        try {
            uMgr.createUser("z[x]", "z[x]");
            fail("A group \"z[x]\" already exists.");
        } catch (AuthorizableExistsException e) {
            // success
        }

        try {
            uMgr.createGroup(new TestPrincipal("z*rik"));
            fail("A user \"z*rik\" already exists");
        } catch (AuthorizableExistsException e) {
            // success
        }
    }
View Full Code Here

    }

    protected Group getTestGroup() throws RepositoryException, NotExecutableException {
        if (testGroup == null) {
            // create the testGroup
            Principal principal = new TestPrincipal("testGroup" + UUID.randomUUID());
            testGroup = getUserManager(superuser).createGroup(principal);
            testGroup.addMember(testUser);
        }
        return testGroup;
    }
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.core.security.TestPrincipal

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.