> - } else if (loginCredentials.hasUnencryptedPrivateKey()) {
> - byte[] privateKey =
> loginCredentials.getOptionalPrivateKey().get().getBytes();
> - jsch.addIdentity(loginCredentials.getUser(), privateKey, null,
> emptyPassPhrase);
> - } else if (agentConnector.isPresent()) {
> - JSch.setConfig("PreferredAuthentications", "publickey");
> - jsch.setIdentityRepository(new
> RemoteIdentityRepository(agentConnector.get()));
> - }
> + if (loginCredentials.hasUnencryptedPrivateKey()) {
> + byte[] privateKey =
> loginCredentials.getOptionalPrivateKey().get().getBytes();
> + jsch.addIdentity(loginCredentials.getUser(),
> privateKey, null, emptyPassPhrase);
> + } else if (loginCredentials.getOptionalPassword().isPresent()) {
> +
> session.setPassword(loginCredentials.getOptionalPassword().orNull());
> + } else if (agentConnector.isPresent()) {
> + JSch.setConfig("PreferredAuthentications", "publickey");
> + jsch.setIdentityRepository(new
> RemoteIdentityRepository(agentConnector.get()));
> + }
Can you set the order of the conditionals so the password authentication takes
preference, just [like in the sshj
driver](https://github.com/jclouds/jclouds/blob/master/drivers/sshj/src/main/java/org/jclouds/sshj/SSHClientConnection.java#L160-L169)?
Also re-indent your change to 3 spaces, to keep the code aligned with the
[jclouds code
style](https://cwiki.apache.org/confluence/display/JCLOUDS/Coding+Standards).
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/735/files#r29032258