Package org.apache.jackrabbit.oak.spi.security.principal

Examples of org.apache.jackrabbit.oak.spi.security.principal.PrincipalImpl


        return getQueryManager().findAuthorizables(query);
    }

    @Override
    public User createUser(final String userId, String password) throws RepositoryException {
        Principal principal = new PrincipalImpl(userId);
        return createUser(userId, password, principal, null);
    }
View Full Code Here


        return user;
    }

    @Override
    public Group createGroup(String groupId) throws RepositoryException {
        Principal principal = new PrincipalImpl(groupId);
        return createGroup(groupId, principal, null);
    }
View Full Code Here

        }
    }

    @Test
    public void testAddEntryWithOakPrincipal() throws Exception {
        Principal oakPrincipal = new PrincipalImpl("name");
        acl.addAccessControlEntry(oakPrincipal, privilegesFromNames(JCR_READ));
    }
View Full Code Here

    @Test
    public void testDifferentPrivilegeImplementation() throws Exception {
        Privilege[] readPriv = privilegesFromNames(JCR_READ);
        acl.addEntry(testPrincipal, readPriv, false);

        assertFalse(acl.addEntry(new PrincipalImpl(testPrincipal.getName()), readPriv, false));
        assertFalse(acl.addEntry(new Principal() {
            public String getName() {
                return testPrincipal.getName();
            }
        }, readPriv, false));
View Full Code Here

    protected List<ACE> createTestEntries() throws RepositoryException {
        List<ACE> entries = new ArrayList<ACE>(3);
        for (int i = 0; i < 3; i++) {
            entries.add(new ACE(
                    new PrincipalImpl("testPrincipal" + i),
                    new Privilege[]{getPrivilegeManager(root).getPrivilege(PrivilegeConstants.JCR_READ)},
                    true, null, namePathMapper));
        }
        return entries;
    }
View Full Code Here

        Principal unknown = getPrincipalManager(root).getPrincipal("unknown");
        int i = 0;
        while (unknown != null) {
            unknown = getPrincipalManager(root).getPrincipal("unknown"+i);
        }
        unknown = new PrincipalImpl("unknown" + i);

        assertEquals(1, acMgr.getApplicablePolicies(unknown).length);
    }
View Full Code Here

        Principal unknown = getPrincipalManager(root).getPrincipal("unknown");
        int i = 0;
        while (unknown != null) {
            unknown = getPrincipalManager(root).getPrincipal("unknown"+i);
        }
        unknown = new PrincipalImpl("unknown" + i);
        assertEquals(0, acMgr.getPolicies(unknown).length);
    }
View Full Code Here

    @Before
    @Override
    public void before() throws Exception {
        super.before();

        userPrincipal = new PrincipalImpl("test");
        group1 = EveryonePrincipal.getInstance();
        group2 = new GroupImpl("group2");
        group3 = new GroupImpl("group3");

        pbp = new PrivilegeBitsProvider(root);
View Full Code Here

        NodeUtil folder = userNode.addChild("folder", UserConstants.NT_REP_AUTHORIZABLE_FOLDER);
        String path = folder.getTree().getPath();

        // authNode - authFolder -> create User
        try {
            Principal p = new PrincipalImpl("test2");
            Authorizable a = userMgr.createUser(p.getName(), p.getName(), p, path);
            root.commit();

            fail("Users may not be nested.");
        } catch (CommitFailedException e) {
            // success
        } finally {
            Authorizable a = userMgr.getAuthorizable("test2");
            if (a != null) {
                a.remove();
                root.commit();
            }
        }

        NodeUtil someContent = userNode.addChild("mystuff", JcrConstants.NT_UNSTRUCTURED);
        path = someContent.getTree().getPath();
        try {
            // authNode - anyNode -> create User
            try {
                Principal p = new PrincipalImpl("test3");
                userMgr.createUser(p.getName(), p.getName(), p, path);
                root.commit();

                fail("Users may not be nested.");
            } catch (CommitFailedException e) {
                // success
            } finally {
                Authorizable a = userMgr.getAuthorizable("test3");
                if (a != null) {
                    a.remove();
                    root.commit();
                }
            }

            // authNode - anyNode - authFolder -> create User
            folder = someContent.addChild("folder", UserConstants.NT_REP_AUTHORIZABLE_FOLDER);
            root.commit(); // this time save node structure
            try {
                Principal p = new PrincipalImpl("test4");
                userMgr.createUser(p.getName(), p.getName(), p, folder.getTree().getPath());
                root.commit();

                fail("Users may not be nested.");
            } catch (CommitFailedException e) {
                // success
View Full Code Here

    @Test
    public void testCreateGroupWithInvalidIdOrPrincipal() throws RepositoryException, NotExecutableException {
        Principal p = getTestPrincipal();
        String uid = p.getName();

        Principal emptyNamePrincipal = new PrincipalImpl("");

        Map<String, Principal> fail = new HashMap<String, Principal>();
        fail.put(uid, null);
        fail.put(uid, emptyNamePrincipal);
        fail.put(null, p);
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.oak.spi.security.principal.PrincipalImpl

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.