Apache Camel has a simple tool to aid in the encryption/decryption of files using PGP.
In order to set this up, you will need to do some legwork beforehand.
-
Install the crypto library in your POM
-
XML
<dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-crypto</artifactId> </dependency>
-
-
Generate a PGP keypair. This can be accomplished in many ways, but a standard way of handling it is using GPG on your unix box (or WSL).
-
Be sure to note the username and passphrase you selected
-
Be sure to follow encryption algorithm guidelines if they are provided by the client
-
-
Receive a public key from the client
-
Populate your secret key and the client’s public key into “resources”
-
this must be done locally as Platform Manager insists that resources be in json format, but these keys are asc
-
Here is an example route
<routes xmlns="http://camel.apache.org/schema/spring">
<route xmlns="http://camel.apache.org/schema/spring" id="testDecryption">
<from uri="file:{{testDecryption.directory}}?include={{testDecryption.filePattern}}&{{file-parameters}}"/>
<log message="Received encrypted file - ${header[CamelFileNameOnly]}" />
<log message="Encrypted Body ${body}" />
<unmarshal><pgp keyFileName="{{testDecryption.secretKey}}" keyUserid="{{testDecryption.email}}" password="{{pfx:secret_key_password}}"/></unmarshal>
<log message="Decrypted Body ${body}" />
<marshal><pgp keyFileName="{{testEncryption.publicKey}}" keyUserid="{{testEncryption.email}}"/></marshal>
<log message="Re-encrypted body ${body}"/>
<to uri="file:{{testEncryption.directory}}?fileName=output.pgp" />
</route>
</routes>