Package org.apache.jackrabbit.api.security.user

Examples of org.apache.jackrabbit.api.security.user.Authorizable


        doImport(getTargetPath(), xml);

        assertTrue(target.isModified());
        assertTrue(adminSession.hasPendingChanges());

        Authorizable newUser = userMgr.getAuthorizable("t");
        Node n = adminSession.getNode(newUser.getPath());

        String pwValue = n.getProperty(UserConstants.REP_PASSWORD).getString();
        assertFalse(plainPw.equals(pwValue));
        assertTrue(pwValue.toLowerCase().startsWith("{sha"));
    }
View Full Code Here


        doImport(getTargetPath(), xml);

        assertTrue(target.isModified());
        assertTrue(adminSession.hasPendingChanges());

        Authorizable newUser = userMgr.getAuthorizable("t");
        assertNotNull(newUser);

        assertTrue(target.hasNode("t"));
        assertTrue(target.hasProperty("t/rep:password"));
        assertFalse(target.getProperty("t/rep:password").getDefinition().isProtected());
View Full Code Here

                "   <sv:property sv:name=\"rep:principalName\" sv:type=\"String\"><sv:value>t</sv:value></sv:property>" +
                "</sv:node>";

        doImport(getTargetPath(), xml);

        Authorizable user = userMgr.getAuthorizable("t");
        assertNotNull(user);
        assertFalse(user.isGroup());
        assertFalse(adminSession.propertyExists(user.getPath() + "/rep:password"));
    }
View Full Code Here

        // to determine the userID.
        try {
            UserManager umgr = getSystemUserManager(workspaceName);
            for (Principal p : subject.getPrincipals()) {
                if (!(p instanceof Group)) {
                    Authorizable authorz = umgr.getAuthorizable(p);
                    if (authorz != null && !authorz.isGroup()) {
                        uid = authorz.getID();
                        break;
                    }
                }
            }
        } catch (RepositoryException e) {
View Full Code Here

    static void createSystemUsers(UserManager userManager,
                                  SystemSession session,
                                  String adminId,
                                  String anonymousId) throws RepositoryException {

        Authorizable admin = null;
        if (adminId != null) {
            admin = userManager.getAuthorizable(adminId);
            if (admin == null) {
                admin = userManager.createUser(adminId, adminId);
                if (!userManager.isAutoSave()) {
                    session.save();
                }
                log.info("... created admin-user with id \'" + adminId + "\' ...");
            }
        }

        // assume administrators groupID and principalName are the same.
        // and avoid retrieving group by principal.
        Group admins = (Group) userManager.getAuthorizable(SecurityConstants.ADMINISTRATORS_NAME);
        if (admins == null) {
            admins = userManager.createGroup(new PrincipalImpl(SecurityConstants.ADMINISTRATORS_NAME));
            if (!userManager.isAutoSave()) {
                session.save();
            }
            log.info("... created administrators group with name '"+SecurityConstants.ADMINISTRATORS_NAME+"'");
        }

        try {
            if (admins != null && admins.addMember(admin)) {
                if (!userManager.isAutoSave()) {
                    session.save();
                }
                log.info("... added admin '" + adminId + "' as member of the administrators group.");
            }
        } catch (RepositoryException e) {
            // administrator has full permissions anyway. just log a
            // warning and ignore the error.
            log.warn("Unexpected error while adding admin to the administrators group", e);
        }

        if (anonymousId != null) {
            Authorizable anonymous = userManager.getAuthorizable(anonymousId);
            if (anonymous == null) {
                userManager.createUser(anonymousId, "");
                if (!userManager.isAutoSave()) {
                    session.save();
                }
View Full Code Here

            adminPw = adminId; // The default value as defined upon #createSystemUsers
        }

        @Override
        public Authorizable getAuthorizable(String id) throws RepositoryException {
            Authorizable a = super.getAuthorizable(id);
            if (a == null && adminId.equals(id)) {
                log.info("Admin user does not exist.");
                a = createAdmin(adminId, adminPw);
            }
            return a;
View Full Code Here

            throw new NotExecutableException();
        }
    }

    public void testGetPrincipal() throws RepositoryException {
        Authorizable admin = userMgr.getAuthorizable(adminId);
        assertNotNull(admin);
        assertFalse(admin.isGroup());
        assertTrue(admin.getPrincipal() instanceof AdminPrincipal);
    }
View Full Code Here

        assertFalse(admin.isGroup());
        assertTrue(admin.getPrincipal() instanceof AdminPrincipal);
    }

    public void testMemberOfAdministrators() throws RepositoryException {
        Authorizable admins = userMgr.getAuthorizable(SecurityConstants.ADMINISTRATORS_NAME);
        if (admins != null && admins.isGroup()) {
            assertTrue(((Group) admins).isMember(userMgr.getAuthorizable(adminId)));
        }
    }
View Full Code Here

            assertTrue(((Group) admins).isMember(userMgr.getAuthorizable(adminId)));
        }
    }

    public void testRemoveSelf() throws RepositoryException, NotExecutableException {
        Authorizable admin = userMgr.getAuthorizable(adminId);
        if (admin == null) {
            throw new NotExecutableException();
        }
        try {
            admin.remove();
            fail("The Administrator should not be allowed to remove the own authorizable.");
        } catch (RepositoryException e) {
            // success
        }
    }
View Full Code Here

            // success
        }
    }

    public void testRemoveAdminNode() throws RepositoryException, NotExecutableException {
        Authorizable admin = userMgr.getAuthorizable(adminId);

        if (admin == null || !(admin instanceof AuthorizableImpl)) {
            throw new NotExecutableException();
        }
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.api.security.user.Authorizable

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.