Enable public key based authentication for netconf 37/59537/12
authorAtul Gosain <agosain@brocade.com>
Tue, 27 Jun 2017 02:13:26 +0000 (19:13 -0700)
committerAtul Gosain <agosain@brocade.com>
Wed, 2 Aug 2017 22:56:51 +0000 (15:56 -0700)
Change-Id: Icca97924515537b670688767d41ddd4bd6e1bbf6
Signed-off-by: Atul Gosain <agosain@brocade.com>
14 files changed:
features/netconf-connector/odl-netconf-connector/pom.xml
features/netconf/features-netconf/pom.xml
features/netconf/features-netconf/src/main/features/features.xml
netconf/netconf-netty-util/pom.xml
netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/handler/ssh/authentication/LoginPassword.java
netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/handler/ssh/authentication/PublicKeyAuth.java [new file with mode: 0644]
netconf/netconf-topology-config/pom.xml
netconf/netconf-topology-config/src/main/resources/initial/odl-sb-netconf-client-keypair.cfg [new file with mode: 0644]
netconf/netconf-topology-config/src/main/resources/org/opendaylight/blueprint/netconf-topology.xml
netconf/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/impl/NetconfTopologyManager.java
netconf/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/impl/RemoteDeviceConnectorImpl.java
netconf/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/impl/utils/NetconfTopologySetup.java
netconf/netconf-topology-singleton/src/main/resources/org/opendaylight/blueprint/netconf-topology-singleton.xml
netconf/netconf-topology/src/main/java/org/opendaylight/netconf/topology/AbstractNetconfTopology.java

index 930a4769d2456b2279d1f5572e3d3c4651585fb9..097ecab5da1e2774b6bf52a1ae53cab0782a23a5 100644 (file)
             <groupId>org.opendaylight.netconf</groupId>
             <artifactId>netconf-config</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.opendaylight.aaa</groupId>
+            <artifactId>odl-aaa-encryption-service</artifactId>
+            <version>0.5.2-SNAPSHOT</version>
+            <type>xml</type>
+            <classifier>features</classifier>
+        </dependency>
     </dependencies>
-</project>
\ No newline at end of file
+</project>
index 6723f7b1eb4434ca5923f247f4563fc9737493ac..d1d9ff9134914c064dc86186d49c127a40b5f250 100644 (file)
       <groupId>${project.groupId}</groupId>
       <artifactId>callhome-provider</artifactId>
     </dependency>
+    <dependency>
+      <groupId>org.opendaylight.aaa</groupId>
+      <artifactId>aaa-encrypt-service</artifactId>
+      <version>${aaa.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.aaa</groupId>
+      <artifactId>aaa-encrypt-service</artifactId>
+      <version>${aaa.version}</version>
+      <classifier>config</classifier>
+      <type>xml</type>
+    </dependency>
   </dependencies>
 
   <scm>
index 29e9400108a8790ac7786fbfc6e2d3bbd1fa2ec0..60847c6c18355560a87c0de847791b6bdc83f6e0 100644 (file)
@@ -80,6 +80,7 @@
     <feature version='${project.version}'>odl-netconf-mapping-api</feature>
     <feature version='${project.version}'>odl-netconf-util</feature>
     <feature version='[4.0.30,5.0.0)'>odl-netty</feature>
+    <feature version='${aaa.version}'>odl-aaa-encryption-service</feature>
     <bundle>mvn:org.opendaylight.netconf/netconf-netty-util/{{VERSION}}</bundle>
     <bundle>mvn:org.bouncycastle/bcpkix-jdk15on/{{VERSION}}</bundle>
     <bundle>mvn:org.bouncycastle/bcprov-jdk15on/{{VERSION}}</bundle>
index 2ae8cc51bdbc4c9ac3e02997d6282563777e44a3..b1005b84898fbf23e516f7c26e1ba508b4119c40 100644 (file)
       <groupId>org.opendaylight.yangtools</groupId>
       <artifactId>mockito-configuration</artifactId>
     </dependency>
+    <dependency>
+      <groupId>org.opendaylight.aaa</groupId>
+      <artifactId>aaa-encrypt-service</artifactId>
+    </dependency>
   </dependencies>
 
   <build>
index 6219f91b2d9998a6c2d2027a457f615f14de69cb..8aee65e734dc00d45dd050556a6fd203b96470b6 100644 (file)
@@ -17,8 +17,8 @@ import org.apache.sshd.client.future.AuthFuture;
  * {@link org.opendaylight.netconf.nettyutil.handler.ssh.client.AsyncSshHandler}
  */
 public class LoginPassword extends AuthenticationHandler {
-    private final String username;
-    private final String password;
+    protected final String username;
+    protected final String password;
 
     public LoginPassword(String username, String password) {
         this.username = username;
diff --git a/netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/handler/ssh/authentication/PublicKeyAuth.java b/netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/handler/ssh/authentication/PublicKeyAuth.java
new file mode 100644 (file)
index 0000000..283089c
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2017 Brocade Communication Systems 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.nettyutil.handler.ssh.authentication;
+
+import com.google.common.base.Strings;
+import java.io.IOException;
+import java.security.KeyPair;
+import org.apache.sshd.ClientSession;
+import org.apache.sshd.client.future.AuthFuture;
+import org.opendaylight.aaa.encrypt.PKIUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Represents Auth information for the public key based authentication for netconf.
+ */
+public class PublicKeyAuth extends LoginPassword {
+    private KeyPair keyPair = null;
+    private static final Logger LOG = LoggerFactory.getLogger(PublicKeyAuth.class);
+
+    public PublicKeyAuth(String username, String password, String keyPath, String passPhrase) {
+        super(username, password);
+        try {
+            boolean isKeyPathAbsent = Strings.isNullOrEmpty(keyPath);
+            passPhrase = Strings.isNullOrEmpty(passPhrase) ? "" : passPhrase;
+            if (!isKeyPathAbsent) {
+                this.keyPair = new PKIUtil().decodePrivateKey(keyPath, passPhrase);
+            } else {
+                LOG.info("Private key path not specified in the config file.");
+            }
+        } catch (IOException ioEx) {
+            LOG.warn("Not able to read the private key and passphrase for netconf client", ioEx);
+        }
+    }
+
+    @Override
+    public AuthFuture authenticate(final ClientSession session) throws IOException {
+        if (keyPair != null) {
+            session.addPublicKeyIdentity(keyPair);
+        }
+        session.addPasswordIdentity(password);
+        return session.auth();
+    }
+}
index ac8b550d3f18e41551a30e992611399d48889bd0..5745af8172cb424735c51f723375873f01059db3 100644 (file)
                     </instructions>
                 </configuration>
             </plugin>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>build-helper-maven-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>attach-artifacts</id>
+                        <goals>
+                            <goal>attach-artifact</goal>
+                        </goals>
+                        <phase>package</phase>
+                        <configuration>
+                            <artifacts>
+                                <artifact>
+                                    <file>${project.build.directory}/classes/initial/odl-sb-netconf-client-keypair.cfg
+                                    </file>
+                                    <type>cfg</type>
+                                    <classifier>config</classifier>
+                                </artifact>
+                            </artifacts>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
         </plugins>
     </build>
 </project>
diff --git a/netconf/netconf-topology-config/src/main/resources/initial/odl-sb-netconf-client-keypair.cfg b/netconf/netconf-topology-config/src/main/resources/initial/odl-sb-netconf-client-keypair.cfg
new file mode 100644 (file)
index 0000000..8aa5993
--- /dev/null
@@ -0,0 +1,10 @@
+# This configuration provides the provision to enable key based authentication for netconf southbound client. 
+# The configuration file should be created by name odl-sb-netconf-client-keypair.cfg inside controller/etc directory. 
+# Following configurations should be done in this file
+# private-key-path - Path for private key file. (Paths are identified relative to controller directory).
+#     eg. If private key file exists in controller/etc/id_rsa, the path can be mentioned as etc/id_rsa
+# private-key-passphrase - Passphrase that was used to encrypt the private key. 
+#       In case of no passphrase, keep it blank or unassigned.
+
+private-key-path=etc/RSA-PK
+private-key-passphrase=abc
index 11e922f34d9220a3f153a3bfce9671f7fbd2f52e..d095bc0a8e0a50378437ac503c79e1ae12f6a555 100755 (executable)
@@ -8,6 +8,7 @@
 -->
 <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
            xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
+           xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
            odl:use-default-for-reference-types="true">
 
     <reference id="clientDispatcherDependency"
         <argument value="shared-schema-repository-impl"/>
     </bean>
 
+    <cm:property-placeholder persistent-id="odl-sb-netconf-client-keypair" update-strategy="none">
+      <cm:default-properties>
+        <cm:property name="private-key-path" value=""/>
+        <cm:property name="private-key-passphrase" value=""/>
+      </cm:default-properties>
+    </cm:property-placeholder>
+
     <bean id="netconfTopology" class="org.opendaylight.netconf.topology.impl.NetconfTopologyImpl"
           init-method="init"
           destroy-method="close">
+        <cm:managed-properties persistent-id="odl-sb-netconf-client-keypair"
+                           update-strategy="container-managed"/>
         <argument value="topology-netconf"/>
         <argument ref="clientDispatcherDependency"/>
         <argument ref="eventExecutor"/>
         <argument ref="schemaRepository"/>
         <argument ref="dataBroker"/>
         <argument ref="mountPointService"/>
+        <property name="privateKeyPath" value="${private-key-path}"/>
+        <property name="privateKeyPassphrase" value="${private-key-passphrase}"/>
     </bean>
 
     <bean id="netconfConnectorFactory" class="org.opendaylight.netconf.topology.impl.NetconfConnectorFactoryImpl"/>
     <service ref="netconfConnectorFactory" interface="org.opendaylight.netconf.topology.api.NetconfConnectorFactory"
              odl:type="default"/>
 
-</blueprint>
\ No newline at end of file
+</blueprint>
index ebaafcf8866a3082a138981b6d33d85fe9799c71..717607bd707263465c271f6ad73d06fb3fa1f0d9 100644 (file)
@@ -77,6 +77,8 @@ public class NetconfTopologyManager
     private final DOMMountPointService mountPointService;
 
     private ListenerRegistration<NetconfTopologyManager> dataChangeListenerRegistration;
+    private String privateKeyPath;
+    private String privateKeyPassphrase;
 
     public NetconfTopologyManager(final DataBroker dataBroker, final RpcProviderRegistry rpcProviderRegistry,
                                   final ClusterSingletonServiceProvider clusterSingletonServiceProvider,
@@ -197,6 +199,20 @@ public class NetconfTopologyManager
         clusterRegistrations.clear();
     }
 
+    /**
+     * Sets the private key path from location specified in configuration file using blueprint
+     */
+    public void setPrivateKeyPath(String privateKeyPath){
+        this.privateKeyPath = privateKeyPath;
+    }
+
+    /**
+     * Sets the private key passphrase from location specified in configuration file using blueprint
+     */
+    public void setPrivateKeyPassphrase(String privateKeyPassphrase){
+        this.privateKeyPassphrase = privateKeyPassphrase;
+    }
+
     private ListenerRegistration<NetconfTopologyManager> registerDataTreeChangeListener(final String topologyId) {
         final WriteTransaction wtx = dataBroker.newWriteOnlyTransaction();
         initTopology(wtx, LogicalDatastoreType.CONFIGURATION, topologyId);
@@ -243,7 +259,9 @@ public class NetconfTopologyManager
                 .setTopologyId(topologyId)
                 .setNetconfClientDispatcher(clientDispatcher)
                 .setSchemaResourceDTO(NetconfTopologyUtils.setupSchemaCacheDTO(node))
-                .setIdleTimeout(writeTxIdleTimeout);
+                .setIdleTimeout(writeTxIdleTimeout)
+                .setPrivateKeyPath(privateKeyPath)
+                .setPrivateKeyPassphrase(privateKeyPassphrase);
 
         return builder.build();
     }
index 39e86a9452fcaa83bf334e5f9333d976f5b817c0..1ffca0ba92ac1f4b85c12a7ff50de3c1e36318be 100644 (file)
@@ -34,6 +34,7 @@ import org.opendaylight.netconf.client.conf.NetconfReconnectingClientConfigurati
 import org.opendaylight.netconf.client.conf.NetconfReconnectingClientConfigurationBuilder;
 import org.opendaylight.netconf.nettyutil.handler.ssh.authentication.AuthenticationHandler;
 import org.opendaylight.netconf.nettyutil.handler.ssh.authentication.LoginPassword;
+import org.opendaylight.netconf.nettyutil.handler.ssh.authentication.PublicKeyAuth;
 import org.opendaylight.netconf.sal.connect.api.RemoteDevice;
 import org.opendaylight.netconf.sal.connect.api.RemoteDeviceHandler;
 import org.opendaylight.netconf.sal.connect.netconf.LibraryModulesSchemas;
@@ -78,6 +79,8 @@ public class RemoteDeviceConnectorImpl implements RemoteDeviceConnector {
     private final RemoteDeviceId remoteDeviceId;
     private final DOMMountPointService mountService;
     private final Timeout actorResponseWaitTime;
+    private final String privateKeyPath;
+    private final String privateKeyPassphrase;
 
     private NetconfConnectorDTO deviceCommunicatorDTO;
 
@@ -89,6 +92,8 @@ public class RemoteDeviceConnectorImpl implements RemoteDeviceConnector {
         this.remoteDeviceId = remoteDeviceId;
         this.actorResponseWaitTime = actorResponseWaitTime;
         this.mountService = mountService;
+        this.privateKeyPath = netconfTopologyDeviceSetup.getPrivateKeyPath();
+        this.privateKeyPassphrase = netconfTopologyDeviceSetup.getPrivateKeyPassphrase();
     }
 
     @Override
@@ -274,9 +279,12 @@ public class RemoteDeviceConnectorImpl implements RemoteDeviceConnector {
         final AuthenticationHandler authHandler;
         final Credentials credentials = node.getCredentials();
         if (credentials instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.credentials.credentials.LoginPassword) {
-            authHandler = new LoginPassword(
-                    ((org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.credentials.credentials.LoginPassword) credentials).getUsername(),
-                    ((org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.credentials.credentials.LoginPassword) credentials).getPassword());
+            authHandler = new PublicKeyAuth(
+                    ((org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf
+                            .node.credentials.credentials.LoginPassword) credentials).getUsername(),
+                    ((org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf
+                            .node.credentials.credentials.LoginPassword) credentials).getPassword(),
+                            this.privateKeyPath, this.privateKeyPassphrase);
         } else {
             throw new IllegalStateException(remoteDeviceId + ": Only login/password authentication is supported");
         }
index cee8c0d80774b077665c771a27a36142439872b1..9ba578f7025b788502b9bc649bb6ff26e5626a98 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2017 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,
@@ -36,6 +36,8 @@ public class NetconfTopologySetup {
     private final String topologyId;
     private final NetconfDevice.SchemaResourcesDTO schemaResourceDTO;
     private final Duration idleTimeout;
+    private final String privateKeyPath;
+    private final String privateKeyPassphrase;
 
     private NetconfTopologySetup(final NetconfTopologySetupBuilder builder) {
         this.clusterSingletonServiceProvider = builder.getClusterSingletonServiceProvider();
@@ -51,6 +53,8 @@ public class NetconfTopologySetup {
         this.topologyId = builder.getTopologyId();
         this.schemaResourceDTO = builder.getSchemaResourceDTO();
         this.idleTimeout = builder.getIdleTimeout();
+        this.privateKeyPath = builder.getPrivateKeyPath();
+        this.privateKeyPassphrase = builder.getPrivateKeyPassphrase();
     }
 
     public ClusterSingletonServiceProvider getClusterSingletonServiceProvider() {
@@ -98,13 +102,21 @@ public class NetconfTopologySetup {
     }
 
     public NetconfDevice.SchemaResourcesDTO getSchemaResourcesDTO() {
-        return  schemaResourceDTO;
+        return schemaResourceDTO;
     }
 
     public Duration getIdleTimeout() {
         return idleTimeout;
     }
 
+    public String getPrivateKeyPath() {
+        return privateKeyPath;
+    }
+
+    public String getPrivateKeyPassphrase() {
+        return privateKeyPassphrase;
+    }
+
     public static class NetconfTopologySetupBuilder {
 
         private ClusterSingletonServiceProvider clusterSingletonServiceProvider;
@@ -120,8 +132,10 @@ public class NetconfTopologySetup {
         private NetconfClientDispatcher netconfClientDispatcher;
         private NetconfDevice.SchemaResourcesDTO schemaResourceDTO;
         private Duration idleTimeout;
+        private String privateKeyPath;
+        private String privateKeyPassphrase;
 
-        public NetconfTopologySetupBuilder(){
+        public NetconfTopologySetupBuilder() {
         }
 
         private ClusterSingletonServiceProvider getClusterSingletonServiceProvider() {
@@ -247,6 +261,24 @@ public class NetconfTopologySetup {
             return idleTimeout;
         }
 
+        public NetconfTopologySetupBuilder setPrivateKeyPath(String privateKeyPath) {
+            this.privateKeyPath = privateKeyPath;
+            return this;
+        }
+
+        public String getPrivateKeyPath() {
+            return this.privateKeyPath;
+        }
+
+        public NetconfTopologySetupBuilder setPrivateKeyPassphrase(String privateKeyPassphrase) {
+            this.privateKeyPassphrase = privateKeyPassphrase;
+            return this;
+        }
+
+        public String getPrivateKeyPassphrase() {
+            return this.privateKeyPassphrase;
+        }
+
         public static NetconfTopologySetupBuilder create() {
             return new NetconfTopologySetupBuilder();
         }
index 8c60682605e6f2534db9cc9bbdcb69cd67369368..26de967c7516d61aa815118fd703c39b03065596 100644 (file)
@@ -9,6 +9,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
 -->
 <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
            xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
+           xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
            odl:use-default-for-reference-types="true">
 
     <reference id="dataBroker"
@@ -39,9 +40,18 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
             binding-class="org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.topology.singleton.config.rev170419.Config"
     />
 
+    <cm:property-placeholder persistent-id="odl-sb-netconf-client-keypair" update-strategy="none">
+        <cm:default-properties>
+            <cm:property name="private-key-path" value=""/>
+            <cm:property name="private-key-passphrase" value=""/>
+        </cm:default-properties>
+    </cm:property-placeholder>
+
     <bean id="netconfTopologyManager"
           class="org.opendaylight.netconf.topology.singleton.impl.NetconfTopologyManager"
           init-method="init" destroy-method="close">
+        <cm:managed-properties persistent-id="odl-sb-netconf-client-keypair"
+                               update-strategy="container-managed"/>
         <argument ref="dataBroker"/>
         <argument ref="rpcRegistry"/>
         <argument ref="clusterSingletonService"/>
@@ -53,6 +63,8 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
         <argument value="topology-netconf"/>
         <argument ref="singletonConfig"/>
         <argument ref="mountPointService"/>
+        <property name="privateKeyPath" value="${private-key-path}"/>
+        <property name="privateKeyPassphrase" value="${private-key-passphrase}"/>
     </bean>
     <service ref="netconfTopologyManager"
              interface="org.opendaylight.netconf.topology.singleton.api.NetconfTopologySingletonService"/>
index 68a6f11f9fd7319abafd8ece766d76dc5263a173..2b5a59fb8902b2e5c0f2ca89e94d0ff441713529 100644 (file)
@@ -36,6 +36,7 @@ import org.opendaylight.netconf.client.conf.NetconfReconnectingClientConfigurati
 import org.opendaylight.netconf.client.conf.NetconfReconnectingClientConfigurationBuilder;
 import org.opendaylight.netconf.nettyutil.handler.ssh.authentication.AuthenticationHandler;
 import org.opendaylight.netconf.nettyutil.handler.ssh.authentication.LoginPassword;
+import org.opendaylight.netconf.nettyutil.handler.ssh.authentication.PublicKeyAuth;
 import org.opendaylight.netconf.sal.connect.api.RemoteDevice;
 import org.opendaylight.netconf.sal.connect.api.RemoteDeviceHandler;
 import org.opendaylight.netconf.sal.connect.netconf.LibraryModulesSchemas;
@@ -163,6 +164,8 @@ public abstract class AbstractNetconfTopology implements NetconfTopology {
     protected SchemaSourceRegistry schemaRegistry = DEFAULT_SCHEMA_REPOSITORY;
     protected SchemaRepository schemaRepository = DEFAULT_SCHEMA_REPOSITORY;
     protected SchemaContextFactory schemaContextFactory = DEFAULT_SCHEMA_CONTEXT_FACTORY;
+    protected String privateKeyPath;
+    protected String privateKeyPassphrase;
 
     protected final HashMap<NodeId, NetconfConnectorDTO> activeConnectors = new HashMap<>();
 
@@ -382,6 +385,20 @@ public abstract class AbstractNetconfTopology implements NetconfTopology {
         return new FilesystemSchemaSourceCache<>(schemaRegistry, YangTextSchemaSource.class, new File(relativeSchemaCacheDirectory));
     }
 
+    /**
+     * Sets the private key path from location specified in configuration file using blueprint
+     */
+    public void setPrivateKeyPath(String privateKeyPath){
+        this.privateKeyPath = privateKeyPath;
+    }
+
+    /**
+     * Sets the private key passphrase from location specified in configuration file using blueprint
+     */
+    public void setPrivateKeyPassphrase(String privateKeyPassphrase){
+        this.privateKeyPassphrase = privateKeyPassphrase;
+    }
+
     public NetconfReconnectingClientConfiguration getClientConfig(final NetconfClientSessionListener listener, final NetconfNode node) {
 
         //setup default values since default value is not supported in mdsal
@@ -399,9 +416,12 @@ public abstract class AbstractNetconfTopology implements NetconfTopology {
         final AuthenticationHandler authHandler;
         final Credentials credentials = node.getCredentials();
         if (credentials instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.credentials.credentials.LoginPassword) {
-            authHandler = new LoginPassword(
-                    ((org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.credentials.credentials.LoginPassword) credentials).getUsername(),
-                    ((org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.credentials.credentials.LoginPassword) credentials).getPassword());
+            authHandler = new PublicKeyAuth(
+                    ((org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114
+                            .netconf.node.credentials.credentials.LoginPassword) credentials).getUsername(),
+                    ((org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114
+                            .netconf.node.credentials.credentials.LoginPassword) credentials).getPassword(),
+                     privateKeyPath, privateKeyPassphrase);
         } else {
             throw new IllegalStateException("Only login/password authentification is supported");
         }