Skip to content

Commit

Permalink
Added workaround/compatibility with Chromium-based browsers on POSIX …
Browse files Browse the repository at this point in the history
…OSes.
  • Loading branch information
EleotleCram committed Apr 1, 2012
1 parent 36ff930 commit ed299df
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -5,7 +5,7 @@
<artifactId>spnego</artifactId>
<packaging>jar</packaging>
<name>Sourceforge SPNEGO</name>
<version>7.0</version>
<version>7.0-with-chromium-fix</version>
<description>Integrated Windows Authentication in Java</description>
<url>http://spnego.sourceforge.net</url>
<licenses>
Expand Down
35 changes: 30 additions & 5 deletions src/main/java/net/sourceforge/spnego/SpnegoProvider.java
Expand Up @@ -73,7 +73,16 @@ public final class SpnegoProvider {
static final GSSManager MANAGER = GSSManager.getInstance(); // NOPMD

/** GSS-API mechanism "1.3.6.1.5.5.2". */
static final Oid SPNEGO_OID = SpnegoProvider.getOid(); // NOPMD
static final Oid SPNEGO_OID = SpnegoProvider.getSpnegoOid(); // NOPMD
/** GSS-API mechanism "1.2.840.113554.1.2.2". */
static final Oid KERBEROS_V5_OID = SpnegoProvider.getKerberosV5Oid(); // NOPMD
/**
* Note: The MIT Kerberos V5 mechanism OID is added for compatibility with
* Chromium-based browsers on POSIX OSes. On these OSes, Chromium erroneously
* responds to an SPNEGO request with a GSS-API MIT Kerberos V5 mechanism
* answer (instead of a MIT Kerberos V5 token inside an SPNEGO mechanism answer).
*/
static final Oid[] SUPPORTED_OIDS = new Oid[]{SPNEGO_OID, KERBEROS_V5_OID}; // NOPMD

/*
* This is a utility class (not a Singleton).
Expand Down Expand Up @@ -171,7 +180,7 @@ public GSSCredential run() throws GSSException {
return MANAGER.createCredential(
null
, GSSCredential.DEFAULT_LIFETIME
, SpnegoProvider.SPNEGO_OID
, SpnegoProvider.SUPPORTED_OIDS
, GSSCredential.INITIATE_ONLY);
}
};
Expand Down Expand Up @@ -228,14 +237,14 @@ public static SpnegoAuthScheme getAuthScheme(final String header) {
throw new UnsupportedOperationException("Negotiate or Basic Only:" + header);
}
}

/**
* Returns the Universal Object Identifier representation of
* the SPNEGO mechanism.
*
* @return Object Identifier of the GSS-API mechanism
*/
private static Oid getOid() {
private static Oid getSpnegoOid() {
Oid oid = null;
try {
oid = new Oid("1.3.6.1.5.5.2");
Expand All @@ -245,6 +254,22 @@ private static Oid getOid() {
return oid;
}

/**
* Returns the Universal Object Identifier representation of
* the MIT Kerberos V5 mechanism.
*
* @return Object Identifier of the GSS-API mechanism
*/
private static Oid getKerberosV5Oid() {
Oid oid = null;
try {
oid = new Oid("1.2.840.113554.1.2.2");
} catch (GSSException gsse) {
LOGGER.log(Level.SEVERE, "Unable to create OID 1.2.840.113554.1.2.2 !", gsse);
}
return oid;
}

/**
* Returns the {@link GSSCredential} the server uses for pre-authentication.
*
Expand All @@ -261,7 +286,7 @@ public GSSCredential run() throws GSSException {
return MANAGER.createCredential(
null
, GSSCredential.INDEFINITE_LIFETIME
, SpnegoProvider.SPNEGO_OID
, SpnegoProvider.SUPPORTED_OIDS
, GSSCredential.ACCEPT_ONLY);
}
};
Expand Down

2 comments on commit ed299df

@ymartin59
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea. Do you mind if I report this patch back mainstream at spnego.sf.net ?

@EleotleCram
Copy link
Owner Author

@EleotleCram EleotleCram commented on ed299df Sep 2, 2012 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.