Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
See why IDC MarketScape names Qlik a 2025 Leader! Read more
cancel
Showing results for 
Search instead for 
Did you mean: 
desanip
Contributor
Contributor

How to read a particular key/Value column combination from a file for encryption

Hello everyone,

I am using the tcontextload functionality to read the database parameters from the file. I have the entire job in a standalone job and have been calling this job using a trunjob component whereever i need in all the jobs. tNow, i want to encrypt the database password in properties file. I am using using StandardPBEStringEncryptor to encrypt and decrypt the string accordingly. However, i want to know how i can get the value of that particular key/value pair (Line 10 from properties file) from trunjob.

My code goes soemthing like this:


StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor();

encryptor.setAlgorithm("PBEWithMD5AndDES");
encryptor.setPassword(password);
String decryptedValue = encryptor.decrypt(encryptedValue);
System.out.println("Decrypted Value is "+decryptedValue);

 

My talend flow is: tlibraryload(Jasypt library) 

                                  ↓

                              oncomponent ok

                                  ↓

                                trunjob( Loading the context) → tcontextload

                                  ↓

                                 tjava( Has the code inside like shown above)

 

Now i know i can use tfixedflowinput component to generate line using context variable.

 

Can someone tell me if i am going in the right direction? 

 

Thank you guys.

                              

                        

Labels (5)
7 Replies
Anonymous
Not applicable

Hi,

 

   You are in the right direction. The only minor change I will do is that I will enbed the encryption and decryption process in a routine rather than in a job. This will help me to call the functions of the routine inside components like tMap easily.

 

Warm Regards,
Nikhil Thampi

Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂

desanip
Contributor
Contributor
Author

Hello @nthampi ,

Thanks for the reply.

I get that we can create a routine and call that routine inside our components.

Lets say i already have the ecncrypted string stored in the file. How i can read that particular string from file?

Ex:

MySQL_Username= "abc"

MySQL_Password= "dummy_example"

 

Now instead of dummy_example, i have the actual encrypted string.

I want to read this and then decrypt it in a routine or inside a job?

How do i achieve this? Please let me know.

 

If you know any other method that you think is right, that would be great as well.

 

Thanks Nikhil.

Anonymous
Not applicable

Hi,

 

    You will have to pass the filepath (which has the encrypted values) as a parameter to the job during run time either from TAC or as a parameter in command line call.

   

    Now this encrypted values contain either the DB passwords or the file path of the properties file which contain the other context values.

 

   I would create a Joblet at Prejob Section which will read the data from this predefined path. I will decrypt the connection parameter data and using that data, I will connect to DB to fetch all other encrypted variables from a configuration table. Once the data is fetched from the table, all the context variables can be loaded using tContextLoad component.

 

Warm Regards,
Nikhil Thampi

Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂

desanip
Contributor
Contributor
Author

@nthampi ,

 

can you pls take a look at the attached job design and let me know your thoughts.

 

I didn't understand the part where you said "You will have to pass the filepath (which has the encrypted values) as a parameter to the job during run time either from TAC or as a parameter in command line call". Can you elaborate ?

 

I created a resuable job in the "Read context from file path". That job reads the database connection parameters from file and passes it on to the tmssqlconnection component.

 

So i have the encryped string in hand, laoded that using the tcontextload, next step is to decerypt that string before passing that value to tmssqlconnection. How do i achieve this ? How does that tjava look for that particular line in file so that it decrypts it using the java logic posted earlier?

 

Any other java code that needs to be added to make this work?

 

 

 

 


job_example.PNG
loading the contexts.PNG
desanip
Contributor
Contributor
Author

@nthampi Any idea about this, sir?

Anonymous
Not applicable

Hi,

 

   You can use a joblet to do both encryption and decryption of context data. The joblet connected at Prejob area should extract the data from database and it should send the encrypted context variables to a routine (which can be called from tMap). The routine need to have a function to decrypt the context values and after that you can load the data to context variables using tContextLoad.

 

   Unfortunately this week is quite busy for me and I may not get time to create full flow. But the essence to create the flow is as specified above.

 

Warm Regards,
Nikhil Thampi

Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂

desanip
Contributor
Contributor
Author

@nthampi  I am able to bring in the encrypted value from tcontextload, however my issue is sending the encrypted variable to my routine. How can i achieve this in my routine?

I have the decryption code ready to decrypt a string. Once i decrypt it i can call the routine form tmssqlconnection component in the password section.

 

Thanks for your time. Please let me know if you get time to create some flow for me. That would be greatly appreciated.

 

Regards.