Details
-
Improvement
-
Status: Open
-
Major
-
Resolution: Unresolved
-
1.0.0, 1.0.1, 1.0.2
-
None
-
None
Description
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
private final String basePath;
private final Strategy strategy;
public HomeDirectoryResolverImpl(final String basePath,
final Strategy strategy)
public String resolve(final User user) {
String homeDirectory = this.basePath
+ (this.basePath.endsWith("/") ? "" : "/");
switch (this.strategy)
return homeDirectory;
}
}
</code>