Tuesday 3 September 2019

How to configure Implicit context in Talend With Encrypt and Decrypt the password values


Context variables:

Context describes the user-defined parameters that are passed to your Job at runtime. Context Variables are the values that may change as you promote your Job from Development, through to Test and Production. Values may also change as your environment changes, for example, passwords may change from time to time.

In Talend context variables can create two ways
  •  Local variables:  create in job level that are only used in the corresponding job. 
  • Global variables: create in Talend Repository that are used in throughout project

How can we pass the Values for Context variables? 
  •   We can hardcode the values in Talend.
  •   We can use tContextLoad component in each job t get the values from file.

And we have one more way to pass the values for context variables in Talend Project. i.e. implicit context


How to configure implicit context in Talend?

We can configure implicit context with files or Database. If you use file or database we need to have two Main columns i.e. key and value.

If you use table for maintain context variables. Just create a table with two columns i.e. key and values.

CREATE TABLE `tbl_implici_context` (`key` varchar (255) DEFAULT NULL, ‘value` varchar (255) DEFAULT NULL) ENGINE=InnoDB DEFAULT CHARSET=latin1;

The charset should be latin1 because it should accept all special characters.

 Generally the most of the customer Expect to maintain security on their values. So they don’t want expose their application passwords. So they need to encrypt all the passwords.

So while loading all variables and values all values for password fields should be encrypted. For this Encryption I have used database encryption algorithm.

i.e. AES_ENCRYPT and AES_DECRYPT

Create a Talend job to populate the implicit context table. For this use case I have taken tFixedflowInput component as source.



 Use tJavaRow1 component to generate insert statement

if(input_row.key.matches(".*password.*"))
{
context.username= "insert into tbl_implici_context values('"+input_row.key+"',AES_ENCRYPT('"+input_row.value+"','mykeystring'));";
System.out.println(context.username);
}
else
{
context.username= "insert into tbl_implici_context values('"+input_row.key+"','"+input_row.value+"');";
System.out.println(context.username);
}


Use tMysqlRow component to execute this insert statement



Run the Job



Check the Results


Configure implicit context in project settings with Decrypt the password values.

In Talend StudioàProject settingsà Job settings


In the Query section we should use the Decrypt methods. Here I have written one Query to decrypt the passwords.

Generally the Query condition option only take where clause.

"`key` not like '%password%'  union  select `key`, case when `key` like '%password%' then AES_DECRYPT(value,'mykeystring') else value  END value  from test.tbl_implici_context"
****************************THANK YOU******************************

java.io.IOException: org.eclipse.aether.deployment.DeploymentException: Failed to deploy artifacts: Could not transfer artifact Return code is: 400, ReasonPhrase: Repository does not allow updating assets: releases.

 HI, by Default in Nexus release branch will not allow redeploy of the Same version of Talend job. if we need to redeploy same job again int...