Encrypt Data in Oracle Integration Cloud using OCI Vault Service

Encrypt Data in Oracle Integration Cloud using OCI Vault Service

In one of my previous blogs, I talk about storing the payload in a database. Now to demonstrate end to end steps, I had saved the payload in clear text. While there are features in database to control access to these tables but a better approach would be to encrypt this payload. And encryption/decryption is a very common requirement that we see in integration projects. Today, we will see how we can call OCI Vault service and its APIs to perform this task from Oracle Integration Cloud.

OCI Vault

Before we jump into OIC, let’s first create a key in OCI Vault. Log into your OCI Cloud Tenancy and in Identity & Security go to Vault

No alt text provided for this image

Click Create Vault.

In case you do not have access, please ask your Administrator to grant your user group appropriate policies as detailed in the documentation.

No alt text provided for this image

Next in the wizard, provide any name as per your naming convention and click Create Vault

No alt text provided for this image

Once the Vault is created, let’s create our first Master Encryption Key by clicking on Create Key

No alt text provided for this image

Here provide the information like Name of the key, Algorithm and click Create Key.

OCI Vault supports importing your own key or generate a key, I have chosen the second option. And in algorithms it supports AES, RSA and ECDSA. For our purpose we need AES.

No alt text provided for this image

Before we go into OIC to use this key for encryption, we need to copy the following information. So please copy them or later when can come to OCI Vault and copy these values.

1)?????Cryptographic Endpoint

2)?????Encryption key OCID

No alt text provided for this image

OCI Vault service provide extensive APIs that can be used by third party systems. The reference of these APIs can be found here in the documentation.

OIC Recipe Encrypt Decrypt Data

Now let’s log into OIC and here we will take benefit of one of the recipes that uses OCI Vault service to encrypt and decrypt data. Log into Oracle Integration Cloud and find this recipe and install it in your environment

No alt text provided for this image

Lets configure this recipe, as you can see it has two connections.

1)?????Oracle Rest Connection: It is used for Trigger.

2)?????Oracle OCI Vault Connection : It is used to call the OCI Vault API

No alt text provided for this image

Let’s edit the Oracle OCI Vault Connection.

In Connection URL, provide the Cryptographic Endpoint that we had copied earlier from OCI Vault screen. And for security policy we will use OCI Signature Version 1 policy. Please refer to this blog for step by step guide on how to set it up.

https://blogs.oracle.com/integration/post/oci-signature-in-rest-adapter-for-oci-rest-apis

Once it is setup, kindly save and test it.

No alt text provided for this image

Now that we have the recipe connections done. We have one lookup in this recipe that we need to configure

No alt text provided for this image
No alt text provided for this image

  • KeyId : Provide the OCI Vault Encryption key OCID that we have copied earlier after creating OCI Encryption Key
  • EmailTo & EmailFrom : The recipe in case of error, sends a notification email so provide email address where you would like email to be sent and a from email address.
  • ?APIVersion : This value you can get from OCI API documentation e.g. from Encrypt API and at the time of writing this blog the version is 20180608

After configuring and saving the lookup. You will notice there are two integrations in this recipe. One to Encrypt the data and the other to Decrypt the data. Go ahead and activate both these integrations. You can go to Design->Integration and find these integrations and not only view these but modify also but for my use case this meets the requirement cent percent. So no need of modification for me.

No alt text provided for this image

Oracle Integration calling Recipe Integration

Now that our recipe has been configured. Let’s use this in one of the integrations. I will take you back to my previous blogs where I was storing payload as plain text into Oracle ATP database table. Now we will pass and store encrypted data.

A quick refresher, in this integration we had used StageFile to save the payload as is using opaqueElement before inserting the data in the database table.

No alt text provided for this image

Now we will introduce the step to encrypt this data right before invoking the database. So from the Actions menu on the right drop the Integrations Action after Stage File (ReadOpaque) action.

No alt text provided for this image

It opens the Integration Adapter wizard, in Basic Info provide a name.

No alt text provided for this image

Next in Select Integrations choose Oracle Encrypt Data. Please note, you will only find activated integrations here so ensure this recipe integration has been activated.

No alt text provided for this image

It has only one operation Post, select that. View the summary and click Done.

No alt text provided for this image

Now our integration looks like this, we have a mapper for EncryptPayload integration to edit

No alt text provided for this image

In the mapper, we will pass our Payload that is coming from StageFile-ReadOpaque activity in the opaqueElement. As we had seen in earlier post, this is in base64 thus we are using decodebase64 function here. This is specific to my use case, to use EncryptData Integration, we just need to pass plain text and here we are converting the data into plain text by using decodebase64 function.

Finally mapping opaqueElement to PlainText in the target.

No alt text provided for this image

Now the mapper that sends the data to EncryptData integration has been setup. We will update the mapper that is inserting records in our ATP Table

No alt text provided for this image


It used to send payload from Stagefile but now we shall be passing the encrypted data coming out of EncryptData integration. So in our mapping, we have mapped EncryptPayload Response and the element we have mapped is Cipher Text to our payload element in the database table.

No alt text provided for this image

Testing the Integration

Now that we have completed this integration, let’s activate and test it.

No alt text provided for this image

I can see this time the payload that is saved in the ATP database is encrypted.

No alt text provided for this image

If we want to decrypt this, we can use the other integration in the recipe i.e. Oracle Decrypt Data. But I will leave that for you to test. I can assure you that works as flawlessly as this one.

Conclusion

Encrypting and Decrypting data is a common requirement. Oracle Cloud Infrastructure provides OCI Vault service that can manage keys and the APIs that can be utilized for this task. There are other methods available and in some cases this might not be the most efficient way due to multiple API calls. But it’s a simple way to achieve the task where it meets your requirement.

And OIC provides a recipe that you can easily configure and use in any of your integrations. While recipes are editable, in this case I did not have to make any modifications as it meets my requirements completely.

I have used?Oracle Integration 3?here for my screenshots. If you are currently using Oracle Integration 2, you can follow the exact same steps to achieve the goal.

Raheem Shaik

Expert on || OIC || SOA || OSB || SQL || Agile Methodologies

8 个月

Thank you helpful, But I have a query how the key will use some other application to send crypted data into our OIC Integration.?

回复
Kabad ul Hasan

Technology Leadership. Enterprise and Cloud Architecture, Emerging Technologies, Pre-sales

2 年

Thanks Harris Qureshi very helpful.

Bhavesh Shah

Technology Architect @ Oracle | Helping Customers Realize Digital Goals with Oracle Cloud ERP, SCM, OCI, Gen AI, PaaS, SaaS | TOGAF? 9 Certified Enterprise Architect

2 年

Good one but feel the process of importing external keys into OCI vault needs to be simplified.

要查看或添加评论,请登录

Harris Qureshi的更多文章

社区洞察

其他会员也浏览了