<classifier>features</classifier>
<type>xml</type>
</dependency>
- <!-- dependency>
+ <dependency>
<groupId>org.opendaylight.aaa</groupId>
<artifactId>features-aaa</artifactId>
<version>${aaa.version}</version>
<classifier>features</classifier>
<type>xml</type>
- </dependency -->
+ </dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
-->
<repository>mvn:org.opendaylight.controller/features-mdsal/${mdsal.version}/xml/features</repository>
<repository>mvn:org.opendaylight.yangtools/features-yangtools/${yangtools.version}/xml/features</repository>
- <!-- repository>mvn:org.opendaylight.aaa/features-aaa/${aaa.version}/xml/features</repository -->
+ <repository>mvn:org.opendaylight.aaa/features-aaa/${aaa.version}/xml/features</repository>
<feature name='odl-restconf-all' version='${project.version}' description='OpenDaylight :: Restconf :: All'>
<!--
Necessary TODO:
-->
<feature name='odl-restconf' version='${project.version}' description="OpenDaylight :: Restconf">
- <!-- feature version='${aaa.version}'>odl-aaa-authn</feature -->
+ <feature version='${aaa.version}'>odl-aaa-authn</feature>
<feature version='${project.version}'>odl-restconf-noauth</feature>
</feature>
<feature name='odl-restconf-noauth' version='${project.version}' description="OpenDaylight :: Restconf">
public static final SchemaPath EVENT_SOURCE_STATUS_PATH = SchemaPath
.create(true, QName.create(EventSourceStatusNotification.QNAME, "event-source-status"));
- private static final NodeIdentifier EVENT_SOURCE_STATUS_ARG = new NodeIdentifier(
+ private static final NodeIdentifier EVENT_SOURCE_STATUS_ARG = NodeIdentifier.create(
EventSourceStatusNotification.QNAME);
private static final String XMLNS_ATTRIBUTE_KEY = "xmlns";
private static final String XMLNS_URI = "http://www.w3.org/2000/xmlns/";
private static final Logger LOG = LoggerFactory.getLogger(NetconfEventSource.class);
- private static final NodeIdentifier TOPIC_NOTIFICATION_ARG = new NodeIdentifier(TopicNotification.QNAME);
- private static final NodeIdentifier EVENT_SOURCE_ARG = new NodeIdentifier(
+ private static final NodeIdentifier TOPIC_NOTIFICATION_ARG = NodeIdentifier.create(TopicNotification.QNAME);
+ private static final NodeIdentifier EVENT_SOURCE_ARG = NodeIdentifier.create(
QName.create(TopicNotification.QNAME, "node-id"));
- private static final NodeIdentifier TOPIC_ID_ARG = new NodeIdentifier(
+ private static final NodeIdentifier TOPIC_ID_ARG = NodeIdentifier.create(
QName.create(TopicNotification.QNAME, "topic-id"));
- private static final NodeIdentifier PAYLOAD_ARG = new NodeIdentifier(
+ private static final NodeIdentifier PAYLOAD_ARG = NodeIdentifier.create(
QName.create(TopicNotification.QNAME, "payload"));
private static final String ConnectionNotificationSourceName = "ConnectionNotificationSource";
public class StreamNotificationTopicRegistration extends NotificationTopicRegistration {
private static final Logger LOG = LoggerFactory.getLogger(StreamNotificationTopicRegistration.class);
- private static final NodeIdentifier STREAM_QNAME = new NodeIdentifier(
+ private static final NodeIdentifier STREAM_QNAME = NodeIdentifier.create(
QName.create(CreateSubscriptionInput.QNAME, "stream"));
private static final SchemaPath CREATE_SUBSCRIPTION = SchemaPath
.create(true, QName.create(CreateSubscriptionInput.QNAME, "create-subscription"));
- private static final NodeIdentifier START_TIME_SUBSCRIPTION = new NodeIdentifier(
+ private static final NodeIdentifier START_TIME_SUBSCRIPTION = NodeIdentifier.create(
QName.create(CreateSubscriptionInput.QNAME, "startTime"));
+ private static final NodeIdentifier CREATE_SUBSCRIPTION_INPUT = NodeIdentifier.create(
+ CreateSubscriptionInput.QNAME);
final private DOMMountPoint domMountPoint;
final private String nodeId;
if (isActive() == false) {
LOG.info("Stream {} is not active on node {}. Will subscribe.", this.getStreamName(), this.nodeId);
final ContainerNode input = Builders.containerBuilder()
- .withNodeIdentifier(new NodeIdentifier(CreateSubscriptionInput.QNAME))
+ .withNodeIdentifier(CREATE_SUBSCRIPTION_INPUT)
.withChild(ImmutableNodes.leafNode(STREAM_QNAME, this.getStreamName())).build();
CheckedFuture<DOMRpcResult, DOMRpcException> csFuture = domMountPoint.getService(DOMRpcService.class).get()
.invokeRpc(CREATE_SUBSCRIPTION, input);
if (isActive()) {
LOG.info("Stream {} is reactivating on node {}.", this.getStreamName(), this.nodeId);
DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> inputBuilder = Builders.containerBuilder()
- .withNodeIdentifier(new NodeIdentifier(CreateSubscriptionInput.QNAME))
+ .withNodeIdentifier(CREATE_SUBSCRIPTION_INPUT)
.withChild(ImmutableNodes.leafNode(STREAM_QNAME, this.getStreamName()));
if (isReplaySupported() && this.getLastEventTime() != null) {
inputBuilder.withChild(ImmutableNodes.leafNode(START_TIME_SUBSCRIPTION, this.getLastEventTime()));
+++ /dev/null
-/*
- * 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.netconf.auth;
-
-public class AuthConstants {
-
- /**
- * This property should be set for every implementation of AuthService published to OSGi.
- * Netconf SSH will pick the service with highest preference in case of multiple services present in OSGi.
- */
- public static final String SERVICE_PREFERENCE_KEY = "preference";
-}
</dependency>
<!-- compile dependencies -->
<dependency>
- <groupId>${project.groupId}</groupId>
+ <groupId>org.opendaylight.controller</groupId>
<artifactId>config-api</artifactId>
<scope>test</scope>
</dependency>
<scope>test</scope>
</dependency>
<dependency>
- <groupId>${project.groupId}</groupId>
+ <groupId>org.opendaylight.controller</groupId>
<artifactId>netty-config-api</artifactId>
<scope>test</scope>
</dependency>
* 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.it;
+package org.opendaylight.netconf.it;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import org.opendaylight.controller.config.yang.test.impl.MultipleDependenciesModuleFactory;
import org.opendaylight.controller.config.yang.test.impl.NetconfTestImplModuleFactory;
import org.opendaylight.controller.config.yang.test.impl.TestImplModuleFactory;
-import org.opendaylight.controller.netconf.api.NetconfMessage;
-import org.opendaylight.controller.netconf.api.monitoring.NetconfMonitoringService;
-import org.opendaylight.controller.netconf.client.NetconfClientDispatcherImpl;
-import org.opendaylight.controller.netconf.client.SimpleNetconfClientSessionListener;
-import org.opendaylight.controller.netconf.client.conf.NetconfClientConfiguration;
-import org.opendaylight.controller.netconf.client.conf.NetconfClientConfigurationBuilder;
-import org.opendaylight.controller.netconf.confignetconfconnector.osgi.NetconfOperationServiceFactoryImpl;
-import org.opendaylight.controller.netconf.impl.NetconfServerDispatcherImpl;
-import org.opendaylight.controller.netconf.impl.NetconfServerSessionNegotiatorFactory;
-import org.opendaylight.controller.netconf.impl.SessionIdProvider;
-import org.opendaylight.controller.netconf.impl.osgi.AggregatedNetconfOperationServiceFactory;
-import org.opendaylight.controller.netconf.impl.osgi.NetconfMonitoringServiceImpl;
+import org.opendaylight.netconf.api.NetconfMessage;
+import org.opendaylight.netconf.api.monitoring.NetconfMonitoringService;
+import org.opendaylight.netconf.client.NetconfClientDispatcherImpl;
+import org.opendaylight.netconf.client.SimpleNetconfClientSessionListener;
+import org.opendaylight.netconf.client.conf.NetconfClientConfiguration;
+import org.opendaylight.netconf.client.conf.NetconfClientConfigurationBuilder;
+import org.opendaylight.netconf.confignetconfconnector.osgi.NetconfOperationServiceFactoryImpl;
+import org.opendaylight.netconf.impl.NetconfServerDispatcherImpl;
+import org.opendaylight.netconf.impl.NetconfServerSessionNegotiatorFactory;
+import org.opendaylight.netconf.impl.SessionIdProvider;
+import org.opendaylight.netconf.impl.osgi.AggregatedNetconfOperationServiceFactory;
+import org.opendaylight.netconf.impl.osgi.NetconfMonitoringServiceImpl;
import org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactory;
import org.opendaylight.netconf.monitoring.osgi.NetconfMonitoringActivator;
import org.opendaylight.netconf.monitoring.osgi.NetconfMonitoringOperationService;
* 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.it;
+package org.opendaylight.netconf.it;
import static org.junit.Assert.assertEquals;
import static org.mockito.Matchers.any;
import org.opendaylight.controller.config.persist.api.ConfigSnapshotHolder;
import org.opendaylight.controller.config.persist.api.Persister;
import org.opendaylight.controller.config.persist.impl.ConfigPersisterNotificationHandler;
-import org.opendaylight.controller.netconf.api.NetconfMessage;
-import org.opendaylight.controller.netconf.client.TestingNetconfClient;
+import org.opendaylight.netconf.api.NetconfMessage;
+import org.opendaylight.netconf.client.TestingNetconfClient;
import org.opendaylight.netconf.util.test.XmlFileLoader;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.test.types.rev131127.TestIdentity1;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.test.types.rev131127.TestIdentity2;
* 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.it;
+package org.opendaylight.netconf.it;
import static org.junit.Assert.assertEquals;
import static org.mockito.Matchers.any;
import org.junit.Test;
import org.opendaylight.controller.config.util.capability.Capability;
import org.opendaylight.controller.config.util.xml.XmlUtil;
-import org.opendaylight.controller.netconf.api.NetconfMessage;
-import org.opendaylight.controller.netconf.api.monitoring.CapabilityListener;
-import org.opendaylight.controller.netconf.client.TestingNetconfClient;
-import org.opendaylight.controller.netconf.impl.osgi.AggregatedNetconfOperationServiceFactory;
+import org.opendaylight.netconf.api.NetconfMessage;
+import org.opendaylight.netconf.api.monitoring.CapabilityListener;
+import org.opendaylight.netconf.client.TestingNetconfClient;
+import org.opendaylight.netconf.impl.osgi.AggregatedNetconfOperationServiceFactory;
import org.opendaylight.netconf.mapping.api.NetconfOperationService;
import org.opendaylight.netconf.util.test.XmlFileLoader;
import org.w3c.dom.Document;
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.controller.netconf.it;
+package org.opendaylight.netconf.it;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicInteger;
-import org.apache.sshd.server.PasswordAuthenticator;
import org.apache.sshd.server.keyprovider.PEMGeneratorHostKeyProvider;
-import org.apache.sshd.server.session.ServerSession;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.controller.config.util.xml.XmlUtil;
-import org.opendaylight.controller.netconf.api.NetconfMessage;
-import org.opendaylight.controller.netconf.auth.AuthProvider;
-import org.opendaylight.controller.netconf.client.NetconfClientDispatcher;
-import org.opendaylight.controller.netconf.client.NetconfClientDispatcherImpl;
-import org.opendaylight.controller.netconf.client.NetconfClientSessionListener;
-import org.opendaylight.controller.netconf.client.SimpleNetconfClientSessionListener;
-import org.opendaylight.controller.netconf.client.TestingNetconfClient;
-import org.opendaylight.controller.netconf.client.conf.NetconfClientConfiguration;
-import org.opendaylight.controller.netconf.client.conf.NetconfClientConfigurationBuilder;
+import org.opendaylight.netconf.api.NetconfMessage;
+import org.opendaylight.netconf.auth.AuthProvider;
+import org.opendaylight.netconf.client.NetconfClientDispatcher;
+import org.opendaylight.netconf.client.NetconfClientDispatcherImpl;
+import org.opendaylight.netconf.client.NetconfClientSessionListener;
+import org.opendaylight.netconf.client.SimpleNetconfClientSessionListener;
+import org.opendaylight.netconf.client.TestingNetconfClient;
+import org.opendaylight.netconf.client.conf.NetconfClientConfiguration;
+import org.opendaylight.netconf.client.conf.NetconfClientConfigurationBuilder;
import org.opendaylight.netconf.nettyutil.handler.ssh.authentication.AuthenticationHandler;
import org.opendaylight.netconf.nettyutil.handler.ssh.authentication.LoginPassword;
-import org.opendaylight.netconf.ssh.SshProxyServer;
-import org.opendaylight.netconf.ssh.SshProxyServerConfigurationBuilder;
-import org.opendaylight.netconf.util.messages.NetconfMessageUtil;
-import org.opendaylight.netconf.util.osgi.NetconfConfigUtil;
import org.opendaylight.netconf.sal.connect.api.RemoteDevice;
import org.opendaylight.netconf.sal.connect.netconf.listener.NetconfDeviceCommunicator;
import org.opendaylight.netconf.sal.connect.netconf.listener.NetconfSessionPreferences;
import org.opendaylight.netconf.sal.connect.util.RemoteDeviceId;
+import org.opendaylight.netconf.ssh.SshProxyServer;
+import org.opendaylight.netconf.ssh.SshProxyServerConfigurationBuilder;
+import org.opendaylight.netconf.util.messages.NetconfMessageUtil;
+import org.opendaylight.netconf.util.osgi.NetconfConfigUtil;
import org.opendaylight.protocol.framework.NeverReconnectStrategy;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.common.RpcResult;
new SshProxyServerConfigurationBuilder()
.setBindingAddress(TLS_ADDRESS)
.setLocalAddress(NetconfConfigUtil.getNetconfLocalAddress())
- .setAuthenticator(new PasswordAuthenticator() {
- @Override
- public boolean authenticate(final String username, final String password, final ServerSession session) {
- return true;
- }
- }
- )
+ .setAuthenticator(new AuthProvider() {
+ @Override
+ public boolean authenticated(String username, String password) {
+ return true;
+ }
+ }
+ )
.setKeyPairProvider(new PEMGeneratorHostKeyProvider(Files.createTempFile("prefix", "suffix").toAbsolutePath().toString()))
.setIdleTimeout(Integer.MAX_VALUE)
.createSshProxyServerConfiguration());
/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
+ * 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.html
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.controller.netconf.it;
+package org.opendaylight.netconf.it;
import static java.lang.Thread.sleep;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
-import static org.opendaylight.controller.netconf.it.NetconfITSecureTest.getSessionListener;
+import static org.opendaylight.netconf.it.NetconfITSecureTest.getSessionListener;
import com.google.common.base.Throwables;
import com.google.common.collect.Lists;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
-import org.opendaylight.controller.netconf.api.NetconfMessage;
-import org.opendaylight.controller.netconf.client.NetconfClientDispatcher;
-import org.opendaylight.controller.netconf.client.NetconfClientDispatcherImpl;
-import org.opendaylight.controller.netconf.client.TestingNetconfClient;
+import org.opendaylight.netconf.api.NetconfMessage;
+import org.opendaylight.netconf.client.NetconfClientDispatcher;
+import org.opendaylight.netconf.client.NetconfClientDispatcherImpl;
+import org.opendaylight.netconf.client.TestingNetconfClient;
import org.opendaylight.netconf.test.tool.Main.Params;
import org.opendaylight.netconf.test.tool.NetconfDeviceSimulator;
import org.opendaylight.netconf.util.test.XmlFileLoader;
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.controller.netconf.it;
+package org.opendaylight.netconf.it;
import static org.hamcrest.CoreMatchers.containsString;
import static org.junit.Assert.assertEquals;
import org.opendaylight.controller.config.yang.test.impl.MultipleDependenciesModuleMXBean;
import org.opendaylight.controller.config.yang.test.impl.NetconfTestImplModuleFactory;
import org.opendaylight.controller.config.yang.test.impl.NetconfTestImplModuleMXBean;
-import org.opendaylight.controller.netconf.api.NetconfMessage;
-import org.opendaylight.controller.netconf.client.NetconfClientDispatcher;
-import org.opendaylight.controller.netconf.client.TestingNetconfClient;
+import org.opendaylight.netconf.api.NetconfMessage;
+import org.opendaylight.netconf.client.NetconfClientDispatcher;
+import org.opendaylight.netconf.client.TestingNetconfClient;
import org.opendaylight.netconf.util.test.XmlFileLoader;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.test.types.rev131127.TestIdentity1;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.test.types.rev131127.TestIdentity2;
<type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:netconf:northbound">prefix:netconf-server-dispatcher</type>
<name>netconf-mdsal-server-dispatcher</name>
</dispatcher>
-
- <username>admin</username>
- <password>admin</password>
+ <auth-provider xmlns="urn:opendaylight:params:xml:ns:yang:controller:netconf:northbound:ssh">
+ <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:netconf:auth">prefix:netconf-auth-provider</type>
+ <name>default-auth-provider</name>
+ </auth-provider>
</module>
import java.net.InetSocketAddress;
import java.net.UnknownHostException;
import java.util.concurrent.Executors;
-import org.apache.sshd.server.PasswordAuthenticator;
import org.apache.sshd.server.keyprovider.PEMGeneratorHostKeyProvider;
-import org.apache.sshd.server.session.ServerSession;
import org.opendaylight.netconf.api.NetconfServerDispatcher;
import org.opendaylight.netconf.ssh.SshProxyServer;
import org.opendaylight.netconf.ssh.SshProxyServerConfigurationBuilder;
final SshProxyServerConfigurationBuilder sshProxyServerConfigurationBuilder = new SshProxyServerConfigurationBuilder();
sshProxyServerConfigurationBuilder.setBindingAddress(bindingAddress);
sshProxyServerConfigurationBuilder.setLocalAddress(localAddress);
- sshProxyServerConfigurationBuilder.setAuthenticator(new UserAuthenticator(getUsername(), getPassword()));
+ sshProxyServerConfigurationBuilder.setAuthenticator(getAuthProviderDependency());
sshProxyServerConfigurationBuilder.setIdleTimeout(Integer.MAX_VALUE);
sshProxyServerConfigurationBuilder.setKeyPairProvider(new PEMGeneratorHostKeyProvider());
}
}
}
-
-
- private static final class UserAuthenticator implements PasswordAuthenticator {
-
- private final String username;
- private final String password;
-
- public UserAuthenticator(final String username, final String password) {
- this.username = username;
- this.password = password;
- }
-
- @Override
- public boolean authenticate(final String username, final String password, final ServerSession session) {
- // FIXME use aaa stuff here instead
- return this.username.equals(username) && this.password.equals(password);
- }
- }
}
import org.apache.sshd.common.io.nio2.Nio2ServiceFactoryFactory;
import org.apache.sshd.common.util.CloseableUtils;
import org.apache.sshd.server.Command;
+import org.apache.sshd.server.PasswordAuthenticator;
import org.apache.sshd.server.ServerFactoryManager;
+import org.apache.sshd.server.session.ServerSession;
/**
* Proxy SSH server that just delegates decrypted content to a delegate server within same VM.
i.remove();
}
}
- sshServer.setPasswordAuthenticator(sshProxyServerConfiguration.getAuthenticator());
+ sshServer.setPasswordAuthenticator(new PasswordAuthenticator() {
+ @Override
+ public boolean authenticate(final String username, final String password, final ServerSession session) {
+ return sshProxyServerConfiguration.getAuthenticator().authenticated(username, password);
+ }
+ });
+
sshServer.setKeyPairProvider(sshProxyServerConfiguration.getKeyPairProvider());
sshServer.setIoServiceFactoryFactory(nioServiceWithPoolFactoryFactory);
import io.netty.channel.local.LocalAddress;
import java.net.InetSocketAddress;
import org.apache.sshd.common.KeyPairProvider;
-import org.apache.sshd.server.PasswordAuthenticator;
+import org.opendaylight.netconf.auth.AuthProvider;
public final class SshProxyServerConfiguration {
private final InetSocketAddress bindingAddress;
private final LocalAddress localAddress;
- private final PasswordAuthenticator authenticator;
+ private final AuthProvider 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) {
+ SshProxyServerConfiguration(final InetSocketAddress bindingAddress, final LocalAddress localAddress, final AuthProvider authenticator, final KeyPairProvider keyPairProvider, final int idleTimeout) {
this.bindingAddress = Preconditions.checkNotNull(bindingAddress);
this.localAddress = Preconditions.checkNotNull(localAddress);
this.authenticator = Preconditions.checkNotNull(authenticator);
return localAddress;
}
- public PasswordAuthenticator getAuthenticator() {
+ public AuthProvider getAuthenticator() {
return authenticator;
}
import io.netty.channel.local.LocalAddress;
import java.net.InetSocketAddress;
import org.apache.sshd.common.KeyPairProvider;
-import org.apache.sshd.server.PasswordAuthenticator;
+import org.opendaylight.netconf.auth.AuthProvider;
public final class SshProxyServerConfigurationBuilder {
private InetSocketAddress bindingAddress;
private LocalAddress localAddress;
- private PasswordAuthenticator authenticator;
+ private AuthProvider authenticator;
private KeyPairProvider keyPairProvider;
private int idleTimeout;
return this;
}
- public SshProxyServerConfigurationBuilder setAuthenticator(final PasswordAuthenticator authenticator) {
+ public SshProxyServerConfigurationBuilder setAuthenticator(final AuthProvider authenticator) {
this.authenticator = authenticator;
return this;
}
package org.opendaylight.netconf.ssh.osgi;
-import com.google.common.base.Preconditions;
-import org.apache.sshd.server.PasswordAuthenticator;
-import org.apache.sshd.server.session.ServerSession;
-import org.opendaylight.netconf.auth.AuthConstants;
import org.opendaylight.netconf.auth.AuthProvider;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-final class AuthProviderTracker implements ServiceTrackerCustomizer<AuthProvider, AuthProvider>, PasswordAuthenticator {
+final class AuthProviderTracker implements ServiceTrackerCustomizer<AuthProvider, AuthProvider>, AuthProvider {
private static final Logger LOG = LoggerFactory.getLogger(AuthProviderTracker.class);
private final BundleContext bundleContext;
- private Integer maxPreference;
private final ServiceTracker<AuthProvider, AuthProvider> listenerTracker;
- private AuthProvider authProvider;
+ private volatile AuthProvider authProvider;
public AuthProviderTracker(final BundleContext bundleContext) {
this.bundleContext = bundleContext;
@Override
public AuthProvider addingService(final ServiceReference<AuthProvider> reference) {
LOG.trace("Service {} added", reference);
- final AuthProvider authService = bundleContext.getService(reference);
- final Integer newServicePreference = getPreference(reference);
- if(isBetter(newServicePreference)) {
- maxPreference = newServicePreference;
- this.authProvider = authService;
- }
- return authService;
- }
-
- private static Integer getPreference(final ServiceReference<AuthProvider> reference) {
- final Object preferenceProperty = reference.getProperty(AuthConstants.SERVICE_PREFERENCE_KEY);
- return preferenceProperty == null ? Integer.MIN_VALUE : Integer.valueOf(preferenceProperty.toString());
- }
-
- private boolean isBetter(final Integer newServicePreference) {
- Preconditions.checkNotNull(newServicePreference);
- if(maxPreference == null) {
- return true;
- }
-
- return newServicePreference > maxPreference;
+ this.authProvider = bundleContext.getService(reference);
+ return authProvider;
}
@Override
public void modifiedService(final ServiceReference<AuthProvider> reference, final AuthProvider service) {
final AuthProvider authService = bundleContext.getService(reference);
- final Integer newServicePreference = getPreference(reference);
- if(isBetter(newServicePreference)) {
- LOG.trace("Replacing modified service {} in netconf SSH.", reference);
- this.authProvider = authService;
- }
+ LOG.trace("Replacing modified service {} in netconf SSH.", reference);
+ this.authProvider = authService;
}
@Override
public void removedService(final ServiceReference<AuthProvider> reference, final AuthProvider service) {
LOG.trace("Removing service {} from netconf SSH. {}", reference,
" SSH won't authenticate users until AuthProvider service will be started.");
- maxPreference = null;
this.authProvider = null;
}
public void stop() {
listenerTracker.close();
+ this.authProvider = null;
// sshThread should finish normally since sshServer.close stops processing
}
@Override
- public boolean authenticate(final String username, final String password, final ServerSession session) {
+ public boolean authenticated(final String username, final String password) {
if (authProvider == null) {
LOG.warn("AuthProvider is missing, failing authentication");
return false;
import threadpool {prefix th;}
import netty {prefix netty;}
import ietf-inet-types { prefix inet; revision-date 2010-09-24; }
+ import netconf-auth { prefix na; revision-date 2015-07-15; }
organization "Cisco Systems, Inc.";
}
}
- // FIXME use auth provider from aaa instead
- leaf username {
- description "Specifies username credential";
- type string;
- }
-
- leaf password {
- description "Specifies password credential";
- type string;
+ container auth-provider {
+ uses config:service-ref {
+ refine type {
+ config:required-identity na:netconf-auth-provider;
+ }
+ }
}
-
}
}
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.controller.netconf.netty;
+package org.opendaylight.netconf.netty;
import io.netty.bootstrap.Bootstrap;
import io.netty.channel.ChannelFuture;
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.controller.netconf.netty;
+package org.opendaylight.netconf.netty;
import static com.google.common.base.Preconditions.checkState;
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.controller.netconf.netty;
+package org.opendaylight.netconf.netty;
import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.ChannelFuture;
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.controller.netconf.netty;
+package org.opendaylight.netconf.netty;
import com.google.common.base.Charsets;
import com.google.common.base.Splitter;
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.controller.netconf.netty;
+package org.opendaylight.netconf.netty;
import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.ChannelFuture;
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.controller.netconf.netty;
+package org.opendaylight.netconf.netty;
import com.google.common.base.Charsets;
import io.netty.bootstrap.Bootstrap;
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.controller.netconf.netty;
+package org.opendaylight.netconf.netty;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
-import org.apache.sshd.server.PasswordAuthenticator;
import org.apache.sshd.server.keyprovider.PEMGeneratorHostKeyProvider;
-import org.apache.sshd.server.session.ServerSession;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
-import org.opendaylight.controller.netconf.netty.EchoClientHandler.State;
+import org.opendaylight.netconf.auth.AuthProvider;
+import org.opendaylight.netconf.netty.EchoClientHandler.State;
import org.opendaylight.netconf.nettyutil.handler.ssh.authentication.LoginPassword;
import org.opendaylight.netconf.nettyutil.handler.ssh.client.AsyncSshHandler;
import org.opendaylight.netconf.ssh.SshProxyServer;
final InetSocketAddress addr = new InetSocketAddress("127.0.0.1", 10831);
final SshProxyServer sshProxyServer = new SshProxyServer(minaTimerEx, nettyGroup, nioExec);
sshProxyServer.bind(
- new SshProxyServerConfigurationBuilder().setBindingAddress(addr).setLocalAddress(NetconfConfigUtil.getNetconfLocalAddress()).setAuthenticator(new PasswordAuthenticator() {
+ new SshProxyServerConfigurationBuilder().setBindingAddress(addr).setLocalAddress(NetconfConfigUtil.getNetconfLocalAddress()).setAuthenticator(new AuthProvider() {
@Override
- public boolean authenticate(final String username, final String password, final ServerSession session) {
+ public boolean authenticated(final String username, final String password) {
return true;
}
}).setKeyPairProvider(new PEMGeneratorHostKeyProvider(sshKeyPair.toPath().toAbsolutePath().toString())).setIdleTimeout(Integer.MAX_VALUE).createSshProxyServerConfiguration());
* 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.authentication;
+package org.opendaylight.netconf.ssh.authentication;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyString;
import org.apache.sshd.SshClient;
import org.apache.sshd.client.future.AuthFuture;
import org.apache.sshd.client.future.ConnectFuture;
-import org.apache.sshd.server.PasswordAuthenticator;
import org.apache.sshd.server.keyprovider.PEMGeneratorHostKeyProvider;
-import org.apache.sshd.server.session.ServerSession;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
+import org.opendaylight.netconf.auth.AuthProvider;
import org.opendaylight.netconf.ssh.SshProxyServer;
import org.opendaylight.netconf.ssh.SshProxyServerConfigurationBuilder;
import org.opendaylight.netconf.util.osgi.NetconfConfigUtil;
final InetSocketAddress addr = InetSocketAddress.createUnresolved(HOST, PORT);
server = new SshProxyServer(minaTimerEx, clientGroup, nioExec);
server.bind(
- new SshProxyServerConfigurationBuilder().setBindingAddress(addr).setLocalAddress(NetconfConfigUtil.getNetconfLocalAddress()).setAuthenticator(new PasswordAuthenticator() {
+ new SshProxyServerConfigurationBuilder().setBindingAddress(addr).setLocalAddress(NetconfConfigUtil.getNetconfLocalAddress()).setAuthenticator(new AuthProvider() {
@Override
- public boolean authenticate(final String username, final String password, final ServerSession session) {
+ public boolean authenticated(final String username, final String password) {
return true;
}
}).setKeyPairProvider(new PEMGeneratorHostKeyProvider(sshKeyPair.toPath().toAbsolutePath().toString())).setIdleTimeout(Integer.MAX_VALUE).createSshProxyServerConfiguration());
</dependencies>
</dependencyManagement>
-
- <profiles>
- <profile>
- <id>integrationtests</id>
- <activation>
- <activeByDefault>false</activeByDefault>
- </activation>
- <modules>
- <module>netconf-it</module>
- </modules>
- </profile>
- </profiles>
</project>
--- /dev/null
+/*
+ * Copyright (c) 2015 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.netconf.sal.connect.netconf.sal;
+
+import com.google.common.base.Function;
+import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
+import com.google.common.collect.FluentIterable;
+import com.google.common.util.concurrent.CheckedFuture;
+import com.google.common.util.concurrent.FutureCallback;
+import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.ListenableFuture;
+import java.util.Set;
+import org.opendaylight.controller.md.sal.binding.api.BindingTransactionChain;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
+import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.AsyncTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionChain;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
+import org.opendaylight.netconf.sal.connect.util.RemoteDeviceId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.inventory.rev140108.NetconfNode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.inventory.rev140108.NetconfNodeBuilder;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Asynchronous (Binding-aware) adapter over datastore subtree for netconf device.
+ *
+ * All data changes are submitted to an ExecutorService to avoid Thread blocking while sal is waiting for schema.
+ *
+ * @deprecated Data is pushed into Topology instead if Inventory model
+ */
+@Deprecated
+final class NetconfDeviceDatastoreAdapter implements AutoCloseable {
+
+ private static final Logger logger = LoggerFactory.getLogger(NetconfDeviceDatastoreAdapter.class);
+
+ private final RemoteDeviceId id;
+ private final BindingTransactionChain txChain;
+
+ NetconfDeviceDatastoreAdapter(final RemoteDeviceId deviceId, final DataBroker dataService) {
+ this.id = Preconditions.checkNotNull(deviceId);
+ this.txChain = Preconditions.checkNotNull(dataService).createTransactionChain(new TransactionChainListener() {
+ @Override
+ public void onTransactionChainFailed(TransactionChain<?, ?> chain, AsyncTransaction<?, ?> transaction, Throwable cause) {
+ logger.error("{}: TransactionChain({}) {} FAILED!", id, chain, transaction.getIdentifier(), cause);
+ throw new IllegalStateException(id + " TransactionChain(" + chain + ") not committed correctly", cause);
+ }
+
+ @Override
+ public void onTransactionChainSuccessful(TransactionChain<?, ?> chain) {
+ logger.trace("{}: TransactionChain({}) {} SUCCESSFUL", id, chain);
+ }
+ });
+
+ initDeviceData();
+ }
+
+ public void updateDeviceState(final boolean up, final Set<QName> capabilities) {
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node data = buildDataForDeviceState(
+ up, capabilities, id);
+
+ final ReadWriteTransaction transaction = txChain.newReadWriteTransaction();
+ logger.trace("{}: Update device state transaction {} merging operational data started.", id, transaction.getIdentifier());
+ transaction.put(LogicalDatastoreType.OPERATIONAL, id.getBindingPath(), data);
+ logger.trace("{}: Update device state transaction {} merging operational data ended.", id, transaction.getIdentifier());
+
+ commitTransaction(transaction, "update");
+ }
+
+ private void removeDeviceConfigAndState() {
+ final WriteTransaction transaction = txChain.newWriteOnlyTransaction();
+ logger.trace("{}: Close device state transaction {} removing all data started.", id, transaction.getIdentifier());
+ transaction.delete(LogicalDatastoreType.CONFIGURATION, id.getBindingPath());
+ transaction.delete(LogicalDatastoreType.OPERATIONAL, id.getBindingPath());
+ logger.trace("{}: Close device state transaction {} removing all data ended.", id, transaction.getIdentifier());
+
+ commitTransaction(transaction, "close");
+ }
+
+ private void initDeviceData() {
+ final WriteTransaction transaction = txChain.newWriteOnlyTransaction();
+
+ createNodesListIfNotPresent(transaction);
+
+ final InstanceIdentifier<Node> path = id.getBindingPath();
+ final Node nodeWithId = getNodeWithId(id);
+
+ logger.trace("{}: Init device state transaction {} putting if absent operational data started.", id, transaction.getIdentifier());
+ transaction.put(LogicalDatastoreType.OPERATIONAL, path, nodeWithId);
+ logger.trace("{}: Init device state transaction {} putting operational data ended.", id, transaction.getIdentifier());
+
+ logger.trace("{}: Init device state transaction {} putting if absent config data started.", id, transaction.getIdentifier());
+ transaction.put(LogicalDatastoreType.CONFIGURATION, path, nodeWithId);
+ logger.trace("{}: Init device state transaction {} putting config data ended.", id, transaction.getIdentifier());
+
+ commitTransaction(transaction, "init");
+ }
+
+ private void createNodesListIfNotPresent(final WriteTransaction writeTx) {
+ final Nodes nodes = new NodesBuilder().build();
+ final InstanceIdentifier<Nodes> path = InstanceIdentifier.builder(Nodes.class).build();
+ logger.trace("{}: Merging {} container to ensure its presence", id, Nodes.QNAME, writeTx.getIdentifier());
+ writeTx.merge(LogicalDatastoreType.CONFIGURATION, path, nodes);
+ writeTx.merge(LogicalDatastoreType.OPERATIONAL, path, nodes);
+ }
+
+ private void commitTransaction(final WriteTransaction transaction, final String txType) {
+ logger.trace("{}: Committing Transaction {}:{}", id, txType, transaction.getIdentifier());
+ final CheckedFuture<Void, TransactionCommitFailedException> result = transaction.submit();
+
+ Futures.addCallback(result, new FutureCallback<Void>() {
+ @Override
+ public void onSuccess(final Void result) {
+ logger.trace("{}: Transaction({}) {} SUCCESSFUL", id, txType, transaction.getIdentifier());
+ }
+
+ @Override
+ public void onFailure(final Throwable t) {
+ logger.error("{}: Transaction({}) {} FAILED!", id, txType, transaction.getIdentifier(), t);
+ throw new IllegalStateException(id + " Transaction(" + txType + ") not committed correctly", t);
+ }
+ });
+
+ }
+
+ @Override
+ public void close() throws Exception {
+ removeDeviceConfigAndState();
+ txChain.close();
+ }
+
+ public static org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node buildDataForDeviceState(
+ final boolean up, final Set<QName> capabilities, final RemoteDeviceId id) {
+
+ final NodeBuilder nodeBuilder = getNodeWithIdBuilder(id);
+ final NetconfNodeBuilder netconfNodeBuilder = new NetconfNodeBuilder();
+ netconfNodeBuilder.setConnected(up);
+ netconfNodeBuilder.setInitialCapability(FluentIterable.from(capabilities)
+ .transform(new Function<QName, String>() {
+ @Override
+ public String apply(final QName input) {
+ return input.toString();
+ }
+ }).toList());
+ nodeBuilder.addAugmentation(NetconfNode.class, netconfNodeBuilder.build());
+
+ return nodeBuilder.build();
+ }
+
+ private static ListenableFuture<Optional<Node>> readNodeData(
+ final LogicalDatastoreType store,
+ final ReadWriteTransaction transaction,
+ final InstanceIdentifier<Node> path) {
+ return transaction.read(store, path);
+ }
+
+ private static Node getNodeWithId(final RemoteDeviceId id) {
+ final NodeBuilder nodeBuilder = getNodeWithIdBuilder(id);
+ return nodeBuilder.build();
+ }
+
+ private static NodeBuilder getNodeWithIdBuilder(final RemoteDeviceId id) {
+ final NodeBuilder nodeBuilder = new NodeBuilder();
+ nodeBuilder.setKey(id.getBindingKey());
+ nodeBuilder.setId(id.getBindingKey().getId());
+ return nodeBuilder;
+ }
+}
package org.opendaylight.netconf.sal.connect.netconf.sal;
import com.google.common.collect.Lists;
+import java.util.Collections;
import java.util.List;
import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
import org.opendaylight.controller.md.sal.dom.api.DOMNotification;
import org.opendaylight.netconf.sal.connect.netconf.listener.NetconfDeviceCapabilities;
import org.opendaylight.netconf.sal.connect.netconf.listener.NetconfSessionPreferences;
import org.opendaylight.netconf.sal.connect.util.RemoteDeviceId;
+import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
final NetconfDeviceNotificationService notificationService = new NetconfDeviceNotificationService();
+ salProvider.getMountInstance().onDeviceConnected(schemaContext, domBroker, deviceRpc, notificationService);
+ salProvider.getDatastoreAdapter().updateDeviceState(true, netconfSessionPreferences.getModuleBasedCaps());
salProvider.getMountInstance().onTopologyDeviceConnected(schemaContext, domBroker, deviceRpc, notificationService);
salProvider.getTopologyDatastoreAdapter().updateDeviceData(true, netconfSessionPreferences.getNetconfDeviceCapabilities());
}
@Override
public synchronized void onDeviceDisconnected() {
- salProvider.getTopologyDatastoreAdapter().updateDeviceData(false,
- new NetconfDeviceCapabilities());
+ salProvider.getDatastoreAdapter().updateDeviceState(false, Collections.<QName>emptySet());
+ salProvider.getTopologyDatastoreAdapter().updateDeviceData(false, new NetconfDeviceCapabilities());
+ salProvider.getMountInstance().onDeviceDisconnected();
salProvider.getMountInstance().onTopologyDeviceDisconnected();
}
@Override
public synchronized void onDeviceFailed(final Throwable throwable) {
salProvider.getTopologyDatastoreAdapter().setDeviceAsFailed(throwable);
+ salProvider.getMountInstance().onDeviceDisconnected();
salProvider.getMountInstance().onTopologyDeviceDisconnected();
}
try {
resource.close();
} catch (final Exception e) {
- LOG.warn("{}: Ignoring exception while closing {}", id,
- resource, e);
+ LOG.warn("{}: Ignoring exception while closing {}", id, resource, e);
}
}
}
final class NetconfDeviceSalProvider implements AutoCloseable, Provider, BindingAwareProvider {
- private static final Logger LOG = LoggerFactory.getLogger(NetconfDeviceSalProvider.class);
+ private static final Logger logger = LoggerFactory.getLogger(NetconfDeviceSalProvider.class);
private final RemoteDeviceId id;
+ private volatile NetconfDeviceDatastoreAdapter datastoreAdapter;
private MountInstance mountInstance;
private volatile NetconfDeviceTopologyAdapter topologyDatastoreAdapter;
return mountInstance;
}
+ public NetconfDeviceDatastoreAdapter getDatastoreAdapter() {
+ Preconditions.checkState(datastoreAdapter != null,
+ "%s: Sal provider %s was not initialized by sal. Cannot get datastore adapter", id);
+ return datastoreAdapter;
+ }
+
public NetconfDeviceTopologyAdapter getTopologyDatastoreAdapter() {
Preconditions.checkState(topologyDatastoreAdapter != null,
"%s: Sal provider %s was not initialized by sal. Cannot get topology datastore adapter", id);
@Override
public void onSessionInitiated(final Broker.ProviderSession session) {
- LOG.debug("{}: (BI)Session with sal established {}", id, session);
+ logger.debug("{}: (BI)Session with sal established {}", id, session);
final DOMMountPointService mountService = session.getService(DOMMountPointService.class);
if (mountService != null) {
@Override
public void onSessionInitiated(final BindingAwareBroker.ProviderContext session) {
- LOG.debug("{}: Session with sal established {}", id, session);
+ logger.debug("{}: Session with sal established {}", id, session);
final DataBroker dataBroker = session.getSALService(DataBroker.class);
+ datastoreAdapter = new NetconfDeviceDatastoreAdapter(id, dataBroker);
topologyDatastoreAdapter = new NetconfDeviceTopologyAdapter(id, dataBroker);
}
public void close() throws Exception {
mountInstance.close();
+ datastoreAdapter.close();
+ datastoreAdapter = null;
topologyDatastoreAdapter.close();
topologyDatastoreAdapter = null;
}
private DOMMountPointService mountService;
private final RemoteDeviceId id;
+ private ObjectRegistration<DOMMountPoint> registration;
private NetconfDeviceNotificationService notificationService;
private ObjectRegistration<DOMMountPoint> topologyRegistration;
this.id = Preconditions.checkNotNull(id);
}
+ @Deprecated
+ synchronized void onDeviceConnected(final SchemaContext initialCtx,
+ final DOMDataBroker broker, final DOMRpcService rpc,
+ final NetconfDeviceNotificationService notificationService) {
+
+ Preconditions.checkNotNull(mountService, "Closed");
+ Preconditions.checkState(registration == null, "Already initialized");
+
+ final DOMMountPointService.DOMMountPointBuilder mountBuilder = mountService.createMountPoint(id.getPath());
+ mountBuilder.addInitialSchemaContext(initialCtx);
+
+ mountBuilder.addService(DOMDataBroker.class, broker);
+ mountBuilder.addService(DOMRpcService.class, rpc);
+ mountBuilder.addService(DOMNotificationService.class, notificationService);
+ this.notificationService = notificationService;
+
+ registration = mountBuilder.register();
+ logger.debug("{}: Mountpoint exposed into MD-SAL {}", id, registration);
+ }
+
+ @Deprecated
+ synchronized void onDeviceDisconnected() {
+ if(registration == null) {
+ logger.trace("{}: Not removing mountpoint from MD-SAL, mountpoint was not registered yet", id);
+ return;
+ }
+
+ try {
+ registration.close();
+ } catch (final Exception e) {
+ // Only log and ignore
+ logger.warn("Unable to unregister mount instance for {}. Ignoring exception", id.getPath(), e);
+ } finally {
+ logger.debug("{}: Mountpoint removed from MD-SAL {}", id, registration);
+ registration = null;
+ }
+ }
+
synchronized void onTopologyDeviceConnected(final SchemaContext initialCtx,
final DOMDataBroker broker, final DOMRpcService rpc,
final NetconfDeviceNotificationService notificationService) {
mountBuilder.addService(DOMDataBroker.class, broker);
mountBuilder.addService(DOMRpcService.class, rpc);
mountBuilder.addService(DOMNotificationService.class, notificationService);
- this.notificationService = notificationService;
topologyRegistration = mountBuilder.register();
- LOG.debug("{}: TOPOLOGY Mountpoint exposed into MD-SAL {}", id,
- topologyRegistration);
+ logger.debug("{}: TOPOLOGY Mountpoint exposed into MD-SAL {}", id, registration);
}
synchronized void onTopologyDeviceDisconnected() {
if(topologyRegistration == null) {
- LOG.trace(
- "{}: Not removing TOPOLOGY mountpoint from MD-SAL, mountpoint was not registered yet",
- id);
+ logger.trace("{}: Not removing TOPOLOGY mountpoint from MD-SAL, mountpoint was not registered yet", id);
return;
}
topologyRegistration.close();
} catch (final Exception e) {
// Only log and ignore
- LOG.warn(
- "Unable to unregister mount instance for {}. Ignoring exception",
- id.getTopologyPath(), e);
+ logger.warn("Unable to unregister mount instance for {}. Ignoring exception", id.getTopologyPath(), e);
} finally {
- LOG.debug("{}: TOPOLOGY Mountpoint removed from MD-SAL {}",
- id, topologyRegistration);
+ logger.debug("{}: TOPOLOGY Mountpoint removed from MD-SAL {}", id, registration);
topologyRegistration = null;
}
}
@Override
synchronized public void close() throws Exception {
+ onDeviceDisconnected();
onTopologyDeviceDisconnected();
mountService = null;
}
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Collections2;
import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
import java.util.Collections;
import java.util.Set;
import javax.annotation.Nullable;
this.capabilities = new CapabilitiesBuilder().setCapability(
Lists.newArrayList(Collections2.transform(capabilities, CAPABILITY_URI_FUNCTION))).build();
+ Set<Capability> moduleCapabilities = Sets.newHashSet();
this.capabilityMultiMap = ArrayListMultimap.create();
for (Capability cap : capabilities) {
- capabilityMultiMap.put(cap.getModuleName().get(), cap);
+ if(cap.getModuleName().isPresent()) {
+ capabilityMultiMap.put(cap.getModuleName().get(), cap);
+ moduleCapabilities.add(cap);
+ }
}
- this.schemas = new SchemasBuilder().setSchema(Lists.newArrayList(Collections2.transform(capabilities, CAPABILITY_SCHEMA_FUNCTION))).build();
+ this.schemas = new SchemasBuilder().setSchema(Lists.newArrayList(Collections2.transform(moduleCapabilities, CAPABILITY_SCHEMA_FUNCTION))).build();
}
@Override
import org.antlr.v4.runtime.ParserRuleContext;
import org.antlr.v4.runtime.tree.ParseTreeWalker;
import org.apache.sshd.common.util.ThreadUtils;
-import org.apache.sshd.server.PasswordAuthenticator;
import org.apache.sshd.server.keyprovider.PEMGeneratorHostKeyProvider;
-import org.apache.sshd.server.session.ServerSession;
+import org.opendaylight.controller.config.util.capability.BasicCapability;
import org.opendaylight.controller.config.util.capability.Capability;
import org.opendaylight.netconf.api.monitoring.NetconfMonitoringService;
import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
+import org.opendaylight.netconf.auth.AuthProvider;
import org.opendaylight.netconf.impl.NetconfServerDispatcherImpl;
import org.opendaylight.netconf.impl.NetconfServerSessionNegotiatorFactory;
import org.opendaylight.netconf.impl.SessionIdProvider;
final NetconfOperationServiceFactory operationProvider = mdSal ? new MdsalOperationProvider(idProvider, capabilities, schemaContext) :
new SimulatedOperationProvider(idProvider, capabilities, notificationsFile);
+ capabilities.add(new BasicCapability("urn:ietf:params:netconf:capability:candidate:1.0"));
+
final NetconfMonitoringService monitoringService1 = new DummyMonitoringService(capabilities);
final NetconfMonitoringActivator.NetconfMonitoringOperationServiceFactory monitoringService =
return new SshProxyServerConfigurationBuilder()
.setBindingAddress(bindingAddress)
.setLocalAddress(tcpLocalAddress)
- .setAuthenticator(new PasswordAuthenticator() {
+ .setAuthenticator(new AuthProvider() {
@Override
- public boolean authenticate(final String username, final String password, final ServerSession session) {
+ public boolean authenticated(final String username, final String password) {
return true;
}
})
<groupId>${project.groupId}</groupId>
<artifactId>features-restconf</artifactId>
<version>${project.version}</version>
+ <classifier>features</classifier>
+ <type>xml</type>
+ <scope>runtime</scope>
</dependency>
</dependencies>
</dependencyManagement>