projects
/
lgpl
/
argeo-commons.git
/ blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Allow to pass SSH password via an InputStream
[lgpl/argeo-commons.git]
/
org.argeo.cms.lib.sshd
/
src
/
org
/
argeo
/
cms
/
ssh
/
AbstractSsh.java
diff --git
a/org.argeo.cms.lib.sshd/src/org/argeo/cms/ssh/AbstractSsh.java
b/org.argeo.cms.lib.sshd/src/org/argeo/cms/ssh/AbstractSsh.java
index c91ab48058f06944489e559a519b6b0789eb348a..8d9e42e2903066ae2dfb43c95c4368238ada331b 100644
(file)
--- a/
org.argeo.cms.lib.sshd/src/org/argeo/cms/ssh/AbstractSsh.java
+++ b/
org.argeo.cms.lib.sshd/src/org/argeo/cms/ssh/AbstractSsh.java
@@
-2,6
+2,7
@@
package org.argeo.cms.ssh;
import java.io.Console;
import java.io.IOException;
import java.io.Console;
import java.io.IOException;
+import java.io.InputStream;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Arrays;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Arrays;
@@
-51,16
+52,20
@@
public abstract class AbstractSsh {
}
public void authenticate() {
}
public void authenticate() {
+ authenticate(System.in);
+ }
+
+ public void authenticate(InputStream in) {
if (sshKeyPair != null) {
session.addPublicKeyIdentity(sshKeyPair.asKeyPair());
} else {
if (sshKeyPair != null) {
session.addPublicKeyIdentity(sshKeyPair.asKeyPair());
} else {
- if (!passwordSet) {
+ if (!passwordSet
&& in != null
) {
String password;
Console console = System.console();
if (console == null) {// IDE
System.out.print("Password: ");
String password;
Console console = System.console();
if (console == null) {// IDE
System.out.print("Password: ");
- try (Scanner s = new Scanner(
System.
in)) {
+ try (Scanner s = new Scanner(in)) {
password = s.next();
}
} else {
password = s.next();
}
} else {