Make idle timeout configurable in ssh proxy server
[controller.git] / opendaylight / netconf / netconf-ssh / src / main / java / org / opendaylight / controller / netconf / ssh / SshProxyServerConfiguration.java
diff --git a/opendaylight/netconf/netconf-ssh/src/main/java/org/opendaylight/controller/netconf/ssh/SshProxyServerConfiguration.java b/opendaylight/netconf/netconf-ssh/src/main/java/org/opendaylight/controller/netconf/ssh/SshProxyServerConfiguration.java
new file mode 100644 (file)
index 0000000..aee3c7b
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.controller.netconf.ssh;
+
+import com.google.common.base.Preconditions;
+import io.netty.channel.local.LocalAddress;
+import java.net.InetSocketAddress;
+import org.apache.sshd.common.KeyPairProvider;
+import org.apache.sshd.server.PasswordAuthenticator;
+
+public final class SshProxyServerConfiguration {
+    private final InetSocketAddress bindingAddress;
+    private final LocalAddress localAddress;
+    private final PasswordAuthenticator authenticator;
+    private final KeyPairProvider keyPairProvider;
+    private final int idleTimeout;
+
+    SshProxyServerConfiguration(final InetSocketAddress bindingAddress, final LocalAddress localAddress, final PasswordAuthenticator authenticator, final KeyPairProvider keyPairProvider, final int idleTimeout) {
+        this.bindingAddress = Preconditions.checkNotNull(bindingAddress);
+        this.localAddress = Preconditions.checkNotNull(localAddress);
+        this.authenticator = Preconditions.checkNotNull(authenticator);
+        this.keyPairProvider = Preconditions.checkNotNull(keyPairProvider);
+        // Idle timeout cannot be disabled in the sshd by using =< 0 value
+        Preconditions.checkArgument(idleTimeout > 0, "Idle timeout has to be > 0");
+        this.idleTimeout = idleTimeout;
+    }
+
+    public InetSocketAddress getBindingAddress() {
+        return bindingAddress;
+    }
+
+    public LocalAddress getLocalAddress() {
+        return localAddress;
+    }
+
+    public PasswordAuthenticator getAuthenticator() {
+        return authenticator;
+    }
+
+    public KeyPairProvider getKeyPairProvider() {
+        return keyPairProvider;
+    }
+
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+
+}