Standardise on Locale.ROOT for case-conversion
git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1579495 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
6cbac13a39
commit
c85a1e0344
|
@ -67,7 +67,7 @@ public class WindowsNegotiateScheme extends AuthSchemeBase {
|
|||
|
||||
public static boolean isAvaliable() {
|
||||
String os = System.getProperty("os.name");
|
||||
os = os != null ? os.toLowerCase(Locale.US) : null;
|
||||
os = os != null ? os.toLowerCase(Locale.ROOT) : null;
|
||||
if (os != null && os.contains("windows")) {
|
||||
try {
|
||||
return Sspi.MAX_TOKEN_SIZE > 0;
|
||||
|
|
|
@ -106,7 +106,7 @@ public abstract class AbstractAuthenticationHandler implements AuthenticationHan
|
|||
}
|
||||
final int endIndex = pos;
|
||||
final String s = buffer.substring(beginIndex, endIndex);
|
||||
map.put(s.toLowerCase(Locale.US), header);
|
||||
map.put(s.toLowerCase(Locale.ROOT), header);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
|
|
@ -111,7 +111,7 @@ class AuthenticationStrategyAdaptor implements AuthenticationStrategy {
|
|||
return options;
|
||||
}
|
||||
final String id = authScheme.getSchemeName();
|
||||
final Header challenge = challenges.get(id.toLowerCase(Locale.US));
|
||||
final Header challenge = challenges.get(id.toLowerCase(Locale.ROOT));
|
||||
authScheme.processChallenge(challenge);
|
||||
|
||||
final AuthScope authScope = new AuthScope(
|
||||
|
|
|
@ -186,12 +186,12 @@ public abstract class AbstractVerifier implements X509HostnameVerifier {
|
|||
|
||||
// We're can be case-insensitive when comparing the host we used to
|
||||
// establish the socket to the hostname in the certificate.
|
||||
final String hostName = normaliseIPv6Address(host.trim().toLowerCase(Locale.US));
|
||||
final String hostName = normaliseIPv6Address(host.trim().toLowerCase(Locale.ROOT));
|
||||
boolean match = false;
|
||||
for(final Iterator<String> it = names.iterator(); it.hasNext();) {
|
||||
// Don't trim the CN, though!
|
||||
String cn = it.next();
|
||||
cn = cn.toLowerCase(Locale.US);
|
||||
cn = cn.toLowerCase(Locale.ROOT);
|
||||
// Store CN in StringBuilder in case we need to report an error.
|
||||
buf.append(" <");
|
||||
buf.append(cn);
|
||||
|
|
|
@ -162,7 +162,7 @@ public abstract class AuthSchemeBase implements ContextAwareAuthScheme {
|
|||
public String toString() {
|
||||
final String name = getSchemeName();
|
||||
if (name != null) {
|
||||
return name.toUpperCase(Locale.US);
|
||||
return name.toUpperCase(Locale.ROOT);
|
||||
} else {
|
||||
return super.toString();
|
||||
}
|
||||
|
|
|
@ -267,7 +267,7 @@ public class DigestScheme extends RFC2617Scheme {
|
|||
final StringTokenizer tok = new StringTokenizer(qoplist, ",");
|
||||
while (tok.hasMoreTokens()) {
|
||||
final String variant = tok.nextToken().trim();
|
||||
qopset.add(variant.toLowerCase(Locale.US));
|
||||
qopset.add(variant.toLowerCase(Locale.ROOT));
|
||||
}
|
||||
if (request instanceof HttpEntityEnclosingRequest && qopset.contains("auth-int")) {
|
||||
qop = QOP_AUTH_INT;
|
||||
|
|
|
@ -131,7 +131,7 @@ public class HttpAuthenticator {
|
|||
case UNCHALLENGED:
|
||||
if (authScheme != null) {
|
||||
final String id = authScheme.getSchemeName();
|
||||
final Header challenge = challenges.get(id.toLowerCase(Locale.US));
|
||||
final Header challenge = challenges.get(id.toLowerCase(Locale.ROOT));
|
||||
if (challenge != null) {
|
||||
this.log.debug("Authorization challenge processed");
|
||||
authScheme.processChallenge(challenge);
|
||||
|
|
|
@ -590,7 +590,7 @@ final class NTLMEngineImpl implements NTLMEngine {
|
|||
*/
|
||||
private static byte[] lmHash(final String password) throws NTLMEngineException {
|
||||
try {
|
||||
final byte[] oemPassword = password.toUpperCase(Locale.US).getBytes(Consts.ASCII);
|
||||
final byte[] oemPassword = password.toUpperCase(Locale.ROOT).getBytes(Consts.ASCII);
|
||||
final int length = Math.min(oemPassword.length, 14);
|
||||
final byte[] keyBytes = new byte[14];
|
||||
System.arraycopy(oemPassword, 0, keyBytes, 0, length);
|
||||
|
@ -643,9 +643,9 @@ final class NTLMEngineImpl implements NTLMEngine {
|
|||
}
|
||||
final HMACMD5 hmacMD5 = new HMACMD5(ntlmHash);
|
||||
// Upper case username, upper case domain!
|
||||
hmacMD5.update(user.toUpperCase(Locale.US).getBytes(UNICODE_LITTLE_UNMARKED));
|
||||
hmacMD5.update(user.toUpperCase(Locale.ROOT).getBytes(UNICODE_LITTLE_UNMARKED));
|
||||
if (domain != null) {
|
||||
hmacMD5.update(domain.toUpperCase(Locale.US).getBytes(UNICODE_LITTLE_UNMARKED));
|
||||
hmacMD5.update(domain.toUpperCase(Locale.ROOT).getBytes(UNICODE_LITTLE_UNMARKED));
|
||||
}
|
||||
return hmacMD5.getOutput();
|
||||
}
|
||||
|
@ -663,7 +663,7 @@ final class NTLMEngineImpl implements NTLMEngine {
|
|||
}
|
||||
final HMACMD5 hmacMD5 = new HMACMD5(ntlmHash);
|
||||
// Upper case username, mixed case target!!
|
||||
hmacMD5.update(user.toUpperCase(Locale.US).getBytes(UNICODE_LITTLE_UNMARKED));
|
||||
hmacMD5.update(user.toUpperCase(Locale.ROOT).getBytes(UNICODE_LITTLE_UNMARKED));
|
||||
if (domain != null) {
|
||||
hmacMD5.update(domain.getBytes(UNICODE_LITTLE_UNMARKED));
|
||||
}
|
||||
|
@ -986,7 +986,7 @@ final class NTLMEngineImpl implements NTLMEngine {
|
|||
|
||||
hostBytes = unqualifiedHost != null? unqualifiedHost.getBytes(Consts.ASCII) : null;
|
||||
domainBytes = unqualifiedDomain != null ? unqualifiedDomain
|
||||
.toUpperCase(Locale.US).getBytes(Consts.ASCII) : null;
|
||||
.toUpperCase(Locale.ROOT).getBytes(Consts.ASCII) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1239,7 +1239,7 @@ final class NTLMEngineImpl implements NTLMEngine {
|
|||
}
|
||||
hostBytes = unqualifiedHost != null ? unqualifiedHost.getBytes(UNICODE_LITTLE_UNMARKED) : null;
|
||||
domainBytes = unqualifiedDomain != null ? unqualifiedDomain
|
||||
.toUpperCase(Locale.US).getBytes(UNICODE_LITTLE_UNMARKED) : null;
|
||||
.toUpperCase(Locale.ROOT).getBytes(UNICODE_LITTLE_UNMARKED) : null;
|
||||
userBytes = user.getBytes(UNICODE_LITTLE_UNMARKED);
|
||||
}
|
||||
|
||||
|
|
|
@ -125,7 +125,7 @@ abstract class AuthenticationStrategyImpl implements AuthenticationStrategy {
|
|||
}
|
||||
final int endIndex = pos;
|
||||
final String s = buffer.substring(beginIndex, endIndex);
|
||||
map.put(s.toLowerCase(Locale.US), header);
|
||||
map.put(s.toLowerCase(Locale.ROOT), header);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
@ -165,7 +165,7 @@ abstract class AuthenticationStrategyImpl implements AuthenticationStrategy {
|
|||
}
|
||||
|
||||
for (final String id: authPrefs) {
|
||||
final Header challenge = challenges.get(id.toLowerCase(Locale.US));
|
||||
final Header challenge = challenges.get(id.toLowerCase(Locale.ROOT));
|
||||
if (challenge != null) {
|
||||
final AuthSchemeProvider authSchemeProvider = registry.lookup(id);
|
||||
if (authSchemeProvider == null) {
|
||||
|
|
|
@ -187,7 +187,7 @@ public class DefaultRedirectStrategy implements RedirectStrategy {
|
|||
final URIBuilder b = new URIBuilder(new URI(location).normalize());
|
||||
final String host = b.getHost();
|
||||
if (host != null) {
|
||||
b.setHost(host.toLowerCase(Locale.US));
|
||||
b.setHost(host.toLowerCase(Locale.ROOT));
|
||||
}
|
||||
final String path = b.getPath();
|
||||
if (TextUtils.isEmpty(path)) {
|
||||
|
|
|
@ -72,7 +72,7 @@ public class StandardHttpRequestRetryHandler extends DefaultHttpRequestRetryHand
|
|||
|
||||
@Override
|
||||
protected boolean handleAsIdempotent(final HttpRequest request) {
|
||||
final String method = request.getRequestLine().getMethod().toUpperCase(Locale.US);
|
||||
final String method = request.getRequestLine().getMethod().toUpperCase(Locale.ROOT);
|
||||
final Boolean b = this.idempotentMethods.get(method);
|
||||
return b != null && b.booleanValue();
|
||||
}
|
||||
|
|
|
@ -92,7 +92,7 @@ public class TestMinimalClientRequestExecution extends IntegrationTestBase {
|
|||
final Header[] headers = reqWrapper.getAllHeaders();
|
||||
final Set<String> headerSet = new HashSet<String>();
|
||||
for (final Header header: headers) {
|
||||
headerSet.add(header.getName().toLowerCase(Locale.US));
|
||||
headerSet.add(header.getName().toLowerCase(Locale.ROOT));
|
||||
}
|
||||
Assert.assertEquals(3, headerSet.size());
|
||||
Assert.assertTrue(headerSet.contains("connection"));
|
||||
|
|
|
@ -54,7 +54,7 @@ public class Header implements Iterable<MinimalField> {
|
|||
if (field == null) {
|
||||
return;
|
||||
}
|
||||
final String key = field.getName().toLowerCase(Locale.US);
|
||||
final String key = field.getName().toLowerCase(Locale.ROOT);
|
||||
List<MinimalField> values = this.fieldMap.get(key);
|
||||
if (values == null) {
|
||||
values = new LinkedList<MinimalField>();
|
||||
|
@ -72,7 +72,7 @@ public class Header implements Iterable<MinimalField> {
|
|||
if (name == null) {
|
||||
return null;
|
||||
}
|
||||
final String key = name.toLowerCase(Locale.US);
|
||||
final String key = name.toLowerCase(Locale.ROOT);
|
||||
final List<MinimalField> list = this.fieldMap.get(key);
|
||||
if (list != null && !list.isEmpty()) {
|
||||
return list.get(0);
|
||||
|
@ -84,7 +84,7 @@ public class Header implements Iterable<MinimalField> {
|
|||
if (name == null) {
|
||||
return null;
|
||||
}
|
||||
final String key = name.toLowerCase(Locale.US);
|
||||
final String key = name.toLowerCase(Locale.ROOT);
|
||||
final List<MinimalField> list = this.fieldMap.get(key);
|
||||
if (list == null || list.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
|
@ -97,7 +97,7 @@ public class Header implements Iterable<MinimalField> {
|
|||
if (name == null) {
|
||||
return 0;
|
||||
}
|
||||
final String key = name.toLowerCase(Locale.US);
|
||||
final String key = name.toLowerCase(Locale.ROOT);
|
||||
final List<MinimalField> removed = fieldMap.remove(key);
|
||||
if (removed == null || removed.isEmpty()) {
|
||||
return 0;
|
||||
|
@ -110,7 +110,7 @@ public class Header implements Iterable<MinimalField> {
|
|||
if (field == null) {
|
||||
return;
|
||||
}
|
||||
final String key = field.getName().toLowerCase(Locale.US);
|
||||
final String key = field.getName().toLowerCase(Locale.ROOT);
|
||||
final List<MinimalField> list = fieldMap.get(key);
|
||||
if (list == null || list.isEmpty()) {
|
||||
addField(field);
|
||||
|
|
Loading…
Reference in New Issue