mirror of https://github.com/apache/jclouds.git
JCLOUDS-921 prioritise key over password in SessionConnection
This commit is contained in:
parent
f88acd67c0
commit
7e1838afbb
|
@ -1,9 +0,0 @@
|
|||
# use glob syntax.
|
||||
syntax: glob
|
||||
target
|
||||
.settings
|
||||
.classpath
|
||||
.project
|
||||
jclouds-jsch.iml
|
||||
jclouds-jsch.ipr
|
||||
jclouds-jsch.iws
|
|
@ -169,11 +169,11 @@ public final class SessionConnection implements Connection<Session> {
|
|||
.getSession(loginCredentials.getUser(), hostAndPort.getHostText(), hostAndPort.getPortOrDefault(22));
|
||||
if (sessionTimeout != 0)
|
||||
session.setTimeout(sessionTimeout);
|
||||
if (loginCredentials.getOptionalPassword().isPresent()) {
|
||||
session.setPassword(loginCredentials.getOptionalPassword().orNull());
|
||||
} else if (loginCredentials.hasUnencryptedPrivateKey()) {
|
||||
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()));
|
||||
|
|
Loading…
Reference in New Issue