diff --git a/jdk/src/share/classes/sun/security/jgss/spnego/SpNegoMechFactory.java b/jdk/src/share/classes/sun/security/jgss/spnego/SpNegoMechFactory.java index ae12d6b3a78..72b77ac7166 100644 --- a/jdk/src/share/classes/sun/security/jgss/spnego/SpNegoMechFactory.java +++ b/jdk/src/share/classes/sun/security/jgss/spnego/SpNegoMechFactory.java @@ -57,6 +57,12 @@ public final class SpNegoMechFactory implements MechanismFactory { GSSName.NT_HOSTBASED_SERVICE, GSSName.NT_EXPORT_NAME}; + // The default underlying mech of SPNEGO, must not be SPNEGO itself. + private static final Oid DEFAULT_SPNEGO_MECH_OID = + ProviderList.DEFAULT_MECH_OID.equals(GSS_SPNEGO_MECH_OID)? + GSSUtil.GSS_KRB5_MECH_OID: + ProviderList.DEFAULT_MECH_OID; + // Use an instance of a GSSManager whose provider list // does not include native provider final GSSManagerImpl manager; @@ -100,18 +106,27 @@ public final class SpNegoMechFactory implements MechanismFactory { availableMechs[j++] = mechs[i]; } } + // Move the preferred mech to first place + for (int i=0; i