mirror of
https://github.com/openjdk/jdk.git
synced 2026-04-08 14:08:48 +00:00
7059542: JNDI name operations should be locale independent
Reviewed-by: weijun
This commit is contained in:
parent
cf6e15a2e3
commit
8e853c8484
@ -25,6 +25,7 @@
|
||||
|
||||
package com.sun.jndi.ldap;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Arrays; // JDK 1.2
|
||||
import java.io.OutputStream;
|
||||
import javax.naming.ldap.Control;
|
||||
@ -71,7 +72,7 @@ class ClientId {
|
||||
ClientId(int version, String hostname, int port, String protocol,
|
||||
Control[] bindCtls, OutputStream trace, String socketFactory) {
|
||||
this.version = version;
|
||||
this.hostname = hostname.toLowerCase(); // ignore case
|
||||
this.hostname = hostname.toLowerCase(Locale.ENGLISH); // ignore case
|
||||
this.port = port;
|
||||
this.protocol = protocol;
|
||||
this.bindCtls = (bindCtls != null ? bindCtls.clone() : null);
|
||||
@ -83,13 +84,15 @@ class ClientId {
|
||||
if ((socketFactory != null) &&
|
||||
!socketFactory.equals(LdapCtx.DEFAULT_SSL_FACTORY)) {
|
||||
try {
|
||||
Class<?> socketFactoryClass = Obj.helper.loadClass(socketFactory);
|
||||
Class<?> socketFactoryClass =
|
||||
Obj.helper.loadClass(socketFactory);
|
||||
Class<?> objClass = Class.forName("java.lang.Object");
|
||||
this.sockComparator = socketFactoryClass.getMethod(
|
||||
"compare", new Class<?>[]{objClass, objClass});
|
||||
Method getDefault =
|
||||
socketFactoryClass.getMethod("getDefault", new Class<?>[]{});
|
||||
this.factory = (SocketFactory) getDefault.invoke(null, new Object[]{});
|
||||
Method getDefault = socketFactoryClass.getMethod(
|
||||
"getDefault", new Class<?>[]{});
|
||||
this.factory =
|
||||
(SocketFactory)getDefault.invoke(null, new Object[]{});
|
||||
} catch (Exception e) {
|
||||
// Ignore it here, the same exceptions are/will be handled by
|
||||
// LdapPoolManager and Connection classes.
|
||||
|
||||
@ -26,6 +26,7 @@
|
||||
package com.sun.jndi.ldap;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.Locale;
|
||||
import java.util.Vector;
|
||||
import java.util.Hashtable;
|
||||
|
||||
@ -738,14 +739,15 @@ public final class LdapClient implements PooledConnection {
|
||||
if (hasBinaryValues) {
|
||||
la.add(ber.parseOctetString(ber.peekByte(), len));
|
||||
} else {
|
||||
la.add(ber.parseStringWithTag(Ber.ASN_SIMPLE_STRING, isLdapv3, len));
|
||||
la.add(ber.parseStringWithTag(
|
||||
Ber.ASN_SIMPLE_STRING, isLdapv3, len));
|
||||
}
|
||||
return len[0];
|
||||
}
|
||||
|
||||
private boolean isBinaryValued(String attrid,
|
||||
Hashtable<String, Boolean> binaryAttrs) {
|
||||
String id = attrid.toLowerCase();
|
||||
String id = attrid.toLowerCase(Locale.ENGLISH);
|
||||
|
||||
return ((id.indexOf(";binary") != -1) ||
|
||||
defaultBinaryAttrs.containsKey(id) ||
|
||||
@ -753,8 +755,8 @@ public final class LdapClient implements PooledConnection {
|
||||
}
|
||||
|
||||
// package entry point; used by Connection
|
||||
static void parseResult(BerDecoder replyBer, LdapResult res, boolean isLdapv3)
|
||||
throws IOException {
|
||||
static void parseResult(BerDecoder replyBer, LdapResult res,
|
||||
boolean isLdapv3) throws IOException {
|
||||
|
||||
res.status = replyBer.parseEnumeration();
|
||||
res.matchedDN = replyBer.parseString(isLdapv3);
|
||||
|
||||
@ -33,6 +33,7 @@ import javax.naming.ldap.*;
|
||||
import javax.naming.ldap.LdapName;
|
||||
import javax.naming.ldap.Rdn;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Vector;
|
||||
import java.util.Hashtable;
|
||||
import java.util.List;
|
||||
@ -2597,7 +2598,7 @@ final public class LdapCtx extends ComponentDirContext
|
||||
} else {
|
||||
binaryAttrs = new Hashtable<>(11, 0.75f);
|
||||
StringTokenizer tokens =
|
||||
new StringTokenizer(attrIds.toLowerCase(), " ");
|
||||
new StringTokenizer(attrIds.toLowerCase(Locale.ENGLISH), " ");
|
||||
|
||||
while (tokens.hasMoreTokens()) {
|
||||
binaryAttrs.put(tokens.nextToken(), Boolean.TRUE);
|
||||
|
||||
@ -28,6 +28,7 @@ package com.sun.jndi.ldap;
|
||||
|
||||
import java.util.Enumeration;
|
||||
import java.util.Vector;
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.naming.*;
|
||||
import javax.naming.directory.Attributes;
|
||||
@ -707,7 +708,7 @@ public final class LdapName implements Name {
|
||||
|
||||
TypeAndValue that = (TypeAndValue)obj;
|
||||
|
||||
int diff = type.toUpperCase().compareTo(that.type.toUpperCase());
|
||||
int diff = type.compareToIgnoreCase(that.type);
|
||||
if (diff != 0) {
|
||||
return diff;
|
||||
}
|
||||
@ -730,7 +731,7 @@ public final class LdapName implements Name {
|
||||
|
||||
public int hashCode() {
|
||||
// If two objects are equal, their hash codes must match.
|
||||
return (type.toUpperCase().hashCode() +
|
||||
return (type.toUpperCase(Locale.ENGLISH).hashCode() +
|
||||
getValueComparable().hashCode());
|
||||
}
|
||||
|
||||
@ -764,11 +765,12 @@ public final class LdapName implements Name {
|
||||
|
||||
// cache result
|
||||
if (binary) {
|
||||
comparable = value.toUpperCase();
|
||||
comparable = value.toUpperCase(Locale.ENGLISH);
|
||||
} else {
|
||||
comparable = (String)unescapeValue(value);
|
||||
if (!valueCaseSensitive) {
|
||||
comparable = comparable.toUpperCase(); // ignore case
|
||||
// ignore case
|
||||
comparable = comparable.toUpperCase(Locale.ENGLISH);
|
||||
}
|
||||
}
|
||||
return comparable;
|
||||
@ -836,7 +838,7 @@ public final class LdapName implements Name {
|
||||
buf.append(Character.forDigit(0xF & b, 16));
|
||||
}
|
||||
|
||||
return (new String(buf)).toUpperCase();
|
||||
return (new String(buf)).toUpperCase(Locale.ENGLISH);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@ -28,6 +28,7 @@ package com.sun.jndi.ldap;
|
||||
import java.io.PrintStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Locale;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import javax.naming.ldap.Control;
|
||||
@ -133,7 +134,7 @@ public final class LdapPoolManager {
|
||||
String mech;
|
||||
int p;
|
||||
for (int i = 0; i < count; i++) {
|
||||
mech = parser.nextToken().toLowerCase();
|
||||
mech = parser.nextToken().toLowerCase(Locale.ENGLISH);
|
||||
if (mech.equals("anonymous")) {
|
||||
mech = "none";
|
||||
}
|
||||
|
||||
@ -910,7 +910,7 @@ final class HierarchicalName extends CompoundName {
|
||||
public int hashCode() {
|
||||
if (hashValue == -1) {
|
||||
|
||||
String name = toString().toUpperCase();
|
||||
String name = toString().toUpperCase(Locale.ENGLISH);
|
||||
int len = name.length();
|
||||
int off = 0;
|
||||
char val[] = new char[len];
|
||||
|
||||
@ -29,6 +29,7 @@ import javax.naming.directory.*;
|
||||
import java.util.Enumeration;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.Vector;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* A class for parsing LDAP search filters (defined in RFC 1960, 2254)
|
||||
@ -395,19 +396,21 @@ public class SearchFilter implements AttrFilter {
|
||||
|
||||
// do we need to begin with the first token?
|
||||
if(proto.charAt(0) != WILDCARD_TOKEN &&
|
||||
!value.toString().toLowerCase().startsWith(
|
||||
subStrs.nextToken().toLowerCase())) {
|
||||
if(debug) {System.out.println("faild initial test");}
|
||||
!value.toString().toLowerCase(Locale.ENGLISH).startsWith(
|
||||
subStrs.nextToken().toLowerCase(Locale.ENGLISH))) {
|
||||
if(debug) {
|
||||
System.out.println("faild initial test");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
while(subStrs.hasMoreTokens()) {
|
||||
String currentStr = subStrs.nextToken();
|
||||
if (debug) {System.out.println("looking for \"" +
|
||||
currentStr +"\"");}
|
||||
currentPos = value.toLowerCase().indexOf(
|
||||
currentStr.toLowerCase(), currentPos);
|
||||
currentPos = value.toLowerCase(Locale.ENGLISH).indexOf(
|
||||
currentStr.toLowerCase(Locale.ENGLISH), currentPos);
|
||||
|
||||
if(currentPos == -1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -33,6 +33,7 @@ import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.spec.InvalidKeySpecException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Locale;
|
||||
import javax.crypto.BadPaddingException;
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.IllegalBlockSizeException;
|
||||
@ -410,7 +411,8 @@ class NTLM {
|
||||
|
||||
static byte[] getP1(char[] password) {
|
||||
try {
|
||||
return new String(password).toUpperCase().getBytes("ISO8859_1");
|
||||
return new String(password).toUpperCase(
|
||||
Locale.ENGLISH).getBytes("ISO8859_1");
|
||||
} catch (UnsupportedEncodingException ex) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -26,6 +26,7 @@
|
||||
package java.security;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.Locale;
|
||||
|
||||
import java.security.spec.PKCS8EncodedKeySpec;
|
||||
import java.security.spec.X509EncodedKeySpec;
|
||||
@ -137,7 +138,7 @@ public class KeyRep implements Serializable {
|
||||
|
||||
this.type = type;
|
||||
this.algorithm = algorithm;
|
||||
this.format = format.toUpperCase();
|
||||
this.format = format.toUpperCase(Locale.ENGLISH);
|
||||
this.encoded = encoded.clone();
|
||||
}
|
||||
|
||||
|
||||
@ -1087,8 +1087,10 @@ public final class Security {
|
||||
// Check the keys for each provider.
|
||||
for (Enumeration<Object> e = providers[i].keys();
|
||||
e.hasMoreElements(); ) {
|
||||
String currentKey = ((String)e.nextElement()).toUpperCase();
|
||||
if (currentKey.startsWith(serviceName.toUpperCase())) {
|
||||
String currentKey =
|
||||
((String)e.nextElement()).toUpperCase(Locale.ENGLISH);
|
||||
if (currentKey.startsWith(
|
||||
serviceName.toUpperCase(Locale.ENGLISH))) {
|
||||
// We should skip the currentKey if it contains a
|
||||
// whitespace. The reason is: such an entry in the
|
||||
// provider property contains attributes for the
|
||||
@ -1096,7 +1098,8 @@ public final class Security {
|
||||
// in entries which lead to the implementation
|
||||
// classes.
|
||||
if (currentKey.indexOf(" ") < 0) {
|
||||
result.add(currentKey.substring(serviceName.length() + 1));
|
||||
result.add(currentKey.substring(
|
||||
serviceName.length() + 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -25,6 +25,7 @@
|
||||
|
||||
package javax.naming;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Vector;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Properties;
|
||||
@ -216,7 +217,8 @@ class NameImpl {
|
||||
}
|
||||
|
||||
private static boolean toBoolean(String name) {
|
||||
return ((name != null) && name.toLowerCase().equals("true"));
|
||||
return ((name != null) &&
|
||||
name.toLowerCase(Locale.ENGLISH).equals("true"));
|
||||
}
|
||||
|
||||
private final void recordNamingConvention(Properties p) {
|
||||
@ -526,11 +528,14 @@ class NameImpl {
|
||||
comp1 = comp1.trim();
|
||||
comp2 = comp2.trim();
|
||||
}
|
||||
|
||||
int local;
|
||||
if (syntaxCaseInsensitive) {
|
||||
comp1 = comp1.toLowerCase();
|
||||
comp2 = comp2.toLowerCase();
|
||||
local = comp1.compareToIgnoreCase(comp2);
|
||||
} else {
|
||||
local = comp1.compareTo(comp2);
|
||||
}
|
||||
int local = comp1.compareTo(comp2);
|
||||
|
||||
if (local != 0) {
|
||||
return local;
|
||||
}
|
||||
@ -696,7 +701,7 @@ class NameImpl {
|
||||
comp = comp.trim();
|
||||
}
|
||||
if (syntaxCaseInsensitive) {
|
||||
comp = comp.toLowerCase();
|
||||
comp = comp.toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
|
||||
hash += comp.hashCode();
|
||||
|
||||
@ -28,6 +28,7 @@ package javax.naming.directory;
|
||||
|
||||
import java.util.Hashtable;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.naming.NamingException;
|
||||
import javax.naming.NamingEnumeration;
|
||||
@ -160,7 +161,7 @@ public class BasicAttributes implements Attributes {
|
||||
|
||||
public Attribute get(String attrID) {
|
||||
Attribute attr = attrs.get(
|
||||
ignoreCase ? attrID.toLowerCase() : attrID);
|
||||
ignoreCase ? attrID.toLowerCase(Locale.ENGLISH) : attrID);
|
||||
return (attr);
|
||||
}
|
||||
|
||||
@ -179,13 +180,13 @@ public class BasicAttributes implements Attributes {
|
||||
public Attribute put(Attribute attr) {
|
||||
String id = attr.getID();
|
||||
if (ignoreCase) {
|
||||
id = id.toLowerCase();
|
||||
id = id.toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
return attrs.put(id, attr);
|
||||
}
|
||||
|
||||
public Attribute remove(String attrID) {
|
||||
String id = (ignoreCase ? attrID.toLowerCase() : attrID);
|
||||
String id = (ignoreCase ? attrID.toLowerCase(Locale.ENGLISH) : attrID);
|
||||
return attrs.remove(id);
|
||||
}
|
||||
|
||||
|
||||
@ -28,6 +28,7 @@ package javax.naming.ldap;
|
||||
import java.util.Iterator;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Locale;
|
||||
import java.util.Collections;
|
||||
|
||||
import javax.naming.InvalidNameException;
|
||||
@ -434,8 +435,7 @@ public class Rdn implements Serializable, Comparable<Object> {
|
||||
}
|
||||
|
||||
public int compareTo(RdnEntry that) {
|
||||
int diff = type.toUpperCase().compareTo(
|
||||
that.type.toUpperCase());
|
||||
int diff = type.compareToIgnoreCase(that.type);
|
||||
if (diff != 0) {
|
||||
return diff;
|
||||
}
|
||||
@ -462,7 +462,7 @@ public class Rdn implements Serializable, Comparable<Object> {
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return (type.toUpperCase().hashCode() +
|
||||
return (type.toUpperCase(Locale.ENGLISH).hashCode() +
|
||||
getValueComparable().hashCode());
|
||||
}
|
||||
|
||||
@ -479,7 +479,7 @@ public class Rdn implements Serializable, Comparable<Object> {
|
||||
if (value instanceof byte[]) {
|
||||
comparable = escapeBinaryValue((byte[]) value);
|
||||
} else {
|
||||
comparable = ((String) value).toUpperCase();
|
||||
comparable = ((String) value).toUpperCase(Locale.ENGLISH);
|
||||
}
|
||||
return comparable;
|
||||
}
|
||||
@ -569,7 +569,6 @@ public class Rdn implements Serializable, Comparable<Object> {
|
||||
builder.append(Character.forDigit(0xF & b, 16));
|
||||
}
|
||||
return builder.toString();
|
||||
// return builder.toString().toUpperCase();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -35,6 +35,7 @@ import java.io.UnsupportedEncodingException;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.security.Provider;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Implements the GSSNameSpi for the krb5 mechanism.
|
||||
@ -184,7 +185,7 @@ public class Krb5NameElement
|
||||
} catch (UnknownHostException e) {
|
||||
// use hostname as it is
|
||||
}
|
||||
hostName = hostName.toLowerCase();
|
||||
hostName = hostName.toLowerCase(Locale.ENGLISH);
|
||||
|
||||
temp = temp.append('/').append(hostName);
|
||||
return temp.toString();
|
||||
|
||||
@ -35,6 +35,7 @@ import sun.security.krb5.internal.*;
|
||||
import sun.security.util.*;
|
||||
import java.net.*;
|
||||
import java.util.Vector;
|
||||
import java.util.Locale;
|
||||
import java.io.IOException;
|
||||
import java.math.BigInteger;
|
||||
import sun.security.krb5.internal.ccache.CCacheOutputStream;
|
||||
@ -389,14 +390,14 @@ public class PrincipalName
|
||||
// Looks if canonicalized is a longer format of hostName,
|
||||
// we accept cases like
|
||||
// bunny -> bunny.rabbit.hole
|
||||
if (canonicalized.toLowerCase()
|
||||
.startsWith(hostName.toLowerCase()+".")) {
|
||||
if (canonicalized.toLowerCase(Locale.ENGLISH).startsWith(
|
||||
hostName.toLowerCase(Locale.ENGLISH)+".")) {
|
||||
hostName = canonicalized;
|
||||
}
|
||||
} catch (UnknownHostException e) {
|
||||
// no canonicalization, use old
|
||||
}
|
||||
nameParts[1] = hostName.toLowerCase();
|
||||
nameParts[1] = hostName.toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
nameStrings = nameParts;
|
||||
nameType = type;
|
||||
|
||||
@ -219,7 +219,7 @@ public final class PKCS12KeyStore extends KeyStoreSpi {
|
||||
public Key engineGetKey(String alias, char[] password)
|
||||
throws NoSuchAlgorithmException, UnrecoverableKeyException
|
||||
{
|
||||
KeyEntry entry = entries.get(alias.toLowerCase());
|
||||
KeyEntry entry = entries.get(alias.toLowerCase(Locale.ENGLISH));
|
||||
Key key = null;
|
||||
|
||||
if (entry == null) {
|
||||
@ -296,7 +296,7 @@ public final class PKCS12KeyStore extends KeyStoreSpi {
|
||||
* <i>key entry</i> without a certificate chain).
|
||||
*/
|
||||
public Certificate[] engineGetCertificateChain(String alias) {
|
||||
KeyEntry entry = entries.get(alias.toLowerCase());
|
||||
KeyEntry entry = entries.get(alias.toLowerCase(Locale.ENGLISH));
|
||||
if (entry != null) {
|
||||
if (entry.chain == null) {
|
||||
return null;
|
||||
@ -324,7 +324,7 @@ public final class PKCS12KeyStore extends KeyStoreSpi {
|
||||
* does not contain a certificate.
|
||||
*/
|
||||
public Certificate engineGetCertificate(String alias) {
|
||||
KeyEntry entry = entries.get(alias.toLowerCase());
|
||||
KeyEntry entry = entries.get(alias.toLowerCase(Locale.ENGLISH));
|
||||
if (entry != null) {
|
||||
if (entry.chain == null) {
|
||||
return null;
|
||||
@ -345,7 +345,7 @@ public final class PKCS12KeyStore extends KeyStoreSpi {
|
||||
* not exist
|
||||
*/
|
||||
public Date engineGetCreationDate(String alias) {
|
||||
KeyEntry entry = entries.get(alias.toLowerCase());
|
||||
KeyEntry entry = entries.get(alias.toLowerCase(Locale.ENGLISH));
|
||||
if (entry != null) {
|
||||
return new Date(entry.date.getTime());
|
||||
} else {
|
||||
@ -409,10 +409,10 @@ public final class PKCS12KeyStore extends KeyStoreSpi {
|
||||
// set the keyId to current date
|
||||
entry.keyId = ("Time " + (entry.date).getTime()).getBytes("UTF8");
|
||||
// set the alias
|
||||
entry.alias = alias.toLowerCase();
|
||||
entry.alias = alias.toLowerCase(Locale.ENGLISH);
|
||||
|
||||
// add the entry
|
||||
entries.put(alias.toLowerCase(), entry);
|
||||
entries.put(alias.toLowerCase(Locale.ENGLISH), entry);
|
||||
} catch (Exception nsae) {
|
||||
throw new KeyStoreException("Key protection " +
|
||||
" algorithm not found: " + nsae, nsae);
|
||||
@ -465,7 +465,7 @@ public final class PKCS12KeyStore extends KeyStoreSpi {
|
||||
// Won't happen
|
||||
}
|
||||
// set the alias
|
||||
entry.alias = alias.toLowerCase();
|
||||
entry.alias = alias.toLowerCase(Locale.ENGLISH);
|
||||
|
||||
entry.protectedPrivKey = key.clone();
|
||||
if (chain != null) {
|
||||
@ -473,7 +473,7 @@ public final class PKCS12KeyStore extends KeyStoreSpi {
|
||||
}
|
||||
|
||||
// add the entry
|
||||
entries.put(alias.toLowerCase(), entry);
|
||||
entries.put(alias.toLowerCase(Locale.ENGLISH), entry);
|
||||
}
|
||||
|
||||
|
||||
@ -618,7 +618,7 @@ public final class PKCS12KeyStore extends KeyStoreSpi {
|
||||
public synchronized void engineSetCertificateEntry(String alias,
|
||||
Certificate cert) throws KeyStoreException
|
||||
{
|
||||
KeyEntry entry = entries.get(alias.toLowerCase());
|
||||
KeyEntry entry = entries.get(alias.toLowerCase(Locale.ENGLISH));
|
||||
if (entry != null) {
|
||||
throw new KeyStoreException("Cannot overwrite own certificate");
|
||||
} else
|
||||
@ -635,7 +635,7 @@ public final class PKCS12KeyStore extends KeyStoreSpi {
|
||||
public synchronized void engineDeleteEntry(String alias)
|
||||
throws KeyStoreException
|
||||
{
|
||||
entries.remove(alias.toLowerCase());
|
||||
entries.remove(alias.toLowerCase(Locale.ENGLISH));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -655,7 +655,7 @@ public final class PKCS12KeyStore extends KeyStoreSpi {
|
||||
* @return true if the alias exists, false otherwise
|
||||
*/
|
||||
public boolean engineContainsAlias(String alias) {
|
||||
return entries.containsKey(alias.toLowerCase());
|
||||
return entries.containsKey(alias.toLowerCase(Locale.ENGLISH));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -675,7 +675,7 @@ public final class PKCS12KeyStore extends KeyStoreSpi {
|
||||
* <i>key entry</i>, false otherwise.
|
||||
*/
|
||||
public boolean engineIsKeyEntry(String alias) {
|
||||
KeyEntry entry = entries.get(alias.toLowerCase());
|
||||
KeyEntry entry = entries.get(alias.toLowerCase(Locale.ENGLISH));
|
||||
if (entry != null) {
|
||||
return true;
|
||||
} else {
|
||||
@ -1274,7 +1274,8 @@ public final class PKCS12KeyStore extends KeyStoreSpi {
|
||||
if (password != null && s.available() > 0) {
|
||||
MacData macData = new MacData(s);
|
||||
try {
|
||||
String algName = macData.getDigestAlgName().toUpperCase();
|
||||
String algName =
|
||||
macData.getDigestAlgName().toUpperCase(Locale.ENGLISH);
|
||||
if (algName.equals("SHA") ||
|
||||
algName.equals("SHA1") ||
|
||||
algName.equals("SHA-1")) {
|
||||
@ -1479,7 +1480,7 @@ public final class PKCS12KeyStore extends KeyStoreSpi {
|
||||
if (alias == null)
|
||||
alias = getUnfriendlyName();
|
||||
entry.alias = alias;
|
||||
entries.put(alias.toLowerCase(), entry);
|
||||
entries.put(alias.toLowerCase(Locale.ENGLISH), entry);
|
||||
} else if (bagItem instanceof X509Certificate) {
|
||||
X509Certificate cert = (X509Certificate)bagItem;
|
||||
// Insert a localKeyID for the corresponding cert
|
||||
|
||||
@ -54,7 +54,7 @@ abstract class JavaKeyStore extends KeyStoreSpi {
|
||||
// regular JKS
|
||||
public static final class JKS extends JavaKeyStore {
|
||||
String convertAlias(String alias) {
|
||||
return alias.toLowerCase();
|
||||
return alias.toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -879,7 +879,8 @@ public class LDAPCertStore extends CertStoreSpi {
|
||||
if (hashCode == 0) {
|
||||
int result = 17;
|
||||
result = 37*result + getPort();
|
||||
result = 37*result + getServerName().toLowerCase().hashCode();
|
||||
result = 37*result +
|
||||
getServerName().toLowerCase(Locale.ENGLISH).hashCode();
|
||||
hashCode = result;
|
||||
}
|
||||
return hashCode;
|
||||
|
||||
@ -33,6 +33,7 @@ import java.util.Enumeration;
|
||||
import java.util.Hashtable;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.Vector;
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.net.ssl.SSLSession;
|
||||
import javax.net.ssl.SSLSessionContext;
|
||||
@ -166,7 +167,8 @@ final class SSLSessionContextImpl implements SSLSessionContext {
|
||||
}
|
||||
|
||||
private String getKey(String hostname, int port) {
|
||||
return (hostname + ":" + String.valueOf(port)).toLowerCase();
|
||||
return (hostname + ":" +
|
||||
String.valueOf(port)).toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
|
||||
// cache a SSLSession
|
||||
|
||||
@ -25,6 +25,8 @@
|
||||
|
||||
package sun.security.tools;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* <p> This class provides several utilities to <code>KeyStore</code>.
|
||||
*
|
||||
@ -63,7 +65,7 @@ public class KeyStoreUtil {
|
||||
} else if(storetype.equalsIgnoreCase("Windows-ROOT")) {
|
||||
return "Windows-ROOT";
|
||||
} else {
|
||||
return storetype.toUpperCase();
|
||||
return storetype.toUpperCase(Locale.ENGLISH);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -266,8 +266,8 @@ public class HostnameChecker {
|
||||
*/
|
||||
private static boolean matchAllWildcards(String name,
|
||||
String template) {
|
||||
name = name.toLowerCase();
|
||||
template = template.toLowerCase();
|
||||
name = name.toLowerCase(Locale.ENGLISH);
|
||||
template = template.toLowerCase(Locale.ENGLISH);
|
||||
StringTokenizer nameSt = new StringTokenizer(name, ".");
|
||||
StringTokenizer templateSt = new StringTokenizer(template, ".");
|
||||
|
||||
@ -296,8 +296,8 @@ public class HostnameChecker {
|
||||
*/
|
||||
private static boolean matchLeftmostWildcard(String name,
|
||||
String template) {
|
||||
name = name.toLowerCase();
|
||||
template = template.toLowerCase();
|
||||
name = name.toLowerCase(Locale.ENGLISH);
|
||||
template = template.toLowerCase(Locale.ENGLISH);
|
||||
|
||||
// Retreive leftmost component
|
||||
int templateIdx = template.indexOf(".");
|
||||
|
||||
@ -159,7 +159,7 @@ public class DNSName implements GeneralNameInterface {
|
||||
* @return a hash code value for this object.
|
||||
*/
|
||||
public int hashCode() {
|
||||
return name.toUpperCase().hashCode();
|
||||
return name.toUpperCase(Locale.ENGLISH).hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -153,7 +153,7 @@ public class RFC822Name implements GeneralNameInterface
|
||||
* @return a hash code value for this object.
|
||||
*/
|
||||
public int hashCode() {
|
||||
return name.toUpperCase().hashCode();
|
||||
return name.toUpperCase(Locale.ENGLISH).hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -23,12 +23,14 @@
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 4635618
|
||||
* @bug 4635618 7059542
|
||||
* @summary Support for manipulating LDAP Names
|
||||
* JNDI name operations should be locale independent
|
||||
*/
|
||||
|
||||
import javax.naming.ldap.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Locale;
|
||||
import java.util.List;
|
||||
import javax.naming.InvalidNameException;
|
||||
|
||||
@ -39,52 +41,61 @@ public class CompareToEqualsTests {
|
||||
|
||||
public static void main(String args[])
|
||||
throws Exception {
|
||||
|
||||
/**
|
||||
* Test cases:
|
||||
* 1) Same RDNs.
|
||||
* 2) same RDN sequence with an AVA ordered differently.
|
||||
* 3) RDN sequences of a differing AVA.
|
||||
* 4) RDN sequence of different length.
|
||||
* 5) RDN sequence of different Case.
|
||||
* 6) Matching binary return values.
|
||||
* 7) Binary values that don't match.
|
||||
*/
|
||||
String names1[] = new String [] {
|
||||
Locale reservedLocale = Locale.getDefault();
|
||||
try {
|
||||
/**
|
||||
* Test cases:
|
||||
* 1) Same RDNs.
|
||||
* 2) same RDN sequence with an AVA ordered differently.
|
||||
* 3) RDN sequences of a differing AVA.
|
||||
* 4) RDN sequence of different length.
|
||||
* 5) RDN sequence of different Case.
|
||||
* 6) Matching binary return values.
|
||||
* 7) Binary values that don't match.
|
||||
*/
|
||||
String names1[] = new String [] {
|
||||
"ou=Sales+cn=Bob", "ou=Sales+cn=Bob", "ou=Sales+cn=Bob",
|
||||
"ou=Sales+cn=Scott+c=US", "cn=config"};
|
||||
|
||||
String names2[] = new String [] {
|
||||
String names2[] = new String [] {
|
||||
"ou=Sales+cn=Bob", "cn=Bob+ou=Sales", "ou=Sales+cn=Scott",
|
||||
"ou=Sales+cn=Scott", "Cn=COnFIG"};
|
||||
|
||||
int expectedResults[] = {0, 0, -1, -1, 0};
|
||||
int expectedResults[] = {0, 0, -1, -1, 0};
|
||||
|
||||
for (Locale locale : Locale.getAvailableLocales()) {
|
||||
// reset the default locale
|
||||
Locale.setDefault(locale);
|
||||
|
||||
for (int i = 0; i < names1.length; i++) {
|
||||
checkResults(new LdapName(names1[i]),
|
||||
for (int i = 0; i < names1.length; i++) {
|
||||
checkResults(new LdapName(names1[i]),
|
||||
new LdapName(names2[i]), expectedResults[i]);
|
||||
}
|
||||
|
||||
byte[] value = "abcxyz".getBytes();
|
||||
Rdn rdn1 = new Rdn("binary", value);
|
||||
ArrayList rdns1 = new ArrayList();
|
||||
rdns1.add(rdn1);
|
||||
LdapName l1 = new LdapName(rdns1);
|
||||
|
||||
Rdn rdn2 = new Rdn("binary", value);
|
||||
ArrayList rdns2 = new ArrayList();
|
||||
rdns2.add(rdn2);
|
||||
LdapName l2 = new LdapName(rdns2);
|
||||
checkResults(l1, l2, 0);
|
||||
|
||||
l2 = new LdapName("binary=#61626378797A");
|
||||
checkResults(l1, l2, 0);
|
||||
|
||||
l2 = new LdapName("binary=#61626378797B");
|
||||
checkResults(l1, l2, -1);
|
||||
|
||||
System.out.println("Tests passed");
|
||||
}
|
||||
} finally {
|
||||
// restore the reserved locale
|
||||
Locale.setDefault(reservedLocale);
|
||||
}
|
||||
|
||||
byte[] value = "abcxyz".getBytes();
|
||||
Rdn rdn1 = new Rdn("binary", value);
|
||||
ArrayList rdns1 = new ArrayList();
|
||||
rdns1.add(rdn1);
|
||||
LdapName l1 = new LdapName(rdns1);
|
||||
|
||||
Rdn rdn2 = new Rdn("binary", value);
|
||||
ArrayList rdns2 = new ArrayList();
|
||||
rdns2.add(rdn2);
|
||||
LdapName l2 = new LdapName(rdns2);
|
||||
checkResults(l1, l2, 0);
|
||||
|
||||
l2 = new LdapName("binary=#61626378797A");
|
||||
checkResults(l1, l2, 0);
|
||||
|
||||
l2 = new LdapName("binary=#61626378797B");
|
||||
checkResults(l1, l2, -1);
|
||||
|
||||
System.out.println("Tests passed");
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user