You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by "Nick Padgett (JIRA)" <ji...@apache.org> on 2009/09/17 00:19:57 UTC

[jira] Created: (FTPSERVER-335) Create a HomeDirectoryResolver interface to Resolve a User's Home Directory

Create a HomeDirectoryResolver interface to Resolve a User's Home Directory
---------------------------------------------------------------------------

                 Key: FTPSERVER-335
                 URL: https://issues.apache.org/jira/browse/FTPSERVER-335
             Project: FtpServer
          Issue Type: Improvement
            Reporter: Nick Padgett


It would be useful to have a HomeDirectoryResolver interface to resolve a user's home directory.  I use such a class to do the following:
1) Prefix a base path to user home directories.  I have FtpServer deployed with two different applications.  In one applicationI need their home directory to begin with "d:/mnt" and in the other I need "/mnt".
2) Allow users to share a common home directory (i.e. "d:/mnt/users").
3) Allow users to have private home directories (i.e. "d:/mnt/users/npadgett").

The interface I use looks something like:
<code>
public interface HomeDirectoryResolver {
    String resolve(final User user);
}
</code>

The class I use looks something like:
<code>
public class HomeDirectoryResolverImpl implements HomeDirectoryResolver {
    public static enum Strategy {
        SHARED, USERNAME, HOME_DIRECTORY
    }

    private final String basePath;
    private final Strategy strategy;

    public HomeDirectoryResolverImpl(final String basePath,
            final Strategy strategy) {
        this.basePath = basePath;
        this.strategy = strategy;
    }

    public String resolve(final User user) {
        String homeDirectory = this.basePath
                + (this.basePath.endsWith("/") ? "" : "/");
        switch (this.strategy) {
            case SHARED:
                // do nothing
                break;
            case USERNAME:
                homeDirectory += user.getName();
                break;
            case HOME_DIRECTORY:
                homeDirectory += user.getHomeDirectory();
                break;
            default:
                throw new IllegalStateException();
        }
        return homeDirectory;
    }
}
</code>

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (FTPSERVER-335) Create a HomeDirectoryResolver interface to Resolve a User's Home Directory

Posted by "Niklas Gustavsson (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/FTPSERVER-335?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Niklas Gustavsson updated FTPSERVER-335:
----------------------------------------

    Affects Version/s: 1.0.0
                       1.0.1
                       1.0.2
        Fix Version/s: 1.1.0

> Create a HomeDirectoryResolver interface to Resolve a User's Home Directory
> ---------------------------------------------------------------------------
>
>                 Key: FTPSERVER-335
>                 URL: https://issues.apache.org/jira/browse/FTPSERVER-335
>             Project: FtpServer
>          Issue Type: Improvement
>    Affects Versions: 1.0.0, 1.0.1, 1.0.2
>            Reporter: Nick Padgett
>             Fix For: 1.1.0
>
>
> It would be useful to have a HomeDirectoryResolver interface to resolve a user's home directory.  I use such a class to do the following:
> 1) Prefix a base path to user home directories.  I have FtpServer deployed with two different applications.  In one applicationI need their home directory to begin with "d:/mnt" and in the other I need "/mnt".
> 2) Allow users to share a common home directory (i.e. "d:/mnt/users").
> 3) Allow users to have private home directories (i.e. "d:/mnt/users/npadgett").
> The interface I use looks something like:
> <code>
> public interface HomeDirectoryResolver {
>     String resolve(final User user);
> }
> </code>
> The class I use looks something like:
> <code>
> public class HomeDirectoryResolverImpl implements HomeDirectoryResolver {
>     public static enum Strategy {
>         SHARED, USERNAME, HOME_DIRECTORY
>     }
>     private final String basePath;
>     private final Strategy strategy;
>     public HomeDirectoryResolverImpl(final String basePath,
>             final Strategy strategy) {
>         this.basePath = basePath;
>         this.strategy = strategy;
>     }
>     public String resolve(final User user) {
>         String homeDirectory = this.basePath
>                 + (this.basePath.endsWith("/") ? "" : "/");
>         switch (this.strategy) {
>             case SHARED:
>                 // do nothing
>                 break;
>             case USERNAME:
>                 homeDirectory += user.getName();
>                 break;
>             case HOME_DIRECTORY:
>                 homeDirectory += user.getHomeDirectory();
>                 break;
>             default:
>                 throw new IllegalStateException();
>         }
>         return homeDirectory;
>     }
> }
> </code>

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (FTPSERVER-335) Create a HomeDirectoryResolver interface to Resolve a User's Home Directory

Posted by "Niklas Gustavsson (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FTPSERVER-335?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12756379#action_12756379 ] 

Niklas Gustavsson commented on FTPSERVER-335:
---------------------------------------------

I think this make a lot of sense. Patches would be much appreciated of course.

> Create a HomeDirectoryResolver interface to Resolve a User's Home Directory
> ---------------------------------------------------------------------------
>
>                 Key: FTPSERVER-335
>                 URL: https://issues.apache.org/jira/browse/FTPSERVER-335
>             Project: FtpServer
>          Issue Type: Improvement
>    Affects Versions: 1.0.0, 1.0.1, 1.0.2
>            Reporter: Nick Padgett
>             Fix For: 1.1.0
>
>
> It would be useful to have a HomeDirectoryResolver interface to resolve a user's home directory.  I use such a class to do the following:
> 1) Prefix a base path to user home directories.  I have FtpServer deployed with two different applications.  In one applicationI need their home directory to begin with "d:/mnt" and in the other I need "/mnt".
> 2) Allow users to share a common home directory (i.e. "d:/mnt/users").
> 3) Allow users to have private home directories (i.e. "d:/mnt/users/npadgett").
> The interface I use looks something like:
> <code>
> public interface HomeDirectoryResolver {
>     String resolve(final User user);
> }
> </code>
> The class I use looks something like:
> <code>
> public class HomeDirectoryResolverImpl implements HomeDirectoryResolver {
>     public static enum Strategy {
>         SHARED, USERNAME, HOME_DIRECTORY
>     }
>     private final String basePath;
>     private final Strategy strategy;
>     public HomeDirectoryResolverImpl(final String basePath,
>             final Strategy strategy) {
>         this.basePath = basePath;
>         this.strategy = strategy;
>     }
>     public String resolve(final User user) {
>         String homeDirectory = this.basePath
>                 + (this.basePath.endsWith("/") ? "" : "/");
>         switch (this.strategy) {
>             case SHARED:
>                 // do nothing
>                 break;
>             case USERNAME:
>                 homeDirectory += user.getName();
>                 break;
>             case HOME_DIRECTORY:
>                 homeDirectory += user.getHomeDirectory();
>                 break;
>             default:
>                 throw new IllegalStateException();
>         }
>         return homeDirectory;
>     }
> }
> </code>

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.