use of com.sshtools.j2ssh.authentication.PasswordAuthenticationClient in project iaf by ibissource.
the class FtpSession method getSshAuthentication.
private SshAuthenticationClient getSshAuthentication() throws Exception {
if (StringUtils.isNotEmpty(privateKeyFilePath)) {
PublicKeyAuthenticationClient pk = new PublicKeyAuthenticationClient();
CredentialFactory pkcf = new CredentialFactory(getPrivateKeyAuthAlias(), getUsername(), getPrivateKeyPassword());
pk.setUsername(pkcf.getUsername());
SshPrivateKeyFile pkFile = SshPrivateKeyFile.parse(new File(privateKeyFilePath));
pk.setKey(pkFile.toPrivateKey(pkcf.getPassword()));
return pk;
}
CredentialFactory usercf = new CredentialFactory(getAuthAlias(), getUsername(), getPassword());
if (StringUtils.isNotEmpty(usercf.getPassword())) {
PasswordAuthenticationClient pac = new PasswordAuthenticationClient();
pac.setUsername(usercf.getUsername());
pac.setPassword(usercf.getPassword());
return pac;
}
throw new Exception("Unknown authentication type, either the password or the privateKeyFile must be filled");
}
Aggregations