[resolved] Encrypted password in tSendMail

One Star

[resolved] Encrypted password in tSendMail

In the tSendMail component, we can use context variables.
For the password of the account used for the SMTP server, you can have also a context variable.
So the encrypted version of the password is saved in default.properties file
now the question is: if I  move my job and need to reconfigure the job with a new smtp server how can I do it?
If I modify the encrypted password, of course it does not work anymore.
So I am looking for a component to be able to reencrypt the new password.
I don't need to know the encryption algorithm.
I just want to enter "password" to get the encrypted version to update the default.properties
Hello Talend experts, is it a dream?
Is there a solution
Why it does not exist?
Thanks
Didier

Accepted Solutions
Seventeen Stars

Re: [resolved] Encrypted password in tSendMail

I have checked that in Talend Open Studio in release 5.5.1 and in my job the password is clear text in the default.properties.
Actually the encryption takes place only if you enter the password directly in the input field and do not use a context variable.
I have seen this is not the case in 6.1.1 ! This is perhaps a problem for migration scenarios.
In 6.1.1 indeed the password is stored as encrypted value. This is actually not that bad and an old requirement.
You can build a job to encrypt a clear text password using the routine routines.system.PasswordEncryptUtil
or you can define the context variable simply as String, it will used as password as well but without encrypting the value in the default.properties.

All Replies
Seventeen Stars

Re: [resolved] Encrypted password in tSendMail

I have checked that in Talend Open Studio in release 5.5.1 and in my job the password is clear text in the default.properties.
Actually the encryption takes place only if you enter the password directly in the input field and do not use a context variable.
I have seen this is not the case in 6.1.1 ! This is perhaps a problem for migration scenarios.
In 6.1.1 indeed the password is stored as encrypted value. This is actually not that bad and an old requirement.
You can build a job to encrypt a clear text password using the routine routines.system.PasswordEncryptUtil
or you can define the context variable simply as String, it will used as password as well but without encrypting the value in the default.properties.
One Star

Re: [resolved] Encrypted password in tSendMail

Ok I test it
One Star

Re: [resolved] Encrypted password in tSendMail

You are right. With a clear text password it works!
now the question is to encrypt it for security reason.
Does the PasswordEncryptUtil routine is a standard routine in talend ou do I need to create it?
Does the encrypted password will be automaticaly decrypted by the tSendMail component?
Thanks for your help
Didier
Seventeen Stars

Re: [resolved] Encrypted password in tSendMail

The mentioned routine is a standard routine. You should be able to create a small simple job to encrypt passwords for your self.
One Star

Re: [resolved] Encrypted password in tSendMail

So I would like to create a job like:




in the java component:
PasswordEncryptUtil.encryptPassword((String)globalMap.get("tMsgBox_1_RESULT"));

but currently I have the following error:


so something like "the tMsgBox requires an input link"
So what can I insert as input component of the tMsgBox component??
Thanks
Didier
Seventeen Stars

Re: [resolved] Encrypted password in tSendMail

I would not use the message box. It is quite enough to use a input context variable and set them as prompt.
One Star

Re: [resolved] Encrypted password in tSendMail

sorry the whole job is not displayed:

Seventeen Stars

Re: [resolved] Encrypted password in tSendMail

Here a job with the message box:
The answer of the message box is given by a return variable (see the Outline view).
((String)globalMap.get("tMsgBox_1_RESULT"))
One Star

Re: [resolved] Encrypted password in tSendMail

now I have the same error on the tJava component:


Encrypt_PWD.zip_20160121-1149.zip
Seventeen Stars

Re: [resolved] Encrypted password in tSendMail

Whats wrong with my suggestion? You do not need and input flow for the message component to allow a question and get the answer.
One Star

Re: [resolved] Encrypted password in tSendMail

I don't have anymore the error at the tMsgBox level
Now I have it at the tJava level
One Star

Re: [resolved] Encrypted password in tSendMail

Now I don't have any erreor but I don't have my encrypted password


in the tJava component:
String EncrypedPWD=PasswordEncryptUtil.encryptPassword(row2.pwd);
??
Smiley Sad
Seventeen Stars

Re: [resolved] Encrypted password in tSendMail

I have made a simple job encrypting a clear password into a encrypted password.
Encrypt_PWD_20160121_1417.zip.zip

Seventeen Stars

Re: [resolved] Encrypted password in tSendMail

You have done numerous errors. All the stuff with the flows are not necessary. 
One Star

Re: [resolved] Encrypted password in tSendMail

Wonderful it works! Thanks!
Now the question is: I can set a context vriable with encrypted variable. How can I save it in the file including the context (default.properties).
Doing something a dump of the current version of the context variables
I have tried :

but the  default.properties file is not updated!!!

Thanks
Didier
One Star

Re: [resolved] Encrypted password in tSendMail

now it works completely

Seventeen Stars

Re: [resolved] Encrypted password in tSendMail

The encrypted password should only by set directly in the default.properties file and not in the studio. In the studio the encryption is done automatically (in such a case you would encrypt an already encrypted password).
You can save this file just all other csv file also (in this case the = is the delimiter and as the line separator use the UNIX style!)