Loading...
A SHA-256 hash is automatically generated for each outgoing message from a destination connector. See the Message Hash variable on Destination Mappings. Using that variable, the hash value can be sent to the destination alongside the message content. The recipient can use the hash to validate that the message hasn't been altered.
An example use case is to include the hash value in a header using an HTTP Sender.
To validate the integrity of incoming messages, you can use JavaScript code in a Source Filter. For example, using an HTTP Receiver and assuming the hash value is being sent in a header named hash, you can use the following code in a JavaScript Filter step:
var receivedHash = sourceMap.get('headers').getHeader('hash'); var generatedHash = HashUtil.generate(connectorMessage.getRawData(), 'UTF-8', 'SHA-256'); return receivedHash != null && generatedHash != null && generatedHash == receivedHash; |