-import static com.google.common.base.Preconditions.checkNotNull;
-
-/**
- * Activator for netconf SSH bundle which creates SSH bridge between netconf client and netconf server. Activator
- * starts SSH Server in its own thread. This thread is closed when activator calls stop() method. Server opens socket
- * and listens for client connections. Each client connection creation is handled in separate
- * {@link org.opendaylight.controller.netconf.ssh.threads.SocketThread} thread.
- * This thread creates two additional threads {@link org.opendaylight.controller.netconf.ssh.threads.IOThread}
- * forwarding data from/to client.IOThread closes servers session and server connection when it gets -1 on input stream.
- * {@link org.opendaylight.controller.netconf.ssh.threads.IOThread}'s run method waits for -1 on input stream to finish.
- * All threads are daemons.
- **/
-public class NetconfSSHActivator implements BundleActivator{
-
- private NetconfSSHServer server;
- private static final Logger logger = LoggerFactory.getLogger(NetconfSSHActivator.class);
- private static final String EXCEPTION_MESSAGE = "Netconf ssh bridge is not available.";
- private IUserManager iUserManager;
- private BundleContext context = null;
- private Optional<String> defaultPassword;
- private Optional<String> defaultUser;
-
- private ServiceTrackerCustomizer<IUserManager, IUserManager> customizer = new ServiceTrackerCustomizer<IUserManager, IUserManager>(){
- @Override
- public IUserManager addingService(ServiceReference<IUserManager> reference) {
- logger.trace("Service {} added, let there be SSH bridge.", reference);
- iUserManager = context.getService(reference);
- try {
- onUserManagerFound(iUserManager);
- } catch (Exception e) {
- logger.trace("Can't start SSH server due to {}",e);
- }
- return iUserManager;
- }
- @Override
- public void modifiedService(ServiceReference<IUserManager> reference, IUserManager service) {
- logger.trace("Replacing modified service {} in netconf SSH.", reference);
- server.addUserManagerService(service);
- }
- @Override
- public void removedService(ServiceReference<IUserManager> reference, IUserManager service) {
- logger.trace("Removing service {} from netconf SSH. " +
- "SSH won't authenticate users until IUserManager service will be started.", reference);
- removeUserManagerService();
- }
- };