Skip to content

Commit

Permalink
fix db2 connect issue (#4995)
Browse files Browse the repository at this point in the history
* fix db2 connect issue

* code format
  • Loading branch information
aiceflower authored Nov 29, 2023
1 parent fc3b23f commit ce0bf43
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package org.apache.linkis.metadata.query.service.db2;

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 +43,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 +120,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 ce0bf43

Please sign in to comment.