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

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


         * @return the repository group
         * @throws RepositoryException if an error occurs
         */
        @CheckForNull
        private Group createGroup(ExternalGroup externalGroup) throws RepositoryException {
            Principal principal = new PrincipalImpl(externalGroup.getPrincipalName());
            Group group = userManager.createGroup(
                    externalGroup.getId(),
                    principal,
                    joinPaths(config.group().getPathPrefix(), externalGroup.getIntermediatePath())
            );
View Full Code Here


                @Override
                public Principal apply(String principalName) {
                    Principal principal = principalManager.getPrincipal(principalName);
                    if (principal == null) {
                        log.debug("Unknown principal " + principalName);
                        principal = new PrincipalImpl(principalName);
                    }
                    return principal;
                }
            }));
        }
View Full Code Here

    public boolean isExcluded(@Nonnull Set<Principal> principals) {
        if (super.isExcluded(principals)) {
            return true;
        }
        for (String principalName : principalNames) {
            if (principals.contains(new PrincipalImpl(principalName))) {
                return true;
            }
        }
        if (principalPaths.length > 0) {
            for (String principalPath : getPrincipalPaths(principals)) {
View Full Code Here

         * @return the repository user
         * @throws RepositoryException if an error occurs
         */
        @CheckForNull
        private User createUser(ExternalUser externalUser) throws RepositoryException {
            Principal principal = new PrincipalImpl(externalUser.getPrincipalName());
            User user = userManager.createUser(
                    externalUser.getId(),
                    null,
                    principal,
                    joinPaths(config.user().getPathPrefix(), externalUser.getIntermediatePath())
View Full Code Here

         * @return the repository group
         * @throws RepositoryException if an error occurs
         */
        @CheckForNull
        private Group createGroup(ExternalGroup externalGroup) throws RepositoryException {
            Principal principal = new PrincipalImpl(externalGroup.getPrincipalName());
            Group group = userManager.createGroup(
                    externalGroup.getId(),
                    principal,
                    joinPaths(config.group().getPathPrefix(), externalGroup.getIntermediatePath())
            );
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

        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");
            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 testInternalPrincipal() throws RepositoryException {
        Principal internal = new PrincipalImpl("unknown");
        acl.addAccessControlEntry(internal, privilegesFromNames(JCR_READ));
    }
View Full Code Here

    @Test
    public void testEmptyPrincipal() throws Exception {

        try {
            acl.addAccessControlEntry(new PrincipalImpl(""), privilegesFromNames(JCR_READ));
            fail("Adding an ACE with empty-named principal should fail");
        } catch (AccessControlException e) {
            // success
        }
    }
View Full Code Here

        }
    }

    @Test
    public void testAddEntriesWithCustomPrincipal()  throws Exception {
        Principal oakPrincipal = new PrincipalImpl("anonymous");
        Principal principal = new Principal() {
            @Override
            public String getName() {
                return "anonymous";
            }
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.