Showing posts with label Encryption. Show all posts
Showing posts with label Encryption. Show all posts

Wednesday, 13 July 2016

Encryption and Decryption of Sensitive Information using Pipeline Components in BizTalk

In this article, I will brief on encrypting and decrypting the sensitive information using custom pipeline component in BizTalk.

Lets create a class library project to implement Execute pipeline component as shown below, relevant reference are added to develop custom component.
Now, lets define properties to specify the cryption type (encryption or decryption) on data and data node as shown. Cryption Type is defined as enum type as below.
Here is the implementation of  IPersistPropertyBag interface, for CryptionType and Element Properties.
Implementation of IComponent Interface is shown below, based on the CryptionType property and Element Name specify, the data would be encrypted or decrypted.

Internal Encryption and Decryption implementation,
Lets create encryption receive pipeline and bring in EncryptDecrypt Component to Decode stage and define the properties as below.
Similarly, Send Pipeline to Decrypt the information
Deploy the solution and define a receive port and location then associate the EncryptData Receive Pipeline as shown below.
Similarly, define two send ports to subscribe the message received on the receive, 1 send port will have DecryptData Send Pipeline and other would be a simple pass through pipeline.
Pass through Send Pipeline, subscribes the encrypted message.
Process messages and verify the result. 
This mechanism allow us to transfer sensitive information in a is a secured manner and thus 3rd party system would be able to access the information.

Custom Funtiods in BizTalk | Encryption and Decryption in Map


In this article, I will brief about developing a custom function in BizTalk for encrypting and decrypting the sensitive information.  Actually, the right place to encrypt and decrypt sensitive information is at the biztalk pipeline using custom component, which I would cover in later topic.

Create a class library project and add the reference of Microsoft.BizTalk.BaseFunctoids assembly and then derive our functoid from Microsoft.BizTalk.BaseFunctoids.  

In the class construct provide the function name, function bitmaps to be displayed in the mapper, tool tip text, description and a functoid ID as shown. Specify category the functoid belongs to (Math, Logical, String etc..) and set input and output parameters restrictions and connection types. finally, specify the function to call.
Here is the encrpytion and decryption methods, compile the library place the dll in BizTalk Mapper folder then GAC it.
Create a new BizTalk Project, already Source, Internal Canonical and Target Schemas are defined. Let create a BizTalk map and load Source and Canonical  as shown; the sensitive information in the source would be encrypted using custom functiod which we built. In order to add the custom function to Toolbox, right click on it then select  choose items.
Then from the BizTalk Mapper tab; select the custom functiod as shown below.
Now, custom funtiod is available under the category we specified.
Another map Canonical to Target is added, where the information is  decrypt using custom function and passed to target system.
Lets now test the both the maps and verify the results.
Encryption of Data,
 Decryption of Data