Fix for HTTPCLIENT-1283.
git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1423832 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
01a7e66d7b
commit
093284e54a
|
@ -1,6 +1,10 @@
|
||||||
Changes in trunk
|
Changes in trunk
|
||||||
-------------------
|
-------------------
|
||||||
|
|
||||||
|
* [HTTPCLIENT-1283] NTLM needs to use Locale-independent form of
|
||||||
|
toUpperCase().
|
||||||
|
Contributed by Karl Wright <DaddyWri at gmail.com>
|
||||||
|
|
||||||
* [HTTPCLIENT-1279] Target host responding with status 407 (proxy authentication required)
|
* [HTTPCLIENT-1279] Target host responding with status 407 (proxy authentication required)
|
||||||
causes an NPE.
|
causes an NPE.
|
||||||
Contributed by Oleg Kalnichevski <olegk at apache.org>
|
Contributed by Oleg Kalnichevski <olegk at apache.org>
|
||||||
|
|
|
@ -29,6 +29,7 @@ package org.apache.http.impl.auth;
|
||||||
import java.security.Key;
|
import java.security.Key;
|
||||||
import java.security.MessageDigest;
|
import java.security.MessageDigest;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
import javax.crypto.Cipher;
|
import javax.crypto.Cipher;
|
||||||
import javax.crypto.spec.SecretKeySpec;
|
import javax.crypto.spec.SecretKeySpec;
|
||||||
|
@ -572,7 +573,7 @@ final class NTLMEngineImpl implements NTLMEngine {
|
||||||
*/
|
*/
|
||||||
private static byte[] lmHash(String password) throws NTLMEngineException {
|
private static byte[] lmHash(String password) throws NTLMEngineException {
|
||||||
try {
|
try {
|
||||||
byte[] oemPassword = password.toUpperCase().getBytes("US-ASCII");
|
byte[] oemPassword = password.toUpperCase(Locale.ROOT).getBytes("US-ASCII");
|
||||||
int length = Math.min(oemPassword.length, 14);
|
int length = Math.min(oemPassword.length, 14);
|
||||||
byte[] keyBytes = new byte[14];
|
byte[] keyBytes = new byte[14];
|
||||||
System.arraycopy(oemPassword, 0, keyBytes, 0, length);
|
System.arraycopy(oemPassword, 0, keyBytes, 0, length);
|
||||||
|
@ -632,7 +633,7 @@ final class NTLMEngineImpl implements NTLMEngine {
|
||||||
byte[] ntlmHash = ntlmHash(password);
|
byte[] ntlmHash = ntlmHash(password);
|
||||||
HMACMD5 hmacMD5 = new HMACMD5(ntlmHash);
|
HMACMD5 hmacMD5 = new HMACMD5(ntlmHash);
|
||||||
// Upper case username, mixed case target!!
|
// Upper case username, mixed case target!!
|
||||||
hmacMD5.update(user.toUpperCase().getBytes("UnicodeLittleUnmarked"));
|
hmacMD5.update(user.toUpperCase(Locale.ROOT).getBytes("UnicodeLittleUnmarked"));
|
||||||
hmacMD5.update(target.getBytes("UnicodeLittleUnmarked"));
|
hmacMD5.update(target.getBytes("UnicodeLittleUnmarked"));
|
||||||
return hmacMD5.getOutput();
|
return hmacMD5.getOutput();
|
||||||
} catch (java.io.UnsupportedEncodingException e) {
|
} catch (java.io.UnsupportedEncodingException e) {
|
||||||
|
@ -951,7 +952,7 @@ final class NTLMEngineImpl implements NTLMEngine {
|
||||||
domain = convertDomain(domain);
|
domain = convertDomain(domain);
|
||||||
|
|
||||||
hostBytes = host.getBytes("UnicodeLittleUnmarked");
|
hostBytes = host.getBytes("UnicodeLittleUnmarked");
|
||||||
domainBytes = domain.toUpperCase().getBytes("UnicodeLittleUnmarked");
|
domainBytes = domain.toUpperCase(Locale.ROOT).getBytes("UnicodeLittleUnmarked");
|
||||||
} catch (java.io.UnsupportedEncodingException e) {
|
} catch (java.io.UnsupportedEncodingException e) {
|
||||||
throw new NTLMEngineException("Unicode unsupported: " + e.getMessage(), e);
|
throw new NTLMEngineException("Unicode unsupported: " + e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
@ -1197,7 +1198,7 @@ final class NTLMEngineImpl implements NTLMEngine {
|
||||||
sessionKey = null;
|
sessionKey = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
domainBytes = domain.toUpperCase().getBytes("UnicodeLittleUnmarked");
|
domainBytes = domain.toUpperCase(Locale.ROOT).getBytes("UnicodeLittleUnmarked");
|
||||||
hostBytes = host.getBytes("UnicodeLittleUnmarked");
|
hostBytes = host.getBytes("UnicodeLittleUnmarked");
|
||||||
userBytes = user.getBytes("UnicodeLittleUnmarked");
|
userBytes = user.getBytes("UnicodeLittleUnmarked");
|
||||||
} catch (java.io.UnsupportedEncodingException e) {
|
} catch (java.io.UnsupportedEncodingException e) {
|
||||||
|
|
Loading…
Reference in New Issue