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

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


            return null;
        }

        @Override
        public Principal getPrincipal() {
            return new PrincipalImpl(userId);
        }
View Full Code Here


    }

    @Override
    public Principal getPrincipal() {
        if (principal == null) {
            principal = new PrincipalImpl(uid);
        }
        return principal;
    }
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

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

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

            Set<Principal> s = new HashSet<Principal>();
            for (final String pName : impersonators) {
                Principal p = principalProvider.getPrincipal(pName);
                if (p == null) {
                    log.debug("Impersonator " + pName + " does not correspond to a known Principal.");
                    p = new PrincipalImpl(pName);
                }
                s.add(p);

            }
            return new PrincipalIteratorAdapter(s);
View Full Code Here

        private void setPrincipal(TextValue txtValue) {
            String principalName = txtValue.getString();
            principal = principalProvider.getPrincipal(principalName);
            // TODO: review handling of unknown principals
            if (principal == null) {
                principal = new PrincipalImpl(principalName);
            }
        }
View Full Code Here

                    handleFailure("Failed to revoke impersonation for " + principalName + " on " + a);
                }
            }
            List<String> nonExisting = new ArrayList<String>();
            for (String principalName : toAdd) {
                if (!imp.grantImpersonation(new PrincipalImpl(principalName))) {
                    handleFailure("Failed to grant impersonation for " + principalName + " on " + a);
                    if (importBehavior == ImportBehavior.BESTEFFORT &&
                            getPrincipalProvider().getPrincipal(principalName) == null) {
                        log.info("ImportBehavior.BESTEFFORT: Remember non-existing impersonator for special processing.");
                        nonExisting.add(principalName);
View Full Code Here

    private Principal getPrincipal(@Nonnull NodeUtil aceNode) {
        String principalName = checkNotNull(aceNode.getString(REP_PRINCIPAL_NAME, null));
        Principal principal = principalProvider.getPrincipal(principalName);
        if (principal == null) {
            log.debug("Unknown principal " + principalName);
            principal = new PrincipalImpl(principalName);
        }
        return principal;
    }
View Full Code Here

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

        NodeUtil folder = userNode.addChild("folder", UserConstants.NT_REP_AUTHORIZABLE_FOLDER);
        String path = folder.getTree().getPath();
        try {
            // 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 {
                root.refresh();
                Authorizable a = userMgr.getAuthorizable("test2");
                if (a != null) {
                    a.remove();
                    root.commit();
                }
            }
        } finally {
            root.refresh();
            folder.getTree().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 {
                root.refresh();
                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

TOP

Related Classes of org.apache.jackrabbit.oak.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.