本文整理汇总了Java中org.apache.ftpserver.usermanager.impl.BaseUser.setPassword方法的典型用法代码示例。如果您正苦于以下问题:Java BaseUser.setPassword方法的具体用法?Java BaseUser.setPassword怎么用?Java BaseUser.setPassword使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.ftpserver.usermanager.impl.BaseUser
的用法示例。
在下文中一共展示了BaseUser.setPassword方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: start
import org.apache.ftpserver.usermanager.impl.BaseUser; //导入方法依赖的package包/类
@BeforeClass
public static void start() throws Exception {
final FtpServerFactory serverFactory = new FtpServerFactory();
final PropertiesUserManagerFactory userManagerFactory = new PropertiesUserManagerFactory();
userManagerFactory.setUrl(ConcurrentTransferWorkerTest.class.getResource("/ftpserver-user.properties"));
final UserManager userManager = userManagerFactory.createUserManager();
BaseUser user = new BaseUser();
user.setName("test");
user.setPassword("test");
user.setHomeDirectory(new TemporaryApplicationResourcesFinder().find().getAbsolute());
List<Authority> authorities = new ArrayList<Authority>();
authorities.add(new WritePermission());
authorities.add(new ConcurrentLoginPermission(2, Integer.MAX_VALUE));
user.setAuthorities(authorities);
userManager.save(user);
serverFactory.setUserManager(userManager);
final ListenerFactory factory = new ListenerFactory();
factory.setPort(PORT_NUMBER);
serverFactory.addListener("default", factory.createListener());
server = serverFactory.createServer();
server.start();
}
示例2: addUser
import org.apache.ftpserver.usermanager.impl.BaseUser; //导入方法依赖的package包/类
public void addUser(String name, String pass, String directory, boolean canWrite) {
BaseUser user = new BaseUser();
user.setName(name);
user.setPassword(pass);
//String root = ProjectManager.getInstance().getCurrentProject().getStoragePath() + "/" + directory;
user.setHomeDirectory(directory);
//check if user can write
if (canWrite) {
List<Authority> auths = new ArrayList<Authority>();
Authority auth = new WritePermission();
auths.add(auth);
user.setAuthorities(auths);
}
try {
um.save(user);
} catch (FtpException e) {
e.printStackTrace();
}
}
示例3: setUp
import org.apache.ftpserver.usermanager.impl.BaseUser; //导入方法依赖的package包/类
/**
* Sets up Apache FTP server.
*
* @throws Exception When it fails.
*/
@Before
public void setUp() throws Exception {
final UserManager manager = new PropertiesUserManagerFactory()
.createUserManager();
final BaseUser user = new BaseUser();
final ListenerFactory listener = new ListenerFactory();
final FtpServerFactory factory = new FtpServerFactory();
user.setName(NAME);
user.setPassword(PASS);
user.setHomeDirectory(TEMP_DIR);
manager.save(user);
listener.setPort(PORT);
factory.setUserManager(manager);
factory.addListener("default", listener.createListener());
this.server = factory.createServer();
this.server.start();
Files.deleteIfExists(TEMP);
}
示例4: create
import org.apache.ftpserver.usermanager.impl.BaseUser; //导入方法依赖的package包/类
public User create() {
BaseUser user = new BaseUser();
user.setEnabled(mEnable);
user.setHomeDirectory(mHomeDirectory);
user.setMaxIdleTime(mIdleSec);
user.setName(mName);
if (!TextUtils.isEmpty(mPassword))
user.setPassword(mPassword);
final ArrayList<Authority> authorities = new ArrayList<>();
if (mHasWritePermission)
authorities.add(new WritePermission());
authorities.add(new TransferRatePermission(mMaxDownloadRate, mMaxUploadRate));
authorities.add(new ConcurrentLoginPermission(mMaxConcurrentLogin,
mMaxConcurrentLoginPerIP));
user.setAuthorities(authorities);
return user;
}
示例5: setUser
import org.apache.ftpserver.usermanager.impl.BaseUser; //导入方法依赖的package包/类
public UserManager setUser() {
BaseUser user = new BaseUser();
user.setName(userName);
user.setPassword(password);
user.setHomeDirectory(homeDirectory);
List<Authority> authorities = new ArrayList<Authority>();
authorities.add(new WritePermission());
user.setAuthorities(authorities);
UserManager um = userManagerFactory.createUserManager();
try {
um.save(user);//Save the user to the user list on the filesystem
} catch (FtpException e1) {
log.error("FTP server startup failed " + e1.getMessage());
}
return um;
}
示例6: getUserByName
import org.apache.ftpserver.usermanager.impl.BaseUser; //导入方法依赖的package包/类
@Override
public User getUserByName(final String name) throws FtpException
{
if (name == null) return null;
fr.gael.dhus.database.object.User u = userService.getUserNoCheck (name);
if (u==null) return null;
BaseUser user = new BaseUser();
user.setName(u.getUsername());
user.setPassword(u.getPassword());
user.setEnabled(
u.isEnabled() &&
u.isAccountNonExpired() &&
u.isAccountNonLocked() &&
u.isCredentialsNonExpired() &&
!u.isDeleted());
user.setHomeDirectory("/");
List<Authority> authorities = new ArrayList<>();
authorities.add(new WritePermission ());
// No special limit
int maxLogin = 0;
int maxLoginPerIP = 0;
authorities.add(new ConcurrentLoginPermission(maxLogin, maxLoginPerIP));
int uploadRate = 0;
int downloadRate = 0;
authorities.add(new TransferRatePermission(downloadRate, uploadRate));
user.setAuthorities(authorities);
user.setMaxIdleTime(1000);
return user;
}
示例7: setUser
import org.apache.ftpserver.usermanager.impl.BaseUser; //导入方法依赖的package包/类
/**
* Sets the user.
*
* @param login the login
* @param password the password
* @param home the home
*/
public void setUser(String login,char[] password,String home){
BaseUser user = new BaseUser();
user.setName(login);
if(password !=null && password.length>0){
user.setPassword(new String(password));
}
user.setHomeDirectory(home);
user.setEnabled(true);
userManager.setUser(user);
}
示例8: InMemoryUserManagerTest
import org.apache.ftpserver.usermanager.impl.BaseUser; //导入方法依赖的package包/类
/**
* Instantiates a new in memory user manager test.
*/
public InMemoryUserManagerTest(){
imum = new InMemoryUserManager();
BaseUser user = new BaseUser();
user.setName(USER);
user.setPassword(USER);
user.setEnabled(true);
imum.setUser(user);
}
示例9: saveIgnoredTEst
import org.apache.ftpserver.usermanager.impl.BaseUser; //导入方法依赖的package包/类
/**
* Save ignored T est.
*
* @throws FtpException the ftp exception
*/
@Test
public void saveIgnoredTEst() throws FtpException{
BaseUser user = new BaseUser();
user.setName("admin2");
user.setPassword(USER);
user.setEnabled(true);
imum.save(user);
User u1 = imum.getUserByName("admin2");
assertNotNull(u1);
assertEquals(USER,u1.getName());
}
示例10: registerFtpUser
import org.apache.ftpserver.usermanager.impl.BaseUser; //导入方法依赖的package包/类
/**
* @param aUsername
* @param aPassword
* @throws FtpException
*/
private void registerFtpUser( String aUsername, String aPassword ) throws FtpException
{
BaseUser user = new BaseUser();
user.setName( aUsername );
user.setPassword( aPassword );
user.setAuthorities(myFtpAuthorities);
UserManager userManager = myServerFactory.getUserManager();
userManager.save(user);
}
示例11: startFtpServer
import org.apache.ftpserver.usermanager.impl.BaseUser; //导入方法依赖的package包/类
@BeforeClass
public static void startFtpServer() throws FtpException {
FtpServerFactory serverFactory = new FtpServerFactory();
BaseUser user = new BaseUser();
user.setName("ftp");
user.setPassword("secret");
serverFactory.getUserManager().save(user);
ListenerFactory factory = new ListenerFactory();
factory.setPort(0);
Listener listener = factory.createListener();
serverFactory.addListener("default", listener);
ftpServer = serverFactory.createServer();
ftpServer.start();
ftpPort = listener.getPort();
}
示例12: createUserManager
import org.apache.ftpserver.usermanager.impl.BaseUser; //导入方法依赖的package包/类
private InMemoryUserManager createUserManager() throws FtpException {
InMemoryUserManager userManager = new InMemoryUserManager();
for (FtpUser user : configuration.users()) {
BaseUser baseUser = new BaseUser();
baseUser.setName(user.login);
baseUser.setPassword(user.password);
baseUser.setMaxIdleTime(0);
baseUser.setHomeDirectory(userHomeCreator.createUserHome(user.login).getAbsolutePath());
baseUser.setEnabled(true);
baseUser.setAuthorities(createAuthorities());
userManager.save(baseUser);
}
return userManager;
}
示例13: MakeUser
import org.apache.ftpserver.usermanager.impl.BaseUser; //导入方法依赖的package包/类
private static BaseUser MakeUser(final String username, final String password) {
final BaseUser Buser = new BaseUser();
// FIXME FTP isn't working properly. No Write Access?
Buser.setName(username);
Buser.setPassword(password);
Buser.setHomeDirectory("ftproot");
return Buser;
}
示例14: createServer
import org.apache.ftpserver.usermanager.impl.BaseUser; //导入方法依赖的package包/类
private FtpServer createServer( int port, String username, String password, boolean implicitSsl ) throws Exception {
ListenerFactory factory = new ListenerFactory();
factory.setPort( port );
if ( implicitSsl ) {
SslConfigurationFactory ssl = new SslConfigurationFactory();
ssl.setKeystoreFile( new File( SERVER_KEYSTORE ) );
ssl.setKeystorePassword( PASSWORD );
// set the SSL configuration for the listener
factory.setSslConfiguration( ssl.createSslConfiguration() );
factory.setImplicitSsl( true );
}
FtpServerFactory serverFactory = new FtpServerFactory();
// replace the default listener
serverFactory.addListener( "default", factory.createListener() );
PropertiesUserManagerFactory userManagerFactory = new PropertiesUserManagerFactory();
userManagerFactory.setFile( new File( SERVER_USERS ) );
UserManager userManager = userManagerFactory.createUserManager();
if ( !userManager.doesExist( username ) ) {
BaseUser user = new BaseUser();
user.setName( username );
user.setPassword( password );
user.setEnabled( true );
user.setHomeDirectory( USER_HOME_DIR );
user.setAuthorities( Collections.<Authority>singletonList( new WritePermission() ) );
userManager.save( user );
}
serverFactory.setUserManager( userManager );
return serverFactory.createServer();
}
示例15: createUser
import org.apache.ftpserver.usermanager.impl.BaseUser; //导入方法依赖的package包/类
/**
* Creates a user based on the configuration set on the factory
* @return The created user
*/
public User createUser() {
BaseUser user = new BaseUser();
user.setName(name);
user.setPassword(password);
user.setHomeDirectory(homeDir);
user.setEnabled(isEnabled);
user.setAuthorities(authorities);
user.setMaxIdleTime(maxIdleTimeSec);
return user;
}