Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How would I use Maven to install the JCE Unlimited Strength Policy files?

Tags:

Some code I have requires the JCE unlimited Strength Policy Files. I'd like to add this dependency into the Maven Pom file so the other developers on my team don't have to individually each apply this to their systems.

I realize that the systems this is eventually deployed to will need to have the JCE files manually installed. This is a development solution only.

I was thinking that we would add the policy files to our repository and maven would be able to handle installation, but I am surprised that I can't find anyone else doing this (and blogging about it.).

like image 856
Jeff Martin Avatar asked Aug 06 '10 16:08

Jeff Martin


People also ask

How do I set crypto policy Unlimited?

setProperty("crypto. policy", "unlimited"); We must set the property before the JCE framework initialization. It defines a directory under JAVA_HOME/jre/lib/security/policy for policy files.

What is unlimited JCE policy?

Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files Download. The Java Cryptography Extension enables applications to use stronger versions of standard algorithms. Current versions of the JDK do not require these policy files. They are provided here for use with older version of the JDK.


1 Answers

I've found that answer, when googling for Maven dependencies for policy JARs and realized that it's JRE installation specific, thus fixing this as part of Maven build will work only for developers and only when you have rights to /jre/lib/security folder. For me the following code hack works much better (invoke this as one of the very first things your application does):

    try {         Field field = Class.forName("javax.crypto.JceSecurity").getDeclaredField("isRestricted");         field.setAccessible(true);         field.set(null, java.lang.Boolean.FALSE);     } catch (ClassNotFoundException | NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException ex) {         ex.printStackTrace(System.err);     } 
like image 126
Bart Prokop Avatar answered Oct 09 '22 03:10

Bart Prokop