2 * Copyright (c) 2019 PANTHEON.tech, s.r.o. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.netconf.nettyutil.handler.ssh.client;
10 import com.google.common.annotations.Beta;
11 import org.opendaylight.netconf.shaded.sshd.client.SshClient;
12 import org.opendaylight.netconf.shaded.sshd.common.Factory;
13 import org.opendaylight.netconf.shaded.sshd.common.forward.PortForwardingEventListener;
14 import org.opendaylight.netconf.shaded.sshd.common.util.net.SshdSocketAddress;
17 * An extension to {@link SshClient} which uses {@link NetconfSessionFactory} to create sessions (leading towards
18 * {@link NetconfClientSessionImpl}.
21 public class NetconfSshClient extends SshClient {
22 public static final Factory<SshClient> DEFAULT_NETCONF_SSH_CLIENT_FACTORY = NetconfSshClient::new;
25 * This is a workaround for sshd-core's instantiation of Proxies. AbstractFactoryManager (which is our superclass)
26 * is calling Proxy.newProxyInstance() with getClass().getClassLoader(), i.e. our class loader.
28 * Since we are not using PortForwardingEventListener, our classloader does not see it (because we do not import
29 * that package), which leads to an instantiation failure.
31 * Having these dumb fields alleviates the problem, as it forces the packages to be imported by our bundle.
33 * FIXME: Remove this once we have an SSHD version with https://issues.apache.org/jira/browse/SSHD-975 fixed
35 static final class Sshd975Workarounds {
36 static final PortForwardingEventListener PFEL = null;
37 static final SshdSocketAddress SSA = null;
41 protected NetconfSessionFactory createSessionFactory() {
42 return new NetconfSessionFactory(this);