You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-users@xmlgraphics.apache.org by Jeremy Nix <Je...@sfsltd.com> on 2003/07/25 15:20:37 UTC

PDF Encryption w/ JDK 1.4.2, BouncyCastle, and Eclipse 3.0m2

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.
Jeremy.Nix@sfsltd.com
(513) 621-6699 ext 1158


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org


Re: PDF Encryption w/ JDK 1.4.2, BouncyCastle, and Eclipse 3.0m2

Posted by "J.Pietschmann" <j3...@yahoo.de>.
Jeremy Nix wrote:

> 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.

Did you tell Eclipse to use the upgraded JDK?
Did you add the bouncy castle provider to the java.security
properties for the JDK Eclipse uses?

Then there's also the policy file, although this may not apply
to you.

J.Pietschmann



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org