Monday, January 4

PGP Encryption for Java

Setting up java to work with an encryption provider can be difficult.  From the day that PGP was declared a weapon, setting up encryption became a lot harder.  The saga of PGP is a fairly entertaining story and worth a read.

These steps should bring you from nothing to a working cryptographic development environment on a Linux machine using Eclipse and Maven.

 1. Create a new maven project from the quickstart archetype
 2. Make sure the project is set up to build to 1.6 both in the POM and the Eclipse builder
 3. If you do not already have the gpg package installed on your machine: sudo apt-get install gnupg
 4. Execute gpg - -gen-key ( this will walk you through the process of generating a new gpg key )
 5. Create a keys directory in your project and move the files generated during key generation there.
 6. On an Ubuntu machine, the basic java policy files are stored in /etc/java-{major_version_number}-sun/security, Go to the downloads page for the correct version of Java, find the JCE Unlimited Strength Jurisdiction Policy Files(, unzip and move the jar files to the /etc/../security directory with some type of tag in the name to delineate them as the unrestricted files.  Then move the current files from JAVA_HOME/jre/lib/security to /etc/.../security and tag them as restricted.
 7. Create a symbolic link to the unrestricted files in the JAVA_HOME/jre/lib/security directory.
Reblog this post [with Zemanta]

No comments: