This is an automated email from the ASF dual-hosted git repository.

lgoldstein pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mina-sshd.git

commit 737475319b914915306575e8b072e7ed94e94cdd
Author: Lyor Goldstein <lgoldst...@apache.org>
AuthorDate: Thu Aug 20 15:29:17 2020 +0300

    [SSHD-1056] Added configurable default auth/connect timeouts to client CLI 
sessions
---
 .../sshd/cli/client/CliClientModuleProperties.java | 48 ++++++++++++++++++++++
 .../sshd/cli/client/SshClientCliSupport.java       |  5 +--
 .../apache/sshd/common/CommonModuleProperties.java |  3 +-
 .../org/apache/sshd/core/CoreModuleProperties.java |  3 +-
 .../org/apache/sshd/scp/ScpModuleProperties.java   |  2 +-
 .../org/apache/sshd/sftp/SftpModuleProperties.java |  2 +-
 6 files changed, 54 insertions(+), 9 deletions(-)

diff --git 
a/sshd-cli/src/main/java/org/apache/sshd/cli/client/CliClientModuleProperties.java
 
b/sshd-cli/src/main/java/org/apache/sshd/cli/client/CliClientModuleProperties.java
new file mode 100644
index 0000000..1287784
--- /dev/null
+++ 
b/sshd-cli/src/main/java/org/apache/sshd/cli/client/CliClientModuleProperties.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.sshd.cli.client;
+
+import java.time.Duration;
+
+import org.apache.sshd.common.Property;
+
+/**
+ * @author <a href="mailto:d...@mina.apache.org";>Apache MINA SSHD Project</a>
+ */
+public final class CliClientModuleProperties {
+    /**
+     * Key used to retrieve the value of the timeout after which it will abort 
the connection if the connection
+     * has not been established - in milliseconds.
+     */
+    public static final Property<Duration> CONECT_TIMEOUT
+        = Property.duration("cli-connect-timeout", Duration.ofMinutes(2));
+
+    /**
+     * Key used to retrieve the value of the timeout after which it will close 
the connection if the other side has not
+     * been authenticated - in milliseconds.
+     */
+    public static final Property<Duration> AUTH_TIMEOUT
+        = Property.duration("cli-auth-timeout", Duration.ofMinutes(2));
+
+
+    private CliClientModuleProperties() {
+        throw new UnsupportedOperationException("No instance");
+    }
+}
diff --git 
a/sshd-cli/src/main/java/org/apache/sshd/cli/client/SshClientCliSupport.java 
b/sshd-cli/src/main/java/org/apache/sshd/cli/client/SshClientCliSupport.java
index 6b17d17..685c812 100644
--- a/sshd-cli/src/main/java/org/apache/sshd/cli/client/SshClientCliSupport.java
+++ b/sshd-cli/src/main/java/org/apache/sshd/cli/client/SshClientCliSupport.java
@@ -82,7 +82,6 @@ import org.apache.sshd.common.util.ValidateUtils;
 import org.apache.sshd.common.util.io.NoCloseOutputStream;
 import org.apache.sshd.common.util.net.SshdSocketAddress;
 import org.apache.sshd.common.util.threads.ThreadUtils;
-import org.apache.sshd.core.CoreModuleProperties;
 
 /**
  * TODO Add javadoc
@@ -259,13 +258,13 @@ public abstract class SshClientCliSupport extends 
CliSupport {
             HostConfigEntry entry = resolveHost(client, login, host, port, 
proxyJump);
             // TODO use a configurable wait time
             ClientSession session = client.connect(entry, null, null)
-                    .verify()
+                    
.verify(CliClientModuleProperties.CONECT_TIMEOUT.getRequired(client))
                     .getSession();
             try {
                 if (GenericUtils.length(password) > 0) {
                     session.addPasswordIdentity(password);
                 }
-                
session.auth().verify(CoreModuleProperties.AUTH_TIMEOUT.getRequired(session));
+                
session.auth().verify(CliClientModuleProperties.AUTH_TIMEOUT.getRequired(session));
                 return session;
             } catch (Exception e) {
                 session.close(true);
diff --git 
a/sshd-common/src/main/java/org/apache/sshd/common/CommonModuleProperties.java 
b/sshd-common/src/main/java/org/apache/sshd/common/CommonModuleProperties.java
index c3da143..0b76b0f 100644
--- 
a/sshd-common/src/main/java/org/apache/sshd/common/CommonModuleProperties.java
+++ 
b/sshd-common/src/main/java/org/apache/sshd/common/CommonModuleProperties.java
@@ -69,7 +69,6 @@ public final class CommonModuleProperties {
             = Property.duration("sshd-close-wait-time", 
Duration.ofSeconds(15L));
 
     private CommonModuleProperties() {
-        // private
+        throw new UnsupportedOperationException("No instance");
     }
-
 }
diff --git 
a/sshd-core/src/main/java/org/apache/sshd/core/CoreModuleProperties.java 
b/sshd-core/src/main/java/org/apache/sshd/core/CoreModuleProperties.java
index 0746249..828bf72 100644
--- a/sshd-core/src/main/java/org/apache/sshd/core/CoreModuleProperties.java
+++ b/sshd-core/src/main/java/org/apache/sshd/core/CoreModuleProperties.java
@@ -679,7 +679,6 @@ public final class CoreModuleProperties {
             = Property.string("x11-fwd-bind-host", 
SshdSocketAddress.LOCALHOST_IPV4);
 
     private CoreModuleProperties() {
-        // private
+        throw new UnsupportedOperationException("No instance");
     }
-
 }
diff --git 
a/sshd-scp/src/main/java/org/apache/sshd/scp/ScpModuleProperties.java 
b/sshd-scp/src/main/java/org/apache/sshd/scp/ScpModuleProperties.java
index 3c6d5f3..4821f34 100644
--- a/sshd-scp/src/main/java/org/apache/sshd/scp/ScpModuleProperties.java
+++ b/sshd-scp/src/main/java/org/apache/sshd/scp/ScpModuleProperties.java
@@ -60,6 +60,6 @@ public final class ScpModuleProperties {
             = Property.charset("scp-shell-name-encoding-charset", 
StandardCharsets.UTF_8);
 
     private ScpModuleProperties() {
-        // private
+        throw new UnsupportedOperationException("No instance");
     }
 }
diff --git 
a/sshd-sftp/src/main/java/org/apache/sshd/sftp/SftpModuleProperties.java 
b/sshd-sftp/src/main/java/org/apache/sshd/sftp/SftpModuleProperties.java
index a719bdf..3144884 100644
--- a/sshd-sftp/src/main/java/org/apache/sshd/sftp/SftpModuleProperties.java
+++ b/sshd-sftp/src/main/java/org/apache/sshd/sftp/SftpModuleProperties.java
@@ -218,7 +218,7 @@ public final class SftpModuleProperties {
             = SshServerConfigFileReader.SFTP_FORCED_VERSION_PROP;
 
     private SftpModuleProperties() {
-        // private
+        throw new UnsupportedOperationException("No instance");
     }
 
 }

Reply via email to