I'm having some difficulty in figuring out my latest delima. I've had
my environment configured for a while now, and I recently upgraded
(which I'm now regretting) both my JDK and my Eclipse IDE. Since the
upgrade, I've been having trouble getting my PDF Encryption piece to
work within FOP. I've restepped through the directions on
(http://xml.apache.org/fop/pdfencryption.html), but I continue to have
the same problems...but only within Eclipse. I've built some Junit
tests that perform various transformations, some involving encryption.
The encryption piece throws the error "Cannot find provider supporting
RC4". I decided to modify my test to include the code listed below to
see just what providers were being registered, and what algorithms these
providers were registering. I've run this Junit test outside of Eclipse
and it works flawlessly, and I've also run this test inside Eclipse
running Tomcat (called the test from a servlet) and it worked
flawlessly. So, does anyone know why my security settings would be
different inside of Eclipse running Junit? I apologize that this is not
exactly an issue for this group.
//Validate I have an RC4 capable provider
Provider[] providers = Security.getProviders("Cipher.RC4");
assertNotNull("No providers supporting RC4", providers);
assertTrue("No providers supporting RC4", providers.length > 0);
//List all RC4 capable providers
for (int i=0;i<providers.length;i++)
{
System.out.println("Provider Name=" + providers[i].getName());
System.out.println("Provider Info=" + providers[i].getInfo());
}
//Now dump all available Cipher's from all the providers
providers = Security.getProviders();
for(int i = 0; i < providers.length; i++)
{
Iterator it = providers[i].keySet().iterator();
while(it.hasNext())
{
String key = (String) it.next();
if(key.startsWith("Alg.Alias.Cipher"))
{
System.out.println("Cipher=" + key.substring(16));
}
else if(key.startsWith("Cipher"))
{
System.out.println("Cipher=" + key.substring(6));
}
}
}
//now the test to end all tests...see if the RC4 cipher can be
instantiated
try
{
Cipher c = Cipher.getInstance("RC4"); //<-- "Cannot find provider
supporting RC4"
assertNotNull("No providers supporting RC4", c);
}
catch (NoSuchAlgorithmException e)
{
e.printStackTrace();
try
{
providers = java.security.Security.getProviders("Cipher.RC4");
Cipher c = Cipher.getInstance("RC4", providers[0]);//<!--"The
provider BC may not be signed by a trusted party"
assertNotNull("Provider does not support RC4", c);
}
catch (NoSuchAlgorithmException ex)
{
e.printStackTrace();
throw ex;
}
}
_________________
Jeremy Nix
Senior Application Developer
Southwest Financial Ltd.
[EMAIL PROTECTED]
(513) 621-6699 ext 1158
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]