HTTPCLIENT-1712: SPNego schemes to take service scheme into account when generating auth token

Contributed by Georg Romstorfer <georg.romstorfer at gmail.com>

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/branches/4.5.x@1724852 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Oleg Kalnichevski 2016-01-15 16:38:07 +00:00
parent b781fa8e03
commit 1d50c1a1a1
1 changed files with 5 additions and 1 deletions

View File

@ -28,6 +28,7 @@ package org.apache.http.impl.auth;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Locale;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.logging.Log;
@ -79,6 +80,7 @@ public abstract class GGSSchemeBase extends AuthSchemeBase {
/** base64 decoded challenge **/
private byte[] token;
private String service;
GGSSchemeBase(final boolean stripPort, final boolean useCanonicalHostname) {
super();
@ -116,7 +118,7 @@ public abstract class GGSSchemeBase extends AuthSchemeBase {
inputBuff = new byte[0];
}
final GSSManager manager = getManager();
final GSSName serverName = manager.createName("HTTP@" + authServer, GSSName.NT_HOSTBASED_SERVICE);
final GSSName serverName = manager.createName(service + "@" + authServer, GSSName.NT_HOSTBASED_SERVICE);
final GSSCredential gssCredential;
if (credentials instanceof KerberosCredentials) {
@ -212,6 +214,8 @@ public abstract class GGSSchemeBase extends AuthSchemeBase {
authServer = hostname + ":" + host.getPort();
}
service = host.getSchemeName().toUpperCase(Locale.ROOT);
if (log.isDebugEnabled()) {
log.debug("init " + authServer);
}