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 an Encrypted MIME Message | How Do You Know Whether the Message Is Encrypted?
 
How Do You Know Whether the Message Is Encrypted?
If your solution always receives encrypted messages, you can simply pass those messages to processEncryptedData when you receive them. However, if your solution receives both encrypted and clear-text messages, you will need to “test” a message to see whether or not it is encrypted, and pass only encrypted messages to the processEncryptedData service.
To discover whether a MIME message is encrypted, pass it to the createMimeData service and check the status of the encrypted variable afterwards. If the value of encrypted is “true,” you must pass the message to processEncryptedData to be decrypted.
Note:
When you process an InputStream with createMimeData, that InputStream is emptied and is no longer available to other services. For this reason, createMimeData returns a copy of the original message stream in the output variable called stream. You pass this variable to processEncryptedData if the original InputStream has been emptied by createMimeData. For additional information about InputStreams, see Working with InputStreams.