2

I need to add signature to a file using apache camel. when i checked in camel documentation, found crypto:sign component where it creates the signature and stores it in the Header keyed by the constant org.apache.camel.component.crypto.DigitalSignatureConstants.SIGNATURE, i.e. "CamelDigitalSignature". The signature can be verified using crypto:verify component, by reading in the contents of this header and do the verification calculation.

But in my case, i need to write the signature to a separate file. for example if the input file is sample. After adding signature there should be two output files (1. sample 2. sample.signed). sample is original file and sample.signed is signature file.

Signature addition should be done using PGP Technique. Can anyone help me on this

rocky
  • 753
  • 2
  • 10
  • 26

1 Answers1

2

once the signature is set in header and all the other processing is complete follow the below steps to write it to a file:

  1. Set the header as the exchange body

<setBody> <simple>${header.CamelDigitalSignature} </simple></setBody>

  1. Set the original file name without extension in header under a different key.

<setHeader name="oFileName"><simple>${file:onlyname.noext}</simple></setHeader>

  1. Then use the below code to write it to a file:

<toD uri="file://path?filename=${header.oFileName}.desired extension/>

Note: Step 2 assumes that the you are using a file component to read the file.

VarunKrish
  • 179
  • 1
  • 9