Re-integrate ssh client
[netconf.git] / netconf / netconf-netty-util / src / main / java / org / opendaylight / netconf / nettyutil / handler / ssh / client / NetconfClientBuilder.java
diff --git a/netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/handler/ssh/client/NetconfClientBuilder.java b/netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/handler/ssh/client/NetconfClientBuilder.java
new file mode 100644 (file)
index 0000000..d0efcf6
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2019 PANTHEON.tech, s.r.o. 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.netconf.nettyutil.handler.ssh.client;
+
+import static com.google.common.base.Verify.verify;
+
+import com.google.common.annotations.Beta;
+import org.opendaylight.netconf.shaded.sshd.client.ClientBuilder;
+import org.opendaylight.netconf.shaded.sshd.client.SshClient;
+
+/**
+ * A {@link ClientBuilder} which builds {@link NetconfSshClient} instances.
+ */
+@Beta
+public class NetconfClientBuilder extends ClientBuilder {
+    @Override
+    public NetconfSshClient build() {
+        final SshClient client = super.build();
+        verify(client instanceof NetconfSshClient, "Unexpected client %s", client);
+        return (NetconfSshClient) client;
+    }
+
+    @Override
+    protected ClientBuilder fillWithDefaultValues() {
+        if (factory == null) {
+            factory = NetconfSshClient.DEFAULT_NETCONF_SSH_CLIENT_FACTORY;
+        }
+        return super.fillWithDefaultValues();
+    }
+}