Package org.apache.jackrabbit.core

Examples of org.apache.jackrabbit.core.SessionImpl


    ACLTemplate(NodeImpl aclNode, String path) throws RepositoryException {
        super(path, (aclNode != null) ? aclNode.getSession().getValueFactory() : null);
        if (aclNode == null || !NT_REP_ACL.equals(aclNode.getPrimaryNodeTypeName())) {
            throw new IllegalArgumentException("Node must be of type 'rep:ACL'");
        }
        SessionImpl sImpl = (SessionImpl) aclNode.getSession();
        principalMgr = sImpl.getPrincipalManager();
        privilegeMgr = (PrivilegeManagerImpl) ((JackrabbitWorkspace) sImpl.getWorkspace()).getPrivilegeManager();

        this.resolver = sImpl;
        jcrRepGlob = sImpl.getJCRName(P_GLOB);

        // load the entries:
        NodeIterator itr = aclNode.getNodes();
        while (itr.hasNext()) {
            NodeImpl aceNode = (NodeImpl) itr.nextNode();
View Full Code Here


     * @see AccessControlProvider#init(Session, Map)
     */
    public void init(Session systemSession, Map configuration) throws RepositoryException {
        super.init(systemSession, configuration);
        if (systemSession instanceof SessionImpl) {
            SessionImpl sImpl = (SessionImpl) systemSession;
            userAdminGroup = (configuration.containsKey(USER_ADMIN_GROUP_NAME)) ? configuration.get(USER_ADMIN_GROUP_NAME).toString() : USER_ADMIN_GROUP_NAME;
            groupAdminGroup = (configuration.containsKey(GROUP_ADMIN_GROUP_NAME)) ? configuration.get(GROUP_ADMIN_GROUP_NAME).toString() : GROUP_ADMIN_GROUP_NAME;

            // make sure the groups exist (and ev. create them).
            UserManager uMgr = sImpl.getUserManager();
            if (!initGroup(uMgr, userAdminGroup)) {
                log.warn("Unable to initialize User admininistrator group -> no user admins.");
                userAdminGroup = null;
            }
            if (!initGroup(uMgr, groupAdminGroup)) {
                log.warn("Unable to initialize Group admininistrator group -> no group admins.");
                groupAdminGroup = null;
            }

            usersPath = sImpl.getQPath(USERS_PATH);
            groupsPath = sImpl.getQPath(GROUPS_PATH);
        } else {
            throw new RepositoryException("SessionImpl (system session) expected.");
        }
    }
View Full Code Here

    protected String getTestPath() {
        return "/ab/c/d";
    }

    protected JackrabbitAccessControlList createEmptyTemplate(String path) throws RepositoryException {
        SessionImpl sImpl = (SessionImpl) superuser;
        PrincipalManager princicipalMgr = sImpl.getPrincipalManager();
        PrivilegeRegistry privilegeRegistry = new PrivilegeRegistry(sImpl);
        return new ACLTemplate(path, princicipalMgr, privilegeRegistry, sImpl.getValueFactory());
    }
View Full Code Here

        currentUser.removeProperty(propertyName1);
    }

    public void testFindNodeWithNonExistingSearchRoot() throws NotExecutableException, RepositoryException {
        String searchRoot = nodeResolver.getSearchRoot(UserConstants.NT_REP_AUTHORIZABLE_FOLDER);
        SessionImpl sImpl = (SessionImpl) superuser;

        if (sImpl.nodeExists(searchRoot)) {
            throw new NotExecutableException();
        }
        Node result = nodeResolver.findNode(sImpl.getQName(UserConstants.GROUP_ADMIN_GROUP_NAME), UserConstants.NT_REP_AUTHORIZABLE);
        assertNull(result);
    }
View Full Code Here

     * @throws RepositoryException
     */
    public void testEnforceAuthorizableFolderHierarchy() throws RepositoryException {
        AuthorizableImpl authImpl = (AuthorizableImpl) userMgr.getAuthorizable(superuser.getUserID());
        Node userNode = authImpl.getNode();
        SessionImpl sImpl = (SessionImpl) userNode.getSession();

        Node folder = userNode.addNode("folder", sImpl.getJCRName(UserConstants.NT_REP_AUTHORIZABLE_FOLDER));
        String path = folder.getPath();
        try {
            // authNode - authFolder -> create User
            Authorizable a = null;
            try {
                Principal p = getTestPrincipal();
                a = userMgr.createUser(p.getName(), p.getName(), p, path);
                fail("Users may not be nested.");
            } catch (RepositoryException e) {
                // success
            } finally {
                if (a != null) {
                    a.remove();
                }
            }
        } finally {
            if (sImpl.nodeExists(path)) {
                folder.remove();
                sImpl.save();
            }
        }

        Node someContent = userNode.addNode("mystuff", "nt:unstructured");
        path = someContent.getPath();
        try {
            // authNode - anyNode -> create User
            Authorizable a = null;
            try {
                Principal p = getTestPrincipal();
                a = userMgr.createUser(p.getName(), p.getName(), p, someContent.getPath());
                fail("Users may not be nested.");
            } catch (RepositoryException e) {
                // success
            } finally {
                if (a != null) {
                    a.remove();
                    a = null;
                }
            }

            // authNode - anyNode - authFolder -> create User
            if (!sImpl.nodeExists(path)) {
                someContent = userNode.addNode("mystuff", "nt:unstructured");              
            }
            folder = someContent.addNode("folder", sImpl.getJCRName(UserConstants.NT_REP_AUTHORIZABLE_FOLDER));
            sImpl.save(); // this time save node structure
            try {
                Principal p = getTestPrincipal();
                a = userMgr.createUser(p.getName(), p.getName(), p, folder.getPath());
                fail("Users may not be nested.");
            } catch (RepositoryException e) {
                // success
            } finally {
                if (a != null) {
                    a.remove();
                }
            }
        } finally {
            if (sImpl.nodeExists(path)) {
                someContent.remove();
                sImpl.save();
            }
        }
    }
View Full Code Here

                otherWsp = wsp;
                break;
            }
        }

        SessionImpl sImpl = (SessionImpl) superuser;
        Subject subject = sImpl.getSubject();

        Session s1 = sImpl.createSession(currentWsp);
        try {
            assertFalse(s1 == sImpl);
            assertFalse(subject == ((SessionImpl) s1).getSubject());
            assertEquals(subject, ((SessionImpl) s1).getSubject());
            assertEquals(currentWsp, s1.getWorkspace().getName());
        } finally {
            s1.logout();
            assertFalse(subject.getPrincipals().isEmpty());
        }


        Session s2 = sImpl.createSession(otherWsp);
        try {
            assertFalse(s2 == sImpl);
            assertFalse(subject == ((SessionImpl) s2).getSubject());
            assertEquals(subject, ((SessionImpl) s2).getSubject());
            assertEquals(otherWsp, s2.getWorkspace().getName());
        } finally {
            s2.logout();
            assertFalse(subject.getPrincipals().isEmpty());
        }

        Session s3 = sImpl.createSession(null);
        try {
            assertFalse(s3 == sImpl);
            assertFalse(subject == ((SessionImpl) s3).getSubject());
            assertEquals(subject, ((SessionImpl) s3).getSubject());
            assertEquals(((RepositoryImpl) sImpl.getRepository()).getConfig().getDefaultWorkspaceName(), s3.getWorkspace().getName());
        } finally {
            s3.logout();
            assertFalse(subject.getPrincipals().isEmpty());
        }
    }
View Full Code Here

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

        SessionImpl s = (SessionImpl) superuser;

        acl = new ACLTemplate(testPath, s.getPrincipalManager(), new PrivilegeRegistry(s), s.getValueFactory(), s);
    }
View Full Code Here

    ACLTemplate(NodeImpl aclNode, PrivilegeRegistry privilegeRegistry) throws RepositoryException {
        super((aclNode != null) ? aclNode.getParent().getPath() : null, (aclNode != null) ? aclNode.getSession().getValueFactory() : null);
        if (aclNode == null || !NT_REP_ACL.equals(((NodeTypeImpl)aclNode.getPrimaryNodeType()).getQName())) {
            throw new IllegalArgumentException("Node must be of type 'rep:ACL'");
        }
        SessionImpl sImpl = (SessionImpl) aclNode.getSession();
        principalMgr = sImpl.getPrincipalManager();

        this.privilegeRegistry = privilegeRegistry;
        this.resolver = sImpl;
        this.id = aclNode.getParentId();
        jcrRepGlob = sImpl.getJCRName(P_GLOB);

        // load the entries:
        AccessControlManager acMgr = sImpl.getAccessControlManager();
        NodeIterator itr = aclNode.getNodes();
        while (itr.hasNext()) {
            NodeImpl aceNode = (NodeImpl) itr.nextNode();
            try {
                String principalName = aceNode.getProperty(P_PRINCIPAL_NAME).getString();
View Full Code Here

        return "/ab/c/d";
    }

    @Override
    protected JackrabbitAccessControlList createEmptyTemplate(String path) throws RepositoryException {
        SessionImpl sImpl = (SessionImpl) superuser;
        PrincipalManager princicipalMgr = sImpl.getPrincipalManager();
        PrivilegeRegistry privilegeRegistry = new PrivilegeRegistry(sImpl);
        return new ACLTemplate(path, princicipalMgr, privilegeRegistry, sImpl.getValueFactory(), sImpl);
    }
View Full Code Here

    public boolean canReadPrincipal(Session session, Principal principal) {
        checkInitialized();
        // check if the session can read the user/group associated with the
        // given principal
        if (session instanceof SessionImpl) {
            SessionImpl sImpl = (SessionImpl) session;
            Subject subject = sImpl.getSubject();
            if (!subject.getPrincipals(SystemPrincipal.class).isEmpty()
                    || !subject.getPrincipals(AdminPrincipal.class).isEmpty()) {
                return true;
            }
            try {
                UserManager umgr = sImpl.getUserManager();
                return umgr.getAuthorizable(principal) != null;
            } catch (RepositoryException e) {
                log.error("Failed to determine accessibility of Principal {}", principal, e);
            }
        }
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.core.SessionImpl

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.