Hi,

    Why do you need this. FileObject already has
canRead(), canWrite(), canDelete() methods.

FileObject depends on UserObject because the
FileSystemView depends on UserObject.

FileSystemSecurityManager looks like an add-hoc
solution for something which already exists.

Thanks,
Rana Bhattacharyya


--- Sergey Vladimirov <[EMAIL PROTECTED]> wrote:

> Hi, ftpserver-dev,
> 
> By this patch I want to introduce
> FileSystemSecurityManager component. It
> should check all file permissions, and it should be
> the single place to
> check all rights.
> The reason to introduce so many methods (instead of
> original hasRead,
> hasWrite, hasDelete) is some application that
> requires different rights to,
> for example, creating files and creating
> directories.
> 
> -- 
> Sergey Vladimirov
> > Index:
>
C:/Vladimirov/workspace/ftpserver/src/java/org/apache/ftpserver/interfaces/FileSystemSecurityManager.java
>
===================================================================
> ---
>
C:/Vladimirov/workspace/ftpserver/src/java/org/apache/ftpserver/interfaces/FileSystemSecurityManager.java
> (revision 0)
> +++
>
C:/Vladimirov/workspace/ftpserver/src/java/org/apache/ftpserver/interfaces/FileSystemSecurityManager.java
> (revision 0)
> @@ -0,0 +1,82 @@
> +/*
> + * Copyright 2004 The Apache Software Foundation
> + *
> + * Licensed under the Apache License, Version 2.0
> (the "License");
> + * you may not use this file except in compliance
> with the License.
> + * You may obtain a copy of the License at
> + *
> + *     http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to
> in writing, software
> + * distributed under the License is distributed on
> an "AS IS" BASIS,
> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
> either express or implied.
> + * See the License for the specific language
> governing permissions and
> + * limitations under the License.
> + */
> +package org.apache.ftpserver.interfaces;
> +
> +import org.apache.ftpserver.ftplet.FileObject;
> +import org.apache.ftpserver.ftplet.FtpException;
> +import org.apache.ftpserver.ftplet.User;
> +
> +/**
> + * This security manager interface checks all
> ftp-related operations.
> + * 
> + * @author <a
> href="mailto:[EMAIL PROTECTED]">Sergey
> Vladimirov</a>
> + */
> +public interface FileSystemSecurityManager {
> +
> +    /**
> +     * Has user rights to append file permission?
> +     */
> +    boolean hasAppendFilePermission(User user,
> FileObject fileObject)
> +            throws FtpException;
> +
> +    /**
> +     * Has user rights to delete permission?
> +     */
> +    boolean hasDeleteFilePermission(User user,
> FileObject fileObject)
> +            throws FtpException;
> +
> +    /**
> +     * Has user rights to listing directory
> permission?
> +     */
> +    boolean hasListingDirPermission(User user,
> FileObject fileObject)
> +            throws FtpException;
> +
> +    /**
> +     * Has user rights to listing file permission?
> +     */
> +    boolean hasListingFilePermission(User user,
> FileObject fileObject)
> +            throws FtpException;
> +
> +    /**
> +     * Has user rights to create directory
> permission?
> +     */
> +    boolean hasMakeDirPermission(User user,
> FileObject dirObject)
> +            throws FtpException;
> +
> +    /**
> +     * Has user rights to read file permission?
> +     */
> +    boolean hasReadFilePermission(User user,
> FileObject fileObject)
> +            throws FtpException;
> +
> +    /**
> +     * Has user rights to delete directory
> permission?
> +     */
> +    boolean hasRemoveDirPermission(User user,
> FileObject dirObject)
> +            throws FtpException;
> +
> +    /**
> +     * Has user rights to rename directory
> permission?
> +     */
> +    boolean hasRenamePermission(User user,
> FileObject sourceFileObject,
> +            FileObject targetFileObject) throws
> FtpException;
> +
> +    /**
> +     * Has user rights to write file permission?
> +     */
> +    boolean hasWriteFilePermission(User user,
> FileObject fileObject)
> +            throws FtpException;
> +}
> Index:
>
C:/Vladimirov/workspace/ftpserver/src/java/org/apache/ftpserver/filesystem/OSVirualFileSystemManager.java
>
===================================================================
> ---
>
C:/Vladimirov/workspace/ftpserver/src/java/org/apache/ftpserver/filesystem/OSVirualFileSystemManager.java
> (revision 405674)
> +++
>
C:/Vladimirov/workspace/ftpserver/src/java/org/apache/ftpserver/filesystem/OSVirualFileSystemManager.java
> (working copy)
> @@ -25,6 +25,7 @@
>  import org.apache.ftpserver.ftplet.FileSystemView;
>  import org.apache.ftpserver.ftplet.FtpException;
>  import org.apache.ftpserver.ftplet.User;
> +import
>
org.apache.ftpserver.interfaces.FileSystemSecurityManager;
>  
>  /**
>   * This is a operating system based virtual root
> file system manager. 
> @@ -81,5 +82,9 @@
>          
>          OSVirualFileSystemView fsView = new
> OSVirualFileSystemView(user, logFactory);
>          return fsView;
> -    }   
> +    }
> +    
> +    public FileSystemSecurityManager
> getFileSystemSecurityManager() {
> +        return
> TempFileSystemSecurityManager.INSTANCE;
> +    }
>  }
> Index:
>
C:/Vladimirov/workspace/ftpserver/src/java/org/apache/ftpserver/filesystem/NativeFileSystemManager.java
>
===================================================================
> ---
>
C:/Vladimirov/workspace/ftpserver/src/java/org/apache/ftpserver/filesystem/NativeFileSystemManager.java
> (revision 405674)
> +++
>
C:/Vladimirov/workspace/ftpserver/src/java/org/apache/ftpserver/filesystem/NativeFileSystemManager.java
> (working copy)
> @@ -25,6 +25,7 @@
>  import org.apache.ftpserver.ftplet.FileSystemView;
>  import org.apache.ftpserver.ftplet.FtpException;
>  import org.apache.ftpserver.ftplet.User;
> +import
>
org.apache.ftpserver.interfaces.FileSystemSecurityManager;
>  
>  /**
>   * Native file system manager. It uses the OS file
> system.
> @@ -81,4 +82,8 @@
>          return fsView;
>      }
>      
> +    public FileSystemSecurityManager
> getFileSystemSecurityManager() {
> +        return
> TempFileSystemSecurityManager.INSTANCE;
> +    }
> +    
>  }
> Index:
>
C:/Vladimirov/workspace/ftpserver/src/java/org/apache/ftpserver/filesystem/AbstractFileSystemSecurityManager.java
>
===================================================================
> ---
>
C:/Vladimirov/workspace/ftpserver/src/java/org/apache/ftpserver/filesystem/AbstractFileSystemSecurityManager.java
> (revision 0)
> +++
>
C:/Vladimirov/workspace/ftpserver/src/java/org/apache/ftpserver/filesystem/AbstractFileSystemSecurityManager.java
> (revision 0)
> @@ -0,0 +1,97 @@
> +/*
> + * Copyright 2004 The Apache Software Foundation
> + *
> + * Licensed under the Apache License, Version 2.0
> (the "License");
> + * you may not use this file except in compliance
> with the License.
> + * You may obtain a copy of the License at
> + *
> + *     http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to
> in writing, software
> 
=== message truncated ===


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Reply via email to