import java.net.InetSocketAddress;
import java.net.SocketAddress;
import org.opendaylight.netconf.api.messages.NetconfHelloMessageAdditionalHeader;
+import org.opendaylight.netconf.shaded.sshd.common.NamedFactory;
import org.opendaylight.netconf.shaded.sshd.common.io.IoInputStream;
import org.opendaylight.netconf.shaded.sshd.common.io.IoOutputStream;
import org.opendaylight.netconf.shaded.sshd.server.Environment;
import org.opendaylight.netconf.shaded.sshd.server.command.AsyncCommand;
import org.opendaylight.netconf.shaded.sshd.server.command.Command;
import org.opendaylight.netconf.shaded.sshd.server.session.ServerSession;
-import org.opendaylight.netconf.shaded.sshd.server.subsystem.SubsystemFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
return netconfHelloMessageAdditionalHeader.getAddress();
}
- public static class NetconfCommandFactory implements SubsystemFactory {
+ public static class NetconfCommandFactory implements NamedFactory<Command> {
public static final String NETCONF = "netconf";
}
@Override
- public Command createSubsystem(final ChannelSession channel) {
+ public RemoteNetconfCommand create() {
return new RemoteNetconfCommand(clientBootstrap, localAddress);
}
}
import com.google.common.annotations.Beta;
import org.opendaylight.netconf.shaded.sshd.client.SshClient;
import org.opendaylight.netconf.shaded.sshd.common.Factory;
+import org.opendaylight.netconf.shaded.sshd.common.forward.PortForwardingEventListener;
+import org.opendaylight.netconf.shaded.sshd.common.util.net.SshdSocketAddress;
/**
* An extension to {@link SshClient} which uses {@link NetconfSessionFactory} to create sessions (leading towards
public class NetconfSshClient extends SshClient {
public static final Factory<SshClient> DEFAULT_NETCONF_SSH_CLIENT_FACTORY = NetconfSshClient::new;
+ /*
+ * This is a workaround for sshd-core's instantiation of Proxies. AbstractFactoryManager (which is our superclass)
+ * is calling Proxy.newProxyInstance() with getClass().getClassLoader(), i.e. our class loader.
+ *
+ * Since we are not using PortForwardingEventListener, our classloader does not see it (because we do not import
+ * that package), which leads to an instantiation failure.
+ *
+ * Having these dumb fields alleviates the problem, as it forces the packages to be imported by our bundle.
+ *
+ * FIXME: Remove this once we have an SSHD version with https://issues.apache.org/jira/browse/SSHD-975 fixed
+ */
+ static final class Sshd975Workarounds {
+ static final PortForwardingEventListener PFEL = null;
+ static final SshdSocketAddress SSA = null;
+ }
+
@Override
protected NetconfSessionFactory createSessionFactory() {
return new NetconfSessionFactory(this);
<dependency>
<groupId>org.apache.sshd</groupId>
<artifactId>sshd-osgi</artifactId>
- <version>2.5.1</version>
</dependency>
<dependency>
<groupId>org.apache.sshd</groupId>
<artifactId>sshd-netty</artifactId>
- <version>2.5.1</version>
</dependency>
<dependency>
<groupId>net.i2p.crypto</groupId>