Compare commits

..

6 Commits

Author SHA1 Message Date
jzhao
1942a2a714 fix(TPS-3546): commit for test solution. 2019-11-06 18:31:42 +08:00
pyzhou
e525d98851 fix(TPS-3290): [7.2.1] SSO enabled Redshift connectivity with Talend
7.2.1 Big Data Platform (Standard Job) (TDI-42674)

Conflicts:
	PATCH_RELEASE_NOTE.md
2019-11-01 16:28:00 +08:00
Dmytro Chmyga
031dcf8074 patch(TPS-3315): password context values
* fix mysql and mssql elt maps

* update release notes
2019-08-12 12:34:56 +03:00
Dmytro Chmyga
a8a764e273 patch(TPS-3315): password context values
* change release notes
2019-08-08 16:47:02 +03:00
Dmytro Chmyga
d803bd655a patch(TPS-3315): password context values
* revert changes in db log javajets

* fix mysql, mssql, oracle and redshift components

* change release notes
2019-08-08 16:23:32 +03:00
Dmytro Chmyga
64b033c51b patch(TPS-3315): password context values
* Throw runtime exception if password is used in plain text field

* Add release note
2019-08-05 15:34:50 +03:00
48 changed files with 650 additions and 170 deletions

View File

@@ -5,13 +5,13 @@ product:
- https://talend.poolparty.biz/coretaxonomy/23
---
# TPS-4053
# TPS-3290
| Info | Value |
| ---------------- | ---------------- |
| Patch Name | Patch\_20200514\_TPS-4053\_v1-7.2.1 |
| Release Date | 2020-05-14 |
| Target Version | 20190620\_1446-V7.2.1 |
| Patch Name | Patch\_20190805\_TPS-3290\_v1-7.2.1 |
| Release Date | 2019-08-05 |
| Target Version | 20190620_1446-V7.2.1 |
| Product affected | Talend Studio |
## Introduction
@@ -24,7 +24,7 @@ This is a self-contained patch.
This patch contains the following fixes:
- TPS-4053 [7.2.1] Unable to execute the job, receiving "Failed to generate code." when using tAmazonRedshiftManage component.(TDI-44070)
- TPS-3290 [7.2.1] SSO enabled Redshift connectivity with Talend 7.2.1 Big Data Platform (Standard Job) (TDI-42674)
## Prerequisites
@@ -55,12 +55,3 @@ Execute the following commands:
1. Talend-Studio-win-x86_64.exe -nosplash -application org.talend.commandline.CommandLine -consoleLog -data commandline-workspace startServer -p 8002 --talendDebug
2. initRemote {tac_url} -ul {TAC login username} -up {TAC login password}
3. checkAndUpdate -tu {TAC login username} -tup {TAC login password}
## Uninstallation
Backup the Affected files list below. Uninstall the patch by restore the backup files.
## Affected files for this patch
The following files are installed by this patch:
- {Talend\_Studio\_path}/plugins/org.talend.designer.components.localprovider\_7.2.1.20190614\_0309/components/tAmazonRedshiftManage/tAmazonRedshiftManage\_begin.javajet

View File

@@ -24,9 +24,6 @@
String user = ElementParameterParser.getValue(node, "__USER__");
String node_type = ElementParameterParser.getValue(node, "__NODE_TYPE__");
String node_count = ElementParameterParser.getValue(node, "__NODE_COUNT__");
if (node_count.isEmpty()) {
node_count = "1";
}
boolean isLog4jEnabled = "true".equals(ElementParameterParser.getValue(node.getProcess(), "__LOG4J_ACTIVATE__"));
@@ -91,46 +88,52 @@
.withMasterUsername(<%=user%>)
.withMasterUserPassword(decryptedPwd_<%=cid%>)
.withNodeType(<%=node_type%>);
.withNodeType(<%=node_type%>)
if (<%=node_count%> > 1) {
request_<%=cid%> = request_<%=cid%>.withNumberOfNodes(<%=node_count%>);
} else {
request_<%=cid%> = request_<%=cid%>.withClusterType("single-node");
}
//advanced settings
<%if(parameterUtil.isValid(parameter_group_name)) {%>
request_<%=cid%> = request_<%=cid%>.withClusterParameterGroupName(<%=parameter_group_name%>);
<%}%>
<%if(parameterUtil.isValid(subnet_group_name)) {%>
request_<%=cid%> = request_<%=cid%>.withClusterSubnetGroupName(<%=subnet_group_name%>);
<%}%>
<%
if(publicly_accessible) {
%>
request_<%=cid%> = request_<%=cid%>.withPubliclyAccessible(true);
<%if(set_public_ip_address) {%>
request_<%=cid%> = request_<%=cid%>.withElasticIp(<%=elastic_ip%>);
<%
if(new Integer(node_count) > 1){
%>
.withNumberOfNodes(<%=node_count%>)
<%
} else {
%>
.withClusterType("single-node")
<%
}
%>
//advanced settings
<%if(parameterUtil.isValid(parameter_group_name)) {%>
.withClusterParameterGroupName(<%=parameter_group_name%>)
<%}%>
<%if(parameterUtil.isValid(subnet_group_name)) {%>
.withClusterSubnetGroupName(<%=subnet_group_name%>)
<%}%>
<%
} else {
%>
request_<%=cid%> = request_<%=cid%>.withPubliclyAccessible(false);
<%
}
%>
<%if(parameterUtil.isValid(availability_zone)) {%>
request_<%=cid%> = request_<%=cid%>.withAvailabilityZone(<%=availability_zone%>);
<%}%>
<%if(parameterUtil.isValid(vpc_security_groupids)) {%>
request_<%=cid%> = request_<%=cid%>.withVpcSecurityGroupIds(<%=vpc_security_groupids%>.split(","));
<%}%>
<%
if(publicly_accessible) {
%>
.withPubliclyAccessible(true)
<%if(set_public_ip_address) {%>
.withElasticIp(<%=elastic_ip%>)
<%}%>
<%
} else {
%>
.withPubliclyAccessible(false)
<%
}
%>
<%if(parameterUtil.isValid(availability_zone)) {%>
.withAvailabilityZone(<%=availability_zone%>)
<%}%>
<%if(parameterUtil.isValid(vpc_security_groupids)) {%>
.withVpcSecurityGroupIds(<%=vpc_security_groupids%>.split(","))
<%}%>
;
com.amazonaws.services.redshift.model.Cluster result_<%=cid%> = client_<%=cid%>.createCluster(request_<%=cid%>);
<%if(isLog4jEnabled) {%>

View File

@@ -1,6 +1,6 @@
<%@ jet
imports="
org.talend.core.model.process.ElementParameterParser
org.talend.designer.codegen.config.CodeGeneratorArgument
java.util.List
org.talend.core.model.process.IConnection
@@ -16,6 +16,7 @@
java.util.HashSet
"
%>
<%@ include file="@{org.talend.designer.components.localprovider}/components/templates/DB/CheckContextPassword.javajet"%>
<%

View File

@@ -1,6 +1,6 @@
<%@ jet
imports="
org.talend.core.model.process.ElementParameterParser
org.talend.designer.codegen.config.CodeGeneratorArgument
java.util.List
@@ -17,6 +17,7 @@
java.util.HashSet
"
%>
<%@ include file="@{org.talend.designer.components.localprovider}/components/templates/DB/CheckContextPassword.javajet"%>
<%

View File

@@ -18,8 +18,56 @@
"
%>
<%
//TPS-3315
org.talend.designer.codegen.config.CodeGeneratorArgument codeGenArgument_pwdCheck = (org.talend.designer.codegen.config.CodeGeneratorArgument)argument;
org.talend.core.model.process.INode node_pwdCheck = (org.talend.core.model.process.INode)codeGenArgument_pwdCheck.getArgument();
boolean useExistingConnection_pwdCheck = "true".equalsIgnoreCase(ElementParameterParser.getValue(node_pwdCheck,"__USE_EXISTING_CONNECTION__"));
if(!useExistingConnection_pwdCheck) {
String user_pwdCheck = ElementParameterParser.getValue(node_pwdCheck, "__USER__");
String dbhost_pwdCheck = ElementParameterParser.getValue(node_pwdCheck, "__HOST__");
String dbport_pwdCheck = ElementParameterParser.getValue(node_pwdCheck, "__PORT__");
String dbname_pwdCheck = ElementParameterParser.getValue(node_pwdCheck, "__DBNAME__");
String dbproperties_pwdCheck = ElementParameterParser.getValue(node_pwdCheck, "__PROPERTIES__");
String localServiceName_pwdCheck = ElementParameterParser.getValue(node_pwdCheck, "__LOCAL_SERVICE_NAME__");
final class ValueChecker {
public boolean checkValueForPassword(String inputValue, org.talend.core.model.process.IContext context) {
if(null == inputValue) {
return false;
}
java.util.List<String> parsed = new java.util.ArrayList<String>();
String value = inputValue.trim();
while(org.talend.core.model.utils.ContextParameterUtils.containContextVariables(value)) {
String nonQuoteStr = org.talend.core.utils.TalendQuoteUtils.filterQuote(value);
String contextVar = org.talend.core.model.utils.ContextParameterUtils.getVariableFromCode(nonQuoteStr);
parsed.add(contextVar);
String curValue = org.talend.core.model.utils.ContextParameterUtils.JAVA_NEW_CONTEXT_PREFIX + contextVar;
int index = value.indexOf(curValue);
if(index != -1) {
value = value.substring(index + curValue.length(), value.length());
}
}
for(String parsedParam : parsed) {
org.talend.core.model.process.IContextParameter param = context.getContextParameter(parsedParam);
if(org.talend.core.model.utils.ContextParameterUtils.isPasswordType(param)) {
return true;
}
}
return false;
}
}
ValueChecker checker = new ValueChecker();
org.talend.core.model.process.IContext context_pwdCheck = node_pwdCheck.getProcess().getContextManager().getDefaultContext();
if(checker.checkValueForPassword(dbhost_pwdCheck, context_pwdCheck) || checker.checkValueForPassword(dbport_pwdCheck, context_pwdCheck) || checker.checkValueForPassword(dbname_pwdCheck, context_pwdCheck) || checker.checkValueForPassword(dbproperties_pwdCheck, context_pwdCheck) || checker.checkValueForPassword(localServiceName_pwdCheck, context_pwdCheck)) {
%>
if(true) {
throw new RuntimeException("Password context variable is used in plain text field!");
}
<%
}
}
//
CodeGeneratorArgument codeGenArgument = (CodeGeneratorArgument) argument;
DbMapComponent node = (DbMapComponent) codeGenArgument.getArgument();
boolean stats = codeGenArgument.isStatistics();

View File

@@ -15,6 +15,7 @@ imports="
skeleton="../templates/db_output_bulk.skeleton"
%>
<%@ include file="@{org.talend.designer.components.localprovider}/components/templates/Log4j/DBLogUtil.javajet"%>
<%@ include file="@{org.talend.designer.components.localprovider}/components/templates/DB/CheckContextPassword.javajet"%>
<%
CodeGeneratorArgument codeGenArgument = (CodeGeneratorArgument) argument;
INode node = (INode)codeGenArgument.getArgument();

View File

@@ -6,6 +6,7 @@ imports="
"
%>
<%@ include file="../templates/DB/HelpClass/HelpClass.javajet"%>
<%@ include file="@{org.talend.designer.components.localprovider}/components/templates/DB/CheckContextPassword.javajet"%>
<%
class ConnectionUtil extends DefaultConnectionUtil{

View File

@@ -13,6 +13,7 @@ imports="
"
%>
<%@ include file="../templates/DB/Input/HelpClass.javajet"%>
<%@ include file="@{org.talend.designer.components.localprovider}/components/templates/DB/CheckContextPassword.javajet"%>
<%
class DBInputBeginUtil extends DefaultDBInputUtil{

View File

@@ -17,6 +17,7 @@ imports="
skeleton="../templates/db_output_bulk.skeleton"
%>
<%@ include file="@{org.talend.designer.components.localprovider}/components/templates/Log4j/DBLogUtil.javajet"%>
<%@ include file="@{org.talend.designer.components.localprovider}/components/templates/DB/CheckContextPassword.javajet"%>
<%
CodeGeneratorArgument codeGenArgument = (CodeGeneratorArgument) argument;
INode node = (INode)codeGenArgument.getArgument();

View File

@@ -6,6 +6,7 @@ imports="
"
%>
<%@ include file="../templates/DB/Row/HelpClass.javajet"%>
<%@ include file="@{org.talend.designer.components.localprovider}/components/templates/DB/CheckContextPassword.javajet"%>
<%
class DBRowBeginUtil extends DefaultDBRowUtil{

View File

@@ -18,6 +18,7 @@ imports="
skeleton="../templates/slowly_change_dimension.skeleton"
%>
<%@ include file="@{org.talend.designer.components.localprovider}/components/templates/Log4j/DBLogUtil.javajet"%>
<%@ include file="@{org.talend.designer.components.localprovider}/components/templates/DB/CheckContextPassword.javajet"%>
<%
CodeGeneratorArgument codeGenArgument = (CodeGeneratorArgument) argument;
INode node = (INode) codeGenArgument.getArgument();

View File

@@ -9,6 +9,7 @@ imports="
"
%>
<%@ include file="@{org.talend.designer.components.localprovider}/components/templates/Log4j/DBLogUtil.javajet"%>
<%@ include file="@{org.talend.designer.components.localprovider}/components/templates/DB/CheckContextPassword.javajet"%>
<%
CodeGeneratorArgument codeGenArgument = (CodeGeneratorArgument) argument;
INode node = (INode) codeGenArgument.getArgument();

View File

@@ -14,6 +14,7 @@ imports="
skeleton="../templates/db_output_bulk.skeleton"
%>
<%@ include file="../templates/Log4j/Log4jDBConnUtil.javajet"%>
<%@ include file="@{org.talend.designer.components.localprovider}/components/templates/DB/CheckContextPassword.javajet"%>
<%
CodeGeneratorArgument codeGenArgument = (CodeGeneratorArgument) argument;
INode node = (INode)codeGenArgument.getArgument();

View File

@@ -6,6 +6,7 @@ imports="
"
%>
<%@ include file="../templates/DB/HelpClass/HelpClass.javajet"%>
<%@ include file="@{org.talend.designer.components.localprovider}/components/templates/DB/CheckContextPassword.javajet"%>
<%
class ConnectionUtil extends DefaultConnectionUtil{

View File

@@ -13,6 +13,7 @@ imports="
"
%>
<%@ include file="../templates/DB/Input/HelpClass.javajet"%>
<%@ include file="@{org.talend.designer.components.localprovider}/components/templates/DB/CheckContextPassword.javajet"%>
<%
class DBInputBeginUtil extends DefaultDBInputUtil{

View File

@@ -17,6 +17,7 @@ imports="
skeleton="../templates/db_output_bulk.skeleton"
%>
<%@ include file="@{org.talend.designer.components.localprovider}/components/templates/Log4j/DBLogUtil.javajet"%>
<%@ include file="@{org.talend.designer.components.localprovider}/components/templates/DB/CheckContextPassword.javajet"%>
<%
CodeGeneratorArgument codeGenArgument = (CodeGeneratorArgument) argument;
INode node = (INode)codeGenArgument.getArgument();

View File

@@ -6,6 +6,7 @@ imports="
"
%>
<%@ include file="../templates/DB/Row/HelpClass.javajet"%>
<%@ include file="@{org.talend.designer.components.localprovider}/components/templates/DB/CheckContextPassword.javajet"%>
<%
class DBRowBeginUtil extends DefaultDBRowUtil{

View File

@@ -16,7 +16,7 @@ imports="
"
skeleton="../templates/slowly_change_dimension.skeleton"
%>
<%@ include file="@{org.talend.designer.components.localprovider}/components/templates/DB/CheckContextPassword.javajet"%>
<%
CodeGeneratorArgument codeGenArgument = (CodeGeneratorArgument) argument;
INode node = (INode) codeGenArgument.getArgument();

View File

@@ -14,7 +14,7 @@ imports="
"
skeleton="../templates/db_output_bulk.skeleton"
%>
<%@ include file="@{org.talend.designer.components.localprovider}/components/templates/DB/CheckContextPassword.javajet"%>
<%
CodeGeneratorArgument codeGenArgument = (CodeGeneratorArgument) argument;
INode node = (INode)codeGenArgument.getArgument();

View File

@@ -8,6 +8,7 @@ imports="
"
%>
<%@ include file="@{org.talend.designer.components.localprovider}/components/templates/Log4j/DBLogUtil.javajet"%>
<%@ include file="@{org.talend.designer.components.localprovider}/components/templates/DB/CheckContextPassword.javajet"%>
<%
CodeGeneratorArgument codeGenArgument = (CodeGeneratorArgument) argument;
INode node = (INode) codeGenArgument.getArgument();

View File

@@ -18,6 +18,7 @@ skeleton="../templates/db_output_bulk.skeleton"
%>
<%@ include file="../templates/Log4j/Log4jDBConnUtil.javajet"%>
<%
CodeGeneratorArgument codeGenArgument = (CodeGeneratorArgument) argument;
INode node = (INode)codeGenArgument.getArgument();
@@ -96,6 +97,57 @@ String url_<%=cid%> = null;
int deletedCount_<%=cid%>=0;
<%
boolean useExistingConnection = "true".equalsIgnoreCase(ElementParameterParser.getValue(node,"__USE_EXISTING_CONNECTION__"));
//TPS-3315
org.talend.designer.codegen.config.CodeGeneratorArgument codeGenArgument_pwdCheck = (org.talend.designer.codegen.config.CodeGeneratorArgument)argument;
org.talend.core.model.process.INode node_pwdCheck = (org.talend.core.model.process.INode)codeGenArgument_pwdCheck.getArgument();
boolean useExistingConnection_pwdCheck = "true".equalsIgnoreCase(ElementParameterParser.getValue(node_pwdCheck,"__USE_EXISTING_CONNECTION__"));
if(!useExistingConnection_pwdCheck) {
String user_pwdCheck = ElementParameterParser.getValue(node_pwdCheck, "__USER__");
String dbhost_pwdCheck = ElementParameterParser.getValue(node_pwdCheck, "__HOST__");
String dbport_pwdCheck = ElementParameterParser.getValue(node_pwdCheck, "__PORT__");
String dbname_pwdCheck = ElementParameterParser.getValue(node_pwdCheck, "__DBNAME__");
String dbproperties_pwdCheck = ElementParameterParser.getValue(node_pwdCheck, "__PROPERTIES__");
String localServiceName_pwdCheck = ElementParameterParser.getValue(node_pwdCheck, "__LOCAL_SERVICE_NAME__");
final class ValueChecker {
public boolean checkValueForPassword(String inputValue, org.talend.core.model.process.IContext context) {
if(null == inputValue) {
return false;
}
java.util.List<String> parsed = new java.util.ArrayList<String>();
String value = inputValue.trim();
while(org.talend.core.model.utils.ContextParameterUtils.containContextVariables(value)) {
String nonQuoteStr = org.talend.core.utils.TalendQuoteUtils.filterQuote(value);
String contextVar = org.talend.core.model.utils.ContextParameterUtils.getVariableFromCode(nonQuoteStr);
parsed.add(contextVar);
String curValue = org.talend.core.model.utils.ContextParameterUtils.JAVA_NEW_CONTEXT_PREFIX + contextVar;
int index = value.indexOf(curValue);
if(index != -1) {
value = value.substring(index + curValue.length(), value.length());
}
}
for(String parsedParam : parsed) {
org.talend.core.model.process.IContextParameter param = context.getContextParameter(parsedParam);
if(org.talend.core.model.utils.ContextParameterUtils.isPasswordType(param)) {
return true;
}
}
return false;
}
}
ValueChecker checker = new ValueChecker();
org.talend.core.model.process.IContext context_pwdCheck = node_pwdCheck.getProcess().getContextManager().getDefaultContext();
if(checker.checkValueForPassword(dbhost_pwdCheck, context_pwdCheck) || checker.checkValueForPassword(dbport_pwdCheck, context_pwdCheck) || checker.checkValueForPassword(dbname_pwdCheck, context_pwdCheck) || checker.checkValueForPassword(dbproperties_pwdCheck, context_pwdCheck) || checker.checkValueForPassword(localServiceName_pwdCheck, context_pwdCheck)) {
%>
if(true) {
throw new RuntimeException("Password context variable is used in plain text field!");
}
<%
}
}
//
if(useExistingConnection) {
String connection = ElementParameterParser.getValue(node,"__CONNECTION__");
String conn = "conn_" + connection;

View File

@@ -7,6 +7,56 @@ imports="
%>
<%@ include file="../templates/DB/HelpClass/HelpClass.javajet"%>
<%
//TPS-3315
org.talend.designer.codegen.config.CodeGeneratorArgument codeGenArgument_pwdCheck = (org.talend.designer.codegen.config.CodeGeneratorArgument)argument;
org.talend.core.model.process.INode node_pwdCheck = (org.talend.core.model.process.INode)codeGenArgument_pwdCheck.getArgument();
boolean useExistingConnection_pwdCheck = "true".equalsIgnoreCase(ElementParameterParser.getValue(node_pwdCheck,"__USE_EXISTING_CONNECTION__"));
if(!useExistingConnection_pwdCheck) {
String user_pwdCheck = ElementParameterParser.getValue(node_pwdCheck, "__USER__");
String dbhost_pwdCheck = ElementParameterParser.getValue(node_pwdCheck, "__HOST__");
String dbport_pwdCheck = ElementParameterParser.getValue(node_pwdCheck, "__PORT__");
String dbname_pwdCheck = ElementParameterParser.getValue(node_pwdCheck, "__DBNAME__");
String dbproperties_pwdCheck = ElementParameterParser.getValue(node_pwdCheck, "__PROPERTIES__");
String localServiceName_pwdCheck = ElementParameterParser.getValue(node_pwdCheck, "__LOCAL_SERVICE_NAME__");
final class ValueChecker {
public boolean checkValueForPassword(String inputValue, org.talend.core.model.process.IContext context) {
if(null == inputValue) {
return false;
}
java.util.List<String> parsed = new java.util.ArrayList<String>();
String value = inputValue.trim();
while(org.talend.core.model.utils.ContextParameterUtils.containContextVariables(value)) {
String nonQuoteStr = org.talend.core.utils.TalendQuoteUtils.filterQuote(value);
String contextVar = org.talend.core.model.utils.ContextParameterUtils.getVariableFromCode(nonQuoteStr);
parsed.add(contextVar);
String curValue = org.talend.core.model.utils.ContextParameterUtils.JAVA_NEW_CONTEXT_PREFIX + contextVar;
int index = value.indexOf(curValue);
if(index != -1) {
value = value.substring(index + curValue.length(), value.length());
}
}
for(String parsedParam : parsed) {
org.talend.core.model.process.IContextParameter param = context.getContextParameter(parsedParam);
if(org.talend.core.model.utils.ContextParameterUtils.isPasswordType(param)) {
return true;
}
}
return false;
}
}
ValueChecker checker = new ValueChecker();
org.talend.core.model.process.IContext context_pwdCheck = node_pwdCheck.getProcess().getContextManager().getDefaultContext();
if(checker.checkValueForPassword(dbhost_pwdCheck, context_pwdCheck) || checker.checkValueForPassword(dbport_pwdCheck, context_pwdCheck) || checker.checkValueForPassword(dbname_pwdCheck, context_pwdCheck) || checker.checkValueForPassword(dbproperties_pwdCheck, context_pwdCheck) || checker.checkValueForPassword(localServiceName_pwdCheck, context_pwdCheck)) {
%>
if(true) {
throw new RuntimeException("Password context variable is used in plain text field!");
}
<%
}
}
//
class ConnectionUtil extends DefaultConnectionUtil{
public void beforeComponentProcess(INode node){

View File

@@ -14,6 +14,56 @@ imports="
%>
<%@ include file="../templates/DB/Input/HelpClass.javajet"%>
<%
//TPS-3315
org.talend.designer.codegen.config.CodeGeneratorArgument codeGenArgument_pwdCheck = (org.talend.designer.codegen.config.CodeGeneratorArgument)argument;
org.talend.core.model.process.INode node_pwdCheck = (org.talend.core.model.process.INode)codeGenArgument_pwdCheck.getArgument();
boolean useExistingConnection_pwdCheck = "true".equalsIgnoreCase(ElementParameterParser.getValue(node_pwdCheck,"__USE_EXISTING_CONNECTION__"));
if(!useExistingConnection_pwdCheck) {
String user_pwdCheck = ElementParameterParser.getValue(node_pwdCheck, "__USER__");
String dbhost_pwdCheck = ElementParameterParser.getValue(node_pwdCheck, "__HOST__");
String dbport_pwdCheck = ElementParameterParser.getValue(node_pwdCheck, "__PORT__");
String dbname_pwdCheck = ElementParameterParser.getValue(node_pwdCheck, "__DBNAME__");
String dbproperties_pwdCheck = ElementParameterParser.getValue(node_pwdCheck, "__PROPERTIES__");
String localServiceName_pwdCheck = ElementParameterParser.getValue(node_pwdCheck, "__LOCAL_SERVICE_NAME__");
final class ValueChecker {
public boolean checkValueForPassword(String inputValue, org.talend.core.model.process.IContext context) {
if(null == inputValue) {
return false;
}
java.util.List<String> parsed = new java.util.ArrayList<String>();
String value = inputValue.trim();
while(org.talend.core.model.utils.ContextParameterUtils.containContextVariables(value)) {
String nonQuoteStr = org.talend.core.utils.TalendQuoteUtils.filterQuote(value);
String contextVar = org.talend.core.model.utils.ContextParameterUtils.getVariableFromCode(nonQuoteStr);
parsed.add(contextVar);
String curValue = org.talend.core.model.utils.ContextParameterUtils.JAVA_NEW_CONTEXT_PREFIX + contextVar;
int index = value.indexOf(curValue);
if(index != -1) {
value = value.substring(index + curValue.length(), value.length());
}
}
for(String parsedParam : parsed) {
org.talend.core.model.process.IContextParameter param = context.getContextParameter(parsedParam);
if(org.talend.core.model.utils.ContextParameterUtils.isPasswordType(param)) {
return true;
}
}
return false;
}
}
ValueChecker checker = new ValueChecker();
org.talend.core.model.process.IContext context_pwdCheck = node_pwdCheck.getProcess().getContextManager().getDefaultContext();
if(checker.checkValueForPassword(dbhost_pwdCheck, context_pwdCheck) || checker.checkValueForPassword(dbport_pwdCheck, context_pwdCheck) || checker.checkValueForPassword(dbname_pwdCheck, context_pwdCheck) || checker.checkValueForPassword(dbproperties_pwdCheck, context_pwdCheck) || checker.checkValueForPassword(localServiceName_pwdCheck, context_pwdCheck)) {
%>
if(true) {
throw new RuntimeException("Password context variable is used in plain text field!");
}
<%
}
}
//
class DBInputBeginUtil extends DefaultDBInputUtil{
private INode node = null;

View File

@@ -51,6 +51,56 @@ skeleton="../templates/db_output_bulk.skeleton"
boolean createGeometryColumns = ("true").equals(ElementParameterParser.getValue(node,"__GEOMETRY_COLUMNS__"));
boolean useExistingConnection = "true".equals(ElementParameterParser.getValue(node,"__USE_EXISTING_CONNECTION__"));
String connection = ElementParameterParser.getValue(node,"__CONNECTION__");
//TPS-3315
org.talend.designer.codegen.config.CodeGeneratorArgument codeGenArgument_pwdCheck = (org.talend.designer.codegen.config.CodeGeneratorArgument)argument;
org.talend.core.model.process.INode node_pwdCheck = (org.talend.core.model.process.INode)codeGenArgument_pwdCheck.getArgument();
boolean useExistingConnection_pwdCheck = "true".equalsIgnoreCase(ElementParameterParser.getValue(node_pwdCheck,"__USE_EXISTING_CONNECTION__"));
if(!useExistingConnection_pwdCheck) {
String user_pwdCheck = ElementParameterParser.getValue(node_pwdCheck, "__USER__");
String dbhost_pwdCheck = ElementParameterParser.getValue(node_pwdCheck, "__HOST__");
String dbport_pwdCheck = ElementParameterParser.getValue(node_pwdCheck, "__PORT__");
String dbname_pwdCheck = ElementParameterParser.getValue(node_pwdCheck, "__DBNAME__");
String dbproperties_pwdCheck = ElementParameterParser.getValue(node_pwdCheck, "__PROPERTIES__");
String localServiceName_pwdCheck = ElementParameterParser.getValue(node_pwdCheck, "__LOCAL_SERVICE_NAME__");
final class ValueChecker {
public boolean checkValueForPassword(String inputValue, org.talend.core.model.process.IContext context) {
if(null == inputValue) {
return false;
}
java.util.List<String> parsed = new java.util.ArrayList<String>();
String value = inputValue.trim();
while(org.talend.core.model.utils.ContextParameterUtils.containContextVariables(value)) {
String nonQuoteStr = org.talend.core.utils.TalendQuoteUtils.filterQuote(value);
String contextVar = org.talend.core.model.utils.ContextParameterUtils.getVariableFromCode(nonQuoteStr);
parsed.add(contextVar);
String curValue = org.talend.core.model.utils.ContextParameterUtils.JAVA_NEW_CONTEXT_PREFIX + contextVar;
int index = value.indexOf(curValue);
if(index != -1) {
value = value.substring(index + curValue.length(), value.length());
}
}
for(String parsedParam : parsed) {
org.talend.core.model.process.IContextParameter param = context.getContextParameter(parsedParam);
if(org.talend.core.model.utils.ContextParameterUtils.isPasswordType(param)) {
return true;
}
}
return false;
}
}
ValueChecker checker = new ValueChecker();
org.talend.core.model.process.IContext context_pwdCheck = node_pwdCheck.getProcess().getContextManager().getDefaultContext();
if(checker.checkValueForPassword(dbhost_pwdCheck, context_pwdCheck) || checker.checkValueForPassword(dbport_pwdCheck, context_pwdCheck) || checker.checkValueForPassword(dbname_pwdCheck, context_pwdCheck) || checker.checkValueForPassword(dbproperties_pwdCheck, context_pwdCheck) || checker.checkValueForPassword(localServiceName_pwdCheck, context_pwdCheck)) {
%>
if(true) {
throw new RuntimeException("Password context variable is used in plain text field!");
}
<%
}
}
//
String rejectConnName = null;
List<? extends IConnection> rejectConns = node.getOutgoingConnections("REJECT");

View File

@@ -6,8 +6,58 @@ imports="
"
%>
<%@ include file="../templates/DB/Row/HelpClass.javajet"%>
<%
<%
//TPS-3315
org.talend.designer.codegen.config.CodeGeneratorArgument codeGenArgument_pwdCheck = (org.talend.designer.codegen.config.CodeGeneratorArgument)argument;
org.talend.core.model.process.INode node_pwdCheck = (org.talend.core.model.process.INode)codeGenArgument_pwdCheck.getArgument();
boolean useExistingConnection_pwdCheck = "true".equalsIgnoreCase(ElementParameterParser.getValue(node_pwdCheck,"__USE_EXISTING_CONNECTION__"));
if(!useExistingConnection_pwdCheck) {
String user_pwdCheck = ElementParameterParser.getValue(node_pwdCheck, "__USER__");
String dbhost_pwdCheck = ElementParameterParser.getValue(node_pwdCheck, "__HOST__");
String dbport_pwdCheck = ElementParameterParser.getValue(node_pwdCheck, "__PORT__");
String dbname_pwdCheck = ElementParameterParser.getValue(node_pwdCheck, "__DBNAME__");
String dbproperties_pwdCheck = ElementParameterParser.getValue(node_pwdCheck, "__PROPERTIES__");
String localServiceName_pwdCheck = ElementParameterParser.getValue(node_pwdCheck, "__LOCAL_SERVICE_NAME__");
final class ValueChecker {
public boolean checkValueForPassword(String inputValue, org.talend.core.model.process.IContext context) {
if(null == inputValue) {
return false;
}
java.util.List<String> parsed = new java.util.ArrayList<String>();
String value = inputValue.trim();
while(org.talend.core.model.utils.ContextParameterUtils.containContextVariables(value)) {
String nonQuoteStr = org.talend.core.utils.TalendQuoteUtils.filterQuote(value);
String contextVar = org.talend.core.model.utils.ContextParameterUtils.getVariableFromCode(nonQuoteStr);
parsed.add(contextVar);
String curValue = org.talend.core.model.utils.ContextParameterUtils.JAVA_NEW_CONTEXT_PREFIX + contextVar;
int index = value.indexOf(curValue);
if(index != -1) {
value = value.substring(index + curValue.length(), value.length());
}
}
for(String parsedParam : parsed) {
org.talend.core.model.process.IContextParameter param = context.getContextParameter(parsedParam);
if(org.talend.core.model.utils.ContextParameterUtils.isPasswordType(param)) {
return true;
}
}
return false;
}
}
ValueChecker checker = new ValueChecker();
org.talend.core.model.process.IContext context_pwdCheck = node_pwdCheck.getProcess().getContextManager().getDefaultContext();
if(checker.checkValueForPassword(dbhost_pwdCheck, context_pwdCheck) || checker.checkValueForPassword(dbport_pwdCheck, context_pwdCheck) || checker.checkValueForPassword(dbname_pwdCheck, context_pwdCheck) || checker.checkValueForPassword(dbproperties_pwdCheck, context_pwdCheck) || checker.checkValueForPassword(localServiceName_pwdCheck, context_pwdCheck)) {
%>
if(true) {
throw new RuntimeException("Password context variable is used in plain text field!");
}
<%
}
}
//
class DBRowBeginUtil extends DefaultDBRowUtil{
public void beforeComponentProcess(INode node){

View File

@@ -18,6 +18,56 @@ skeleton="../templates/slowly_change_dimension.skeleton"
%>
<%
//TPS-3315
org.talend.designer.codegen.config.CodeGeneratorArgument codeGenArgument_pwdCheck = (org.talend.designer.codegen.config.CodeGeneratorArgument)argument;
org.talend.core.model.process.INode node_pwdCheck = (org.talend.core.model.process.INode)codeGenArgument_pwdCheck.getArgument();
boolean useExistingConnection_pwdCheck = "true".equalsIgnoreCase(ElementParameterParser.getValue(node_pwdCheck,"__USE_EXISTING_CONNECTION__"));
if(!useExistingConnection_pwdCheck) {
String user_pwdCheck = ElementParameterParser.getValue(node_pwdCheck, "__USER__");
String dbhost_pwdCheck = ElementParameterParser.getValue(node_pwdCheck, "__HOST__");
String dbport_pwdCheck = ElementParameterParser.getValue(node_pwdCheck, "__PORT__");
String dbname_pwdCheck = ElementParameterParser.getValue(node_pwdCheck, "__DBNAME__");
String dbproperties_pwdCheck = ElementParameterParser.getValue(node_pwdCheck, "__PROPERTIES__");
String localServiceName_pwdCheck = ElementParameterParser.getValue(node_pwdCheck, "__LOCAL_SERVICE_NAME__");
final class ValueChecker {
public boolean checkValueForPassword(String inputValue, org.talend.core.model.process.IContext context) {
if(null == inputValue) {
return false;
}
java.util.List<String> parsed = new java.util.ArrayList<String>();
String value = inputValue.trim();
while(org.talend.core.model.utils.ContextParameterUtils.containContextVariables(value)) {
String nonQuoteStr = org.talend.core.utils.TalendQuoteUtils.filterQuote(value);
String contextVar = org.talend.core.model.utils.ContextParameterUtils.getVariableFromCode(nonQuoteStr);
parsed.add(contextVar);
String curValue = org.talend.core.model.utils.ContextParameterUtils.JAVA_NEW_CONTEXT_PREFIX + contextVar;
int index = value.indexOf(curValue);
if(index != -1) {
value = value.substring(index + curValue.length(), value.length());
}
}
for(String parsedParam : parsed) {
org.talend.core.model.process.IContextParameter param = context.getContextParameter(parsedParam);
if(org.talend.core.model.utils.ContextParameterUtils.isPasswordType(param)) {
return true;
}
}
return false;
}
}
ValueChecker checker = new ValueChecker();
org.talend.core.model.process.IContext context_pwdCheck = node_pwdCheck.getProcess().getContextManager().getDefaultContext();
if(checker.checkValueForPassword(dbhost_pwdCheck, context_pwdCheck) || checker.checkValueForPassword(dbport_pwdCheck, context_pwdCheck) || checker.checkValueForPassword(dbname_pwdCheck, context_pwdCheck) || checker.checkValueForPassword(dbproperties_pwdCheck, context_pwdCheck) || checker.checkValueForPassword(localServiceName_pwdCheck, context_pwdCheck)) {
%>
if(true) {
throw new RuntimeException("Password context variable is used in plain text field!");
}
<%
}
}
//
CodeGeneratorArgument codeGenArgument = (CodeGeneratorArgument) argument;
INode node = (INode) codeGenArgument.getArgument();
String cid = node.getUniqueName();

View File

@@ -14,8 +14,57 @@ imports="
"
skeleton="../templates/db_output_bulk.skeleton"
%>
<%
//TPS-3315
org.talend.designer.codegen.config.CodeGeneratorArgument codeGenArgument_pwdCheck = (org.talend.designer.codegen.config.CodeGeneratorArgument)argument;
org.talend.core.model.process.INode node_pwdCheck = (org.talend.core.model.process.INode)codeGenArgument_pwdCheck.getArgument();
boolean useExistingConnection_pwdCheck = "true".equalsIgnoreCase(ElementParameterParser.getValue(node_pwdCheck,"__USE_EXISTING_CONNECTION__"));
if(!useExistingConnection_pwdCheck) {
String user_pwdCheck = ElementParameterParser.getValue(node_pwdCheck, "__USER__");
String dbhost_pwdCheck = ElementParameterParser.getValue(node_pwdCheck, "__HOST__");
String dbport_pwdCheck = ElementParameterParser.getValue(node_pwdCheck, "__PORT__");
String dbname_pwdCheck = ElementParameterParser.getValue(node_pwdCheck, "__DBNAME__");
String dbproperties_pwdCheck = ElementParameterParser.getValue(node_pwdCheck, "__PROPERTIES__");
String localServiceName_pwdCheck = ElementParameterParser.getValue(node_pwdCheck, "__LOCAL_SERVICE_NAME__");
final class ValueChecker {
public boolean checkValueForPassword(String inputValue, org.talend.core.model.process.IContext context) {
if(null == inputValue) {
return false;
}
java.util.List<String> parsed = new java.util.ArrayList<String>();
String value = inputValue.trim();
while(org.talend.core.model.utils.ContextParameterUtils.containContextVariables(value)) {
String nonQuoteStr = org.talend.core.utils.TalendQuoteUtils.filterQuote(value);
String contextVar = org.talend.core.model.utils.ContextParameterUtils.getVariableFromCode(nonQuoteStr);
parsed.add(contextVar);
String curValue = org.talend.core.model.utils.ContextParameterUtils.JAVA_NEW_CONTEXT_PREFIX + contextVar;
int index = value.indexOf(curValue);
if(index != -1) {
value = value.substring(index + curValue.length(), value.length());
}
}
for(String parsedParam : parsed) {
org.talend.core.model.process.IContextParameter param = context.getContextParameter(parsedParam);
if(org.talend.core.model.utils.ContextParameterUtils.isPasswordType(param)) {
return true;
}
}
return false;
}
}
ValueChecker checker = new ValueChecker();
org.talend.core.model.process.IContext context_pwdCheck = node_pwdCheck.getProcess().getContextManager().getDefaultContext();
if(checker.checkValueForPassword(dbhost_pwdCheck, context_pwdCheck) || checker.checkValueForPassword(dbport_pwdCheck, context_pwdCheck) || checker.checkValueForPassword(dbname_pwdCheck, context_pwdCheck) || checker.checkValueForPassword(dbproperties_pwdCheck, context_pwdCheck) || checker.checkValueForPassword(localServiceName_pwdCheck, context_pwdCheck)) {
%>
if(true) {
throw new RuntimeException("Password context variable is used in plain text field!");
}
<%
}
}
//
CodeGeneratorArgument codeGenArgument = (CodeGeneratorArgument) argument;
INode node = (INode)codeGenArgument.getArgument();
String cid = node.getUniqueName();

View File

@@ -7,8 +7,57 @@ imports="
java.util.Map
"
%>
<%
//TPS-3315
org.talend.designer.codegen.config.CodeGeneratorArgument codeGenArgument_pwdCheck = (org.talend.designer.codegen.config.CodeGeneratorArgument)argument;
org.talend.core.model.process.INode node_pwdCheck = (org.talend.core.model.process.INode)codeGenArgument_pwdCheck.getArgument();
boolean useExistingConnection_pwdCheck = "true".equalsIgnoreCase(ElementParameterParser.getValue(node_pwdCheck,"__USE_EXISTING_CONNECTION__"));
if(!useExistingConnection_pwdCheck) {
String user_pwdCheck = ElementParameterParser.getValue(node_pwdCheck, "__USER__");
String dbhost_pwdCheck = ElementParameterParser.getValue(node_pwdCheck, "__HOST__");
String dbport_pwdCheck = ElementParameterParser.getValue(node_pwdCheck, "__PORT__");
String dbname_pwdCheck = ElementParameterParser.getValue(node_pwdCheck, "__DBNAME__");
String dbproperties_pwdCheck = ElementParameterParser.getValue(node_pwdCheck, "__PROPERTIES__");
String localServiceName_pwdCheck = ElementParameterParser.getValue(node_pwdCheck, "__LOCAL_SERVICE_NAME__");
final class ValueChecker {
public boolean checkValueForPassword(String inputValue, org.talend.core.model.process.IContext context) {
if(null == inputValue) {
return false;
}
java.util.List<String> parsed = new java.util.ArrayList<String>();
String value = inputValue.trim();
while(org.talend.core.model.utils.ContextParameterUtils.containContextVariables(value)) {
String nonQuoteStr = org.talend.core.utils.TalendQuoteUtils.filterQuote(value);
String contextVar = org.talend.core.model.utils.ContextParameterUtils.getVariableFromCode(nonQuoteStr);
parsed.add(contextVar);
String curValue = org.talend.core.model.utils.ContextParameterUtils.JAVA_NEW_CONTEXT_PREFIX + contextVar;
int index = value.indexOf(curValue);
if(index != -1) {
value = value.substring(index + curValue.length(), value.length());
}
}
for(String parsedParam : parsed) {
org.talend.core.model.process.IContextParameter param = context.getContextParameter(parsedParam);
if(org.talend.core.model.utils.ContextParameterUtils.isPasswordType(param)) {
return true;
}
}
return false;
}
}
ValueChecker checker = new ValueChecker();
org.talend.core.model.process.IContext context_pwdCheck = node_pwdCheck.getProcess().getContextManager().getDefaultContext();
if(checker.checkValueForPassword(dbhost_pwdCheck, context_pwdCheck) || checker.checkValueForPassword(dbport_pwdCheck, context_pwdCheck) || checker.checkValueForPassword(dbname_pwdCheck, context_pwdCheck) || checker.checkValueForPassword(dbproperties_pwdCheck, context_pwdCheck) || checker.checkValueForPassword(localServiceName_pwdCheck, context_pwdCheck)) {
%>
if(true) {
throw new RuntimeException("Password context variable is used in plain text field!");
}
<%
}
}
//
CodeGeneratorArgument codeGenArgument = (CodeGeneratorArgument) argument;
INode node = (INode) codeGenArgument.getArgument();
String cid = node.getUniqueName();

View File

@@ -14,6 +14,7 @@ imports="
skeleton="../templates/db_output_bulk.skeleton"
%>
<%@ include file="../templates/Log4j/Log4jDBConnUtil.javajet"%>
<%@ include file="@{org.talend.designer.components.localprovider}/components/templates/DB/CheckContextPassword.javajet"%>
<%
CodeGeneratorArgument codeGenArgument = (CodeGeneratorArgument) argument;
INode node = (INode)codeGenArgument.getArgument();
@@ -99,17 +100,17 @@ skeleton="../templates/db_output_bulk.skeleton"
}
%>
String url_<%=cid%> = sbuilder_<%=cid%>.toString();
<% if (!"SSO".equals(jdbcUrl)){
String passwordFieldName = "__PASS__";
if (ElementParameterParser.canEncrypt(node, passwordFieldName)) {%>
final String decryptedPass_<%=cid%> = routines.system.PasswordEncryptUtil.decryptPassword(<%=ElementParameterParser.getEncryptedValue(node, passwordFieldName)%>);
<%} else {%>
final String decryptedPass_<%=cid%> = <%= ElementParameterParser.getValue(node, passwordFieldName)%>;
<%}%>
String dbUser_<%=cid %> = <%=userName%>;
String dbPwd_<%=cid %> = decryptedPass_<%=cid%>;
<% }
<%
String passwordFieldName = "__PASS__";
if (ElementParameterParser.canEncrypt(node, passwordFieldName)) {%>
final String decryptedPass_<%=cid%> = routines.system.PasswordEncryptUtil.decryptPassword(<%=ElementParameterParser.getEncryptedValue(node, passwordFieldName)%>);
<%} else {%>
final String decryptedPass_<%=cid%> = <%= ElementParameterParser.getValue(node, passwordFieldName)%>;
<%}%>
String dbUser_<%=cid %> = <%=userName%>;
String dbPwd_<%=cid %> = decryptedPass_<%=cid%>;
<%
log4jCodeGenerateUtil.connect(node);
}

View File

@@ -70,13 +70,13 @@
<PARAMETER NAME="USER" FIELD="TEXT" NUM_ROW="5"
REPOSITORY_VALUE="USERNAME" REQUIRED="true"
SHOW_IF="(USE_EXISTING_CONNECTION == 'false') AND (JDBC_URL=='STANDARD')" GROUP="DB_CONFIG">
SHOW_IF="(USE_EXISTING_CONNECTION == 'false') " GROUP="DB_CONFIG">
<DEFAULT>""</DEFAULT>
</PARAMETER>
<PARAMETER NAME="PASS" FIELD="PASSWORD" NUM_ROW="5"
REPOSITORY_VALUE="PASSWORD" REQUIRED="true"
SHOW_IF="(USE_EXISTING_CONNECTION == 'false') AND (JDBC_URL=='STANDARD')" GROUP="DB_CONFIG">
SHOW_IF="(USE_EXISTING_CONNECTION == 'false') " GROUP="DB_CONFIG">
<DEFAULT>""</DEFAULT>
</PARAMETER>
@@ -419,7 +419,7 @@
UrlPath="platform:/plugin/org.talend.libraries.apache.common/lib/commons-logging-1.1.3.jar"
REQUIRED_IF="(JDBC_URL == 'SSO') AND (USE_EXISTING_CONNECTION == 'false')" />
<IMPORT NAME="commons-codec-1.6.jar" MODULE="commons-codec-1.6.jar"
MVN="mvn:org.talend.libraries/commons-codec-1.6/6.0.0"
MVN="mvn:commons-codec/commons-codec/1.6"
UrlPath="platform:/plugin/org.talend.libraries.apache.common/lib/commons-codec-1.6.jar"
REQUIRED="true" />
</IMPORTS>

View File

@@ -6,6 +6,7 @@ imports="
"
%>
<%@ include file="../templates/DB/HelpClass/HelpClass.javajet"%>
<%@ include file="@{org.talend.designer.components.localprovider}/components/templates/DB/CheckContextPassword.javajet"%>
<%
class ConnectionUtil extends DefaultConnectionUtil{

View File

@@ -99,7 +99,6 @@
NUM_ROW="4"
REPOSITORY_VALUE="USERNAME"
REQUIRED="true"
SHOW_IF="JDBC_URL=='STANDARD'"
>
<DEFAULT>""</DEFAULT>
</PARAMETER>
@@ -110,7 +109,6 @@
NUM_ROW="4"
REPOSITORY_VALUE="PASSWORD"
REQUIRED="true"
SHOW_IF="JDBC_URL=='STANDARD'"
>
<DEFAULT>""</DEFAULT>
</PARAMETER>
@@ -207,6 +205,7 @@
<IMPORT NAME="httpcore-4.4.9.jar" MODULE="httpcore-4.4.9.jar" MVN="mvn:org.apache.httpcomponents/httpcore/4.4.9" REQUIRED_IF="(JDBC_URL == 'SSO')" />
<IMPORT NAME="httpclient-4.5.5.jar" MODULE="httpclient-4.5.5.jar" MVN="mvn:org.apache.httpcomponents/httpclient/4.5.5" REQUIRED_IF="(JDBC_URL == 'SSO')" />
<IMPORT NAME="joda-time-2.8.1.jar" MODULE="joda-time-2.8.1.jar" MVN="mvn:joda-time/joda-time/2.8.1" REQUIRED_IF="(JDBC_URL == 'SSO')" />
<IMPORT NAME="commons-codec-1.6.jar" MODULE="commons-codec-1.6.jar" MVN="mvn:commons-codec/commons-codec/1.6" UrlPath="platform:/plugin/org.talend.libraries.apache.common/lib/commons-codec-1.6.jar" REQUIRED_IF="(JDBC_URL == 'SSO')" />
</IMPORTS>
</CODEGENERATION>

View File

@@ -13,6 +13,7 @@ imports="
"
%>
<%@ include file="../templates/DB/Input/HelpClass.javajet"%>
<%@ include file="@{org.talend.designer.components.localprovider}/components/templates/DB/CheckContextPassword.javajet"%>
<%
class DBInputBeginUtil extends DefaultDBInputUtil{
@@ -76,8 +77,7 @@ imports="
public void createConnection(INode node) {
String jdbcUrl = ElementParameterParser.getValue(node, "__JDBC_URL__");
if ("SSO".equals(jdbcUrl)) needUserAndPassword = false;
super.createConnection(node, needUserAndPassword);
super.createConnection(node);
String useCursor= ElementParameterParser.getValue(node, "__USE_CURSOR__");
if(("true").equals(useCursor)) {
log4jCodeGenerateUtil.autoCommit(node,false);

View File

@@ -120,7 +120,7 @@
NUM_ROW="5"
REPOSITORY_VALUE="USERNAME"
REQUIRED="true"
SHOW_IF="(USE_EXISTING_CONNECTION == 'false') AND (JDBC_URL=='STANDARD')"
SHOW_IF="(USE_EXISTING_CONNECTION == 'false') "
>
<DEFAULT>""</DEFAULT>
</PARAMETER>
@@ -131,7 +131,7 @@
NUM_ROW="5"
REPOSITORY_VALUE="PASSWORD"
REQUIRED="true"
SHOW_IF="(USE_EXISTING_CONNECTION == 'false') AND (JDBC_URL=='STANDARD')"
SHOW_IF="(USE_EXISTING_CONNECTION == 'false') "
>
<DEFAULT>""</DEFAULT>
</PARAMETER>
@@ -288,6 +288,7 @@
<IMPORT NAME="httpcore-4.4.9.jar" MODULE="httpcore-4.4.9.jar" MVN="mvn:org.apache.httpcomponents/httpcore/4.4.9" REQUIRED_IF="(JDBC_URL == 'SSO') AND (USE_EXISTING_CONNECTION == 'false')" />
<IMPORT NAME="httpclient-4.5.5.jar" MODULE="httpclient-4.5.5.jar" MVN="mvn:org.apache.httpcomponents/httpclient/4.5.5" REQUIRED_IF="(JDBC_URL == 'SSO') AND (USE_EXISTING_CONNECTION == 'false')" />
<IMPORT NAME="joda-time-2.8.1.jar" MODULE="joda-time-2.8.1.jar" MVN="mvn:joda-time/joda-time/2.8.1" REQUIRED_IF="(JDBC_URL == 'SSO') AND (USE_EXISTING_CONNECTION == 'false')" />
<IMPORT NAME="commons-codec-1.6.jar" MODULE="commons-codec-1.6.jar" MVN="mvn:commons-codec/commons-codec/1.6" UrlPath="platform:/plugin/org.talend.libraries.apache.common/lib/commons-codec-1.6.jar" REQUIRED_IF="(JDBC_URL == 'SSO') AND (USE_EXISTING_CONNECTION == 'false')" />
</IMPORTS>
</CODEGENERATION>

View File

@@ -16,6 +16,7 @@ imports="
skeleton="../templates/db_output_bulk.skeleton"
%>
<%@ include file="@{org.talend.designer.components.localprovider}/components/templates/Log4j/DBLogUtil.javajet"%>
<%@ include file="@{org.talend.designer.components.localprovider}/components/templates/DB/CheckContextPassword.javajet"%>
<%
CodeGeneratorArgument codeGenArgument = (CodeGeneratorArgument) argument;
INode node = (INode)codeGenArgument.getArgument();
@@ -221,11 +222,7 @@ if(("true").equals(useExistingConn)) {
jdbcUrl = ElementParameterParser.getValue(ne, "__JDBC_URL__");
}
}
if ("SSO".equals(jdbcUrl)){
dbLog.conn().useExistConn("conn_"+cid+".getMetaData().getURL()", null);
} else {
dbLog.conn().useExistConn("conn_"+cid+".getMetaData().getURL()", "conn_"+cid+".getMetaData().getUserName()");
}
dbLog.conn().useExistConn("conn_"+cid+".getMetaData().getURL()", "conn_"+cid+".getMetaData().getUserName()");
%>
<%
} else {
@@ -261,23 +258,18 @@ if(("true").equals(useExistingConn)) {
<% if ("SSO".equals(jdbcUrl)){%>
conn_<%=cid%> = java.sql.DriverManager.getConnection(url_<%=cid %>);
<%dbLog.conn().connTry(dbLog.var("url"), null);%>
<%dbLog.conn().connDone(dbLog.var("url"));%>
<% } else {%>
String dbUser_<%=cid %> = <%=dbuser%>;
<%
String passwordFieldName = "__PASS__";
%>
String dbUser_<%=cid %> = <%=dbuser%>;
<%
String passwordFieldName = "__PASS__";
%>
<%@ include file="@{org.talend.designer.components.localprovider}/components/templates/password.javajet"%>
<%@ include file="@{org.talend.designer.components.localprovider}/components/templates/password.javajet"%>
String dbPwd_<%=cid %> = decryptedPassword_<%=cid%>;
conn_<%=cid%> = java.sql.DriverManager.getConnection(url_<%=cid %>,dbUser_<%=cid%>,dbPwd_<%=cid%>);
<%dbLog.conn().connTry(dbLog.var("url"), dbLog.var("dbUser"));%>
<%dbLog.conn().connDone(dbLog.var("url"));%>
<% }%>
String dbPwd_<%=cid %> = decryptedPassword_<%=cid%>;
conn_<%=cid%> = java.sql.DriverManager.getConnection(url_<%=cid %>,dbUser_<%=cid%>,dbPwd_<%=cid%>);
<%dbLog.conn().connTry(dbLog.var("url"), dbLog.var("dbUser"));%>
<%dbLog.conn().connDone(dbLog.var("url"));%>
resourceMap.put("conn_<%=cid%>", conn_<%=cid%>);
conn_<%=cid%>.setAutoCommit(false);
<%

View File

@@ -124,7 +124,7 @@
NUM_ROW="5"
REPOSITORY_VALUE="USERNAME"
REQUIRED="true"
SHOW_IF="(USE_EXISTING_CONNECTION == 'false') AND (JDBC_URL=='STANDARD')"
SHOW_IF="(USE_EXISTING_CONNECTION == 'false') "
>
<DEFAULT>""</DEFAULT>
</PARAMETER>
@@ -135,7 +135,7 @@
NUM_ROW="5"
REPOSITORY_VALUE="PASSWORD"
REQUIRED="true"
SHOW_IF="(USE_EXISTING_CONNECTION == 'false') AND (JDBC_URL=='STANDARD')"
SHOW_IF="(USE_EXISTING_CONNECTION == 'false') "
>
<DEFAULT>""</DEFAULT>
</PARAMETER>
@@ -378,6 +378,7 @@
<IMPORT NAME="httpcore-4.4.9.jar" MODULE="httpcore-4.4.9.jar" MVN="mvn:org.apache.httpcomponents/httpcore/4.4.9" REQUIRED_IF="(JDBC_URL == 'SSO') AND (USE_EXISTING_CONNECTION == 'false')" />
<IMPORT NAME="httpclient-4.5.5.jar" MODULE="httpclient-4.5.5.jar" MVN="mvn:org.apache.httpcomponents/httpclient/4.5.5" REQUIRED_IF="(JDBC_URL == 'SSO') AND (USE_EXISTING_CONNECTION == 'false')" />
<IMPORT NAME="joda-time-2.8.1.jar" MODULE="joda-time-2.8.1.jar" MVN="mvn:joda-time/joda-time/2.8.1" REQUIRED_IF="(JDBC_URL == 'SSO') AND (USE_EXISTING_CONNECTION == 'false')" />
<IMPORT NAME="commons-codec-1.6.jar" MODULE="commons-codec-1.6.jar" MVN="mvn:commons-codec/commons-codec/1.6" UrlPath="platform:/plugin/org.talend.libraries.apache.common/lib/commons-codec-1.6.jar" REQUIRED_IF="(JDBC_URL == 'SSO') AND (USE_EXISTING_CONNECTION == 'false')" />
</IMPORTS>
</CODEGENERATION>

View File

@@ -63,12 +63,12 @@
<DEFAULT>Redshift</DEFAULT>
</PARAMETER>
<PARAMETER NAME="USER" FIELD="TEXT" NUM_ROW="5" SHOW_IF="(USE_EXISTING_CONNECTION == 'false') AND (JDBC_URL=='STANDARD')"
<PARAMETER NAME="USER" FIELD="TEXT" NUM_ROW="5" SHOW_IF="(USE_EXISTING_CONNECTION == 'false') "
REPOSITORY_VALUE="USERNAME" REQUIRED="true" GROUP="DB_CONFIG">
<DEFAULT>""</DEFAULT>
</PARAMETER>
<PARAMETER NAME="PASS" FIELD="PASSWORD" NUM_ROW="5" SHOW_IF="(USE_EXISTING_CONNECTION == 'false') AND (JDBC_URL=='STANDARD')"
<PARAMETER NAME="PASS" FIELD="PASSWORD" NUM_ROW="5" SHOW_IF="(USE_EXISTING_CONNECTION == 'false') "
REPOSITORY_VALUE="PASSWORD" REQUIRED="true" GROUP="DB_CONFIG">
<DEFAULT>""</DEFAULT>
</PARAMETER>
@@ -538,7 +538,7 @@
UrlPath="platform:/plugin/org.talend.libraries.apache.common/lib/commons-logging-1.1.3.jar"
REQUIRED="true" />
<IMPORT NAME="commons-codec-1.6.jar" MODULE="commons-codec-1.6.jar"
MVN="mvn:org.talend.libraries/commons-codec-1.6/6.0.0"
MVN="mvn:commons-codec/commons-codec/1.6"
UrlPath="platform:/plugin/org.talend.libraries.apache.common/lib/commons-codec-1.6.jar"
REQUIRED="true" />
</IMPORTS>

View File

@@ -8,6 +8,7 @@ imports="
"
%>
<%@ include file="../templates/DB/Row/HelpClass.javajet"%>
<%@ include file="@{org.talend.designer.components.localprovider}/components/templates/DB/CheckContextPassword.javajet"%>
<%
class DBRowBeginUtil extends DefaultDBRowUtil{

View File

@@ -122,7 +122,7 @@
NUM_ROW="5"
REPOSITORY_VALUE="USERNAME"
REQUIRED="true"
SHOW_IF="(USE_EXISTING_CONNECTION == 'false') AND (JDBC_URL=='STANDARD')"
SHOW_IF="(USE_EXISTING_CONNECTION == 'false') "
>
<DEFAULT>""</DEFAULT>
</PARAMETER>
@@ -133,7 +133,7 @@
NUM_ROW="5"
REPOSITORY_VALUE="PASSWORD"
REQUIRED="true"
SHOW_IF="(USE_EXISTING_CONNECTION == 'false') AND (JDBC_URL=='STANDARD')"
SHOW_IF="(USE_EXISTING_CONNECTION == 'false') "
>
<DEFAULT>""</DEFAULT>
</PARAMETER>
@@ -306,6 +306,7 @@
<IMPORT NAME="httpcore-4.4.9.jar" MODULE="httpcore-4.4.9.jar" MVN="mvn:org.apache.httpcomponents/httpcore/4.4.9" REQUIRED_IF="(JDBC_URL == 'SSO') AND (USE_EXISTING_CONNECTION == 'false')" />
<IMPORT NAME="httpclient-4.5.5.jar" MODULE="httpclient-4.5.5.jar" MVN="mvn:org.apache.httpcomponents/httpclient/4.5.5" REQUIRED_IF="(JDBC_URL == 'SSO') AND (USE_EXISTING_CONNECTION == 'false')" />
<IMPORT NAME="joda-time-2.8.1.jar" MODULE="joda-time-2.8.1.jar" MVN="mvn:joda-time/joda-time/2.8.1" REQUIRED_IF="(JDBC_URL == 'SSO') AND (USE_EXISTING_CONNECTION == 'false')" />
<IMPORT NAME="commons-codec-1.6.jar" MODULE="commons-codec-1.6.jar" MVN="mvn:commons-codec/commons-codec/1.6" UrlPath="platform:/plugin/org.talend.libraries.apache.common/lib/commons-codec-1.6.jar" REQUIRED_IF="(JDBC_URL == 'SSO') AND (USE_EXISTING_CONNECTION == 'false')" />
</IMPORTS>
</CODEGENERATION>

View File

@@ -14,6 +14,7 @@ imports="
"
%>
<%@ include file="../templates/Log4j/Log4jDBConnUtil.javajet"%>
<%@ include file="@{org.talend.designer.components.localprovider}/components/templates/DB/CheckContextPassword.javajet"%>
<%
CodeGeneratorArgument codeGenArgument = (CodeGeneratorArgument) argument;
INode node = (INode)codeGenArgument.getArgument();
@@ -48,8 +49,7 @@ imports="
jdbcUrl = ElementParameterParser.getValue(ne, "__JDBC_URL__");
}
}
boolean needUserAndPassword = !"SSO".equals(jdbcUrl);
log4jCodeGenerateUtil.useExistConnection(node, needUserAndPassword);
log4jCodeGenerateUtil.useExistConnection(node);
} else {
%>
String driverClass_<%=cid%> = "com.amazon.redshift.jdbc42.Driver";
@@ -78,17 +78,16 @@ imports="
%>
String url_<%=cid%> = sbuilder_<%=cid%>.toString();
<%
if (!"SSO".equals(jdbcUrl)){
String passwordFieldName = "__PASS__";
%>
<%if (ElementParameterParser.canEncrypt(node, passwordFieldName)) {%>
final String decryptedPass_<%=cid%> = routines.system.PasswordEncryptUtil.decryptPassword(<%=ElementParameterParser.getEncryptedValue(node, passwordFieldName)%>);
<%} else {%>
final String decryptedPass_<%=cid%> = <%= ElementParameterParser.getValue(node, passwordFieldName)%>;
<%}%>
String dbUser_<%=cid %> = <%=userName%>;
String dbPwd_<%=cid %> = decryptedPass_<%=cid%>;
<% }
String passwordFieldName = "__PASS__";
%>
<%if (ElementParameterParser.canEncrypt(node, passwordFieldName)) {%>
final String decryptedPass_<%=cid%> = routines.system.PasswordEncryptUtil.decryptPassword(<%=ElementParameterParser.getEncryptedValue(node, passwordFieldName)%>);
<%} else {%>
final String decryptedPass_<%=cid%> = <%= ElementParameterParser.getValue(node, passwordFieldName)%>;
<%}%>
String dbUser_<%=cid %> = <%=userName%>;
String dbPwd_<%=cid %> = decryptedPass_<%=cid%>;
<%
log4jCodeGenerateUtil.connect(node);
}

View File

@@ -62,12 +62,12 @@
<DEFAULT>Redshift</DEFAULT>
</PARAMETER>
<PARAMETER NAME="USER" FIELD="TEXT" NUM_ROW="5" SHOW_IF="(USE_EXISTING_CONNECTION == 'false') AND (JDBC_URL=='STANDARD')"
<PARAMETER NAME="USER" FIELD="TEXT" NUM_ROW="5" SHOW_IF="(USE_EXISTING_CONNECTION == 'false') "
REPOSITORY_VALUE="USERNAME" REQUIRED="true" GROUP="DB_CONFIG">
<DEFAULT>""</DEFAULT>
</PARAMETER>
<PARAMETER NAME="PASS" FIELD="PASSWORD" NUM_ROW="5" SHOW_IF="(USE_EXISTING_CONNECTION == 'false') AND (JDBC_URL=='STANDARD')"
<PARAMETER NAME="PASS" FIELD="PASSWORD" NUM_ROW="5" SHOW_IF="(USE_EXISTING_CONNECTION == 'false') "
REPOSITORY_VALUE="PASSWORD" REQUIRED="true" GROUP="DB_CONFIG">
<DEFAULT>""</DEFAULT>
</PARAMETER>
@@ -281,6 +281,7 @@
<IMPORT NAME="httpcore-4.4.9.jar" MODULE="httpcore-4.4.9.jar" MVN="mvn:org.apache.httpcomponents/httpcore/4.4.9" REQUIRED_IF="(JDBC_URL == 'SSO') AND (USE_EXISTING_CONNECTION == 'false')" />
<IMPORT NAME="httpclient-4.5.5.jar" MODULE="httpclient-4.5.5.jar" MVN="mvn:org.apache.httpcomponents/httpclient/4.5.5" REQUIRED_IF="(JDBC_URL == 'SSO') AND (USE_EXISTING_CONNECTION == 'false')" />
<IMPORT NAME="joda-time-2.8.1.jar" MODULE="joda-time-2.8.1.jar" MVN="mvn:joda-time/joda-time/2.8.1" REQUIRED_IF="(JDBC_URL == 'SSO') AND (USE_EXISTING_CONNECTION == 'false')" />
<IMPORT NAME="commons-codec-1.6.jar" MODULE="commons-codec-1.6.jar" MVN="mvn:commons-codec/commons-codec/1.6" UrlPath="platform:/plugin/org.talend.libraries.apache.common/lib/commons-codec-1.6.jar" REQUIRED_IF="(JDBC_URL == 'SSO') AND (USE_EXISTING_CONNECTION == 'false')" />
</IMPORTS>
</CODEGENERATION>
<RETURNS />

View File

@@ -26,22 +26,17 @@ imports="
connUtil.beforeComponentProcess(node);
connUtil.createURL(node);
%>
<%
if (!"SSO".equals(ElementParameterParser.getValue(node, "__JDBC_URL__"))){
%>
String dbUser_<%=cid%> = <%=(dbuser != null && dbuser.trim().length() == 0)? "null":dbuser%>;<%//the tSQLiteConnection component not contain user and pass return null%>
<%if(dbpass != null && dbpass.trim().length() == 0) {%>
String dbPwd_<%=cid%> = null;
<%} else {
String passwordFieldName = "__PASS__";
%>
<%@ include file="@{org.talend.designer.components.localprovider}/components/templates/password.javajet"%>
String dbPwd_<%=cid%> = decryptedPassword_<%=cid%>;
<%}%>
<%
}
%>
String dbUser_<%=cid%> = <%=(dbuser != null && dbuser.trim().length() == 0)? "null":dbuser%>;<%//the tSQLiteConnection component not contain user and pass return null%>
<%if(dbpass != null && dbpass.trim().length() == 0) {%>
String dbPwd_<%=cid%> = null;
<%} else {
String passwordFieldName = "__PASS__";
%>
<%@ include file="@{org.talend.designer.components.localprovider}/components/templates/password.javajet"%>
String dbPwd_<%=cid%> = decryptedPassword_<%=cid%>;
<%}%>
java.sql.Connection conn_<%=cid%> = null;
<%@ include file="../Log4j/Log4jDBConnUtil.javajet"%>
<%
@@ -63,13 +58,8 @@ imports="
<%connUtil.classForName(node);%>
<%
log4jCodeGenerateUtil.debugConnectionParams(node);
if ("SSO".equals(ElementParameterParser.getValue(node, "__JDBC_URL__"))){
log4jCodeGenerateUtil.connect_begin_noUser();
connUtil.createConnection(node, false);
} else {
log4jCodeGenerateUtil.connect_begin();
connUtil.createConnection(node);
}
log4jCodeGenerateUtil.connect_begin();
connUtil.createConnection(node);
log4jCodeGenerateUtil.connect_end();
%>

View File

@@ -0,0 +1,50 @@
<%@jet%>
<%
org.talend.designer.codegen.config.CodeGeneratorArgument codeGenArgument_pwdCheck = (org.talend.designer.codegen.config.CodeGeneratorArgument)argument;
org.talend.core.model.process.INode node_pwdCheck = (org.talend.core.model.process.INode)codeGenArgument_pwdCheck.getArgument();
boolean useExistingConnection_pwdCheck = "true".equalsIgnoreCase(ElementParameterParser.getValue(node_pwdCheck,"__USE_EXISTING_CONNECTION__"));
if(!useExistingConnection_pwdCheck) {
String dbhost_pwdCheck = ElementParameterParser.getValue(node_pwdCheck, "__HOST__");
String dbuser_pwdCheck = ElementParameterParser.getValue(node_pwdCheck, "__USER__");
String dbport_pwdCheck = ElementParameterParser.getValue(node_pwdCheck, "__PORT__");
String dbname_pwdCheck = ElementParameterParser.getValue(node_pwdCheck, "__DBNAME__");
String dbproperties_pwdCheck = ElementParameterParser.getValue(node_pwdCheck, "__PROPERTIES__");
final class ValueChecker {
public boolean checkValueForPassword(String inputValue, org.talend.core.model.process.IContext context) {
if(null == inputValue) {
return false;
}
java.util.List<String> parsed = new java.util.ArrayList<String>();
String value = inputValue.trim();
while(org.talend.core.model.utils.ContextParameterUtils.containContextVariables(value)) {
String nonQuoteStr = org.talend.core.utils.TalendQuoteUtils.filterQuote(value);
String contextVar = org.talend.core.model.utils.ContextParameterUtils.getVariableFromCode(nonQuoteStr);
parsed.add(contextVar);
String curValue = org.talend.core.model.utils.ContextParameterUtils.JAVA_NEW_CONTEXT_PREFIX + contextVar;
int index = value.indexOf(curValue);
if(index != -1) {
value = value.substring(index + curValue.length(), value.length());
}
}
for(String parsedParam : parsed) {
org.talend.core.model.process.IContextParameter param = context.getContextParameter(parsedParam);
if(org.talend.core.model.utils.ContextParameterUtils.isPasswordType(param)) {
return true;
}
}
return false;
}
}
ValueChecker checker = new ValueChecker();
org.talend.core.model.process.IContext context_pwdCheck = node_pwdCheck.getProcess().getContextManager().getDefaultContext();
if(checker.checkValueForPassword(dbhost_pwdCheck, context_pwdCheck) || checker.checkValueForPassword(dbport_pwdCheck, context_pwdCheck) || checker.checkValueForPassword(dbname_pwdCheck, context_pwdCheck) || checker.checkValueForPassword(dbproperties_pwdCheck, context_pwdCheck) || checker.checkValueForPassword(dbuser_pwdCheck, context_pwdCheck)) {
%>
if(true) {
throw new RuntimeException("Password context variable is used in plain text field!");
}
<%
}
}
%>

View File

@@ -73,7 +73,8 @@ imports="
jdbcUrl = ElementParameterParser.getValue(ne, "__JDBC_URL__");
}
}
boolean needUserAndPassword = !"SSO".equals(jdbcUrl);
//TODO changeme
boolean needUserAndPassword = true;
log4jCodeGenerateUtil.useExistConnection(node, needUserAndPassword);
} else {
log4jCodeGenerateUtil.useExistConnection(node);

View File

@@ -93,7 +93,7 @@ imports="
<%this.setURL(node);%>
<%
log4jCodeGenerateUtil.debugConnectionParams(node);
if ("SSO".equals(ElementParameterParser.getValue(node, "__JDBC_URL__")) || !needUserAndPassword){
if (!needUserAndPassword){
log4jCodeGenerateUtil.connect_begin_noUser();
} else {
log4jCodeGenerateUtil.connect_begin();

View File

@@ -27,11 +27,7 @@ imports="
String query_<%=cid %> = "";
boolean whetherReject_<%=cid%> = false;
<%
if ("SSO".equals(ElementParameterParser.getValue(node, "__JDBC_URL__"))){
dbRowBeginUtil.createConnection(node, false);
} else {
dbRowBeginUtil.createConnection(node);
}
dbRowBeginUtil.createConnection(node);
%>
resourceMap.put("conn_<%=cid%>", conn_<%=cid%>);
<%

View File

@@ -81,7 +81,8 @@
jdbcUrl = ElementParameterParser.getValue(ne, "__JDBC_URL__");
}
}
needUserAndPassword = !"SSO".equals(jdbcUrl);
//TODO changeme
needUserAndPassword = true;
this.afterUseExistConnection(node, needUserAndPassword);
} else {
this.afterUseExistConnection(node);

View File

@@ -88,11 +88,7 @@ imports="
public void connect(INode node){
beforeComponentProcess(node);
if ("SSO".equals(ElementParameterParser.getValue(node, "__JDBC_URL__"))){
connectWithSSO();
} else {
connect();
}
connect();
}
public void connect(){
@@ -103,14 +99,6 @@ imports="
connect_end();
}
public void connectWithSSO(){
connect_begin_noUser();
%>
conn_<%=cid%> = java.sql.DriverManager.getConnection(url_<%=cid %>);
<%
connect_end();
}
public void connect_begin(){
logInfo(node,"debug",cid+" - Connection attempt to '\" + url_"+cid+" + \"' with the username '\" + dbUser_"+cid+" + \"'.");
}