Software AG Products 10.7 | Integrating On-Premises and Cloud Applications | Managing MIME messages | Extracting Data from MIME and S/MIME Messages | Extracting the Payload from a Signed MIME Message | Example—Extracting Content from a Signed S/MIME Message
 
Example—Extracting Content from a Signed S/MIME Message
The following flow service extracts the payload from a signed MIME message.
To run this example, you must have a private key, the associated certificate, and the certificate of the CA that signed it. These credentials are needed by the helper service, sample.smime.helpers:acquireSignedMsg, which generates the signed test message used in this example. You will need to edit the first step in the helper service to specify the location of these files on your system.
This service assumes that the signature contains the signer’s certificate chain, so you do not need to supply a certificate chain at run time.
Flow service that extracts the content from a signed MIME message
Step
Description
1
This step acquires an InputStream containing a signed MIME message. This example uses a helper service to produce a test message. In a production solution, it is more likely that a MIME message would be passed into the pipeline by a content handler or a back-end system.
2
This step takes the InputStream generated in step 1 and processes the signature. If the signature is valid, this step produces a MIME object called mimeData, containing the parsed message. If the signature is invalid, this step returns an empty mimeData object and sets the verify flag to “false.”
3
This step checks whether or not the signature was processed successfully by testing the value of the output variable verify. If verify is “true,” this step extracts the payload and converts it to a String. If verify is “false,” this step collects the error information in the pipeline and passes it to an error-logging service.