import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
-import org.apache.sshd.common.keyprovider.KeyPairProvider;
-import org.apache.sshd.common.util.SecurityUtils;
-import org.apache.sshd.common.util.threads.ThreadUtils;
+import org.apache.sshd.common.util.ThreadUtils;
+import org.apache.sshd.server.keyprovider.PEMGeneratorHostKeyProvider;
import org.opendaylight.controller.config.util.capability.BasicCapability;
import org.opendaylight.controller.config.util.capability.Capability;
import org.opendaylight.controller.config.util.capability.YangModuleCapability;
final List<Integer> openDevices = Lists.newArrayList();
// Generate key to temp folder
- final KeyPairProvider keyPairProvider = getPemGeneratorHostKeyProvider();
+ final PEMGeneratorHostKeyProvider keyPairProvider = getPemGeneratorHostKeyProvider();
for (int i = 0; i < params.deviceCount; i++) {
if (currentPort > 65535) {
return openDevices;
}
- private static SshProxyServerConfiguration getSshConfiguration(final InetSocketAddress bindingAddress,
- final LocalAddress tcpLocalAddress, final KeyPairProvider keyPairProvider) {
+ private SshProxyServerConfiguration getSshConfiguration(final InetSocketAddress bindingAddress, final LocalAddress tcpLocalAddress, final PEMGeneratorHostKeyProvider keyPairProvider) throws IOException {
return new SshProxyServerConfigurationBuilder()
.setBindingAddress(bindingAddress)
.setLocalAddress(tcpLocalAddress)
.createSshProxyServerConfiguration();
}
- private static KeyPairProvider getPemGeneratorHostKeyProvider() {
+ private PEMGeneratorHostKeyProvider getPemGeneratorHostKeyProvider() {
try {
final Path tempFile = Files.createTempFile("tempKeyNetconfTest", "suffix");
- return SecurityUtils.createGeneratorHostKeyProvider(tempFile.toAbsolutePath());
+ return new PEMGeneratorHostKeyProvider(tempFile.toAbsolutePath().toString());
} catch (final IOException e) {
LOG.error("Unable to generate PEM key", e);
- throw new RuntimeException("Unable to generate PEM key", e);
+ throw new RuntimeException(e);
}
}
return capabilities;
}
- private static void addModuleCapability(final SharedSchemaRepository consumer, final Set<Capability> capabilities,
- final Module module) {
+ private void addModuleCapability(final SharedSchemaRepository consumer, final Set<Capability> capabilities, final Module module) {
final SourceIdentifier moduleSourceIdentifier = SourceIdentifier.create(module.getName(),
(SimpleDateFormatUtil.DEFAULT_DATE_REV == module.getRevision() ? Optional.<String>absent() :
Optional.of(SimpleDateFormatUtil.getRevisionFormat().format(module.getRevision()))));
}
}
- private static void addDefaultSchemas(final SharedSchemaRepository consumer) {
+ private void addDefaultSchemas(final SharedSchemaRepository consumer) {
SourceIdentifier sId = RevisionSourceIdentifier.create("ietf-netconf-monitoring", "2010-10-04");
registerSource(consumer, "/META-INF/yang/ietf-netconf-monitoring.yang", sId);
registerSource(consumer, "/META-INF/yang/ietf-inet-types@2013-07-15.yang", sId);
}
- private static void registerSource(final SharedSchemaRepository consumer, final String resource,
- final SourceIdentifier sourceId) {
+ private void registerSource(final SharedSchemaRepository consumer, final String resource, final SourceIdentifier sourceId) {
consumer.registerSchemaSource(new SchemaSourceProvider<SchemaSourceRepresentation>() {
@Override
public CheckedFuture<? extends SchemaSourceRepresentation, SchemaSourceException> getSource(final SourceIdentifier sourceIdentifier) {
@Override
public void close() {
for (final SshProxyServer sshWrapper : sshWrappers) {
- try {
- sshWrapper.close();
- } catch (IOException e) {
- LOG.error("Failed to close wrapper {}", sshWrapper, e);
- }
+ sshWrapper.close();
}
for (final Channel deviceCh : devicesChannels) {
deviceCh.close();