Package org.apache.slide.common

Examples of org.apache.slide.common.NamespaceConfig


     * @throws SourceException If an exception occurs.
     **/
    public SourcePermission[] getSourcePermissions() throws SourceException {
        try {

            NamespaceConfig config = this.nat.getNamespaceConfig();

            ObjectNode current = structure.retrieve(this.slideToken,
                                                    this.config.getFilesPath()+
                                                    this.path);

            security.checkCredentials(this.slideToken, current,
                                      config.getReadPermissionsAction());

            String userspath = config.getUsersPath();

            // read
            String readObjectUri = config.getReadObjectAction().getUri();
            String readRevisionMetadataUri = config.getReadRevisionMetadataAction().getUri();
            String readRevisionContentUri = config.getReadRevisionContentAction().getUri();

            // write
            String createObjectUri = config.getCreateObjectAction().getUri();
            String removeObjectUri = config.getRemoveObjectAction().getUri();
            String lockObjectUri = config.getLockObjectAction().getUri();
            String readLocksUri = config.getReadLocksAction().getUri();
            String createRevisionMetadataUri = config.getCreateRevisionMetadataAction().getUri();
            String modifyRevisionMetadataUri = config.getModifyRevisionMetadataAction().getUri();
            String removeRevisionMetadataUri = config.getRemoveRevisionMetadataAction().getUri();
            String createRevisionContentUri = config.getCreateRevisionContentAction().getUri();
            String modifyRevisionContentUri = config.getModifyRevisionContentAction().getUri();
            String removeRevisionContentUri = config.getRemoveRevisionContentAction().getUri();

            // read-acl
            String readPermissionsUri = config.getReadPermissionsAction().getUri();

            // write-acl
            String grantPermissionUri = config.getGrantPermissionAction().getUri();
            String revokePermissionUri = config.getRevokePermissionAction().getUri();

            boolean inheritedPermissions = false;
            Vector permissions = new Vector();

            ArrayList sourcepermissions = new ArrayList();
View Full Code Here


     * @throws SourceException If an exception occurs during this operation
     **/
    public void addSourcePermission(SourcePermission sourcepermission)
      throws SourceException {

        NamespaceConfig config = this.nat.getNamespaceConfig();

        String subject = null;

        if (sourcepermission instanceof PrincipalSourcePermission) {
            subject = config.getUsersPath()+"/"+
                      ((PrincipalSourcePermission) sourcepermission).getPrincipal();

            // Test if principal exists
            try {
                ObjectNode objectnode = structure.retrieve(this.slideToken,
                                                           subject);

                if ( !(objectnode instanceof SubjectNode)) {
                    throw new SourceException("Principal '"+
                                              ((PrincipalSourcePermission) sourcepermission).getPrincipal()+
                                              "' doesn't exists");
                }
            } catch (SlideException se) {
                throw new SourceException("Could not retrieve object for principal '"+
                                          ((PrincipalSourcePermission) sourcepermission).getPrincipal()+
                                          "'", se);
            }

        } else if (sourcepermission instanceof GroupSourcePermission) {
            subject = config.getUsersPath()+"/"+
                      ((GroupSourcePermission) sourcepermission).getGroup();

            // Test if group exists
            try {
                ObjectNode objectnode = structure.retrieve(this.slideToken,
                                                           subject);

                if ( !(objectnode instanceof GroupNode)) {
                    throw new SourceException("Group '"+
                                              ((GroupSourcePermission) sourcepermission).getGroup()+
                                              "' doesn't exists");
                }
            } catch (SlideException se) {
                throw new SourceException("Could not retrieve object for group '"+
                                          ((GroupSourcePermission) sourcepermission).getGroup()+
                                          "'", se);
            }

            subject = "+"+subject; // Additional '+' to expand the group
        } else {
            throw new SourceException("Does't support category of permission");
        }

        boolean negative = sourcepermission.isNegative();
        boolean inheritable = sourcepermission.isInheritable();

        if (sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_ALL)) {
            addPermission(subject, "/", negative, inheritable);
        } else if (sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_READ)) {
            addPermission(subject, config.getReadObjectAction().getUri(),
                          negative, inheritable);
            addPermission(subject, config.getReadLocksAction().getUri(),
                          negative, inheritable);
            addPermission(subject,
                          config.getReadRevisionMetadataAction().getUri(),
                          negative, inheritable);
            addPermission(subject,
                          config.getReadRevisionContentAction().getUri(),
                          negative, inheritable);
        } else if (sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_READ_SOURCE)) {
            addPermission(subject, config.getReadObjectAction().getUri(),
                          negative, inheritable);
        } else if (sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_READ_LOCKS)) {
            addPermission(subject, config.getReadLocksAction().getUri(),
                          negative, inheritable);
        } else if (sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_READ_PROPERTY)) {
            addPermission(subject,
                          config.getReadRevisionMetadataAction().getUri(),
                          negative, inheritable);
        } else if (sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_READ_CONTENT)) {
            addPermission(subject,
                          config.getReadRevisionContentAction().getUri(),
                          negative, inheritable);
        } else if (sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_WRITE)) {
            addPermission(subject, config.getCreateObjectAction().getUri(),
                          negative, inheritable);
            addPermission(subject, config.getRemoveObjectAction().getUri(),
                          negative, inheritable);
            addPermission(subject, config.getLockObjectAction().getUri(),
                          negative, inheritable);
            addPermission(subject,
                          config.getCreateRevisionMetadataAction().getUri(),
                          negative, inheritable);
            addPermission(subject,
                          config.getModifyRevisionMetadataAction().getUri(),
                          negative, inheritable);
            addPermission(subject,
                          config.getRemoveRevisionMetadataAction().getUri(),
                          negative, inheritable);
            addPermission(subject,
                          config.getCreateRevisionContentAction().getUri(),
                          negative, inheritable);
            addPermission(subject,
                          config.getModifyRevisionContentAction().getUri(),
                          negative, inheritable);
            addPermission(subject,
                          config.getRemoveRevisionContentAction().getUri(),
                          negative, inheritable);
        } else if (sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_CREATE_SOURCE)) {
            addPermission(subject, config.getCreateObjectAction().getUri(),
                          negative, inheritable);
        } else if (sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_REMOVE_SOURCE)) {
            addPermission(subject, config.getRemoveObjectAction().getUri(),
                          negative, inheritable);
        } else if (sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_LOCK_SOURCE)) {
            addPermission(subject, config.getLockObjectAction().getUri(),
                          negative, inheritable);
        } else if (sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_CREATE_PROPERTY)) {
            addPermission(subject,
                          config.getCreateRevisionMetadataAction().getUri(),
                          negative, inheritable);
        } else if (sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_MODIFY_PROPERTY)) {
            addPermission(subject,
                          config.getModifyRevisionMetadataAction().getUri(),
                          negative, inheritable);
        } else if (sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_REMOVE_PROPERTY)) {
            addPermission(subject,
                          config.getRemoveRevisionMetadataAction().getUri(),
                          negative, inheritable);
        } else if (sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_CREATE_CONTENT)) {
            addPermission(subject,
                          config.getCreateRevisionContentAction().getUri(),
                          negative, inheritable);
        } else if (sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_MODIFY_CONTENT)) {
            addPermission(subject,
                          config.getModifyRevisionContentAction().getUri(),
                          negative, inheritable);
        } else if (sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_REMOVE_CONTENT)) {
            addPermission(subject,
                          config.getRemoveRevisionContentAction().getUri(),
                          negative, inheritable);
        } else if (sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_READ_ACL)) {
            addPermission(subject,
                          config.getReadPermissionsAction().getUri(),
                          negative, inheritable);
        } else if (sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_WRITE_ACL)) {
            addPermission(subject,
                          config.getGrantPermissionAction().getUri(),
                          negative, inheritable);
            addPermission(subject,
                          config.getRevokePermissionAction().getUri(),
                          negative, inheritable);
        } else if (sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_GRANT_PERMISSION)) {
            addPermission(subject,
                          config.getGrantPermissionAction().getUri(),
                          negative, inheritable);
        } else if (sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_REVOKE_PERMISSION)) {
            addPermission(subject,
                          config.getRevokePermissionAction().getUri(),
                          negative, inheritable);
        }
    }
View Full Code Here

     * @throws SourceException If an exception occurs during this operation
     **/
    public void removeSourcePermission(SourcePermission sourcepermission)
      throws SourceException {

        NamespaceConfig config = this.nat.getNamespaceConfig();

        String subject = null;

        if (sourcepermission instanceof PrincipalSourcePermission) {
            subject = config.getUsersPath()+"/"+
                      ((PrincipalSourcePermission) sourcepermission).getPrincipal();

            // Test if principal exists
            try {
                ObjectNode objectnode = structure.retrieve(this.slideToken,
                                                           subject);

                if ( !(objectnode instanceof SubjectNode)) {
                    throw new SourceException("Principal '"+
                                              ((PrincipalSourcePermission) sourcepermission).getPrincipal()+
                                              "' doesn't exists");
                }
            } catch (SlideException se) {
                throw new SourceException("Could not retrieve object for principal '"+
                                          ((PrincipalSourcePermission) sourcepermission).getPrincipal()+
                                          "'", se);
            }

        } else if (sourcepermission instanceof GroupSourcePermission) {
            subject = config.getUsersPath()+"/"+
                      ((GroupSourcePermission) sourcepermission).getGroup();

            // Test if group exists
            try {
                ObjectNode objectnode = structure.retrieve(this.slideToken,
                                                           subject);

                if ( !(objectnode instanceof GroupNode)) {
                    throw new SourceException("Group '"+
                                              ((GroupSourcePermission) sourcepermission).getGroup()+
                                              "' doesn't exists");
                }
            } catch (SlideException se) {
                throw new SourceException("Could not retrieve object for group '"+
                                          ((GroupSourcePermission) sourcepermission).getGroup()+
                                          "'", se);
            }

            subject = "+"+subject; // Additional '+' to expand the group
        } else {
            throw new SourceException("Does't support category of permission");
        }

        boolean negative = sourcepermission.isNegative();
        boolean inheritable = sourcepermission.isInheritable();

        if (sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_ALL)) {
            removePermission(subject, "/", negative, inheritable);
        } else if (sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_READ)) {
            removePermission(subject, config.getReadObjectAction().getUri(),
                             negative, inheritable);
            removePermission(subject, config.getReadLocksAction().getUri(),
                             negative, inheritable);
            removePermission(subject,
                             config.getReadRevisionMetadataAction().getUri(),
                             negative, inheritable);
            removePermission(subject,
                             config.getReadRevisionContentAction().getUri(),
                             negative, inheritable);
        } else if (sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_READ_SOURCE)) {
            removePermission(subject, config.getReadObjectAction().getUri(),
                             negative, inheritable);
        } else if (sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_READ_LOCKS)) {
            removePermission(subject, config.getReadLocksAction().getUri(),
                             negative, inheritable);
        } else if (sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_READ_PROPERTY)) {
            removePermission(subject,
                             config.getReadRevisionMetadataAction().getUri(),
                             negative, inheritable);
        } else if (sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_READ_CONTENT)) {
            removePermission(subject,
                             config.getReadRevisionContentAction().getUri(),
                             negative, inheritable);
        } else if (sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_WRITE)) {
            removePermission(subject,
                             config.getCreateObjectAction().getUri(),
                             negative, inheritable);
            removePermission(subject,
                             config.getRemoveObjectAction().getUri(),
                             negative, inheritable);
            removePermission(subject, config.getLockObjectAction().getUri(),
                             negative, inheritable);
            removePermission(subject,
                             config.getCreateRevisionMetadataAction().getUri(),
                             negative, inheritable);
            removePermission(subject,
                             config.getModifyRevisionMetadataAction().getUri(),
                             negative, inheritable);
            removePermission(subject,
                             config.getRemoveRevisionMetadataAction().getUri(),
                             negative, inheritable);
            removePermission(subject,
                             config.getCreateRevisionContentAction().getUri(),
                             negative, inheritable);
            removePermission(subject,
                             config.getModifyRevisionContentAction().getUri(),
                             negative, inheritable);
            removePermission(subject,
                             config.getRemoveRevisionContentAction().getUri(),
                             negative, inheritable);
        } else if (sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_CREATE_SOURCE)) {
            removePermission(subject,
                             config.getCreateObjectAction().getUri(),
                             negative, inheritable);
        } else if (sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_REMOVE_SOURCE)) {
            removePermission(subject,
                             config.getRemoveObjectAction().getUri(),
                             negative, inheritable);
        } else if (sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_LOCK_SOURCE)) {
            removePermission(subject, config.getLockObjectAction().getUri(),
                             negative, inheritable);
        } else if (sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_CREATE_PROPERTY)) {
            removePermission(subject,
                             config.getCreateRevisionMetadataAction().getUri(),
                             negative, inheritable);
        } else if (sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_MODIFY_PROPERTY)) {
            removePermission(subject,
                             config.getModifyRevisionMetadataAction().getUri(),
                             negative, inheritable);
        } else if (sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_REMOVE_PROPERTY)) {
            removePermission(subject,
                             config.getRemoveRevisionMetadataAction().getUri(),
                             negative, inheritable);
        } else if (sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_CREATE_CONTENT)) {
            removePermission(subject,
                             config.getCreateRevisionContentAction().getUri(),
                             negative, inheritable);
        } else if (sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_MODIFY_CONTENT)) {
            removePermission(subject,
                             config.getModifyRevisionContentAction().getUri(),
                             negative, inheritable);
        } else if (sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_REMOVE_CONTENT)) {
            removePermission(subject,
                             config.getRemoveRevisionContentAction().getUri(),
                             negative, inheritable);
        } else if (sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_READ_ACL)) {
            removePermission(subject,
                             config.getReadPermissionsAction().getUri(),
                             negative, inheritable);
        } else if (sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_WRITE_ACL)) {
            removePermission(subject,
                             config.getGrantPermissionAction().getUri(),
                             negative, inheritable);
            removePermission(subject,
                             config.getRevokePermissionAction().getUri(),
                             negative, inheritable);
        } else if (sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_GRANT_PERMISSION)) {
            removePermission(subject,
                             config.getGrantPermissionAction().getUri(),
                             negative, inheritable);
        } else if (sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_REVOKE_PERMISSION)) {
            removePermission(subject,
                             config.getRevokePermissionAction().getUri(),
                             negative, inheritable);
        }
    }
View Full Code Here

     * @throws   JDOMException
     */
    public XMLValue computeCurrentuserPrivilegeSet(NodeRevisionDescriptors revisionDescriptors, NodeRevisionDescriptor revisionDescriptor, String contextPath, String servletPath) throws ObjectLockedException, RevisionDescriptorNotFoundException, ServiceAccessException, LinkedObjectNotFoundException, AccessDeniedException, ObjectNotFoundException, LockTokenNotFoundException, JDOMException {
        XMLValue xmlValue = new XMLValue();
       
        NamespaceConfig config = nsaToken.getNamespaceConfig();
        Structure structure = nsaToken.getStructureHelper();
        ObjectNode object =  structure.retrieve(sToken, revisionDescriptors.getUri());
       
        // check read-own-permissions permission
        Security security = nsaToken.getSecurityHelper();
        security.checkCredentials(sToken, object, config.getReadOwnPermissionsAction());
       
        try {
            String actionsPath = config.getActionsPath();
            Uri actionsPathUri = nsaToken.getUri(sToken, actionsPath);
            ObjectNode actionsPathNode = actionsPathUri.getStore().retrieveObject(actionsPathUri);
            Enumeration actions = actionsPathNode.enumerateChildren();
            while (actions.hasMoreElements()) {
                ActionNode aNode = ActionNode.getActionNode((String)actions.nextElement());
View Full Code Here

     */
    public XMLValue computeAcl(NodeRevisionDescriptors revisionDescriptors, NodeRevisionDescriptor revisionDescriptor, String contextPath, String servletPath) throws ObjectLockedException, RevisionDescriptorNotFoundException, ServiceAccessException, LinkedObjectNotFoundException, AccessDeniedException, ObjectNotFoundException, LockTokenNotFoundException, JDOMException {
       
        XMLValue xmlValue = new XMLValue();
       
        NamespaceConfig config = nsaToken.getNamespaceConfig();
        Structure structure = nsaToken.getStructureHelper();
        ObjectNode objectNode =  structure.retrieve(sToken, revisionDescriptors.getUri());
       
        // check read-acl permission
        Security security = nsaToken.getSecurityHelper();
        security.checkCredentials(sToken, objectNode, config.getReadPermissionsAction());
       
        String currentSubjectUri = "";
        boolean currentNegative = false;
        Element currentAceElm = null;
        Element currentGrantDenyElm = null;
View Full Code Here

     * @throws   ObjectNotFoundException
     * @throws   JDOMException
     */
    public XMLValue computePrincipalCollectionSet(NodeRevisionDescriptors revisionDescriptors, NodeRevisionDescriptor revisionDescriptor, String contextPath, String servletPath) throws ObjectLockedException, RevisionDescriptorNotFoundException, ServiceAccessException, LinkedObjectNotFoundException, AccessDeniedException, ObjectNotFoundException, LockTokenNotFoundException, JDOMException {
        XMLValue xmlValue = new XMLValue();
        NamespaceConfig namespaceConfig = nsaToken.getNamespaceConfig();
       
        xmlValue.addHref(WebdavUtils.getAbsolutePath (namespaceConfig.getUsersPath(),
                                                      contextPath, null, sConf));
       
        if (namespaceConfig.getGroupsPath() != null) {
           
            xmlValue.addHref(WebdavUtils.getAbsolutePath (namespaceConfig.getGroupsPath(),
                                                          contextPath, null, sConf));
        }
        if (namespaceConfig.getRolesPath() != null) {
            xmlValue.addHref(WebdavUtils.getAbsolutePath (namespaceConfig.getRolesPath(),
                                                          contextPath, null, sConf));
        }
        return xmlValue;
    }
View Full Code Here

    }
   
   
    public XMLValue computePrivilegeCollectionSet(NodeRevisionDescriptors revisionDescriptors, NodeRevisionDescriptor revisionDescriptor, String contextPath, String servletPath) throws ObjectLockedException, RevisionDescriptorNotFoundException, ServiceAccessException, LinkedObjectNotFoundException, AccessDeniedException, ObjectNotFoundException, LockTokenNotFoundException, JDOMException {
        XMLValue xmlValue = new XMLValue();
        NamespaceConfig namespaceConfig = nsaToken.getNamespaceConfig();
       
        String absUri = WebdavUtils.getAbsolutePath (namespaceConfig.getActionsPath(),
                                                     contextPath, servletPath, sConf);
       
        xmlValue.addHref(absUri);
        return xmlValue;
    }
View Full Code Here

   
    // FIXME wihtout servletPath??
    private XMLValue createUserPath(NodeProperty userProperty, String contextPath) throws IllegalArgumentException {
        XMLValue xmlValue = new XMLValue();
        String userHref = "";
        NamespaceConfig config = nsaToken.getNamespaceConfig();
        if ((userProperty != null) && (userProperty.getValue()!=null) &&
                (!"".equals(userProperty.getValue().toString()))) {
           
            userHref = contextPath + config.getUsersPath() + "/" + userProperty.getValue().toString();
            xmlValue.addHref(userHref);
        }
        else {
            xmlValue.add(new Element(E_UNAUTHENTICATED, DNSP));
        }
View Full Code Here

    /**
     * Factory method.
     */
    static public ResourceKind determineResourceKind( NamespaceAccessToken nsaToken, String resourcePath, NodeRevisionDescriptor nrd ) {
        UriHandler uh = UriHandler.getUriHandler( resourcePath );
        NamespaceConfig config = nsaToken.getNamespaceConfig();
       
        if( nrd == null ) {
            return DeltavCompliantUnmappedUrlImpl.getInstance();
        }
        else if( uh.isHistoryUri() ) {
            return VersionHistoryImpl.getInstance();
        }
        else if( uh.isVersionUri() ) {
            return VersionImpl.getInstance();
        }
        else if( uh.isWorkspaceUri() ) {
            return WorkspaceImpl.getInstance();
        }
        else if( uh.isWorkingresourceUri() ) {
            return WorkingImpl.getInstance();
        }
        else if( nrd.exists(P_CHECKED_IN) ) {
            return CheckedInVersionControlledImpl.getInstance();
        }
        else if( nrd.exists(P_CHECKED_OUT) ) {
            return CheckedOutVersionControlledImpl.getInstance();
        }
        else if( config.isPrincipal(resourcePath) ) {
            return PrincipalImpl.getInstance();
        }
        else if( nrd.propertyValueContains(P_RESOURCETYPE, E_COLLECTION) ) {
            return DeltavCompliantCollectionImpl.getInstance();
        }
View Full Code Here

                                         "This report is only defined for depth=0."),
                resourcePath
            );
        }
        UriPath resourcepath = new UriPath(resourcePath);
        NamespaceConfig namespaceConfig = token.getNamespaceConfig();
        UriPath userspath = namespaceConfig.getUsersPath() != null
            ? new UriPath(namespaceConfig.getUsersPath())
            : null;
        UriPath groupspath = namespaceConfig.getGroupsPath() != null
            ? new UriPath(namespaceConfig.getGroupsPath())
            : null;
        UriPath rolespath = namespaceConfig.getRolesPath() != null
            ? new UriPath(namespaceConfig.getRolesPath())
            : null;
        if (!resourcepath.equals(userspath) &&
            !resourcepath.equals(groupspath) &&
            !resourcepath.equals(rolespath)) {
            throw new PreconditionViolationException(
View Full Code Here

TOP

Related Classes of org.apache.slide.common.NamespaceConfig

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.