Creating an excel output is quite common in MuleSoft. But sometime we need to assign a password protection to the excel sheet. In this post, I am going to explain how to achieve this in Mulesoft.
What is the Problem?
MuleSoft provides a way to transform the output to css or excel but how to make an excel file password protected.
Solution
Remember to store sensitive information, we protect excel sheet. So how do we create a password protected file? There is no inbuilt option in MuleSoft. There are various ways but I am going to suggest using Java class to achieve this.
We are going to use Apache POI to access, create excel sheet and then protect it with a password.
We will create a Java class for it. Remember once you protect an excel file with password, you cannot get the original payload using MuleSoft without decrypting it back.
List Of Steps
Use Transform to get excel file content in payload
Add Apache POI dependency in pom
Create Java class, get payload in stream
Add encryptor method to password protect file with given password
If you are using Cloudhub, you may use /tmp location to store unprotected file temporarily or if on premise, select folder path from local file system.
Please Share this post with your friends community.