This is an automated email from the ASF dual-hosted git repository.

lgoldstein pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mina-sshd.git

commit 27405a9753b2d0ea575478b095ae87d7a3ae5acb
Author: Lyor Goldstein <lgoldst...@apache.org>
AuthorDate: Sat Nov 9 19:13:43 2019 +0200

    Minor code re-write regarding 1st packet after KEX initial guess
---
 .../apache/sshd/common/kex/KexProposalOption.java  | 25 +++++++++++-----------
 .../common/session/helpers/AbstractSession.java    |  6 +++---
 2 files changed, 15 insertions(+), 16 deletions(-)

diff --git 
a/sshd-common/src/main/java/org/apache/sshd/common/kex/KexProposalOption.java 
b/sshd-common/src/main/java/org/apache/sshd/common/kex/KexProposalOption.java
index 752b41e..a5b0def 100644
--- 
a/sshd-common/src/main/java/org/apache/sshd/common/kex/KexProposalOption.java
+++ 
b/sshd-common/src/main/java/org/apache/sshd/common/kex/KexProposalOption.java
@@ -19,11 +19,11 @@
 
 package org.apache.sshd.common.kex;
 
-import java.util.Collection;
 import java.util.Collections;
 import java.util.Comparator;
 import java.util.EnumSet;
 import java.util.List;
+import java.util.Set;
 import java.util.stream.Collectors;
 
 import org.apache.sshd.common.util.GenericUtils;
@@ -43,21 +43,20 @@ public enum KexProposalOption {
     C2SLANG(Constants.PROPOSAL_LANG_CTOS, "languages (client to server)"),
     S2CLANG(Constants.PROPOSAL_LANG_STOC, "languages (server to client)");
 
-    public static final Collection<KexProposalOption> CIPHER_PROPOSALS =
-        Collections.unmodifiableSet(
-            EnumSet.of(KexProposalOption.C2SENC, KexProposalOption.S2CENC));
+    public static final Set<KexProposalOption> CIPHER_PROPOSALS =
+        Collections.unmodifiableSet(EnumSet.of(C2SENC, S2CENC));
 
-    public static final Collection<KexProposalOption> MAC_PROPOSALS =
-        Collections.unmodifiableSet(
-            EnumSet.of(KexProposalOption.C2SMAC, KexProposalOption.S2CMAC));
+    public static final Set<KexProposalOption> MAC_PROPOSALS =
+        Collections.unmodifiableSet(EnumSet.of(C2SMAC, S2CMAC));
 
-    public static final Collection<KexProposalOption> COMPRESSION_PROPOSALS =
-        Collections.unmodifiableSet(
-            EnumSet.of(KexProposalOption.C2SCOMP, KexProposalOption.S2CCOMP));
+    public static final Set<KexProposalOption> COMPRESSION_PROPOSALS =
+        Collections.unmodifiableSet(EnumSet.of(C2SCOMP, S2CCOMP));
 
-    public static final Collection<KexProposalOption> LANGUAGE_PROPOSALS =
-        Collections.unmodifiableSet(
-            EnumSet.of(KexProposalOption.C2SLANG, KexProposalOption.S2CLANG));
+    public static final Set<KexProposalOption> LANGUAGE_PROPOSALS =
+        Collections.unmodifiableSet(EnumSet.of(C2SLANG, S2CLANG));
+
+    public static final Set<KexProposalOption> FIRST_KEX_PACKET_GUESS_MATCHES =
+        Collections.unmodifiableSet(EnumSet.of(ALGORITHMS, SERVERKEYS));
 
     /**
      * Compares values according to {@link 
KexProposalOption#getProposalIndex()}
diff --git 
a/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractSession.java
 
b/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractSession.java
index fcf2c7d..54d9929 100644
--- 
a/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractSession.java
+++ 
b/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractSession.java
@@ -496,7 +496,7 @@ public abstract class AbstractSession extends SessionHelper 
{
          *      the next packet MUST be silently ignored
          */
         boolean debugEnabled = log.isDebugEnabled();
-        for (KexProposalOption option : new 
KexProposalOption[]{KexProposalOption.ALGORITHMS, 
KexProposalOption.SERVERKEYS}) {
+        for (KexProposalOption option : 
KexProposalOption.FIRST_KEX_PACKET_GUESS_MATCHES) {
             Map.Entry<String, String> result = 
comparePreferredKexProposalOption(option);
             if (result != null) {
                 if (debugEnabled) {
@@ -514,10 +514,10 @@ public abstract class AbstractSession extends 
SessionHelper {
      * Compares the specified {@link KexProposalOption} option value for 
client vs. server
      *
      * @param option The option to check
-     * @return {@code null} if option is equal, otherwise a kex/value pair 
where key=client
+     * @return {@code null} if option is equal, otherwise a key/value pair 
where key=client
      * option value and value=the server-side one
      */
-    protected SimpleImmutableEntry<String, String> 
comparePreferredKexProposalOption(KexProposalOption option) {
+    protected Map.Entry<String, String> 
comparePreferredKexProposalOption(KexProposalOption option) {
         String[] clientPreferences = 
GenericUtils.split(clientProposal.get(option), ',');
         String clientValue = GenericUtils.isEmpty(clientPreferences) ? null : 
clientPreferences[0];
         String[] serverPreferences = 
GenericUtils.split(serverProposal.get(option), ',');

Reply via email to