-
Bug
-
Resolution: Won't Fix
-
P4
-
None
-
1.4.2
-
x86
-
windows_2000
Name: gm110360 Date: 07/16/2003
FULL PRODUCT VERSION :
java version "1.4.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92)
Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)
FULL OPERATING SYSTEM VERSION :
Microsoft Windows 2000 [Version 5.00.2195]
A DESCRIPTION OF THE PROBLEM :
KeyStore converts all characters in its key aliases to
lower case. For example if you put in the key alias "ABC"
you get out the key alias "abc" when you enumerate the
KeyStore's key aliases.
KeyStore should not tranform its key aliases. In general,
methods should never have the side-effect of tranforming
data unless it is its function to do so.
In my application, this buggy side-effect really messes
things up, because what I put in to KeyStore is not what I
get out from KeyStore.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Compile enclosed JavaBug4.java program.
2. Run JavaBug4 program.
3. You should see the following output:
Please wait for SunJCE to initialize...
The key alias [Go SF Giants!] is added to the KeyStore.
BUG: KeyStore changed the key alias to lowercase. Now it's
[go sf giants!] which is wrong.
EXPECTED VERSUS ACTUAL BEHAVIOR :
The JavaBug4 program produces the following output:
Please wait for SunJCE to initialize...
The key alias [Go SF Giants!] is added to the KeyStore.
BUG: KeyStore changed the key alias to lowercase. Now it's
[go sf giants!] which is wrong.
******
What should occur when enumerating aliases in KeyStore is
that the original aliases should be returned. The key
aliases should not be changed.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.util.*;
import javax.crypto.*;
import java.security.*;
class JavaBug4
{
public static void main(String[] args)
{
final String alias = "Go SF Giants!";
final String password = "Win World Series!";
System.out.println("Please wait for SunJCE to initialize...");
try
{
KeyStore keyStore = KeyStore.getInstance("JCEKS", "SunJCE");
keyStore.load(null, password.toCharArray());
KeyGenerator keyGen = KeyGenerator.getInstance("Blowfish");
SecretKey secretKey = keyGen.generateKey();
System.out.println("The key alias [" + alias
+ "] is added to the KeyStore.");
keyStore.setKeyEntry(alias, (SecretKey)secretKey,
password.toCharArray(), null);
for (Enumeration e = keyStore.aliases(); e.hasMoreElements();)
System.out.println(
"BUG: KeyStore changed the key alias to lowercase. "
+ "Now it's [" + (String)e.nextElement()
+ "] which is wrong.");
}
catch (Exception e) { e.printStackTrace(); }
}
}
---------- END SOURCE ----------
CUSTOMER WORKAROUND :
Unfortunately, there is no workaround.
(Incident Review ID: 165768)
======================================================================