本文整理汇总了Java中org.apache.sshd.server.auth.password.PasswordChangeRequiredException类的典型用法代码示例。如果您正苦于以下问题:Java PasswordChangeRequiredException类的具体用法?Java PasswordChangeRequiredException怎么用?Java PasswordChangeRequiredException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PasswordChangeRequiredException类属于org.apache.sshd.server.auth.password包,在下文中一共展示了PasswordChangeRequiredException类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: authenticate
import org.apache.sshd.server.auth.password.PasswordChangeRequiredException; //导入依赖的package包/类
@Override
public boolean authenticate(String username, String password, ServerSession session) throws
PasswordChangeRequiredException {
try {
Authentication auth = authProvider.authenticate(
new UsernamePasswordAuthenticationToken(username, password));
session.getIoSession().setAttribute(Constants.USER, username);
session.getIoSession().setAttribute(Constants.USER_ROLES, auth.getAuthorities().stream()
.map(ga -> ga.getAuthority()).collect(Collectors.toSet()));
return true;
} catch (AuthenticationException ex) {
log.warn(ex.getMessage());
return false;
}
}
示例2: authenticate
import org.apache.sshd.server.auth.password.PasswordChangeRequiredException; //导入依赖的package包/类
@Override
public boolean authenticate(String username, String password, ServerSession session) throws
PasswordChangeRequiredException {
session.getIoSession().setAttribute(Constants.USER_ROLES, Collections.<String>singleton("*"));
session.getIoSession().setAttribute(Constants.USER, username);
return username.equals(props.getUsername()) && password.equals(props.getPassword());
}
示例3: create
import org.apache.sshd.server.auth.password.PasswordChangeRequiredException; //导入依赖的package包/类
public static SshServer create() {
SshServer sshd = SshServer.setUpDefaultServer();
sshd.setPort(SpashConfig.getInstance().spashListenPort());
AbstractGeneratorHostKeyProvider keyProvider = new SimpleGeneratorHostKeyProvider(new File(SpashConfig.getInstance().spashKeyFileName()));
keyProvider.setAlgorithm(SpashConfig.getInstance().spashKeyAlgorithm());
keyProvider.setKeySize(SpashConfig.getInstance().spashKeyLength());
sshd.setKeyPairProvider(keyProvider);
List<NamedFactory<UserAuth>> userAuthFactories = new ArrayList<NamedFactory<UserAuth>>();
userAuthFactories.add(new UserAuthPasswordFactory());
sshd.setUserAuthFactories(userAuthFactories);
sshd.setPasswordAuthenticator(new PasswordAuthenticator() {
@Override
public boolean authenticate(String username, String password, ServerSession serverSession) throws PasswordChangeRequiredException {
return username!=null && username.length()>0 && username.equals(password);
}
});
sshd.setShellFactory(new SpashShellFactory());
List<NamedFactory<Command>> namedFactoryList = new ArrayList<>();
namedFactoryList.add(new SftpSubsystemFactory());
sshd.setSubsystemFactories(namedFactoryList);
sshd.setCommandFactory(new ScpCommandFactory());
sshd.setFileSystemFactory(new FileSystemFactory() {
@Override
public FileSystem createFileSystem(Session session) throws IOException {
return SpashFileSystem.get().getFileSystem();
}
});
return sshd;
}
示例4: setup
import org.apache.sshd.server.auth.password.PasswordChangeRequiredException; //导入依赖的package包/类
@BeforeClass
public static void setup() throws Exception {
sshdServer.setPort(PORT);
sshdServer.setKeyPairProvider(new SimpleGeneratorHostKeyProvider());
sshdServer.setPasswordAuthenticator(new PasswordAuthenticator() {
public boolean authenticate(String user, String password, ServerSession serverSession) throws PasswordChangeRequiredException {
return user.equals(USERNAME) && password.equals(USERPWD);
}
});
sshdServer.start();
}
示例5: authenticate
import org.apache.sshd.server.auth.password.PasswordChangeRequiredException; //导入依赖的package包/类
@Override
public boolean authenticate(String username, String password, ServerSession session)
throws PasswordChangeRequiredException
{
return Objects.equals(username, "admin") && Objects.equals(password, "admin");
}
示例6: authenticate
import org.apache.sshd.server.auth.password.PasswordChangeRequiredException; //导入依赖的package包/类
@Override
public boolean authenticate(String username, String password, ServerSession serverSession) throws PasswordChangeRequiredException {
return password.equals(users.get(username));
}
示例7: authenticate
import org.apache.sshd.server.auth.password.PasswordChangeRequiredException; //导入依赖的package包/类
@Override
public boolean authenticate(String username, String password, ServerSession session)
throws PasswordChangeRequiredException {
return username.equals("testuser") && password.equals("pass");
}