Successfully reported this slideshow.
Your SlideShare is downloading. ×

Encrypting/Decrypting mule

Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Loading in …3
×

Check these out next

1 of 17 Ad

More Related Content

Advertisement

Similar to Encrypting/Decrypting mule (20)

More from Anirban Sen Chowdhary (20)

Advertisement

Recently uploaded (20)

Encrypting/Decrypting mule

  1. 1. By Anirban Sen Chowdhary
  2. 2. .
  3. 3. Fortunately we have base64-encoder-transformer and base64- decoder-transformer available in our Mule
  4. 4. So, to encrypt a payload in our Mule flow, we can use base64-encoder-transformer as follows :- As you can see we have used a file inbound to pick a file in our flow, and then we encrypt it with base64-encoder-transformer and the output of the flow will produce a encrypted file
  5. 5. Our corresponding Mule flow will be as follows :- <flow name="encryptFlow1" doc:name="encryptFlow1"> <file:inbound-endpoint path="E:backuptest" responseTimeout="10000" doc:name="File"> <file:filename-regex-filter pattern="abc.doc" caseSensitive="false" /> </file:inbound-endpoint> <base64-encoder-transformer encoding="utf8" /> <logger level="INFO" message="#[message.payloadAs(java.lang.String)]" /> <file:outbound-endpoint path="E:backuptestnewfolder" responseTimeout="10000" doc:name="File" /> </flow>
  6. 6. As you can see in the code it will pick a file called abc.doc from E:backuptest location , encrypt it and put the encrypted file to E:backuptestnewfolder So, let us place a file abc.doc in the source folder as follows :-
  7. 7. Let run our application and we can see, the file has been transferred to location E:backuptestnewfolder Now, this transferred file is an encrypted file
  8. 8. We can see our compressed file here in location E:backuptestnewfolder :-
  9. 9. Now if we open the file abc.doc in E:backuptestnewfolder we will find the content of the file is in encrypted form as follows:-
  10. 10. Now what about decrypting the file back to the original content ???
  11. 11. In case of decrypting a file back to original content ( content before the encryption) we will be using base64-decoder- transformer as follows:- As you can see, it will pick up the encrypted file abc.doc from the location E:backuptestnewfolder and put it into a new location E:backuptestoriginalFile
  12. 12. The corresponding our Mule flow will be :- <flow name="decrypt"> <file:inbound-endpoint path="E:backuptestnewfolder" responseTimeout="10000" doc:name="File"> <file:filename-regex-filter pattern="abc.doc" caseSensitive="false" /> </file:inbound-endpoint> <base64-decoder-transformer encoding="utf8" /> <file:outbound-endpoint path="E:backuptestoriginalFile" responseTimeout="10000" doc:name="File" /> </flow>
  13. 13. Now if we run the flow, we will get the following in our console :- The file has been decrypted back to it’s original content into the location E:backuptestoriginalFile
  14. 14. Now if we open the decrypted file we will get a normal content:-
  15. 15. Hope you enjoyed the tips of compressing and decompressing using base64-encoder-transformer/base64-decoder-transformer in Mule Next slide I will bring some more simple yet interesting topic

×