本文整理汇总了Java中net.schmizz.sshj.userauth.password.PasswordFinder类的典型用法代码示例。如果您正苦于以下问题:Java PasswordFinder类的具体用法?Java PasswordFinder怎么用?Java PasswordFinder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PasswordFinder类属于net.schmizz.sshj.userauth.password包,在下文中一共展示了PasswordFinder类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sshAuth
import net.schmizz.sshj.userauth.password.PasswordFinder; //导入依赖的package包/类
private void sshAuth() throws IOException, UserAuthException, TransportException, CryptographyException {
if (server != null) {
ssh.connect(server.getHost(), server.getPort());
switch (server.getAuthentication().getAuthenticationTypeEnum()) {
case NO_AUTHENTICATION:
NoAuthentication noAuthentication = (NoAuthentication) server.getAuthentication();
ssh.auth(noAuthentication.getLogin());
break;
case SSH_AUTHENTICATION_PASSWORD:
SSHAuthenticationPassword sshAuthenticationPassword = (SSHAuthenticationPassword) server.getAuthentication();
String password = sshAuthenticationPassword.getDecryptPassword(myAuthentication.getKey());
PasswordFinder createOneOff = PasswordUtils.createOneOff(password.toCharArray());
ssh.auth(sshAuthenticationPassword.getLogin(), new AuthPassword(createOneOff));
break;
default:
throw new RuntimeException("authentication type is not supported");
}
} else {
throw new IllegalStateException("server is required");
}
}