Remove PublicKeyAuth 09/108609/6
authorRobert Varga <robert.varga@pantheon.tech>
Mon, 23 Oct 2023 23:41:09 +0000 (01:41 +0200)
committerRobert Varga <nite@hq.sk>
Tue, 24 Oct 2023 13:59:17 +0000 (13:59 +0000)
This class is not used anywhere, remove it. Also make
LoginPasswordHandler final, as there are no subclasses (and it is a
trivial implementation).

JIRA: NETCONF-1108
Change-Id: Ibb9acfd9aa2f6adeab767af46e3c048e1bf84d1b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/handler/ssh/authentication/LoginPasswordHandler.java
netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/handler/ssh/authentication/PublicKeyAuth.java [deleted file]

index 880a55282dd10d0eb20c20e6ec829ba15637ec06..2245152f08de12b2b6a830d7ee2cb1448ff566e5 100644 (file)
@@ -5,7 +5,6 @@
  * 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 java.io.IOException;
@@ -16,9 +15,9 @@ import org.opendaylight.netconf.shaded.sshd.client.session.ClientSession;
  * Class Providing username/password authentication option to
  * {@link org.opendaylight.netconf.nettyutil.handler.ssh.client.AsyncSshHandler}.
  */
-public class LoginPasswordHandler extends AuthenticationHandler {
-    protected final String username;
-    protected final String password;
+public final class LoginPasswordHandler extends AuthenticationHandler {
+    private final String username;
+    private final String password;
 
     public LoginPasswordHandler(final String username, final 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
deleted file mode 100644 (file)
index fff34f3..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * 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.opendaylight.aaa.encrypt.PKIUtil;
-import org.opendaylight.netconf.shaded.sshd.client.future.AuthFuture;
-import org.opendaylight.netconf.shaded.sshd.client.session.ClientSession;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Represents Auth information for the public key based authentication for netconf.
- */
-public class PublicKeyAuth extends LoginPasswordHandler {
-    private KeyPair keyPair = null;
-    private static final Logger LOG = LoggerFactory.getLogger(PublicKeyAuth.class);
-
-    public PublicKeyAuth(final String username, final String password, final 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);
-        }
-
-        return super.authenticate(session);
-    }
-}