Examples of AccessManager


Examples of org.apache.jackrabbit.core.security.AccessManager

        NodeId targetId = targetNode.getNodeId();
        int index = srcPath.getNormalizedIndex();

        // check permissions
        AccessManager acMgr = context.getAccessManager();
        if (!(acMgr.isGranted(srcPath, Permission.REMOVE_NODE) &&
                acMgr.isGranted(destPath, Permission.ADD_NODE | Permission.NODE_TYPE_MNGMT))) {
            String msg = "Not allowed to move node " + srcAbsPath + " to " + destAbsPath;
            log.debug(msg);
            throw new AccessDeniedException(msg);
        }
View Full Code Here

Examples of org.apache.jackrabbit.core.security.AccessManager

     * @see javax.jcr.Session#getAccessControlManager()
     * @since JCR 2.0
     */
    public AccessControlManager getAccessControlManager()
            throws UnsupportedRepositoryOperationException, RepositoryException {
        AccessManager accessMgr = context.getAccessManager();
        if (accessMgr instanceof AccessControlManager) {
            return (AccessControlManager) accessMgr;
        } else {
            throw new UnsupportedRepositoryOperationException(
                    "Access control discovery is not supported.");
View Full Code Here

Examples of org.apache.jackrabbit.core.security.AccessManager

        checkInitialized();
        AccessManagerConfig amConfig = repository.getConfig().getSecurityConfig().getAccessManagerConfig();
        try {
            String wspName = session.getWorkspace().getName();
            AccessControlProvider pp = getAccessControlProvider(wspName);
            AccessManager accessMgr;
            if (amConfig == null) {
                log.debug("No configuration entry for AccessManager. Using org.apache.jackrabbit.core.security.DefaultAccessManager");
                accessMgr = new DefaultAccessManager();
            } else {
                accessMgr = amConfig.newInstance(AccessManager.class);
            }

            accessMgr.init(amContext, pp, workspaceAccessManager);
            return accessMgr;
        } catch (AccessDeniedException e) {
            // re-throw
            throw e;
        } catch (Exception e) {
View Full Code Here

Examples of org.apache.jackrabbit.core.security.AccessManager

        }


        List ids;
        List scores;
        AccessManager accessMgr = session.getAccessManager();

        // execute it
        QueryHits result = null;
        try {
            result = index.executeQuery(this, query, orderProperties, ascSpecs);
            ids = new ArrayList(result.length());
            scores = new ArrayList(result.length());

            for (int i = 0; i < result.length(); i++) {
                NodeId id = NodeId.valueOf(result.doc(i).get(FieldNames.UUID));
                // check access
                if (accessMgr.isGranted(id, AccessManager.READ)) {
                    ids.add(id);
                    scores.add(new Float(result.score(i)));
                }
            }
        } catch (IOException e) {
View Full Code Here

Examples of org.apache.jackrabbit.core.security.AccessManager

         * (for adding/removing child entries of a node), in
         * Node.addMixin/removeMixin (for mixin changes on nodes)
         * and in Property.setValue (for properties to be modified).
         */

        AccessManager accessMgr = session.getAccessManager();
        // walk through list of dirty transient items and validate each
        while (dirtyIter.hasNext()) {
            ItemState itemState = (ItemState) dirtyIter.next();

            if (itemState.getStatus() != ItemState.STATUS_NEW) {
                // transient item is not 'new', therefore it has to be 'modified'

                // check WRITE permission
                ItemId id = itemState.getId();
                if (!accessMgr.isGranted(id, AccessManager.WRITE)) {
                    String msg = itemMgr.safeGetJCRPath(id)
                            + ": not allowed to modify item";
                    log.debug(msg);
                    throw new AccessDeniedException(msg);
                }
            }

            if (itemState.isNode()) {
                // the transient item is a node
                NodeState nodeState = (NodeState) itemState;
                ItemId id = nodeState.getNodeId();
                NodeImpl node = (NodeImpl) itemMgr.getItem(id);
                NodeDefinition def = node.getDefinition();
                // primary type
                NodeTypeImpl pnt = (NodeTypeImpl) node.getPrimaryNodeType();
                // effective node type (primary type incl. mixins)
                EffectiveNodeType ent = node.getEffectiveNodeType();
                /**
                 * if the transient node was added (i.e. if it is 'new'),
                 * check its node's node type against the required node type
                 * in its definition
                 */
                if (nodeState.getStatus() == ItemState.STATUS_NEW) {
                    NodeType[] nta = def.getRequiredPrimaryTypes();
                    for (int i = 0; i < nta.length; i++) {
                        NodeTypeImpl ntReq = (NodeTypeImpl) nta[i];
                        if (!(pnt.getQName().equals(ntReq.getQName())
                                || pnt.isDerivedFrom(ntReq.getQName()))) {
                            /**
                             * the transient node's primary node type does not
                             * satisfy the 'required primary types' constraint
                             */
                            String msg = node.safeGetJCRPath()
                                    + " must be of node type " + ntReq.getName();
                            log.debug(msg);
                            throw new ConstraintViolationException(msg);
                        }
                    }
                }

                // mandatory child properties
                PropDef[] pda = ent.getMandatoryPropDefs();
                for (int i = 0; i < pda.length; i++) {
                    PropDef pd = pda[i];
                    if (pd.getDeclaringNodeType().equals(QName.MIX_VERSIONABLE)) {
                        /**
                         * todo FIXME workaround for mix:versionable:
                         * the mandatory properties are initialized at a
                         * later stage and might not exist yet
                         */
                        continue;
                    }
                    if (!nodeState.hasPropertyName(pd.getName())) {
                        String msg = node.safeGetJCRPath()
                                + ": mandatory property " + pd.getName()
                                + " does not exist";
                        log.debug(msg);
                        throw new ConstraintViolationException(msg);
                    }
                }
                // mandatory child nodes
                NodeDef[] cnda = ent.getMandatoryNodeDefs();
                for (int i = 0; i < cnda.length; i++) {
                    NodeDef cnd = cnda[i];
                    if (!nodeState.hasChildNodeEntry(cnd.getName())) {
                        String msg = node.safeGetJCRPath()
                                + ": mandatory child node " + cnd.getName()
                                + " does not exist";
                        log.debug(msg);
                        throw new ConstraintViolationException(msg);
                    }
                }
            } else {
                // the transient item is a property
                PropertyState propState = (PropertyState) itemState;
                ItemId propId = propState.getPropertyId();
                PropertyImpl prop = (PropertyImpl) itemMgr.getItem(propId);
                PropertyDefinitionImpl def =
                        (PropertyDefinitionImpl) prop.getDefinition();

                /**
                 * check value constraints
                 * (no need to check value constraints of protected properties
                 * as those are set by the implementation only, i.e. they
                 * cannot be set by the user through the api)
                 */
                if (!def.isProtected()) {
                    String[] constraints = def.getValueConstraints();
                    if (constraints != null) {
                        InternalValue[] values = propState.getValues();
                        try {
                            EffectiveNodeType.checkSetPropertyValueConstraints(
                                    def.unwrap(), values);
                        } catch (RepositoryException e) {
                            // repack exception for providing verboser error message
                            String msg = prop.safeGetJCRPath() + ": " + e.getMessage();
                            log.debug(msg);
                            throw new ConstraintViolationException(msg);
                        }

                        /**
                         * need to manually check REFERENCE value constraints
                         * as this requires a session (target node needs to
                         * be checked)
                         */
                        if (constraints.length > 0
                                && def.getRequiredType() == PropertyType.REFERENCE) {
                            for (int i = 0; i < values.length; i++) {
                                boolean satisfied = false;
                                try {
                                    UUID targetUUID = (UUID) values[i].internalValue();
                                    Node targetNode = session.getNodeByUUID(targetUUID);
                                    /**
                                     * constraints are OR-ed, i.e. at least one
                                     * has to be satisfied
                                     */
                                    for (int j = 0; j < constraints.length; j++) {
                                        /**
                                         * a REFERENCE value constraint specifies
                                         * the name of the required node type of
                                         * the target node
                                         */
                                        String ntName = constraints[j];
                                        if (targetNode.isNodeType(ntName)) {
                                            satisfied = true;
                                            break;
                                        }
                                    }
                                } catch (RepositoryException re) {
                                    String msg = prop.safeGetJCRPath()
                                            + ": failed to check REFERENCE value constraint";
                                    log.debug(msg);
                                    throw new ConstraintViolationException(msg, re);
                                }
                                if (!satisfied) {
                                    String msg = prop.safeGetJCRPath()
                                            + ": does not satisfy the value constraint "
                                            + constraints[0];   // just report the 1st
                                    log.debug(msg);
                                    throw new ConstraintViolationException(msg);
                                }
                            }
                        }
                    }
                }

                /**
                 * no need to check the protected flag as this is checked
                 * in PropertyImpl.setValue(Value)
                 */
            }
        }

        // walk through list of removed transient items and check REMOVE permission
        while (removedIter.hasNext()) {
            ItemState itemState = (ItemState) removedIter.next();
            ItemId id = itemState.getId();
            // check REMOVE permission
            if (!accessMgr.isGranted(id, AccessManager.REMOVE)) {
                String msg = itemMgr.safeGetJCRPath(id)
                        + ": not allowed to remove item";
                log.debug(msg);
                throw new AccessDeniedException(msg);
            }
View Full Code Here

Examples of org.apache.jackrabbit.core.security.AccessManager

        }

        // 3. access rights

        if ((options & CHECK_ACCESS) == CHECK_ACCESS) {
            AccessManager accessMgr = session.getAccessManager();
            // make sure current session is granted read access on parent node
            if (!accessMgr.isGranted(parentState.getNodeId(), AccessManager.READ)) {
                throw new ItemNotFoundException(safeGetJCRPath(parentState.getNodeId()));
            }
            // make sure current session is granted write access on parent node
            if (!accessMgr.isGranted(parentState.getNodeId(), AccessManager.WRITE)) {
                throw new AccessDeniedException(safeGetJCRPath(parentState.getNodeId())
                        + ": not allowed to add child node");
            }
        }
View Full Code Here

Examples of org.apache.jackrabbit.core.security.AccessManager

        }

        // 3. access rights

        if ((options & CHECK_ACCESS) == CHECK_ACCESS) {
            AccessManager accessMgr = session.getAccessManager();
            try {
                // make sure current session is granted read access on parent node
                if (!accessMgr.isGranted(targetId, AccessManager.READ)) {
                    throw new PathNotFoundException(safeGetJCRPath(targetId));
                }
                // make sure current session is allowed to remove target node
                if (!accessMgr.isGranted(targetId, AccessManager.REMOVE)) {
                    throw new AccessDeniedException(safeGetJCRPath(targetId)
                            + ": not allowed to remove node");
                }
            } catch (ItemNotFoundException infe) {
                String msg = "internal error: failed to check access rights for "
View Full Code Here

Examples of org.apache.jackrabbit.core.security.AccessManager

            RepositoryException {

        NodeState node = getNodeState(nodePath);

        // access rights
        AccessManager accessMgr = session.getAccessManager();
        // make sure current session is granted read access on node
        if (!accessMgr.isGranted(node.getNodeId(), AccessManager.READ)) {
            throw new PathNotFoundException(safeGetJCRPath(node.getNodeId()));
        }
        // make sure current session is granted write access on node
        if (!accessMgr.isGranted(node.getNodeId(), AccessManager.WRITE)) {
            throw new AccessDeniedException(safeGetJCRPath(node.getNodeId())
                    + ": not allowed to modify node");
        }

        // locking status
View Full Code Here

Examples of org.apache.jackrabbit.core.security.AccessManager

    public void verifyCanRead(Path nodePath)
            throws PathNotFoundException, RepositoryException {
        NodeState node = getNodeState(nodePath);

        // access rights
        AccessManager accessMgr = session.getAccessManager();
        // make sure current session is granted read access on node
        if (!accessMgr.isGranted(node.getNodeId(), AccessManager.READ)) {
            throw new PathNotFoundException(safeGetJCRPath(node.getNodeId()));
        }
    }
View Full Code Here

Examples of org.apache.jackrabbit.core.security.AccessManager

            AMContext ctx = new AMContext(new File(rep.getConfig().getHomeDir()),
                    rep.getFileSystem(),
                    subject,
                    hierMgr,
                    wsp.getName());
            AccessManager accessMgr = (AccessManager) amConfig.newInstance();
            accessMgr.init(ctx);
            return accessMgr;
        } catch (AccessDeniedException ade) {
            // re-throw
            throw ade;
        } catch (Exception e) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.