Kerberos and SPNego auth schemes use incorrect authorization header name when authenticating with a proxy

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1424447 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Oleg Kalnichevski 2012-12-20 13:04:50 +00:00
parent b0090c516f
commit f492a000e7
2 changed files with 15 additions and 2 deletions

View File

@ -1,6 +1,10 @@
Changes in trunk
-------------------
* Kerberos and SPNego auth schemes use incorrect authorization header name when authenticating
with a proxy.
Contributed by Oleg Kalnichevski <olegk at apache.org>
* [HTTPCLIENT-1283] NTLM needs to use Locale-independent form of
toUpperCase().
Contributed by Karl Wright <DaddyWri at gmail.com>

View File

@ -31,6 +31,7 @@ import org.apache.commons.logging.LogFactory;
import org.apache.http.Header;
import org.apache.http.HttpHost;
import org.apache.http.HttpRequest;
import org.apache.http.auth.AUTH;
import org.apache.http.auth.AuthenticationException;
import org.apache.http.auth.ContextAwareAuthScheme;
import org.apache.http.auth.Credentials;
@ -38,7 +39,7 @@ import org.apache.http.auth.InvalidCredentialsException;
import org.apache.http.auth.MalformedChallengeException;
import org.apache.http.client.protocol.ClientContext;
import org.apache.http.conn.routing.HttpRoute;
import org.apache.http.message.BasicHeader;
import org.apache.http.message.BufferedHeader;
import org.apache.http.protocol.HttpContext;
import org.apache.http.util.Args;
import org.apache.http.util.CharArrayBuffer;
@ -175,7 +176,15 @@ public abstract class GGSSchemeBase extends AuthSchemeBase {
if (log.isDebugEnabled()) {
log.debug("Sending response '" + tokenstr + "' back to the auth server");
}
return new BasicHeader("Authorization", "Negotiate " + tokenstr);
CharArrayBuffer buffer = new CharArrayBuffer(32);
if (isProxy()) {
buffer.append(AUTH.PROXY_AUTH_RESP);
} else {
buffer.append(AUTH.WWW_AUTH_RESP);
}
buffer.append(": Negotiate ");
buffer.append(tokenstr);
return new BufferedHeader(buffer);
default:
throw new IllegalStateException("Illegal state: " + state);
}