Skip to content

Commit

Permalink
fix db2 connect issue
Browse files Browse the repository at this point in the history
  • Loading branch information
aiceflower committed Nov 23, 2023
1 parent 1afc612 commit 1c4f5d3
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
package org.apache.linkis.metadata.query.service.db2;

import org.apache.linkis.common.conf.CommonVars;
import org.apache.linkis.common.conf.CommonVars$;
import org.apache.linkis.common.exception.LinkisSecurityException;
import org.apache.linkis.metadata.query.service.AbstractSqlConnection;

import org.apache.commons.collections.MapUtils;
Expand All @@ -42,6 +44,10 @@ public class SqlConnection extends AbstractSqlConnection {
private static final CommonVars<String> SQL_CONNECT_URL =
CommonVars.apply("wds.linkis.server.mdm.service.db2.url", "jdbc:db2://%s:%s/%s");

/** clientRerouteServerListJNDIName */
private static final CommonVars<String> DB2_SENSITIVE_PARAMS =
CommonVars.apply("linkis.db2.sensitive.params", "clientRerouteServerListJNDIName");

public SqlConnection(
String host,
Integer port,
Expand Down Expand Up @@ -115,6 +121,9 @@ public Connection getDBConnection(ConnectMessage connectMessage, String database
.collect(Collectors.joining("&"));
url += "?" + extraParamString;
}
if (url.toLowerCase().contains(DB2_SENSITIVE_PARAMS.getValue().toLowerCase())){
throw new LinkisSecurityException(35000, "Invalid db2 connection params.");
}
return DriverManager.getConnection(url, connectMessage.username, connectMessage.password);
}

Expand Down

0 comments on commit 1c4f5d3

Please sign in to comment.