From 5de591cabe93f24c23e21106634419823a956327 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Wed, 29 Apr 2020 14:14:18 +0200 Subject: [PATCH] Do not require NetconfSessionImpl Drop the instanceOf checks down to simple null checks, so that we are not tied to a particular implementation. JIRA: NETCONF-674 Change-Id: I3b9d123d6034a96e6b2d09d68d3cf5bae117cc78 Signed-off-by: Robert Varga (cherry picked from commit d6d0678d47378b5f7ed1316d34ebd240991f5756) --- .../netconf/callhome/protocol/CallHomeAuthorization.java | 3 --- .../netconf/callhome/protocol/CallHomeSessionContext.java | 7 ++----- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/netconf/callhome-protocol/src/main/java/org/opendaylight/netconf/callhome/protocol/CallHomeAuthorization.java b/netconf/callhome-protocol/src/main/java/org/opendaylight/netconf/callhome/protocol/CallHomeAuthorization.java index 673c932050..6bcabfe917 100644 --- a/netconf/callhome-protocol/src/main/java/org/opendaylight/netconf/callhome/protocol/CallHomeAuthorization.java +++ b/netconf/callhome-protocol/src/main/java/org/opendaylight/netconf/callhome/protocol/CallHomeAuthorization.java @@ -7,7 +7,6 @@ */ package org.opendaylight.netconf.callhome.protocol; -import static com.google.common.base.Preconditions.checkArgument; import static java.util.Objects.requireNonNull; import com.google.common.collect.ImmutableSet; @@ -16,7 +15,6 @@ import java.util.Collection; import java.util.HashSet; import java.util.Set; import org.apache.sshd.client.session.ClientSession; -import org.apache.sshd.client.session.ClientSessionImpl; /** * Authorization context for incoming call home sessions. @@ -166,7 +164,6 @@ public abstract class CallHomeAuthorization { @Override protected void applyTo(final ClientSession session) { - checkArgument(session instanceof ClientSessionImpl); session.setUsername(username); // First try authentication using server host keys, else try password. diff --git a/netconf/callhome-protocol/src/main/java/org/opendaylight/netconf/callhome/protocol/CallHomeSessionContext.java b/netconf/callhome-protocol/src/main/java/org/opendaylight/netconf/callhome/protocol/CallHomeSessionContext.java index cf064152d1..4e7bf41b2b 100644 --- a/netconf/callhome-protocol/src/main/java/org/opendaylight/netconf/callhome/protocol/CallHomeSessionContext.java +++ b/netconf/callhome-protocol/src/main/java/org/opendaylight/netconf/callhome/protocol/CallHomeSessionContext.java @@ -23,7 +23,6 @@ import org.apache.sshd.client.channel.ClientChannel; import org.apache.sshd.client.future.AuthFuture; import org.apache.sshd.client.future.OpenFuture; import org.apache.sshd.client.session.ClientSession; -import org.apache.sshd.client.session.ClientSessionImpl; import org.apache.sshd.common.future.SshFutureListener; import org.apache.sshd.common.session.Session; import org.checkerframework.checker.lock.qual.Holding; @@ -41,7 +40,7 @@ class CallHomeSessionContext implements CallHomeProtocolSessionContext { private static final String NETCONF = "netconf"; - private final ClientSessionImpl sshSession; + private final ClientSession sshSession; private final CallHomeAuthorization authorization; private final Factory factory; @@ -55,10 +54,8 @@ class CallHomeSessionContext implements CallHomeProtocolSessionContext { final SocketAddress remoteAddress, final Factory factory) { this.authorization = requireNonNull(authorization, "authorization"); checkArgument(this.authorization.isServerAllowed(), "Server was not allowed."); - checkArgument(sshSession instanceof ClientSessionImpl, - "sshSession must implement ClientSessionImpl"); this.factory = requireNonNull(factory, "factory"); - this.sshSession = (ClientSessionImpl) sshSession; + this.sshSession = requireNonNull(sshSession, "sshSession"); this.sshSession.setAttribute(SESSION_KEY, this); this.remoteAddress = (InetSocketAddress) this.sshSession.getIoSession().getRemoteAddress(); this.serverKey = this.sshSession.getKex().getServerKey(); -- 2.36.6