Do not require NetconfSessionImpl
[netconf.git] / netconf / callhome-protocol / src / main / java / org / opendaylight / netconf / callhome / protocol / CallHomeAuthorization.java
index 81d6c6fa75bedd843df58a5098bd166942295fa0..6bcabfe9179a6c4e79e1cbb62debabdba208600b 100644 (file)
@@ -7,14 +7,14 @@
  */
 package org.opendaylight.netconf.callhome.protocol;
 
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
 import com.google.common.collect.ImmutableSet;
 import java.security.KeyPair;
 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.
@@ -104,8 +104,8 @@ public abstract class CallHomeAuthorization {
         private final Set<KeyPair> clientKeys = new HashSet<>();
 
         Builder(final String nodeId, final String username) {
-            this.nodeId = Preconditions.checkNotNull(nodeId);
-            this.username = Preconditions.checkNotNull(username);
+            this.nodeId = requireNonNull(nodeId);
+            this.username = requireNonNull(username);
         }
 
         /**
@@ -146,10 +146,10 @@ public abstract class CallHomeAuthorization {
 
         ServerAllowed(final String nodeId, final String username, final Collection<String> passwords,
                       final Collection<KeyPair> clientKeyPairs) {
-            this.username = Preconditions.checkNotNull(username);
+            this.username = requireNonNull(username);
             this.passwords = ImmutableSet.copyOf(passwords);
             this.clientKeyPair = ImmutableSet.copyOf(clientKeyPairs);
-            this.nodeId = Preconditions.checkNotNull(nodeId);
+            this.nodeId = requireNonNull(nodeId);
         }
 
         @Override
@@ -164,7 +164,6 @@ public abstract class CallHomeAuthorization {
 
         @Override
         protected void applyTo(final ClientSession session) {
-            Preconditions.checkArgument(session instanceof ClientSessionImpl);
             session.setUsername(username);
 
             // First try authentication using server host keys, else try password.