本文整理汇总了Java中org.apache.ftpserver.usermanager.UsernamePasswordAuthentication类的典型用法代码示例。如果您正苦于以下问题:Java UsernamePasswordAuthentication类的具体用法?Java UsernamePasswordAuthentication怎么用?Java UsernamePasswordAuthentication使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UsernamePasswordAuthentication类属于org.apache.ftpserver.usermanager包,在下文中一共展示了UsernamePasswordAuthentication类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: authenticate
import org.apache.ftpserver.usermanager.UsernamePasswordAuthentication; //导入依赖的package包/类
/**
* Tries to do the login using a client generated on the fly
*/
@Override
public User authenticate(Authentication authentication)
throws AuthenticationFailedException {
if (authentication instanceof UsernamePasswordAuthentication) {
UsernamePasswordAuthentication auth = (UsernamePasswordAuthentication) authentication;
AdministratorGeoStoreClient client = new AdministratorGeoStoreClient();
client.setUsername(auth.getUsername());
client.setPassword(auth.getPassword());
client.setGeostoreRestUrl(this.client.getGeostoreRestUrl());
it.geosolutions.geostore.core.model.User gsUser = client
.getUserDetails();
User user = new GeoStoreFTPUser(gsUser, authoritiesProvider);
return user;
} else {
LOGGER.error("Unrecognized authentication type: "
+ authentication.getClass().getName());
throw new AuthenticationFailedException(
"Unrecognized authentication type: "
+ authentication.getClass().getName());
}
}
开发者ID:geosolutions-it,项目名称:OpenSDI-Manager2,代码行数:28,代码来源:GeoStoreFTPUserManager.java
示例2: authenticate
import org.apache.ftpserver.usermanager.UsernamePasswordAuthentication; //导入依赖的package包/类
@Override
public User authenticate(Authentication authentication) throws AuthenticationFailedException {
if (authentication instanceof UsernamePasswordAuthentication) {
UsernamePasswordAuthentication usernameAndPassword = (UsernamePasswordAuthentication) authentication;
String username = usernameAndPassword.getUsername();
User user = users.get(username);
if (null == user) {
throw new AuthenticationFailedException("unknown user '" + username + "'");
}
String password = usernameAndPassword.getPassword();
if (getPasswordEncryptor().matches(password, user.getPassword())) {
return user;
} else {
throw new AuthenticationFailedException("password wrong");
}
}
throw new AuthenticationFailedException("try harder");
}
开发者ID:signed,项目名称:in-memory-infrastructure,代码行数:20,代码来源:InMemoryUserManager.java
示例3: setPassword
import org.apache.ftpserver.usermanager.UsernamePasswordAuthentication; //导入依赖的package包/类
/**
* 修改密码
*
* @param userInfo 用户信息
* @throws FtpException FTP异常
* @throws AuthenticationFailedException 验证用户异常
*/
public void setPassword(UserInfo userInfo) throws FtpException {
String username = um.getAdminName();
User savedUser = um.authenticate(new UsernamePasswordAuthentication(username, userInfo.getOldPassword()));
BaseUser baseUser = new BaseUser(savedUser);
baseUser.setPassword(userInfo.getPassword());
um.save(baseUser);
}
开发者ID:wyp0596,项目名称:ftp-server,代码行数:15,代码来源:MyFtpServer.java
示例4: authenticate
import org.apache.ftpserver.usermanager.UsernamePasswordAuthentication; //导入依赖的package包/类
@Override
public User authenticate(Authentication auth) throws AuthenticationFailedException {
if(auth!=null && auth instanceof UsernamePasswordAuthentication){
UsernamePasswordAuthentication userAuth = (UsernamePasswordAuthentication) auth;
if(user.getName().equals(userAuth.getUsername()) && user.getPassword().equals(userAuth.getPassword())){
return user;
}
}
return null;
}
开发者ID:dubasdey,项目名称:portable-ftp-server,代码行数:11,代码来源:InMemoryUserManager.java
示例5: authenticate
import org.apache.ftpserver.usermanager.UsernamePasswordAuthentication; //导入依赖的package包/类
@Override
public User authenticate(Authentication authentication) throws AuthenticationFailedException {
Class<UsernamePasswordAuthentication> authenticationClass = UsernamePasswordAuthentication.class;
assertAboutAuthentication(authenticationClass.isAssignableFrom(authentication.getClass()),
"you must login using a username and password");
UsernamePasswordAuthentication auth = authenticationClass.cast(authentication);
assertAboutAuthentication(StringUtils.hasText(auth.getUsername()), "you must provide a username");
assertAboutAuthentication(StringUtils.hasText(auth.getPassword()), "you must provide a password");
return this.ftpUserRepository.findByUsername(auth.getUsername())
.filter(u -> u.getPassword().equals(auth.getPassword()))
.orElseThrow(() -> new AuthenticationFailedException(
"the provided username and password is invalid"));
}
开发者ID:joshlong,项目名称:cloudfoundry-ftp-service-broker,代码行数:14,代码来源:FtpUserManager.java
示例6: authenticate
import org.apache.ftpserver.usermanager.UsernamePasswordAuthentication; //导入依赖的package包/类
@Override
public User authenticate(Authentication auth) throws AuthenticationFailedException {
if (auth instanceof UsernamePasswordAuthentication) {
UsernamePasswordAuthentication a = ((UsernamePasswordAuthentication) auth);
if ("admin".equals(a.getUsername()) && "admin".equals(a.getPassword())) {
return getUserByName("admin");
}
}
throw new AuthenticationFailedException();
}
开发者ID:Blazebit,项目名称:blaze-storage,代码行数:13,代码来源:AdminUserManagerFactory.java
示例7: authenticate
import org.apache.ftpserver.usermanager.UsernamePasswordAuthentication; //导入依赖的package包/类
@Override
public User authenticate(Authentication authentication) throws AuthenticationFailedException {
if (authentication instanceof UsernamePasswordAuthentication) {
UsernamePasswordAuthentication auth = (UsernamePasswordAuthentication) authentication;
if (ftpUser.getName().equals(auth.getUsername()) && "topsecret".equals(auth.getPassword())) {
return ftpUser;
}
}
throw new AuthenticationFailedException();
}
开发者ID:AludraTest,项目名称:aludratest,代码行数:11,代码来源:FtpFileServiceTest.java
示例8: authenticate
import org.apache.ftpserver.usermanager.UsernamePasswordAuthentication; //导入依赖的package包/类
@Override
public User authenticate(Authentication authentication) throws AuthenticationFailedException {
if (UsernamePasswordAuthentication.class.isAssignableFrom(authentication.getClass())) {
UsernamePasswordAuthentication upAuth = (UsernamePasswordAuthentication) authentication;
BaseUser user = users.get(upAuth.getUsername());
if (user != null && user.getEnabled() && (user.getName().equals("anonymous") || user.getPassword().equals(upAuth.getPassword()))){
return user;
}
} else if (AnonymousAuthentication.class.isAssignableFrom(authentication.getClass())) {
BaseUser anonymous = users.get("anonymous");
return anonymous.getEnabled() ? anonymous : null;
}
return null;
}
开发者ID:andresoviedo,项目名称:google-drive-ftp-adapter,代码行数:15,代码来源:GFtpServerFactory.java
示例9: authenticate
import org.apache.ftpserver.usermanager.UsernamePasswordAuthentication; //导入依赖的package包/类
public User authenticate(Authentication authentication) throws AuthenticationFailedException {
if ((authentication instanceof UsernamePasswordAuthentication) == false) {
throw new AuthenticationFailedException("Can't manage " + authentication.getClass().getSimpleName() + " auth class.");
}
UsernamePasswordAuthentication auth = (UsernamePasswordAuthentication) authentication;
String addr = auth.getUserMetadata().getInetAddress().getHostAddress();
String username = auth.getUsername();
String login_name = FTPUser.makeUserId(username, domain);
try {
FTPUser user = FTPUser.getUserByName(username, domain);
if (user == null) {
AccessControl.failedAttempt(addr, login_name);
return null;
}
if (user.validPassword(auth)) {
AccessControl.releaseIP(addr);
return user.updateLastLogin();
} else {
AccessControl.failedAttempt(addr, login_name);
}
} catch (ConnectionException e) {
Loggers.FTPserver.error("Can't access to db", e);
}
return null;
}
开发者ID:hdsdi3g,项目名称:MyDMAM,代码行数:28,代码来源:FTPUserManager.java
示例10: authenticate
import org.apache.ftpserver.usermanager.UsernamePasswordAuthentication; //导入依赖的package包/类
@Override
public User authenticate(final Authentication inAuth) throws AuthenticationFailedException {
UsernamePasswordAuthentication upa = (UsernamePasswordAuthentication) inAuth;
String login = upa.getUsername();
String password = upa.getPassword();
if (user.equals(login) && pass.equals(password))
return new FtpUser(homePath, login, password);
throw new AuthenticationFailedException();
}
开发者ID:bingoohuang,项目名称:aoc,代码行数:11,代码来源:FtpUserManager.java
示例11: testAuthenticateWrongPassword
import org.apache.ftpserver.usermanager.UsernamePasswordAuthentication; //导入依赖的package包/类
public void testAuthenticateWrongPassword() throws Exception {
try {
userManager.authenticate(new UsernamePasswordAuthentication(
"user1", "foo"));
fail("Must throw AuthenticationFailedException");
} catch (AuthenticationFailedException e) {
// ok
}
}
开发者ID:saaconsltd,项目名称:mina-ftpserver,代码行数:10,代码来源:UserManagerTestTemplate.java
示例12: testAuthenticateUnknownUser
import org.apache.ftpserver.usermanager.UsernamePasswordAuthentication; //导入依赖的package包/类
public void testAuthenticateUnknownUser() throws Exception {
try {
userManager.authenticate(new UsernamePasswordAuthentication("foo",
"foo"));
fail("Must throw AuthenticationFailedException");
} catch (AuthenticationFailedException e) {
// ok
}
}
开发者ID:saaconsltd,项目名称:mina-ftpserver,代码行数:10,代码来源:UserManagerTestTemplate.java
示例13: testAuthenticateNullUser
import org.apache.ftpserver.usermanager.UsernamePasswordAuthentication; //导入依赖的package包/类
public void testAuthenticateNullUser() throws Exception {
try {
userManager.authenticate(new UsernamePasswordAuthentication(null,
"foo"));
fail("Must throw AuthenticationFailedException");
} catch (AuthenticationFailedException e) {
// ok
}
}
开发者ID:saaconsltd,项目名称:mina-ftpserver,代码行数:10,代码来源:UserManagerTestTemplate.java
示例14: authenticate
import org.apache.ftpserver.usermanager.UsernamePasswordAuthentication; //导入依赖的package包/类
/**
* User authenticate method
*/
public User authenticate(Authentication authentication)
throws AuthenticationFailedException {
if (authentication instanceof UsernamePasswordAuthentication) {
UsernamePasswordAuthentication upauth = (UsernamePasswordAuthentication) authentication;
String user = upauth.getUsername();
String password = upauth.getPassword();
if (user == null) {
throw new AuthenticationFailedException("Authentication failed");
}
if (password == null) {
password = "";
}
String storedPassword = userDataProp.getProperty(PREFIX + user
+ '.' + ATTR_PASSWORD);
if (storedPassword == null) {
// user does not exist
throw new AuthenticationFailedException("Authentication failed");
}
if (getPasswordEncryptor().matches(password, storedPassword)) {
return getUserByName(user);
} else {
throw new AuthenticationFailedException("Authentication failed");
}
} else if (authentication instanceof AnonymousAuthentication) {
if (doesExist("anonymous")) {
return getUserByName("anonymous");
} else {
throw new AuthenticationFailedException("Authentication failed");
}
} else {
throw new IllegalArgumentException(
"Authentication not supported by this user manager");
}
}
开发者ID:lgnlgn,项目名称:feluca,代码行数:45,代码来源:PropertiesUserManager.java
示例15: validPassword
import org.apache.ftpserver.usermanager.UsernamePasswordAuthentication; //导入依赖的package包/类
boolean validPassword(UsernamePasswordAuthentication auth) {
return password.checkPassword(auth.getPassword(), this.obscured_password);
}
开发者ID:hdsdi3g,项目名称:MyDMAM,代码行数:4,代码来源:FTPUser.java
示例16: testAuthenticate
import org.apache.ftpserver.usermanager.UsernamePasswordAuthentication; //导入依赖的package包/类
public void testAuthenticate() throws Exception {
assertNotNull(userManager
.authenticate(new UsernamePasswordAuthentication("user1", "pw1")));
}
开发者ID:saaconsltd,项目名称:mina-ftpserver,代码行数:5,代码来源:UserManagerTestTemplate.java
示例17: testAuthenticateEmptyPassword
import org.apache.ftpserver.usermanager.UsernamePasswordAuthentication; //导入依赖的package包/类
public void testAuthenticateEmptyPassword() throws Exception {
assertNotNull(userManager
.authenticate(new UsernamePasswordAuthentication("user3", "")));
}
开发者ID:saaconsltd,项目名称:mina-ftpserver,代码行数:5,代码来源:UserManagerTestTemplate.java
示例18: testAuthenticateNullPassword
import org.apache.ftpserver.usermanager.UsernamePasswordAuthentication; //导入依赖的package包/类
public void testAuthenticateNullPassword() throws Exception {
assertNotNull(userManager
.authenticate(new UsernamePasswordAuthentication("user3", null)));
}
开发者ID:saaconsltd,项目名称:mina-ftpserver,代码行数:5,代码来源:UserManagerTestTemplate.java
注:本文中的org.apache.ftpserver.usermanager.UsernamePasswordAuthentication类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论