Software AG Products 10.7 | Integrating On-Premises and Cloud Applications | Managing MIME messages | Extracting Data from MIME and S/MIME Messages | Extracting Data from a Signed and Encrypted MIME Message | Example—Extracting Content from a Signed and Encrypted S/MIME Message
 
Example—Extracting Content from a Signed and Encrypted S/MIME Message
The following flow service extracts data from MIME and S/MIME messages.
To run this example, you must provide the keystore alias and key alias for the recipient's private key. Some of these credentials are needed by the helper service, sample.smime.helpers:acquireSignedAndEncryptedMsg, which generates the 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.
When you run this service from Designer, it will prompt you for the following:
Input Parameter
Description
recipientsKeystoreAlias
String Alias of the recipient’s keystore.
recipientsKeyAlias
String Alias of the private key in the recipient’s keystore.
Flow service that extracts the content from a signed and/or encrypted MIME message
Step
Description
1
This step acquires an InputStream containing a signed and encrypted MIME message. This example uses a helper service to produce the 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 attempts to create a MIME object from the InputStream produced in step 1.
3
This step tests the encrypted flag to see whether the message is encrypted. If it is, it obtains the credentials needed to decrypt the message and passes those credentials and the message to the processEncryptedData service. Note that the stream output variable is linked to the SMimeEnvStream input parameter, because the original InputStream from step 1 was emptied by step 2.
Note that if encrypted is “false,” execution falls through to step 4.
4
This step tests the signed flag to see whether the message is signed. If it is, it passes the message to the processSignedData service. Note that the stream output variable is linked to the SMimeEnvStream input parameter, because the original InputStream from step 1 was emptied in step 2. (When a message is decrypted in step 3, the processEncryptedData service produces the stream used by this step.)
Note that if signed is “false,” execution falls through to step 5.
5
This step extracts the data from the mimeData object produced by the preceding steps.