本文整理汇总了Java中org.apache.ftpserver.ftplet.User.getHomeDirectory方法的典型用法代码示例。如果您正苦于以下问题:Java User.getHomeDirectory方法的具体用法?Java User.getHomeDirectory怎么用?Java User.getHomeDirectory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.ftpserver.ftplet.User
的用法示例。
在下文中一共展示了User.getHomeDirectory方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createFileSystemView
import org.apache.ftpserver.ftplet.User; //导入方法依赖的package包/类
@Override
public FileSystemView createFileSystemView(User user) throws FtpException {
final String home = user.getHomeDirectory();
final String owner = user.getName();
final String group = user.getName();
final int streamSize = FTPFile.DEFAULT_SIZE;
synchronized (this) {
if (mViews.isEmpty()) {
return new FTPFileSystemView(home, owner, group, streamSize);
} else {
final FTPFileSystemView view = mViews.remove(0);
view.init(home, owner, group, streamSize);
return view;
}
}
}
示例2: from
import org.apache.ftpserver.ftplet.User; //导入方法依赖的package包/类
static FTPUser from(User user) {
final String name = user.getName();
final String password = user.getPassword();
final String homeDirectory = user.getHomeDirectory();
final boolean enable = user.getEnabled();
final int idleSec = user.getMaxIdleTime();
boolean hasWritePermission = false;
List<? extends Authority> authorities = user.getAuthorities();
if (authorities != null) {
for (Authority authority : authorities) {
if (authority instanceof WritePermission) {
hasWritePermission = true;
break;
}
}
}
return new FTPUser(name, password, homeDirectory, false,
enable, idleSec, hasWritePermission,
0, 0, 10, 10);
}
示例3: createFileSystemView
import org.apache.ftpserver.ftplet.User; //导入方法依赖的package包/类
/**
* Create the appropriate user file system view.
*/
public FileSystemView createFileSystemView(User user) throws FtpException {
synchronized (user) {
// create home if does not exist
if (createHome) {
String homeDirStr = user.getHomeDirectory();
File homeDir = new File(homeDirStr);
if (homeDir.isFile()) {
LOG.warn("Not a directory :: " + homeDirStr);
throw new FtpException("Not a directory :: " + homeDirStr);
}
if ((!homeDir.exists()) && (!homeDir.mkdirs())) {
LOG.warn("Cannot create user home :: " + homeDirStr);
throw new FtpException("Cannot create user home :: "
+ homeDirStr);
}
}
FileSystemView fsView = new NativeFileSystemView(user,
caseInsensitive);
return fsView;
}
}
示例4: NativeFileSystemView
import org.apache.ftpserver.ftplet.User; //导入方法依赖的package包/类
/**
* Constructor - internal do not use directly, use {@link NativeFileSystemFactory} instead
*/
public NativeFileSystemView(User user, boolean caseInsensitive)
throws FtpException {
if (user == null) {
throw new IllegalArgumentException("user can not be null");
}
if (user.getHomeDirectory() == null) {
throw new IllegalArgumentException(
"User home directory can not be null");
}
this.caseInsensitive = caseInsensitive;
// add last '/' if necessary
String rootDir = user.getHomeDirectory();
rootDir = normalizeSeparateChar(rootDir);
rootDir = appendSlash(rootDir);
LOG.debug("Native filesystem view created for user \"{}\" with root \"{}\"", user.getName(), rootDir);
this.rootDir = rootDir;
this.user = user;
currDir = "/";
}
示例5: BaseUser
import org.apache.ftpserver.ftplet.User; //导入方法依赖的package包/类
/**
* Copy constructor.
*/
public BaseUser(User user) {
name = user.getName();
password = user.getPassword();
authorities = user.getAuthorities();
maxIdleTimeSec = user.getMaxIdleTime();
homeDir = user.getHomeDirectory();
isEnabled = user.getEnabled();
}
示例6: save
import org.apache.ftpserver.ftplet.User; //导入方法依赖的package包/类
/**
* Save user data. Store the properties.
*/
public synchronized void save(User usr) throws FtpException {
// null value check
if (usr.getName() == null) {
throw new NullPointerException("User name is null.");
}
String thisPrefix = PREFIX + usr.getName() + '.';
// set other properties
userDataProp.setProperty(thisPrefix + ATTR_PASSWORD, getPassword(usr));
String home = usr.getHomeDirectory();
if (home == null) {
home = "/";
}
userDataProp.setProperty(thisPrefix + ATTR_HOME, home);
userDataProp.setProperty(thisPrefix + ATTR_ENABLE, usr.getEnabled());
userDataProp.setProperty(thisPrefix + ATTR_WRITE_PERM, usr
.authorize(new WriteRequest()) != null);
userDataProp.setProperty(thisPrefix + ATTR_MAX_IDLE_TIME, usr
.getMaxIdleTime());
TransferRateRequest transferRateRequest = new TransferRateRequest();
transferRateRequest = (TransferRateRequest) usr
.authorize(transferRateRequest);
if (transferRateRequest != null) {
userDataProp.setProperty(thisPrefix + ATTR_MAX_UPLOAD_RATE,
transferRateRequest.getMaxUploadRate());
userDataProp.setProperty(thisPrefix + ATTR_MAX_DOWNLOAD_RATE,
transferRateRequest.getMaxDownloadRate());
} else {
userDataProp.remove(thisPrefix + ATTR_MAX_UPLOAD_RATE);
userDataProp.remove(thisPrefix + ATTR_MAX_DOWNLOAD_RATE);
}
// request that always will succeed
ConcurrentLoginRequest concurrentLoginRequest = new ConcurrentLoginRequest(
0, 0);
concurrentLoginRequest = (ConcurrentLoginRequest) usr
.authorize(concurrentLoginRequest);
if (concurrentLoginRequest != null) {
userDataProp.setProperty(thisPrefix + ATTR_MAX_LOGIN_NUMBER,
concurrentLoginRequest.getMaxConcurrentLogins());
userDataProp.setProperty(thisPrefix + ATTR_MAX_LOGIN_PER_IP,
concurrentLoginRequest.getMaxConcurrentLoginsPerIP());
} else {
userDataProp.remove(thisPrefix + ATTR_MAX_LOGIN_NUMBER);
userDataProp.remove(thisPrefix + ATTR_MAX_LOGIN_PER_IP);
}
saveUserData();
}