Commit 1125fb35 by zinc

修改获取ip端口的正则

parent d3ea414e
package com.palacesun.engine.test; package com.palacesun.engine.test;
import bean.Column; import bean.Column;
import com.alibaba.druid.DbType;
import com.alibaba.druid.sql.SQLUtils;
import com.alibaba.druid.sql.ast.SQLStatement;
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
import com.alibaba.druid.sql.visitor.SchemaStatVisitor;
import com.alibaba.druid.stat.TableStat;
import com.palacesun.engine.common.ConnectionInformation; import com.palacesun.engine.common.ConnectionInformation;
import com.palacesun.engine.common.PreparedStatementInformation; import com.palacesun.engine.common.PreparedStatementInformation;
import com.palacesun.engine.common.ResultSetInformation; import com.palacesun.engine.common.ResultSetInformation;
...@@ -10,11 +16,6 @@ import com.palacesun.engine.gateway.EncryptionGatewayManager; ...@@ -10,11 +16,6 @@ import com.palacesun.engine.gateway.EncryptionGatewayManager;
import com.palacesun.engine.gateway.GatewayContext; import com.palacesun.engine.gateway.GatewayContext;
import com.palacesun.engine.log.DblogClient; import com.palacesun.engine.log.DblogClient;
import com.palacesun.engine.wrapper.ConnectionWrapper; import com.palacesun.engine.wrapper.ConnectionWrapper;
import com.alibaba.druid.DbType;
import com.alibaba.druid.sql.SQLUtils;
import com.alibaba.druid.sql.ast.SQLStatement;
import com.alibaba.druid.sql.visitor.SchemaStatVisitor;
import com.alibaba.druid.stat.TableStat;
import com.palacesun.masking.adapter.StringUtils; import com.palacesun.masking.adapter.StringUtils;
import com.palacesun.masking.log.vo.EncryLogVO; import com.palacesun.masking.log.vo.EncryLogVO;
import com.palacesun.masking.tools.EngineUtil; import com.palacesun.masking.tools.EngineUtil;
...@@ -24,34 +25,33 @@ import com.palacesun.masking.vo.ConnectionInfo; ...@@ -24,34 +25,33 @@ import com.palacesun.masking.vo.ConnectionInfo;
import com.palacesun.masking.vo.JsonRootBean; import com.palacesun.masking.vo.JsonRootBean;
import com.palacesun.masking.vo.TableInfo; import com.palacesun.masking.vo.TableInfo;
import com.palacesun.masking.vo.masking.MaskingColumnInfo; import com.palacesun.masking.vo.masking.MaskingColumnInfo;
import util.SqlUtil;
import java.sql.Connection; import java.sql.Connection;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.ResultSetMetaData; import java.sql.ResultSetMetaData;
import java.sql.SQLException; import java.sql.SQLException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.*;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.logging.Logger; import java.util.logging.Logger;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import util.SqlUtil;
public class TestJdbcEventListener extends JdbcEventListener { public class TestJdbcEventListener extends JdbcEventListener {
private static final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); private static final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
private ResultSetMetaData metaData; private ResultSetMetaData metaData;
private volatile String flag = "0"; private volatile String flag = "0";
protected static Logger logger = Logger.getLogger(TestJdbcEventListener.class.getName()); protected static Logger logger = Logger.getLogger(TestJdbcEventListener.class.getName());
public static Map<String, Map<String, String>> ipPortMap = new HashMap();
public static Map<String, Set<Columninfo>> sqlColumSecretKeyMap = new HashMap(); public static Map<String, Map<String, String>> ipPortMap = new HashMap<String, Map<String, String>>();
public static Map<String, Set<Columninfo>> sqlColumSecretKeyMap = new HashMap<String, Set<Columninfo>>();
public void onBeforeGetConnection(ConnectionInformation connectionInformation) throws ClassNotFoundException { public void onBeforeGetConnection(ConnectionInformation connectionInformation) throws ClassNotFoundException {
if ("0".equals(this.flag)) { if ("0".equals(this.flag))
try { try {
Class.forName("com.palacesun.masking.tools.EngineUtil"); Class.forName("com.palacesun.masking.tools.EngineUtil");
this.flag = "1"; this.flag = "1";
...@@ -61,13 +61,10 @@ public class TestJdbcEventListener extends JdbcEventListener { ...@@ -61,13 +61,10 @@ public class TestJdbcEventListener extends JdbcEventListener {
} }
} }
}
public void onAfterGetConnection(ConnectionInformation connectionInformation, SQLException e) throws SQLException { public void onAfterGetConnection(ConnectionInformation connectionInformation, SQLException e) throws SQLException {
if (e != null) { if (e != null)
throw e; throw e;
} }
}
public void onConnectionWrapped(ConnectionInformation connectionInformation) { public void onConnectionWrapped(ConnectionInformation connectionInformation) {
} }
...@@ -120,7 +117,9 @@ public class TestJdbcEventListener extends JdbcEventListener { ...@@ -120,7 +117,9 @@ public class TestJdbcEventListener extends JdbcEventListener {
private String sqlTypeAnalysis(String sql) { private String sqlTypeAnalysis(String sql) {
String[] wordArr = sql.split("\\s+"); String[] wordArr = sql.split("\\s+");
return wordArr.length > 0 ? wordArr[0].toUpperCase() : ""; if (wordArr.length > 0)
return wordArr[0].toUpperCase();
return "";
} }
public void onAfterExecuteQuery(PreparedStatementInformation statementInformation, long timeElapsedNanos, SQLException e) { public void onAfterExecuteQuery(PreparedStatementInformation statementInformation, long timeElapsedNanos, SQLException e) {
...@@ -154,126 +153,104 @@ public class TestJdbcEventListener extends JdbcEventListener { ...@@ -154,126 +153,104 @@ public class TestJdbcEventListener extends JdbcEventListener {
} }
public Object onAfterResultSetGet(ResultSetInformation resultSetInformation, String columnLabel, Object value, SQLException e) throws SQLException { public Object onAfterResultSetGet(ResultSetInformation resultSetInformation, String columnLabel, Object value, SQLException e) throws SQLException {
if (!GatewayContext.isPluginEnabled()) { if (!GatewayContext.isPluginEnabled())
return value;
if (value == null || (value instanceof String && StringUtils.isBlank((String) value)))
return value; return value;
} else if (value != null && (!(value instanceof String) || !StringUtils.isBlank((String)value))) {
String encPrefix = EncryptionGatewayManager.getParameterValue("encryption.label"); String encPrefix = EncryptionGatewayManager.getParameterValue("encryption.label");
if (value.toString().contains(encPrefix) && GatewayContext.isCurrentUserCanSeeDecInfo()) { if (value.toString().contains(encPrefix) && GatewayContext.isCurrentUserCanSeeDecInfo()) {
String sqlTemplate = this.getSqlTemplate(resultSetInformation); String sqlTemplate = getSqlTemplate(resultSetInformation);
RuleLoadUtil.writeLog("@@插件@@---TestJdbcEventListener--columnLabel--解密前的值:" + value); RuleLoadUtil.writeLog("@@" + value);
value = this.getDecData(value, sqlTemplate, columnLabel, encPrefix); value = getDecData(value, sqlTemplate, columnLabel, encPrefix);
RuleLoadUtil.writeLog("@@插件@@---TestJdbcEventListener--columnLabel--解密前的值:" + value); RuleLoadUtil.writeLog("@@" + value);
} }
if (!EncryptionGatewayManager.checkParameterFlag("maskingRule"))
if (!EncryptionGatewayManager.checkParameterFlag("maskingRule")) {
return value; return value;
} else {
int columnIndex = -1; int columnIndex = -1;
String columnName = ""; String columnName = "";
String tableName = ""; String tableName = "";
String columnType = ""; String columnType = "";
try { try {
ResultSetMetaData metaData = resultSetInformation.getResultSet().getMetaData(); ResultSetMetaData metaData = resultSetInformation.getResultSet().getMetaData();
int count = metaData.getColumnCount(); int count = metaData.getColumnCount();
for (int i = 1; i <= count; i++) {
for(int i = 1; i <= count; ++i) {
if (metaData.getColumnLabel(i).equalsIgnoreCase(columnLabel)) { if (metaData.getColumnLabel(i).equalsIgnoreCase(columnLabel)) {
columnIndex = i; columnIndex = i;
columnName = metaData.getColumnLabel(i); columnName = metaData.getColumnLabel(i);
columnType = metaData.getColumnTypeName(i); columnType = metaData.getColumnTypeName(i);
if (columnName == null || "".equals(columnName)) { if (columnName == null || "".equals(columnName))
columnName = metaData.getColumnName(i); columnName = metaData.getColumnName(i);
} tableName = metaData.getTableName(columnIndex);
tableName = metaData.getTableName(i);
break; break;
} }
} }
if (columnIndex == -1)
if (columnIndex == -1) {
return value; return value;
} else if (value == null) { if (value == null)
return value; return value;
} else {
String schema = metaData.getCatalogName(columnIndex); String schema = metaData.getCatalogName(columnIndex);
if (StringUtils.isEmpty(schema)) { if (StringUtils.isEmpty(schema))
schema = metaData.getSchemaName(columnIndex); schema = metaData.getSchemaName(columnIndex);
}
Connection connection = resultSetInformation.getConnectionInformation().getConnection(); Connection connection = resultSetInformation.getConnectionInformation().getConnection();
String urlTemp = connection.getMetaData().getURL(); String urlTemp = connection.getMetaData().getURL();
Map<String, String> ipAndPortMap = getIpAndPort(urlTemp); Map<String, String> ipAndPortMap = getIpAndPort(urlTemp);
String ip = (String)ipAndPortMap.get("ip"); String ip = ipAndPortMap.get("ip");
String port = (String)ipAndPortMap.get("port"); String port = ipAndPortMap.get("port");
String driverName = resultSetInformation.getConnectionInformation().getConnection().getMetaData().getDriverName(); String driverName = resultSetInformation.getConnectionInformation().getConnection().getMetaData().getDriverName();
String urlDbType = resultSetInformation.getConnectionInformation().getUrl(); String urlDbType = resultSetInformation.getConnectionInformation().getUrl();
String dbType = ""; String dbType = "";
dbType = ConnectionWrapper.getDbType(driverName, urlDbType, dbType); dbType = ConnectionWrapper.getDbType(driverName, urlDbType, dbType);
if ("oracle".equals(dbType)) { if ("oracle".equals(dbType)) {
if (columnType.toLowerCase(Locale.ROOT).contains("char") && value != null && value instanceof String && !"".equals(value.toString())) { int j;
if (columnType.toLowerCase(Locale.ROOT).contains("char") &&
value != null && value instanceof String && !"".equals(value.toString()))
value = value.toString().trim(); value = value.toString().trim();
}
schema = connection.getMetaData().getUserName(); schema = connection.getMetaData().getUserName();
StatementInformation statementInformation = resultSetInformation.getStatementInformation(); StatementInformation statementInformation = resultSetInformation.getStatementInformation();
String sqlAll = statementInformation.getSql(); String sqlAll = statementInformation.getSql();
if (sqlAll.indexOf("-- appUsername=") > 0) { if (sqlAll.indexOf("-- appUsername=") > 0)
sqlAll = sqlAll.substring(0, sqlAll.indexOf("-- appUsername=")).trim(); sqlAll = sqlAll.substring(0, sqlAll.indexOf("-- appUsername=")).trim();
} if (sqlAll.endsWith(";"))
if (sqlAll.endsWith(";")) {
sqlAll = sqlAll.substring(0, sqlAll.length() - 1); sqlAll = sqlAll.substring(0, sqlAll.length() - 1);
}
String[] splitSql = sqlAll.split(";"); String[] splitSql = sqlAll.split(";");
int i;
if (splitSql.length == 1) { if (splitSql.length == 1) {
i = 0; j = 0;
} else { } else {
for(i = 0; i < splitSql.length; ++i) { for (j = 0; j < splitSql.length; j++) {
String trim = splitSql[i].toLowerCase().trim(); String trim = splitSql[j].toLowerCase().trim();
if (trim.startsWith("select")) { if (trim.startsWith("select"))
break; break;
}
if (trim.contains("*/")) { if (trim.contains("*/")) {
int index = trim.indexOf("*/"); int index = trim.indexOf("*/");
trim = trim.substring(index + 2).trim(); trim = trim.substring(index + 2).trim();
if (trim.startsWith("select")) { if (trim.startsWith("select"))
break; break;
} }
} }
if (j == splitSql.length)
j = splitSql.length - 1;
} }
List<Map<String, Object>> sqlParseList = (List<Map<String, Object>>) ConnectionWrapper.sqlParseMap.get(sqlAll);
if (i == splitSql.length) { if (sqlParseList == null || sqlParseList.isEmpty())
i = splitSql.length - 1;
}
}
List<Map<String, Object>> sqlParseList = (List)ConnectionWrapper.sqlParseMap.get(sqlAll);
if (sqlParseList == null || sqlParseList.isEmpty()) {
sqlParseList = statementInformation.sqlParse; sqlParseList = statementInformation.sqlParse;
} if (sqlParseList == null || sqlParseList.isEmpty())
if (sqlParseList == null || sqlParseList.isEmpty()) {
return value; return value;
} Map<String, Object> sqlParse = sqlParseList.get(j);
Map<String, Object> sqlParse = (Map)sqlParseList.get(i);
if (sqlParse != null && !sqlParse.isEmpty()) { if (sqlParse != null && !sqlParse.isEmpty()) {
List<Column> cols = (List)sqlParse.get("output-cols"); List<Column> cols = (List<Column>) sqlParse.get("output-cols");
if (cols != null && cols.size() > 0) { if (cols != null && cols.size() > 0) {
new ArrayList(); List<Column> idxCols = new ArrayList<Column>();
for (Column col : cols) {
for(Column col : cols) {
if (col.seq == columnIndex) { if (col.seq == columnIndex) {
String table = col.getTable(); String table = col.getTable();
if (table != null && table.length() != 0) { if (table == null || table.length() == 0)
continue;
String fullname = col.getColumnName(); String fullname = col.getColumnName();
if (fullname != null && fullname.length() != 0) { if (fullname == null || fullname.length() == 0)
continue;
int idx = fullname.toLowerCase().indexOf(table.toLowerCase()); int idx = fullname.toLowerCase().indexOf(table.toLowerCase());
if (idx != -1) { if (idx == -1)
continue;
String cname = fullname.substring(idx + table.length() + 1); String cname = fullname.substring(idx + table.length() + 1);
columnName = cname; columnName = cname;
tableName = table; tableName = table;
...@@ -282,17 +259,21 @@ public class TestJdbcEventListener extends JdbcEventListener { ...@@ -282,17 +259,21 @@ public class TestJdbcEventListener extends JdbcEventListener {
} }
} }
} }
} else if ("postgresql".equals(dbType) || "greenplum".equals(dbType) || "gauss".equals(dbType)) {
String url = connection.getMetaData().getURL();
if (url.indexOf("searchpath") > 0) {
schema = url.substring(url.indexOf("searchpath") + 11);
} else if (url.indexOf("currentSchema") > 0) {
schema = url.substring(url.indexOf("currentSchema") + 14);
} else {
schema = "public";
} }
} } else if ("sql server".equals(dbType)) {
}
} else if (!"postgresql".equals(dbType) && !"greenplum".equals(dbType) && !"gauss".equals(dbType)) {
if ("sql server".equals(dbType)) {
String url = connection.getMetaData().getURL(); String url = connection.getMetaData().getURL();
if (url.indexOf("applicationName") > 0) { if (url.indexOf("applicationName") > 0) {
schema = url.substring(url.indexOf("applicationName") + "applicationName".length() + 1); schema = url.substring(url.indexOf("applicationName") + "applicationName".length() + 1);
if (schema.indexOf(";") != -1) { if (schema.indexOf(";") != -1)
schema = schema.substring(0, schema.indexOf(";")); schema = schema.substring(0, schema.indexOf(";"));
}
} else { } else {
schema = "dbo"; schema = "dbo";
} }
...@@ -303,7 +284,7 @@ public class TestJdbcEventListener extends JdbcEventListener { ...@@ -303,7 +284,7 @@ public class TestJdbcEventListener extends JdbcEventListener {
} else { } else {
int from = url.indexOf("://"); int from = url.indexOf("://");
int end = url.indexOf("?"); int end = url.indexOf("?");
String address = end == -1 ? url.substring(from + 3) : url.substring(from + 3, end); String address = (end == -1) ? url.substring(from + 3) : url.substring(from + 3, end);
int idx = address.lastIndexOf("/"); int idx = address.lastIndexOf("/");
schema = address.substring(idx + 1); schema = address.substring(idx + 1);
} }
...@@ -327,152 +308,121 @@ public class TestJdbcEventListener extends JdbcEventListener { ...@@ -327,152 +308,121 @@ public class TestJdbcEventListener extends JdbcEventListener {
String url = connection.getMetaData().getURL(); String url = connection.getMetaData().getURL();
int from = url.indexOf("://"); int from = url.indexOf("://");
int end = url.indexOf("?"); int end = url.indexOf("?");
String address = end == -1 ? url.substring(from + 3) : url.substring(from + 3, end); String address = (end == -1) ? url.substring(from + 3) : url.substring(from + 3, end);
int idx = address.lastIndexOf("/"); int idx = address.lastIndexOf("/");
schema = address.substring(idx + 1); schema = address.substring(idx + 1);
} else if ("hive".equals(dbType)) { } else if ("hive".equals(dbType)) {
String url = connection.getMetaData().getURL(); String url = connection.getMetaData().getURL();
int from = url.indexOf("://"); int from = url.indexOf("://");
int end = url.indexOf("?"); int end = url.indexOf("?");
String address = end == -1 ? url.substring(from + 3) : url.substring(from + 3, end); String address = (end == -1) ? url.substring(from + 3) : url.substring(from + 3, end);
int idx = address.lastIndexOf("/"); int idx = address.lastIndexOf("/");
schema = address.substring(idx + 1); schema = address.substring(idx + 1);
} }
} else {
String url = connection.getMetaData().getURL();
if (url.indexOf("searchpath") > 0) {
schema = url.substring(url.indexOf("searchpath") + 11);
} else if (url.indexOf("currentSchema") > 0) {
schema = url.substring(url.indexOf("currentSchema") + 14);
} else {
schema = "public";
}
}
if (!"oracle".equals(dbType)) { if (!"oracle".equals(dbType)) {
Map<String, String> map = this.getColumnNameAndTableNameByAlisaName(resultSetInformation, dbType, schema, tableName, columnName); Map<String, String> map = getColumnNameAndTableNameByAlisaName(resultSetInformation, dbType, schema, tableName, columnName);
columnName = (String)map.get("columnName"); columnName = map.get("columnName");
tableName = (String)map.get("tableName"); tableName = map.get("tableName");
schema = (String)map.get("schema"); schema = map.get("schema");
} }
String mathKey = (ip + "_" + port + "_" + schema + "_" + tableName + "_" + columnName).toLowerCase().replace("`", "").replace("\"", ""); String mathKey = (ip + "_" + port + "_" + schema + "_" + tableName + "_" + columnName).toLowerCase().replace("`", "").replace("\"", "");
RuleLoadUtil.writeLog("@@插件@@---TestJdbcEventListener--columnLabel--mathKey:" + mathKey); RuleLoadUtil.writeLog("@@" + mathKey);
if (EngineUtil.encryptionMap.isEmpty()) { if (EngineUtil.encryptionMap.isEmpty())
EngineUtil.keyCacheFromFile(); EngineUtil.keyCacheFromFile();
}
boolean ismaksing = EngineUtil.encryptionMap.containsKey(mathKey); boolean ismaksing = EngineUtil.encryptionMap.containsKey(mathKey);
if (ismaksing && (EncryptionGatewayManager.getParameterValue("projectid").length() == 0 || GatewayContext.isCurrentUserCanSeeDecInfo())) { if (ismaksing && (EncryptionGatewayManager.getParameterValue("projectid").length() == 0 || GatewayContext.isCurrentUserCanSeeDecInfo())) {
Columninfo map = (Columninfo)EngineUtil.encryptionMap.get(mathKey); Columninfo map = (Columninfo) EngineUtil.encryptionMap.get(mathKey);
RuleLoadUtil.writeLog("@@插件@@---TestJdbcEventListener--columnLabel--解密前的值:" + value); RuleLoadUtil.writeLog("@@" + value);
value = EngineUtil.exeEngine(map, (ConnectionInfo)null, true, value, false); value = EngineUtil.exeEngine(map, null, Boolean.valueOf(true), value, Boolean.valueOf(false));
RuleLoadUtil.writeLog("@@插件@@---TestJdbcEventListener--columnLabel--解密后的值:" + value); RuleLoadUtil.writeLog("@@" + value);
EncryLogVO encryLogVO = new EncryLogVO(); EncryLogVO encryLogVO = new EncryLogVO();
encryLogVO.setRalsql(resultSetInformation.getSql()); encryLogVO.setRalsql(resultSetInformation.getSql());
encryLogVO.setStatus("解密成功"); encryLogVO.setStatus("");
encryLogVO.setRalsql(null); encryLogVO.setRalsql(null);
encryLogVO.setExeSql(null); encryLogVO.setExeSql(null);
encryLogVO.setAccessSqlType(null); encryLogVO.setAccessSqlType(null);
encryLogVO.setDecrypt(mathKey); encryLogVO.setDecrypt(mathKey);
encryLogVO.setEncryFieldSet((Set)null); encryLogVO.setEncryFieldSet(null);
DblogClient.inputAuditLog(encryLogVO); DblogClient.inputAuditLog(encryLogVO);
} }
ismaksing = EngineUtil.maskingmap.containsKey(mathKey); ismaksing = EngineUtil.maskingmap.containsKey(mathKey);
if (ismaksing && GatewayContext.isCurrentUserNeedMask()) { if (ismaksing && GatewayContext.isCurrentUserNeedMask())
try { try {
MaskingColumnInfo map = (MaskingColumnInfo)EngineUtil.maskingmap.get(mathKey); MaskingColumnInfo map = (MaskingColumnInfo) EngineUtil.maskingmap.get(mathKey);
if (null != map && null != map.getExpression() && !map.getExpression().trim().equals("")) { if (null != map && null != map.getExpression() && !map.getExpression().trim().equals(""))
value = EngineUtil.exeMaskingEngine(map, value); value = EngineUtil.exeMaskingEngine(map, value);
}
} catch (Exception e1) { } catch (Exception e1) {
e1.printStackTrace(); e1.printStackTrace();
throw e1; throw e1;
} finally { } finally {
;
}
}
return value;
} }
} catch (Exception e1) { } catch (Exception e1) {
e1.printStackTrace(); e1.printStackTrace();
throw new SQLException(e); throw new SQLException(e);
} finally { } finally {
;
}
} }
} else {
return value; return value;
} }
}
private Object getDecData(Object value, String sqlTemplate, Object column, String encPrefix) { private Object getDecData(Object value, String sqlTemplate, Object column, String encPrefix) {
StringBuilder stringBuilder = new StringBuilder(); StringBuilder stringBuilder = new StringBuilder();
if (GatewayContext.isCurrentUserCanSeeDecInfo()) { if (GatewayContext.isCurrentUserCanSeeDecInfo()) {
String[] split = value.toString().split(EncryptionGatewayManager.getParameterValue("encryption.separator")); String[] split = value.toString().split(EncryptionGatewayManager.getParameterValue("encryption.separator"));
String likeFlag = EncryptionGatewayManager.getParameterValue("encryption.like.split"); String likeFlag = EncryptionGatewayManager.getParameterValue("encryption.like.split");
Set<Columninfo> secretKeySet = new HashSet(); Set<Columninfo> secretKeySet = new HashSet<Columninfo>();
for (String s : split) {
for(String s : split) {
if (s.contains(encPrefix)) { if (s.contains(encPrefix)) {
Set<Columninfo> columninfos = (Set)sqlColumSecretKeyMap.get(sqlTemplate + "_" + column); Set<Columninfo> columninfos = sqlColumSecretKeyMap.get(sqlTemplate + "_" + column);
if (null != columninfos && columninfos.size() > 0) { if (null != columninfos && columninfos.size() > 0) {
for(Columninfo columninfo : columninfos) { for (Columninfo columninfo : columninfos) {
if (s.startsWith(encPrefix)) { if (s.startsWith(encPrefix)) {
if (!s.contains(likeFlag) || !"0".equals(columninfo.getIsLike())) { if (s.contains(likeFlag) && "0".equals(columninfo.getIsLike()))
continue;
try { try {
s = (String)EngineUtil.exeEngine(columninfo, (ConnectionInfo)null, true, s, false); s = (String) EngineUtil.exeEngine(columninfo, null, Boolean.valueOf(true), s, Boolean.valueOf(false));
} catch (Exception var21) { } catch (Exception exception) {
} }
if (!s.contains(encPrefix))
if (!s.contains(encPrefix)) {
break; break;
continue;
} }
}
} else {
String substring = s.substring(0, s.indexOf(encPrefix)); String substring = s.substring(0, s.indexOf(encPrefix));
if (!s.contains(likeFlag) || !"0".equals(columninfo.getIsLike())) { if (s.contains(likeFlag) && "0".equals(columninfo.getIsLike()))
continue;
stringBuilder.append(substring); stringBuilder.append(substring);
s = s.substring(s.indexOf(encPrefix)); s = s.substring(s.indexOf(encPrefix));
try { try {
s = (String)EngineUtil.exeEngine(columninfo, (ConnectionInfo)null, true, s, false); s = (String) EngineUtil.exeEngine(columninfo, null, Boolean.valueOf(true), s, Boolean.valueOf(false));
} catch (Exception var20) { } catch (Exception exception) {
} }
if (!s.contains(encPrefix))
if (!s.contains(encPrefix)) {
break; break;
} }
}
}
}
} else { } else {
for(Columninfo columninfo : EngineUtil.encryptionSet) { for (Columninfo columninfo : EngineUtil.encryptionSet) {
if (s.startsWith(encPrefix)) { if (s.startsWith(encPrefix)) {
if (!s.contains(likeFlag) || !"0".equals(columninfo.getIsLike())) { if (s.contains(likeFlag) && "0".equals(columninfo.getIsLike()))
continue;
try { try {
s = (String)EngineUtil.exeEngine(columninfo, (ConnectionInfo)null, true, s, false); s = (String) EngineUtil.exeEngine(columninfo, null, Boolean.valueOf(true), s, Boolean.valueOf(false));
} catch (Exception var19) { } catch (Exception exception) {
} }
if (!s.contains(encPrefix)) { if (!s.contains(encPrefix)) {
secretKeySet.add(columninfo); secretKeySet.add(columninfo);
sqlColumSecretKeyMap.put(sqlTemplate + "_" + column, secretKeySet); sqlColumSecretKeyMap.put(sqlTemplate + "_" + column, secretKeySet);
break; break;
} }
continue;
} }
} else {
String substring = s.substring(0, s.indexOf(encPrefix)); String substring = s.substring(0, s.indexOf(encPrefix));
stringBuilder.append(substring); stringBuilder.append(substring);
s = s.substring(s.indexOf(encPrefix)); s = s.substring(s.indexOf(encPrefix));
if (!s.contains(likeFlag) || !"0".equals(columninfo.getIsLike())) { if (s.contains(likeFlag) && "0".equals(columninfo.getIsLike()))
continue;
try { try {
s = (String)EngineUtil.exeEngine(columninfo, (ConnectionInfo)null, true, s, false); s = (String) EngineUtil.exeEngine(columninfo, null, Boolean.valueOf(true), s, Boolean.valueOf(false));
} catch (Exception var18) { } catch (Exception exception) {
} }
if (!s.contains(encPrefix)) { if (!s.contains(encPrefix)) {
secretKeySet.add(columninfo); secretKeySet.add(columninfo);
sqlColumSecretKeyMap.put(sqlTemplate + "_" + column, secretKeySet); sqlColumSecretKeyMap.put(sqlTemplate + "_" + column, secretKeySet);
...@@ -481,25 +431,18 @@ public class TestJdbcEventListener extends JdbcEventListener { ...@@ -481,25 +431,18 @@ public class TestJdbcEventListener extends JdbcEventListener {
} }
} }
} }
}
}
stringBuilder.append(s); stringBuilder.append(s);
} }
value = stringBuilder.toString(); value = stringBuilder.toString();
} }
return value; return value;
} }
private String getDbType(Connection connection, String dbType) { private String getDbType(Connection connection, String dbType) {
try { try {
String hiveurl = connection.toString(); String hiveurl = connection.toString();
if (hiveurl.toLowerCase().contains("hive")) { if (hiveurl.toLowerCase().contains("hive"))
return "hive"; return "hive";
}
String driverName = connection.getMetaData().getDriverName(); String driverName = connection.getMetaData().getDriverName();
if (driverName.toLowerCase().contains("mysql")) { if (driverName.toLowerCase().contains("mysql")) {
dbType = "mysql"; dbType = "mysql";
...@@ -512,7 +455,6 @@ public class TestJdbcEventListener extends JdbcEventListener { ...@@ -512,7 +455,6 @@ public class TestJdbcEventListener extends JdbcEventListener {
dbType = "gauss"; dbType = "gauss";
return dbType; return dbType;
} }
if (url.contains("greenplum")) { if (url.contains("greenplum")) {
dbType = "greenplum"; dbType = "greenplum";
return dbType; return dbType;
...@@ -533,117 +475,164 @@ public class TestJdbcEventListener extends JdbcEventListener { ...@@ -533,117 +475,164 @@ public class TestJdbcEventListener extends JdbcEventListener {
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
return dbType; return dbType;
} }
public boolean getParsedMetaInfo(StatementInformation statementInformation, int columnIndex, Map<String, String> out) { public boolean getParsedMetaInfo(StatementInformation statementInformation, int columnIndex, Map<String, String> out) {
List<Map<String, Object>> sqlParseList = statementInformation.sqlParse; List<Map<String, Object>> sqlParseList = statementInformation.sqlParse;
Map<String, Object> sqlParse = (Map)sqlParseList.get(0); Map<String, Object> sqlParse = sqlParseList.get(0);
if (sqlParse != null && sqlParse.size() != 0) { if (sqlParse == null || sqlParse.size() == 0)
List<Column> cols = (List)sqlParse.get("output-cols"); return false;
if (cols != null && cols.size() != 0) { List<Column> cols = (List<Column>) sqlParse.get("output-cols");
new ArrayList(); if (cols == null || cols.size() == 0)
return false;
for(Column col : cols) { List<Column> idxCols = new ArrayList<Column>();
for (Column col : cols) {
if (col.seq == columnIndex) { if (col.seq == columnIndex) {
String table = col.getTable(); String table = col.getTable();
if (table != null && table.length() != 0) { if (table == null || table.length() == 0)
continue;
String fullname = col.getColumnName(); String fullname = col.getColumnName();
if (fullname != null && fullname.length() != 0) { if (fullname == null || fullname.length() == 0)
continue;
int idx = fullname.toLowerCase().indexOf(table.toLowerCase()); int idx = fullname.toLowerCase().indexOf(table.toLowerCase());
if (idx != -1) { if (idx == -1)
continue;
String cname = fullname.substring(idx + table.length() + 1); String cname = fullname.substring(idx + table.length() + 1);
out.put("columnName", cname); out.put("columnName", cname);
out.put("tableName", table); out.put("tableName", table);
return true; return true;
} }
} }
}
}
}
return false;
} else {
return false; return false;
} }
} else {
return false;
}
}
public String getFieldTableName(String sql, String field, String dbType) { public String getFieldTableName(String sql, String field, String dbType) {
try { try {
String tableName = ""; String tableName = "";
List<SQLStatement> stmtList = SQLUtils.parseStatements(sql, dbType); List<SQLStatement> stmtList = SQLUtils.parseStatements(sql, dbType);
SchemaStatVisitor visitor = SQLUtils.createSchemaStatVisitor(DbType.of(dbType)); SchemaStatVisitor visitor = SQLUtils.createSchemaStatVisitor(DbType.of(dbType));
SQLStatement sqlStatement = (SQLStatement)stmtList.get(0); SQLStatement sqlStatement = stmtList.get(0);
sqlStatement.accept(visitor); sqlStatement.accept((SQLASTVisitor) visitor);
Collection<TableStat.Column> columns = visitor.getColumns(); Collection<TableStat.Column> columns = visitor.getColumns();
for (TableStat.Column column : columns) {
for(TableStat.Column column : columns) {
if (column.getName().equalsIgnoreCase(field)) { if (column.getName().equalsIgnoreCase(field)) {
tableName = column.getTable(); tableName = column.getTable();
break; break;
} }
} }
if ((tableName == null || tableName.length() == 0) && columns.size() > 0)
if ((tableName == null || tableName.length() == 0) && columns.size() > 0) { tableName = ((TableStat.Column) columns.iterator().next()).getTable();
tableName = ((TableStat.Column)columns.iterator().next()).getTable(); if (tableName.contains("."))
}
if (tableName.contains(".")) {
tableName = tableName.split("\\.")[1]; tableName = tableName.split("\\.")[1];
}
return tableName; return tableName;
} catch (Exception var11) { } catch (Exception e) {
return null; return null;
} }
} }
public Object onAfterResultSetGet(ResultSetInformation resultSetInformation, int columnIndex, Object value, SQLException e) throws Exception { public Object onAfterResultSetGet(ResultSetInformation resultSetInformation, int columnIndex, Object value, SQLException e) throws Exception {
if (!GatewayContext.isPluginEnabled()) { if (!GatewayContext.isPluginEnabled())
return value;
if (value == null || (value instanceof String && StringUtils.isBlank((String) value)))
return value; return value;
} else if (value != null && (!(value instanceof String) || !StringUtils.isBlank((String)value))) {
String encPrefix = EncryptionGatewayManager.getParameterValue("encryption.label"); String encPrefix = EncryptionGatewayManager.getParameterValue("encryption.label");
if (value.toString().contains(encPrefix) && GatewayContext.isCurrentUserCanSeeDecInfo()) { if (value.toString().contains(encPrefix) && GatewayContext.isCurrentUserCanSeeDecInfo()) {
String sqlTemplate = this.getSqlTemplate(resultSetInformation); String sqlTemplate = getSqlTemplate(resultSetInformation);
RuleLoadUtil.writeLog("@@插件@@---TestJdbcEventListener--columnIndex--解密前的值:" + value); RuleLoadUtil.writeLog("@@" + value);
value = this.getDecData(value, sqlTemplate, columnIndex, encPrefix); value = getDecData(value, sqlTemplate, Integer.valueOf(columnIndex), encPrefix);
RuleLoadUtil.writeLog("@@插件@@---TestJdbcEventListener--columnIndex--解密后的值:" + value); RuleLoadUtil.writeLog("@@" + value);
} }
if (!EncryptionGatewayManager.checkParameterFlag("maskingRule"))
if (!EncryptionGatewayManager.checkParameterFlag("maskingRule")) {
return value; return value;
} else {
ResultSetMetaData metaData = resultSetInformation.getResultSet().getMetaData(); ResultSetMetaData metaData = resultSetInformation.getResultSet().getMetaData();
String schema = resultSetInformation.getResultSet().getMetaData().getCatalogName(columnIndex); String schema = resultSetInformation.getResultSet().getMetaData().getCatalogName(columnIndex);
String tableName = metaData.getTableName(columnIndex); String tableName = metaData.getTableName(columnIndex);
String columnName = metaData.getColumnLabel(columnIndex); String columnName = metaData.getColumnLabel(columnIndex);
String columnType = metaData.getColumnTypeName(columnIndex); String columnType = metaData.getColumnTypeName(columnIndex);
if (columnName == null || "".equals(columnName)) { if (columnName == null || "".equals(columnName))
columnName = metaData.getColumnName(columnIndex); columnName = metaData.getColumnName(columnIndex);
}
Connection connection = resultSetInformation.getConnectionInformation().getConnection(); Connection connection = resultSetInformation.getConnectionInformation().getConnection();
String urlTemp = connection.getMetaData().getURL(); String urlTemp = connection.getMetaData().getURL();
Map<String, String> ipAndPortMap = getIpAndPort(urlTemp); Map<String, String> ipAndPortMap = getIpAndPort(urlTemp);
String ip = (String)ipAndPortMap.get("ip"); String ip = ipAndPortMap.get("ip");
String port = (String)ipAndPortMap.get("port"); String port = ipAndPortMap.get("port");
String driverName = resultSetInformation.getConnectionInformation().getConnection().getMetaData().getDriverName(); String driverName = resultSetInformation.getConnectionInformation().getConnection().getMetaData().getDriverName();
String urlDbType = resultSetInformation.getConnectionInformation().getUrl(); String urlDbType = resultSetInformation.getConnectionInformation().getUrl();
String dbType = ""; String dbType = "";
dbType = ConnectionWrapper.getDbType(driverName, urlDbType, dbType); dbType = ConnectionWrapper.getDbType(driverName, urlDbType, dbType);
if (!"oracle".equals(dbType)) { if ("oracle".equals(dbType)) {
if (!"postgresql".equals(dbType) && !"greenplum".equals(dbType) && !"gauss".equals(dbType)) { int i;
if ("sql server".equals(dbType)) { schema = connection.getMetaData().getUserName();
StatementInformation statementInformation = resultSetInformation.getStatementInformation();
String sqlAll = statementInformation.getSql();
if (sqlAll.indexOf("-- appUsername=") > 0)
sqlAll = sqlAll.substring(0, sqlAll.indexOf("-- appUsername=")).trim();
if (sqlAll.endsWith(";"))
sqlAll = sqlAll.substring(0, sqlAll.length() - 1);
String[] splitSql = sqlAll.split(";");
if (splitSql.length == 1) {
i = 0;
} else {
for (i = 0; i < splitSql.length; i++) {
String trim = splitSql[i].toLowerCase().trim();
if (trim.startsWith("select"))
break;
if (trim.contains("*/")) {
int index = trim.indexOf("*/");
trim = trim.substring(index + 2).trim();
if (trim.startsWith("select"))
break;
}
}
if (i == splitSql.length)
i = splitSql.length - 1;
}
List<Map<String, Object>> sqlParseList = (List<Map<String, Object>>) ConnectionWrapper.sqlParseMap.get(sqlAll);
if (sqlParseList == null || sqlParseList.isEmpty())
sqlParseList = statementInformation.sqlParse;
if (sqlParseList == null || sqlParseList.isEmpty())
return value;
Map<String, Object> sqlParse = sqlParseList.get(i);
if (sqlParse != null && !sqlParse.isEmpty()) {
List<Column> cols = (List<Column>) sqlParse.get("output-cols");
if (cols != null && cols.size() > 0)
for (Column col : cols) {
if (col.seq == columnIndex) {
String table = col.getTable();
if (table == null || table.length() == 0)
continue;
String fullname = col.getColumnName();
if (fullname == null || fullname.length() == 0)
continue;
int idx = fullname.toLowerCase().indexOf(table.toLowerCase());
if (idx == -1)
continue;
String cname = fullname.substring(idx + table.length() + 1);
columnName = cname;
tableName = table;
schema = col.getSchema();
}
}
}
if (columnType.toLowerCase(Locale.ROOT).contains("char") &&
value != null && value instanceof String && !"".equals(value.toString()))
value = value.toString().trim();
} else if ("postgresql".equals(dbType) || "greenplum".equals(dbType) || "gauss".equals(dbType)) {
String url = connection.getMetaData().getURL();
if (url.indexOf("searchpath") > 0) {
schema = url.substring(url.indexOf("searchpath") + 11);
} else if (url.indexOf("currentSchema") > 0) {
schema = url.substring(url.indexOf("currentSchema") + 14);
} else {
schema = "public";
}
} else if ("sql server".equals(dbType)) {
String url = connection.getMetaData().getURL(); String url = connection.getMetaData().getURL();
if (url.indexOf("applicationName") > 0) { if (url.indexOf("applicationName") > 0) {
schema = url.substring(url.indexOf("applicationName") + "applicationName".length() + 1); schema = url.substring(url.indexOf("applicationName") + "applicationName".length() + 1);
if (schema.indexOf(";") != -1) { if (schema.indexOf(";") != -1)
schema = schema.substring(0, schema.indexOf(";")); schema = schema.substring(0, schema.indexOf(";"));
}
} else { } else {
schema = "dbo"; schema = "dbo";
} }
...@@ -654,7 +643,7 @@ public class TestJdbcEventListener extends JdbcEventListener { ...@@ -654,7 +643,7 @@ public class TestJdbcEventListener extends JdbcEventListener {
} else { } else {
int from = url.indexOf("://"); int from = url.indexOf("://");
int end = url.indexOf("?"); int end = url.indexOf("?");
String address = end == -1 ? url.substring(from + 3) : url.substring(from + 3, end); String address = (end == -1) ? url.substring(from + 3) : url.substring(from + 3, end);
int idx = address.lastIndexOf("/"); int idx = address.lastIndexOf("/");
schema = address.substring(idx + 1); schema = address.substring(idx + 1);
} }
...@@ -678,181 +667,77 @@ public class TestJdbcEventListener extends JdbcEventListener { ...@@ -678,181 +667,77 @@ public class TestJdbcEventListener extends JdbcEventListener {
String url = connection.getMetaData().getURL(); String url = connection.getMetaData().getURL();
int from = url.indexOf("://"); int from = url.indexOf("://");
int end = url.indexOf("?"); int end = url.indexOf("?");
String address = end == -1 ? url.substring(from + 3) : url.substring(from + 3, end); String address = (end == -1) ? url.substring(from + 3) : url.substring(from + 3, end);
int idx = address.lastIndexOf("/"); int idx = address.lastIndexOf("/");
schema = address.substring(idx + 1); schema = address.substring(idx + 1);
} else if ("mariadb".equals(dbType)) { } else if ("mariadb".equals(dbType)) {
String url = connection.getMetaData().getURL(); String url = connection.getMetaData().getURL();
int from = url.indexOf("://"); int from = url.indexOf("://");
int end = url.indexOf("?"); int end = url.indexOf("?");
String address = end == -1 ? url.substring(from + 3) : url.substring(from + 3, end); String address = (end == -1) ? url.substring(from + 3) : url.substring(from + 3, end);
int idx = address.lastIndexOf("/"); int idx = address.lastIndexOf("/");
schema = address.substring(idx + 1); schema = address.substring(idx + 1);
} else if ("hive".equals(dbType)) { } else if ("hive".equals(dbType)) {
String url = connection.getMetaData().getURL(); String url = connection.getMetaData().getURL();
int from = url.indexOf("://"); int from = url.indexOf("://");
int end = url.indexOf("?"); int end = url.indexOf("?");
String address = end == -1 ? url.substring(from + 3) : url.substring(from + 3, end); String address = (end == -1) ? url.substring(from + 3) : url.substring(from + 3, end);
int idx = address.lastIndexOf("/"); int idx = address.lastIndexOf("/");
schema = address.substring(idx + 1); schema = address.substring(idx + 1);
} }
} else { if (value == null)
String url = connection.getMetaData().getURL();
if (url.indexOf("searchpath") > 0) {
schema = url.substring(url.indexOf("searchpath") + 11);
} else if (url.indexOf("currentSchema") > 0) {
schema = url.substring(url.indexOf("currentSchema") + 14);
} else {
schema = "public";
}
}
} else {
schema = connection.getMetaData().getUserName();
StatementInformation statementInformation = resultSetInformation.getStatementInformation();
String sqlAll = statementInformation.getSql();
if (sqlAll.indexOf("-- appUsername=") > 0) {
sqlAll = sqlAll.substring(0, sqlAll.indexOf("-- appUsername=")).trim();
}
if (sqlAll.endsWith(";")) {
sqlAll = sqlAll.substring(0, sqlAll.length() - 1);
}
String[] splitSql = sqlAll.split(";");
int i;
if (splitSql.length == 1) {
i = 0;
} else {
for(i = 0; i < splitSql.length; ++i) {
String trim = splitSql[i].toLowerCase().trim();
if (trim.startsWith("select")) {
break;
}
if (trim.contains("*/")) {
int index = trim.indexOf("*/");
trim = trim.substring(index + 2).trim();
if (trim.startsWith("select")) {
break;
}
}
}
if (i == splitSql.length) {
i = splitSql.length - 1;
}
}
List<Map<String, Object>> sqlParseList = (List)ConnectionWrapper.sqlParseMap.get(sqlAll);
if (sqlParseList == null || sqlParseList.isEmpty()) {
sqlParseList = statementInformation.sqlParse;
}
if (sqlParseList == null || sqlParseList.isEmpty()) {
return value;
}
Map<String, Object> sqlParse = (Map)sqlParseList.get(i);
if (sqlParse != null && !sqlParse.isEmpty()) {
List<Column> cols = (List)sqlParse.get("output-cols");
if (cols != null && cols.size() > 0) {
for(Column col : cols) {
if (col.seq == columnIndex) {
String table = col.getTable();
if (table != null && table.length() != 0) {
String fullname = col.getColumnName();
if (fullname != null && fullname.length() != 0) {
int idx = fullname.toLowerCase().indexOf(table.toLowerCase());
if (idx != -1) {
String cname = fullname.substring(idx + table.length() + 1);
columnName = cname;
tableName = table;
schema = col.getSchema();
}
}
}
}
}
}
}
if (columnType.toLowerCase(Locale.ROOT).contains("char") && value != null && value instanceof String && !"".equals(value.toString())) {
value = value.toString().trim();
}
}
if (value == null) {
return value; return value;
} else {
if (!"oracle".equals(dbType)) { if (!"oracle".equals(dbType)) {
Map<String, String> map = this.getColumnNameAndTableNameByAlisaName(resultSetInformation, dbType, schema, tableName, columnName); Map<String, String> map = getColumnNameAndTableNameByAlisaName(resultSetInformation, dbType, schema, tableName, columnName);
columnName = (String)map.get("columnName"); columnName = map.get("columnName");
tableName = (String)map.get("tableName"); tableName = map.get("tableName");
schema = (String)map.get("schema"); schema = map.get("schema");
} }
String mathKey = (ip + "_" + port + "_" + schema + "_" + tableName + "_" + columnName).toLowerCase().replace("`", "").replace("\"", ""); String mathKey = (ip + "_" + port + "_" + schema + "_" + tableName + "_" + columnName).toLowerCase().replace("`", "").replace("\"", "");
RuleLoadUtil.writeLog("@@插件@@---TestJdbcEventListener--columnIndex--mathKey:" + mathKey); RuleLoadUtil.writeLog("@@" + mathKey);
if (EngineUtil.encryptionMap.isEmpty()) { if (EngineUtil.encryptionMap.isEmpty())
EngineUtil.keyCacheFromFile(); EngineUtil.keyCacheFromFile();
}
boolean isEncrpt = EngineUtil.encryptionMap.containsKey(mathKey); boolean isEncrpt = EngineUtil.encryptionMap.containsKey(mathKey);
if (isEncrpt && (EncryptionGatewayManager.getParameterValue("projectid").length() == 0 || GatewayContext.isCurrentUserCanSeeDecInfo())) { if (isEncrpt && (EncryptionGatewayManager.getParameterValue("projectid").length() == 0 || GatewayContext.isCurrentUserCanSeeDecInfo()))
try { try {
Columninfo map = (Columninfo)EngineUtil.encryptionMap.get(mathKey); Columninfo map = (Columninfo) EngineUtil.encryptionMap.get(mathKey);
RuleLoadUtil.writeLog("@@插件@@---TestJdbcEventListener--columnIndex--解密前的值:" + value); RuleLoadUtil.writeLog("@@" + value);
value = EngineUtil.exeEngine(map, (ConnectionInfo)null, true, value, false); value = EngineUtil.exeEngine(map, null, Boolean.valueOf(true), value, Boolean.valueOf(false));
RuleLoadUtil.writeLog("@@插件@@---TestJdbcEventListener--columnIndex--解密后的值:" + value); RuleLoadUtil.writeLog("@@" + value);
} catch (Exception e1) { } catch (Exception e1) {
e1.printStackTrace(); e1.printStackTrace();
throw new SQLException(e1); throw new SQLException(e1);
} finally { } finally {
;
}
} }
boolean ismaksing = EngineUtil.maskingmap.containsKey(mathKey); boolean ismaksing = EngineUtil.maskingmap.containsKey(mathKey);
if (ismaksing && GatewayContext.isCurrentUserNeedMask()) { if (ismaksing && GatewayContext.isCurrentUserNeedMask())
try { try {
MaskingColumnInfo map = (MaskingColumnInfo)EngineUtil.maskingmap.get(mathKey); MaskingColumnInfo map = (MaskingColumnInfo) EngineUtil.maskingmap.get(mathKey);
if (null != map && null != map.getExpression() && !map.getExpression().trim().equals("")) { if (null != map && null != map.getExpression() && !map.getExpression().trim().equals(""))
value = EngineUtil.exeMaskingEngine(map, value); value = EngineUtil.exeMaskingEngine(map, value);
}
} catch (Exception e1) { } catch (Exception e1) {
e1.printStackTrace(); e1.printStackTrace();
throw e1; throw e1;
} finally { } finally {
;
}
} }
return value; return value;
} }
}
} else {
return value;
}
}
private Map<String, String> getColumnNameAndTableNameByAlisaName(ResultSetInformation resultSetInformation, String dbType, String schema, String tableName, String columnName) { private Map<String, String> getColumnNameAndTableNameByAlisaName(ResultSetInformation resultSetInformation, String dbType, String schema, String tableName, String columnName) {
Map<String, String> map = new HashMap(); int i;
Map<String, String> map = new HashMap<String, String>();
StatementInformation statementInformation = resultSetInformation.getStatementInformation(); StatementInformation statementInformation = resultSetInformation.getStatementInformation();
String sqlTemp = statementInformation.getSql(); String sqlTemp = statementInformation.getSql();
if (sqlTemp.indexOf("-- appUsername=") > 0) { if (sqlTemp.indexOf("-- appUsername=") > 0)
sqlTemp = sqlTemp.substring(0, sqlTemp.indexOf("-- appUsername=")).trim(); sqlTemp = sqlTemp.substring(0, sqlTemp.indexOf("-- appUsername=")).trim();
} List<Map<String, Object>> sqlParseList = (List<Map<String, Object>>) ConnectionWrapper.sqlParseMap.get(sqlTemp);
if (sqlParseList == null || sqlParseList.isEmpty())
List<Map<String, Object>> sqlParseList = (List)ConnectionWrapper.sqlParseMap.get(sqlTemp);
if (sqlParseList == null || sqlParseList.isEmpty()) {
sqlParseList = statementInformation.sqlParse; sqlParseList = statementInformation.sqlParse;
}
if (sqlParseList == null || sqlParseList.isEmpty()) { if (sqlParseList == null || sqlParseList.isEmpty()) {
try { try {
ConnectionInformation connectionInformation = resultSetInformation.getConnectionInformation(); ConnectionInformation connectionInformation = resultSetInformation.getConnectionInformation();
String sql = resultSetInformation.getStatementInformation().getStatementQuery(); String str1 = resultSetInformation.getStatementInformation().getStatementQuery();
Map<String, String> params = new HashMap(); Map<String, String> params = new HashMap<String, String>();
params.put("sql", sqlTemp); params.put("sql", sqlTemp);
params.put("dbType", dbType); params.put("dbType", dbType);
params.put("schema", schema); params.put("schema", schema);
...@@ -867,47 +752,35 @@ public class TestJdbcEventListener extends JdbcEventListener { ...@@ -867,47 +752,35 @@ public class TestJdbcEventListener extends JdbcEventListener {
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
if (sqlParseList == null || sqlParseList.isEmpty())
if (sqlParseList == null || sqlParseList.isEmpty()) { return new HashMap<String, String>();
return new HashMap();
} }
}
String sql = statementInformation.getStatementQuery().toLowerCase(); String sql = statementInformation.getStatementQuery().toLowerCase();
String sqlAll = statementInformation.getSql().trim(); String sqlAll = statementInformation.getSql().trim();
if (sqlAll.endsWith(";")) { if (sqlAll.endsWith(";"))
sqlAll = sqlAll.substring(0, sqlAll.length() - 1); sqlAll = sqlAll.substring(0, sqlAll.length() - 1);
}
String[] splitSql = sqlAll.split(";"); String[] splitSql = sqlAll.split(";");
int i;
if (splitSql.length == 1) { if (splitSql.length == 1) {
i = 0; i = 0;
} else { } else {
for(i = 0; i < splitSql.length; ++i) { for (i = 0; i < splitSql.length; i++) {
String trim = splitSql[i].toLowerCase().trim(); String trim = splitSql[i].toLowerCase().trim();
if (trim.startsWith("select")) { if (trim.startsWith("select"))
break; break;
}
if (trim.contains("*/")) { if (trim.contains("*/")) {
int index = trim.indexOf("*/"); int index = trim.indexOf("*/");
trim = trim.substring(index + 2).trim(); trim = trim.substring(index + 2).trim();
if (trim.startsWith("select")) { if (trim.startsWith("select"))
break; break;
} }
} }
} if (i == splitSql.length)
if (i == splitSql.length) {
i = splitSql.length - 1; i = splitSql.length - 1;
} }
} Map<String, Object> sqlParse = sqlParseList.get(i);
List<Column> list = (List<Column>) sqlParse.get("columnList");
Map<String, Object> sqlParse = (Map)sqlParseList.get(i); if (list != null && list.size() > 0)
List<Column> list = (List)sqlParse.get("columnList"); for (Column column : list) {
if (list != null && list.size() > 0) {
for(Column column : list) {
if (columnName.equalsIgnoreCase(column.getColumnAlisa())) { if (columnName.equalsIgnoreCase(column.getColumnAlisa())) {
String[] split = column.getColumnName().split("\\."); String[] split = column.getColumnName().split("\\.");
if (split.length == 2) { if (split.length == 2) {
...@@ -915,60 +788,51 @@ public class TestJdbcEventListener extends JdbcEventListener { ...@@ -915,60 +788,51 @@ public class TestJdbcEventListener extends JdbcEventListener {
} else { } else {
map.put("columnName", column.getColumnName().replace("\"", "")); map.put("columnName", column.getColumnName().replace("\"", ""));
} }
map.put("tableName", column.getTable()); map.put("tableName", column.getTable());
map.put("schema", column.getSchema()); map.put("schema", column.getSchema());
return map; return map;
} }
} }
}
map.put("columnName", columnName); map.put("columnName", columnName);
map.put("tableName", tableName); map.put("tableName", tableName);
map.put("schema", schema); map.put("schema", schema);
String columnNameTmp = ""; String columnNameTmp = "";
if (list != null && list.size() > 0) { if (list != null && list.size() > 0)
for(Column column : list) { for (Column column : list) {
String[] split = column.getColumnName().split("\\."); String[] split = column.getColumnName().split("\\.");
if (split.length == 2) { if (split.length == 2) {
columnNameTmp = column.getColumnName().split("\\.")[1].replace("\"", ""); columnNameTmp = column.getColumnName().split("\\.")[1].replace("\"", "");
} else { } else {
columnNameTmp = column.getColumnName().replace("\"", ""); columnNameTmp = column.getColumnName().replace("\"", "");
} }
if (columnNameTmp.equalsIgnoreCase(columnName)) { if (columnNameTmp.equalsIgnoreCase(columnName)) {
map.put("tableName", column.getTable()); map.put("tableName", column.getTable());
map.put("schema", column.getSchema()); map.put("schema", column.getSchema());
} }
} }
}
return map; return map;
} }
public Object encData(Object value, String tableName, String columnName, String schema) throws Exception { public Object encData(Object value, String tableName, String columnName, String schema) throws Exception {
for(JsonRootBean authBean : EngineUtil.encryptonBeanList) { for (JsonRootBean authBean : EngineUtil.encryptonBeanList) {
String maskingColumnname = ""; String maskingColumnname = "";
String desensitizationexpression = "Sm4Util:true"; String desensitizationexpression = "Sm4Util:true";
List<TableInfo> tableinfoList = authBean.getTableInfo(); List<TableInfo> tableinfoList = authBean.getTableInfo();
for (int i = 0; i < tableinfoList.size(); i++) {
for(int i = 0; i < tableinfoList.size(); ++i) { List<Columninfo> fieldinfoList = ((TableInfo) tableinfoList.get(i)).getColumninfo();
List<Columninfo> fieldinfoList = ((TableInfo)tableinfoList.get(i)).getColumninfo(); String maskingTableName = ((TableInfo) tableinfoList.get(i)).getTablename();
String maskingTableName = ((TableInfo)tableinfoList.get(i)).getTablename();
String maskingSchemaName = authBean.getSchema(); String maskingSchemaName = authBean.getSchema();
for (int j = 0; j < fieldinfoList.size(); j++) {
for(int j = 0; j < fieldinfoList.size(); ++j) { Boolean flag = Boolean.valueOf(false);
Boolean flag = false; Columninfo fieldinfo = fieldinfoList.get(j);
Columninfo fieldinfo = (Columninfo)fieldinfoList.get(j);
maskingColumnname = fieldinfo.getColumnname(); maskingColumnname = fieldinfo.getColumnname();
if (StringUtils.isNotBlank(maskingColumnname) && tableName.equalsIgnoreCase(maskingTableName) && columnName.equalsIgnoreCase(maskingColumnname) && maskingSchemaName.equalsIgnoreCase(schema)) { if (StringUtils.isNotBlank(maskingColumnname) && tableName.equalsIgnoreCase(maskingTableName) && columnName.equalsIgnoreCase(maskingColumnname) && maskingSchemaName.equalsIgnoreCase(schema)) {
value = EngineUtil.exeEngine(fieldinfo, (ConnectionInfo)null, flag, value, true); value = EngineUtil.exeEngine(fieldinfo, null, flag, value, Boolean.valueOf(true));
break; break;
} }
} }
} }
} }
return value; return value;
} }
...@@ -978,34 +842,28 @@ public class TestJdbcEventListener extends JdbcEventListener { ...@@ -978,34 +842,28 @@ public class TestJdbcEventListener extends JdbcEventListener {
} }
public static Map<String, String> getIpAndPort(String url) { public static Map<String, String> getIpAndPort(String url) {
Map<String, String> ipMap = (Map)ipPortMap.get(url); Map<String, String> ipMap = ipPortMap.get(url);
if (ipMap != null && ipMap.size() > 0) { if (ipMap != null && ipMap.size() > 0)
return ipMap; return ipMap;
} else { Map<String, String> map = new HashMap<String, String>(2);
Map<String, String> map = new HashMap(2); // 修改后的代码 - 支持IP、localhost和域名
Pattern p = Pattern.compile("(\\d+\\.\\d+\\.\\d+\\.\\d+)\\:(\\d+)"); Pattern p = Pattern.compile("//([^:/\\s]+):(\\d+)");
Matcher m = p.matcher(url); Matcher m = p.matcher(url);
while (m.find()) {
while(m.find()) {
map.put("ip", m.group(1)); map.put("ip", m.group(1));
map.put("port", m.group(2)); map.put("port", m.group(2));
} }
if (null != EncryptionGatewayManager.getParameterValue("dataBase.ip") && !"".equals(EncryptionGatewayManager.getParameterValue("dataBase.ip"))) { if (null != EncryptionGatewayManager.getParameterValue("dataBase.ip") && !"".equals(EncryptionGatewayManager.getParameterValue("dataBase.ip"))) {
map.put("ip", EncryptionGatewayManager.getParameterValue("dataBase.ip")); map.put("ip", EncryptionGatewayManager.getParameterValue("dataBase.ip"));
map.put("port", EncryptionGatewayManager.getParameterValue("dataBase.port")); map.put("port", EncryptionGatewayManager.getParameterValue("dataBase.port"));
} }
ipPortMap.put(url, map); ipPortMap.put(url, map);
return map; return map;
} }
}
public String getSqlTemplate(ResultSetInformation resultSetInformation) { public String getSqlTemplate(ResultSetInformation resultSetInformation) {
if (null == resultSetInformation.getSqlTemplate() || "".equals(resultSetInformation.getSql())) { if (null == resultSetInformation.getSqlTemplate() || "".equals(resultSetInformation.getSql()))
resultSetInformation.setSqlTemplate(resultSetInformation.getSql()); resultSetInformation.setSqlTemplate(resultSetInformation.getSql());
}
return resultSetInformation.getSqlTemplate(); return resultSetInformation.getSqlTemplate();
} }
......
...@@ -3,6 +3,7 @@ package com.palacesun.engine.wrapper; ...@@ -3,6 +3,7 @@ package com.palacesun.engine.wrapper;
import bean.Column; import bean.Column;
import com.palacesun.engine.common.PreparedStatementInformation; import com.palacesun.engine.common.PreparedStatementInformation;
import com.palacesun.engine.common.ResultSetInformation; import com.palacesun.engine.common.ResultSetInformation;
import com.palacesun.engine.common.StatementInformation;
import com.palacesun.engine.event.JdbcEventListener; import com.palacesun.engine.event.JdbcEventListener;
import com.palacesun.engine.gateway.EncryptionGatewayManager; import com.palacesun.engine.gateway.EncryptionGatewayManager;
import com.palacesun.engine.gateway.GatewayContext; import com.palacesun.engine.gateway.GatewayContext;
...@@ -58,207 +59,186 @@ import util.sqlparse.visitor.common.scope.ReplaceInfo; ...@@ -58,207 +59,186 @@ import util.sqlparse.visitor.common.scope.ReplaceInfo;
public class PreparedStatementWrapper extends StatementWrapper implements PreparedStatement { public class PreparedStatementWrapper extends StatementWrapper implements PreparedStatement {
private final PreparedStatement delegate; private final PreparedStatement delegate;
private final PreparedStatementInformation statementInformation; private final PreparedStatementInformation statementInformation;
protected static Logger logger = Logger.getLogger(PreparedStatementWrapper.class.getName()); protected static Logger logger = Logger.getLogger(PreparedStatementWrapper.class.getName());
public static Map<String, Columninfo> sqlIndexKeyMap = new HashMap();
public static Map<String, Columninfo> sqlIndexKeyMap = new HashMap<String, Columninfo>();
private static final String ENCRYPT_LIKE_OPEN = EncryptionGatewayManager.getParameterValue("encryption.like.open"); private static final String ENCRYPT_LIKE_OPEN = EncryptionGatewayManager.getParameterValue("encryption.like.open");
private static final String ENCRYPT_SEPARATOR = EncryptionGatewayManager.getParameterValue("encryption.separator"); private static final String ENCRYPT_SEPARATOR = EncryptionGatewayManager.getParameterValue("encryption.separator");
public static PreparedStatement wrap(PreparedStatement delegate, PreparedStatementInformation preparedStatementInformation, JdbcEventListener eventListener) { public static PreparedStatement wrap(PreparedStatement delegate, PreparedStatementInformation preparedStatementInformation, JdbcEventListener eventListener) {
return delegate == null ? null : new PreparedStatementWrapper(delegate, preparedStatementInformation, eventListener); if (delegate == null)
return null;
return new PreparedStatementWrapper(delegate, preparedStatementInformation, eventListener);
} }
protected PreparedStatementWrapper(PreparedStatement delegate, PreparedStatementInformation preparedStatementInformation, JdbcEventListener eventListener) { protected PreparedStatementWrapper(PreparedStatement delegate, PreparedStatementInformation preparedStatementInformation, JdbcEventListener eventListener) {
super(delegate, preparedStatementInformation, eventListener); super(delegate, (StatementInformation)preparedStatementInformation, eventListener);
this.delegate = delegate; this.delegate = delegate;
this.statementInformation = preparedStatementInformation; this.statementInformation = preparedStatementInformation;
if (this.statementInformation.context == null) { if (this.statementInformation.context == null)
this.statementInformation.context = new AccessContext(this.statementInformation); this.statementInformation.context = new AccessContext((StatementInformation)this.statementInformation);
}
this.sqlBuffer = this.statementInformation.context.getBuffer(); this.sqlBuffer = this.statementInformation.context.getBuffer();
} }
public ResultSet executeQuery() throws SQLException { public ResultSet executeQuery() throws SQLException {
SQLException e = null; SQLException e = null;
long start = System.nanoTime(); long start = System.nanoTime();
ResultSet var4;
try { try {
this.eventListener.onBeforeExecuteQuery(this.statementInformation); this.eventListener.onBeforeExecuteQuery(this.statementInformation);
var4 = ResultSetWrapper.wrap(this.delegate.executeQuery(), new ResultSetInformation(this.statementInformation), this.eventListener); return ResultSetWrapper.wrap(this.delegate.executeQuery(), new ResultSetInformation((StatementInformation)this.statementInformation), this.eventListener);
} catch (SQLException sqle) { } catch (SQLException sqle) {
e = sqle; e = sqle;
throw sqle; throw e;
} finally { } finally {
this.eventListener.onAfterExecuteQuery(this.statementInformation, System.nanoTime() - start, e); this.eventListener.onAfterExecuteQuery(this.statementInformation, System.nanoTime() - start, e);
} }
return var4;
} }
public int executeUpdate() throws SQLException { public int executeUpdate() throws SQLException {
SQLException e = null; SQLException e = null;
long start = System.nanoTime(); long start = System.nanoTime();
int rowCount = 0; int rowCount = 0;
int var5;
try { try {
this.eventListener.onBeforeExecuteUpdate(this.statementInformation); this.eventListener.onBeforeExecuteUpdate(this.statementInformation);
rowCount = this.delegate.executeUpdate(); rowCount = this.delegate.executeUpdate();
var5 = rowCount; return rowCount;
} catch (SQLException sqle) { } catch (SQLException sqle) {
e = sqle; e = sqle;
throw sqle; throw e;
} finally { } finally {
this.eventListener.onAfterExecuteUpdate(this.statementInformation, System.nanoTime() - start, rowCount, e); this.eventListener.onAfterExecuteUpdate(this.statementInformation, System.nanoTime() - start, rowCount, e);
} }
return var5;
} }
public void setNull(int parameterIndex, int sqlType) throws SQLException { public void setNull(int parameterIndex, int sqlType) throws SQLException {
SQLException e = null; SQLException e = null;
try { try {
parameterIndex = this.getParameterIndex(parameterIndex); parameterIndex = getParameterIndex(parameterIndex);
this.sqlBuffer.setValueSqlType(0, parameterIndex, sqlType); this.sqlBuffer.setValueSqlType(0, parameterIndex, sqlType);
this.delegate.setNull(parameterIndex, sqlType); this.delegate.setNull(parameterIndex, sqlType);
} catch (SQLException sqle) { } catch (SQLException sqle) {
e = sqle; e = sqle;
throw sqle; throw e;
} finally { } finally {
this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, null, e); this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, null, e);
} }
} }
public void setBoolean(int parameterIndex, boolean x) throws SQLException { public void setBoolean(int parameterIndex, boolean x) throws SQLException {
SQLException e = null; SQLException e = null;
try { try {
parameterIndex = this.getParameterIndex(parameterIndex); parameterIndex = getParameterIndex(parameterIndex);
this.sqlBuffer.setValue(1, parameterIndex, x); this.sqlBuffer.setValue(1, parameterIndex, Boolean.valueOf(x));
this.delegate.setBoolean(parameterIndex, x); this.delegate.setBoolean(parameterIndex, x);
} catch (SQLException sqle) { } catch (SQLException sqle) {
e = sqle; e = sqle;
throw sqle; throw e;
} finally { } finally {
this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, x, e); this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, Boolean.valueOf(x), e);
} }
} }
public void setByte(int parameterIndex, byte x) throws SQLException { public void setByte(int parameterIndex, byte x) throws SQLException {
SQLException e = null; SQLException e = null;
try { try {
parameterIndex = this.getParameterIndex(parameterIndex); parameterIndex = getParameterIndex(parameterIndex);
this.sqlBuffer.setValue(2, parameterIndex, x); this.sqlBuffer.setValue(2, parameterIndex, Byte.valueOf(x));
this.delegate.setByte(parameterIndex, x); this.delegate.setByte(parameterIndex, x);
} catch (SQLException sqle) { } catch (SQLException sqle) {
e = sqle; e = sqle;
throw sqle; throw e;
} finally { } finally {
this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, x, e); this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, Byte.valueOf(x), e);
} }
} }
public void setShort(int parameterIndex, short x) throws SQLException { public void setShort(int parameterIndex, short x) throws SQLException {
SQLException e = null; SQLException e = null;
try { try {
parameterIndex = this.getParameterIndex(parameterIndex); parameterIndex = getParameterIndex(parameterIndex);
this.sqlBuffer.setValue(7, parameterIndex, x); this.sqlBuffer.setValue(7, parameterIndex, Short.valueOf(x));
this.delegate.setShort(parameterIndex, x); this.delegate.setShort(parameterIndex, x);
} catch (SQLException sqle) { } catch (SQLException sqle) {
e = sqle; e = sqle;
throw sqle; throw e;
} finally { } finally {
this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, x, e); this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, Short.valueOf(x), e);
} }
} }
public void setInt(int parameterIndex, int x) throws SQLException { public void setInt(int parameterIndex, int x) throws SQLException {
SQLException e = null; SQLException e = null;
try { try {
parameterIndex = this.getParameterIndex(parameterIndex); parameterIndex = getParameterIndex(parameterIndex);
this.sqlBuffer.setValue(4, parameterIndex, x); this.sqlBuffer.setValue(4, parameterIndex, Integer.valueOf(x));
this.delegate.setInt(parameterIndex, x); this.delegate.setInt(parameterIndex, x);
} catch (SQLException sqle) { } catch (SQLException sqle) {
e = sqle; e = sqle;
throw sqle; throw e;
} finally { } finally {
this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, x, e); this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, Integer.valueOf(x), e);
} }
} }
public void setLong(int parameterIndex, long x) throws SQLException { public void setLong(int parameterIndex, long x) throws SQLException {
SQLException e = null; SQLException e = null;
try { try {
parameterIndex = this.getParameterIndex(parameterIndex); parameterIndex = getParameterIndex(parameterIndex);
this.sqlBuffer.setValue(3, parameterIndex, x); this.sqlBuffer.setValue(3, parameterIndex, Long.valueOf(x));
this.delegate.setLong(parameterIndex, x); this.delegate.setLong(parameterIndex, x);
} catch (SQLException sqle) { } catch (SQLException sqle) {
e = sqle; e = sqle;
throw sqle; throw e;
} finally { } finally {
this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, x, e); this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, Long.valueOf(x), e);
} }
} }
public void setFloat(int parameterIndex, float x) throws SQLException { public void setFloat(int parameterIndex, float x) throws SQLException {
SQLException e = null; SQLException e = null;
try { try {
parameterIndex = this.getParameterIndex(parameterIndex); parameterIndex = getParameterIndex(parameterIndex);
this.sqlBuffer.setValue(5, parameterIndex, x); this.sqlBuffer.setValue(5, parameterIndex, Float.valueOf(x));
this.delegate.setFloat(parameterIndex, x); this.delegate.setFloat(parameterIndex, x);
} catch (SQLException sqle) { } catch (SQLException sqle) {
e = sqle; e = sqle;
throw sqle; throw e;
} finally { } finally {
this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, x, e); this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, Float.valueOf(x), e);
} }
} }
public void setDouble(int parameterIndex, double x) throws SQLException { public void setDouble(int parameterIndex, double x) throws SQLException {
SQLException e = null; SQLException e = null;
try { try {
parameterIndex = this.getParameterIndex(parameterIndex); parameterIndex = getParameterIndex(parameterIndex);
this.sqlBuffer.setValue(6, parameterIndex, x); this.sqlBuffer.setValue(6, parameterIndex, Double.valueOf(x));
this.delegate.setDouble(parameterIndex, x); this.delegate.setDouble(parameterIndex, x);
} catch (SQLException sqle) { } catch (SQLException sqle) {
e = sqle; e = sqle;
throw sqle; throw e;
} finally { } finally {
this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, x, e); this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, Double.valueOf(x), e);
} }
} }
public void setBigDecimal(int parameterIndex, BigDecimal x) throws SQLException { public void setBigDecimal(int parameterIndex, BigDecimal x) throws SQLException {
SQLException e = null; SQLException e = null;
try { try {
parameterIndex = this.getParameterIndex(parameterIndex); parameterIndex = getParameterIndex(parameterIndex);
this.sqlBuffer.setValue(8, parameterIndex, x); this.sqlBuffer.setValue(8, parameterIndex, x);
this.delegate.setBigDecimal(parameterIndex, x); this.delegate.setBigDecimal(parameterIndex, x);
} catch (SQLException sqle) { } catch (SQLException sqle) {
e = sqle; e = sqle;
throw sqle; throw e;
} finally { } finally {
this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, x, e); this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, x, e);
} }
} }
private int getParameterIndex(int parameterIndex) { private int getParameterIndex(int parameterIndex) {
...@@ -266,22 +246,16 @@ public class PreparedStatementWrapper extends StatementWrapper implements Prepar ...@@ -266,22 +246,16 @@ public class PreparedStatementWrapper extends StatementWrapper implements Prepar
boolean where = false; boolean where = false;
Map<String, Integer> digestMap = this.statementInformation.getDigestMap(); Map<String, Integer> digestMap = this.statementInformation.getDigestMap();
if (!digestMap.isEmpty()) { if (!digestMap.isEmpty()) {
for(String key : digestMap.keySet()) { for (String key : digestMap.keySet()) {
Integer value = (Integer)digestMap.get(key); Integer value = digestMap.get(key);
if (value < whereLocation) { if (value.intValue() < whereLocation)
whereLocation = value; whereLocation = value.intValue();
} }
} if (parameterIndex >= whereLocation)
if (parameterIndex >= whereLocation) {
where = true; where = true;
} }
} if (where)
if (where) {
parameterIndex += digestMap.size(); parameterIndex += digestMap.size();
}
return parameterIndex; return parameterIndex;
} }
...@@ -293,26 +267,24 @@ public class PreparedStatementWrapper extends StatementWrapper implements Prepar ...@@ -293,26 +267,24 @@ public class PreparedStatementWrapper extends StatementWrapper implements Prepar
boolean where = false; boolean where = false;
String tableAndColumnName = null; String tableAndColumnName = null;
String mathKey = null; String mathKey = null;
try { try {
String sql = this.statementInformation.getSql(); String sql = this.statementInformation.getSql();
boolean needSqlParse = DbCache.isNeedSqlParse(sql, this.statementInformation); boolean needSqlParse = DbCache.isNeedSqlParse(sql, (StatementInformation)this.statementInformation);
RuleLoadUtil.writeLog("@@插件@@---PreparedstatementWrapper解析setString-->" + sql); RuleLoadUtil.writeLog("@@"+ sql);
RuleLoadUtil.writeLog("@@插件@@---PreparedstatementWrapper解析setString-needSqlParse->" + needSqlParse); RuleLoadUtil.writeLog("@@"+ needSqlParse);
if (!needSqlParse) { if (!needSqlParse) {
this.sqlBuffer.setValue(9, parameterIndex, (Object)x1, (Object)x1); this.sqlBuffer.setValue(9, parameterIndex, x1, x1);
this.delegate.setString(parameterIndex, x1); this.delegate.setString(parameterIndex, x1);
return; return;
} }
Columninfo columninfo = sqlIndexKeyMap.get(sql + "_" + parameterIndex);
Columninfo columninfo = (Columninfo)sqlIndexKeyMap.get(sql + "_" + parameterIndex);
if (columninfo == null) { if (columninfo == null) {
map = this.encData(this.statementInformation, parameterIndex, x1); map = encData(this.statementInformation, parameterIndex, x1);
x = (String)map.get("x"); x = map.get("x");
tableAndColumnName = (String)map.get("tableAndColumnName"); tableAndColumnName = map.get("tableAndColumnName");
mathKey = (String)map.get("mathKey"); mathKey = map.get("mathKey");
} else if (columninfo.getSecretkey() != null) { } else if (columninfo.getSecretkey() != null) {
x = (String)EngineUtil.exeEngine(columninfo, (ConnectionInfo)null, false, x1, true); x = (String)EngineUtil.exeEngine(columninfo, null, Boolean.valueOf(false), x1, Boolean.valueOf(true));
tableAndColumnName = columninfo.getColumnname(); tableAndColumnName = columninfo.getColumnname();
mathKey = columninfo.getId(); mathKey = columninfo.getId();
} else { } else {
...@@ -320,157 +292,135 @@ public class PreparedStatementWrapper extends StatementWrapper implements Prepar ...@@ -320,157 +292,135 @@ public class PreparedStatementWrapper extends StatementWrapper implements Prepar
tableAndColumnName = columninfo.getColumnname(); tableAndColumnName = columninfo.getColumnname();
mathKey = columninfo.getId(); mathKey = columninfo.getId();
} }
this.sqlBuffer.setValue(9, parameterIndex, x, x1);
this.sqlBuffer.setValue(9, parameterIndex, (Object)x, (Object)x1);
this.delegate.setString(parameterIndex, x); this.delegate.setString(parameterIndex, x);
if (EngineUtil.digestMap.isEmpty()) { if (EngineUtil.digestMap.isEmpty())
return; return;
}
int whereLocation = 100000000; int whereLocation = 100000000;
digestMap = this.statementInformation.getDigestMap(); digestMap = this.statementInformation.getDigestMap();
if (!digestMap.isEmpty()) { if (!digestMap.isEmpty()) {
for(String key : digestMap.keySet()) { for (String key : digestMap.keySet()) {
Integer value = (Integer)digestMap.get(key); Integer value = digestMap.get(key);
if (value < whereLocation) { if (value.intValue() < whereLocation)
whereLocation = value; whereLocation = value.intValue();
}
} }
if (parameterIndex >= whereLocation)
if (parameterIndex >= whereLocation) {
where = true; where = true;
} }
}
} catch (Exception exception) { } catch (Exception exception) {
exception.printStackTrace(); exception.printStackTrace();
} }
try { try {
this.sqlBuffer.setValue(9, parameterIndex, (Object)x, (Object)x1); this.sqlBuffer.setValue(9, parameterIndex, x, x1);
this.delegate.setString(parameterIndex, x); this.delegate.setString(parameterIndex, x);
if (!digestMap.isEmpty() && !where && tableAndColumnName != null && digestMap.get(tableAndColumnName) != null) { if (!digestMap.isEmpty() && !where && tableAndColumnName != null && digestMap.get(tableAndColumnName) != null) {
String digestValue = this.abstractData(mathKey, x); String digestValue = abstractData(mathKey, x);
this.sqlBuffer.setValue(9, (Integer)digestMap.get(tableAndColumnName), (Object)digestValue, null); this.sqlBuffer.setValue(9, ((Integer)digestMap.get(tableAndColumnName)).intValue(), digestValue, null);
this.delegate.setString((Integer)digestMap.get(tableAndColumnName), digestValue); this.delegate.setString(((Integer)digestMap.get(tableAndColumnName)).intValue(), digestValue);
} }
} catch (SQLException sqle) { } catch (SQLException sqle) {
e = sqle; e = sqle;
throw sqle; throw e;
} catch (Exception ex) { } catch (Exception ex) {
ex.printStackTrace(); ex.printStackTrace();
} finally { } finally {
this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, x, e); this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, x, e);
} }
} }
public void setBytes(int parameterIndex, byte[] x) throws SQLException { public void setBytes(int parameterIndex, byte[] x) throws SQLException {
SQLException e = null; SQLException e = null;
try { try {
parameterIndex = this.getParameterIndex(parameterIndex); parameterIndex = getParameterIndex(parameterIndex);
this.sqlBuffer.setValue(10, parameterIndex, x); this.sqlBuffer.setValue(10, parameterIndex, x);
this.delegate.setBytes(parameterIndex, x); this.delegate.setBytes(parameterIndex, x);
} catch (SQLException sqle) { } catch (SQLException sqle) {
e = sqle; e = sqle;
throw sqle; throw e;
} finally { } finally {
this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, x, e); this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, x, e);
} }
} }
public void setDate(int parameterIndex, Date x) throws SQLException { public void setDate(int parameterIndex, Date x) throws SQLException {
SQLException e = null; SQLException e = null;
try { try {
parameterIndex = this.getParameterIndex(parameterIndex); parameterIndex = getParameterIndex(parameterIndex);
this.sqlBuffer.setValue(11, parameterIndex, x); this.sqlBuffer.setValue(11, parameterIndex, x);
this.delegate.setDate(parameterIndex, x); this.delegate.setDate(parameterIndex, x);
} catch (SQLException sqle) { } catch (SQLException sqle) {
e = sqle; e = sqle;
throw sqle; throw e;
} finally { } finally {
this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, x, e); this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, x, e);
} }
} }
public void setTime(int parameterIndex, Time x) throws SQLException { public void setTime(int parameterIndex, Time x) throws SQLException {
SQLException e = null; SQLException e = null;
try { try {
parameterIndex = this.getParameterIndex(parameterIndex); parameterIndex = getParameterIndex(parameterIndex);
this.sqlBuffer.setValue(12, parameterIndex, x); this.sqlBuffer.setValue(12, parameterIndex, x);
this.delegate.setTime(parameterIndex, x); this.delegate.setTime(parameterIndex, x);
} catch (SQLException sqle) { } catch (SQLException sqle) {
e = sqle; e = sqle;
throw sqle; throw e;
} finally { } finally {
this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, x, e); this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, x, e);
} }
} }
public void setTimestamp(int parameterIndex, Timestamp x) throws SQLException { public void setTimestamp(int parameterIndex, Timestamp x) throws SQLException {
SQLException e = null; SQLException e = null;
try { try {
parameterIndex = this.getParameterIndex(parameterIndex); parameterIndex = getParameterIndex(parameterIndex);
this.sqlBuffer.setValue(13, parameterIndex, x); this.sqlBuffer.setValue(13, parameterIndex, x);
this.delegate.setTimestamp(parameterIndex, x); this.delegate.setTimestamp(parameterIndex, x);
} catch (SQLException sqle) { } catch (SQLException sqle) {
e = sqle; e = sqle;
throw sqle; throw e;
} finally { } finally {
this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, x, e); this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, x, e);
} }
} }
public void setAsciiStream(int parameterIndex, InputStream x, int length) throws SQLException { public void setAsciiStream(int parameterIndex, InputStream x, int length) throws SQLException {
SQLException e = null; SQLException e = null;
try { try {
this.sqlBuffer.setValue(14, parameterIndex, (InputStream)x, (long)length, "byte[ascii]"); this.sqlBuffer.setValue(14, parameterIndex, x, length, "byte[ascii]");
this.delegate.setAsciiStream(parameterIndex, x, length); this.delegate.setAsciiStream(parameterIndex, x, length);
} catch (SQLException sqle) { } catch (SQLException sqle) {
e = sqle; e = sqle;
throw sqle; throw e;
} finally { } finally {
this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, x, e); this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, x, e);
} }
} }
public void setUnicodeStream(int parameterIndex, InputStream x, int length) throws SQLException { public void setUnicodeStream(int parameterIndex, InputStream x, int length) throws SQLException {
SQLException e = null; SQLException e = null;
try { try {
this.sqlBuffer.setValue(14, parameterIndex, (InputStream)x, (long)length, "byte[ascii]"); this.sqlBuffer.setValue(14, parameterIndex, x, length, "byte[ascii]");
this.delegate.setUnicodeStream(parameterIndex, x, length); this.delegate.setUnicodeStream(parameterIndex, x, length);
} catch (SQLException sqle) { } catch (SQLException sqle) {
e = sqle; e = sqle;
throw sqle; throw e;
} finally { } finally {
this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, x, e); this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, x, e);
} }
} }
public void setBinaryStream(int parameterIndex, InputStream x, int length) throws SQLException { public void setBinaryStream(int parameterIndex, InputStream x, int length) throws SQLException {
SQLException e = null; SQLException e = null;
try { try {
this.sqlBuffer.setValue(14, parameterIndex, (InputStream)x, (long)length, "byte[]"); this.sqlBuffer.setValue(14, parameterIndex, x, length, "byte[]");
this.delegate.setBinaryStream(parameterIndex, x, length); this.delegate.setBinaryStream(parameterIndex, x, length);
} catch (SQLException sqle) { } catch (SQLException sqle) {
e = sqle; e = sqle;
throw sqle; throw e;
} finally { } finally {
this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, x, e); this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, x, e);
} }
} }
public void clearParameters() throws SQLException { public void clearParameters() throws SQLException {
...@@ -485,21 +435,20 @@ public class PreparedStatementWrapper extends StatementWrapper implements Prepar ...@@ -485,21 +435,20 @@ public class PreparedStatementWrapper extends StatementWrapper implements Prepar
boolean where = false; boolean where = false;
String tableAndColumnName = null; String tableAndColumnName = null;
String mathKey = null; String mathKey = null;
try { try {
String sql = this.statementInformation.getSql(); String sql = this.statementInformation.getSql();
Columninfo columninfo = (Columninfo)sqlIndexKeyMap.get(sql + "_" + parameterIndex); Columninfo columninfo = sqlIndexKeyMap.get(sql + "_" + parameterIndex);
if (columninfo == null) { if (columninfo == null) {
if (x1 instanceof String) { if (x1 instanceof String) {
map = this.encData(this.statementInformation, parameterIndex, x1.toString()); map = encData(this.statementInformation, parameterIndex, x1.toString());
x = map.get("x"); x = map.get("x");
tableAndColumnName = (String)map.get("tableAndColumnName"); tableAndColumnName = map.get("tableAndColumnName");
mathKey = (String)map.get("mathKey"); mathKey = map.get("mathKey");
} else { } else {
x = x1; x = x1;
} }
} else if (columninfo.getSecretkey() != null) { } else if (columninfo.getSecretkey() != null) {
x = (String)EngineUtil.exeEngine(columninfo, (ConnectionInfo)null, false, x1, true); x = EngineUtil.exeEngine(columninfo, null, Boolean.valueOf(false), x1, Boolean.valueOf(true));
tableAndColumnName = columninfo.getColumnname(); tableAndColumnName = columninfo.getColumnname();
mathKey = columninfo.getId(); mathKey = columninfo.getId();
} else { } else {
...@@ -507,43 +456,34 @@ public class PreparedStatementWrapper extends StatementWrapper implements Prepar ...@@ -507,43 +456,34 @@ public class PreparedStatementWrapper extends StatementWrapper implements Prepar
tableAndColumnName = columninfo.getColumnname(); tableAndColumnName = columninfo.getColumnname();
mathKey = columninfo.getId(); mathKey = columninfo.getId();
} }
this.sqlBuffer.setValue(-1, parameterIndex, x, x1, targetSqlType);
this.sqlBuffer.setValue(-1, parameterIndex, (Object)x, (Object)x1, targetSqlType);
this.delegate.setObject(parameterIndex, x, targetSqlType); this.delegate.setObject(parameterIndex, x, targetSqlType);
if (!EngineUtil.digestMap.isEmpty()) { if (EngineUtil.digestMap.isEmpty())
return;
int whereLocation = 100000000; int whereLocation = 100000000;
digestMap = this.statementInformation.getDigestMap(); digestMap = this.statementInformation.getDigestMap();
if (!digestMap.isEmpty()) { if (!digestMap.isEmpty()) {
for(String key : digestMap.keySet()) { for (String key : digestMap.keySet()) {
Integer value = (Integer)digestMap.get(key); Integer value = digestMap.get(key);
if (value < whereLocation) { if (value.intValue() < whereLocation)
whereLocation = value; whereLocation = value.intValue();
}
} }
if (parameterIndex >= whereLocation)
if (parameterIndex >= whereLocation) {
where = true; where = true;
} }
}
if (!digestMap.isEmpty() && !where && tableAndColumnName != null && digestMap.get(tableAndColumnName) != null) { if (!digestMap.isEmpty() && !where && tableAndColumnName != null && digestMap.get(tableAndColumnName) != null) {
String digestValue = this.abstractData(mathKey, x.toString()); String digestValue = abstractData(mathKey, x.toString());
this.sqlBuffer.setValue(-1, (Integer)digestMap.get(tableAndColumnName), (Object)digestValue, null); this.sqlBuffer.setValue(-1, ((Integer)digestMap.get(tableAndColumnName)).intValue(), digestValue, null);
this.delegate.setString((Integer)digestMap.get(tableAndColumnName), digestValue); this.delegate.setString(((Integer)digestMap.get(tableAndColumnName)).intValue(), digestValue);
}
return;
} }
} catch (SQLException sqle) { } catch (SQLException sqle) {
e = sqle; e = sqle;
throw sqle; throw e;
} catch (Exception ex) { } catch (Exception ex) {
ex.printStackTrace(); ex.printStackTrace();
return;
} finally { } finally {
this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, x, e); this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, x, e);
} }
} }
public void setObject(int parameterIndex, Object x1) throws SQLException { public void setObject(int parameterIndex, Object x1) throws SQLException {
...@@ -554,23 +494,26 @@ public class PreparedStatementWrapper extends StatementWrapper implements Prepar ...@@ -554,23 +494,26 @@ public class PreparedStatementWrapper extends StatementWrapper implements Prepar
boolean where = false; boolean where = false;
String tableAndColumnName = null; String tableAndColumnName = null;
String mathKey = null; String mathKey = null;
try { try {
String sql = this.statementInformation.getSql(); String sql = this.statementInformation.getSql();
boolean needSqlParse = DbCache.isNeedSqlParse(sql, this.statementInformation); boolean needSqlParse = DbCache.isNeedSqlParse(sql, (StatementInformation)this.statementInformation);
if (needSqlParse) { if (!needSqlParse) {
Columninfo columninfo = (Columninfo)sqlIndexKeyMap.get(sql + "_" + parameterIndex); this.sqlBuffer.setValue(-1, parameterIndex, x1, x1);
this.delegate.setObject(parameterIndex, x1);
return;
}
Columninfo columninfo = sqlIndexKeyMap.get(sql + "_" + parameterIndex);
if (columninfo == null) { if (columninfo == null) {
if (x1 instanceof String) { if (x1 instanceof String) {
map = this.encData(this.statementInformation, parameterIndex, x1.toString()); map = encData(this.statementInformation, parameterIndex, x1.toString());
x = map.get("x"); x = map.get("x");
tableAndColumnName = (String)map.get("tableAndColumnName"); tableAndColumnName = map.get("tableAndColumnName");
mathKey = (String)map.get("mathKey"); mathKey = map.get("mathKey");
} else { } else {
x = x1; x = x1;
} }
} else if (columninfo.getSecretkey() != null) { } else if (columninfo.getSecretkey() != null) {
x = (String)EngineUtil.exeEngine(columninfo, (ConnectionInfo)null, false, x1, true); x = EngineUtil.exeEngine(columninfo, null, Boolean.valueOf(false), x1, Boolean.valueOf(true));
tableAndColumnName = columninfo.getColumnname(); tableAndColumnName = columninfo.getColumnname();
mathKey = columninfo.getId(); mathKey = columninfo.getId();
} else { } else {
...@@ -578,419 +521,349 @@ public class PreparedStatementWrapper extends StatementWrapper implements Prepar ...@@ -578,419 +521,349 @@ public class PreparedStatementWrapper extends StatementWrapper implements Prepar
tableAndColumnName = columninfo.getColumnname(); tableAndColumnName = columninfo.getColumnname();
mathKey = columninfo.getId(); mathKey = columninfo.getId();
} }
this.sqlBuffer.setValue(-1, parameterIndex, x, x1);
this.sqlBuffer.setValue(-1, parameterIndex, (Object)x, (Object)x1);
this.delegate.setObject(parameterIndex, x); this.delegate.setObject(parameterIndex, x);
if (EngineUtil.digestMap.isEmpty()) { if (EngineUtil.digestMap.isEmpty())
return; return;
}
int whereLocation = 100000000; int whereLocation = 100000000;
digestMap = this.statementInformation.getDigestMap(); digestMap = this.statementInformation.getDigestMap();
if (!digestMap.isEmpty()) { if (!digestMap.isEmpty()) {
for(String key : digestMap.keySet()) { for (String key : digestMap.keySet()) {
Integer value = (Integer)digestMap.get(key); Integer value = digestMap.get(key);
if (value < whereLocation) { if (value.intValue() < whereLocation)
whereLocation = value; whereLocation = value.intValue();
}
} }
if (parameterIndex >= whereLocation)
if (parameterIndex >= whereLocation) {
where = true; where = true;
} }
}
if (!digestMap.isEmpty() && !where && tableAndColumnName != null && digestMap.get(tableAndColumnName) != null) { if (!digestMap.isEmpty() && !where && tableAndColumnName != null && digestMap.get(tableAndColumnName) != null) {
String digestValue = this.abstractData(mathKey, x.toString()); String digestValue = abstractData(mathKey, x.toString());
this.sqlBuffer.setValue(-1, (Integer)digestMap.get(tableAndColumnName), (Object)digestValue, null); this.sqlBuffer.setValue(-1, ((Integer)digestMap.get(tableAndColumnName)).intValue(), digestValue, null);
this.delegate.setString((Integer)digestMap.get(tableAndColumnName), digestValue); this.delegate.setString(((Integer)digestMap.get(tableAndColumnName)).intValue(), digestValue);
} }
return;
}
this.sqlBuffer.setValue(-1, parameterIndex, (Object)x1, (Object)x1);
this.delegate.setObject(parameterIndex, x1);
} catch (SQLException sqle) { } catch (SQLException sqle) {
e = sqle; e = sqle;
throw sqle; throw e;
} catch (Exception ex) { } catch (Exception ex) {
ex.printStackTrace(); ex.printStackTrace();
return;
} finally { } finally {
this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, x, e); this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, x, e);
} }
} }
public boolean execute() throws SQLException { public boolean execute() throws SQLException {
SQLException e = null; SQLException e = null;
long start = System.nanoTime(); long start = System.nanoTime();
boolean var4;
try { try {
this.eventListener.onBeforeExecute(this.statementInformation); this.eventListener.onBeforeExecute(this.statementInformation);
var4 = this.delegate.execute(); return this.delegate.execute();
} catch (SQLException sqle) { } catch (SQLException sqle) {
e = sqle; e = sqle;
throw sqle; throw e;
} finally { } finally {
this.eventListener.onAfterExecute(this.statementInformation, System.nanoTime() - start, e); this.eventListener.onAfterExecute(this.statementInformation, System.nanoTime() - start, e);
} }
return var4;
} }
public void addBatch() throws SQLException { public void addBatch() throws SQLException {
SQLException e = null; SQLException e = null;
long start = System.nanoTime(); long start = System.nanoTime();
try { try {
this.eventListener.onBeforeAddBatch(this.statementInformation); this.eventListener.onBeforeAddBatch(this.statementInformation);
this.delegate.addBatch(); this.delegate.addBatch();
} catch (SQLException sqle) { } catch (SQLException sqle) {
e = sqle; e = sqle;
throw sqle; throw e;
} finally { } finally {
this.eventListener.onAfterAddBatch(this.statementInformation, System.nanoTime() - start, e); this.eventListener.onAfterAddBatch(this.statementInformation, System.nanoTime() - start, e);
} }
} }
public void setCharacterStream(int parameterIndex, Reader reader, int length) throws SQLException { public void setCharacterStream(int parameterIndex, Reader reader, int length) throws SQLException {
SQLException e = null; SQLException e = null;
try { try {
this.sqlBuffer.setValue(15, parameterIndex, (Object)reader, (Object)length); this.sqlBuffer.setValue(15, parameterIndex, reader, Integer.valueOf(length));
this.delegate.setCharacterStream(parameterIndex, reader, length); this.delegate.setCharacterStream(parameterIndex, reader, length);
} catch (SQLException sqle) { } catch (SQLException sqle) {
e = sqle; e = sqle;
throw sqle; throw e;
} finally { } finally {
this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, reader, e); this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, reader, e);
} }
} }
public void setRef(int parameterIndex, Ref x) throws SQLException { public void setRef(int parameterIndex, Ref x) throws SQLException {
SQLException e = null; SQLException e = null;
try { try {
this.sqlBuffer.setValue(16, parameterIndex, x); this.sqlBuffer.setValue(16, parameterIndex, x);
this.delegate.setRef(parameterIndex, x); this.delegate.setRef(parameterIndex, x);
} catch (SQLException sqle) { } catch (SQLException sqle) {
e = sqle; e = sqle;
throw sqle; throw e;
} finally { } finally {
this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, x, e); this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, x, e);
} }
} }
public void setBlob(int parameterIndex, Blob x) throws SQLException { public void setBlob(int parameterIndex, Blob x) throws SQLException {
SQLException e = null; SQLException e = null;
try { try {
this.sqlBuffer.setValue(18, parameterIndex, x); this.sqlBuffer.setValue(18, parameterIndex, x);
this.delegate.setBlob(parameterIndex, x); this.delegate.setBlob(parameterIndex, x);
} catch (SQLException sqle) { } catch (SQLException sqle) {
e = sqle; e = sqle;
throw sqle; throw e;
} finally { } finally {
this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, x, e); this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, x, e);
} }
} }
public void setClob(int parameterIndex, Clob x2) throws SQLException { public void setClob(int parameterIndex, Clob x2) throws SQLException {
SQLException e = null; SQLException e = null;
String x = null; String x = null;
String x1 = null; String x1 = null;
try { try {
x1 = this.clobToString(x2); x1 = clobToString(x2);
} catch (Exception exception) { } catch (Exception exception) {
exception.printStackTrace(); exception.printStackTrace();
} }
Map<String, Integer> digestMap = null; Map<String, Integer> digestMap = null;
Map<String, String> map = null; Map<String, String> map = null;
boolean where = false; boolean where = false;
try { try {
map = this.encData(this.statementInformation, parameterIndex, x1); map = encData(this.statementInformation, parameterIndex, x1);
x = (String)map.get("x"); x = map.get("x");
int whereLocation = 100000000; int whereLocation = 100000000;
digestMap = this.statementInformation.getDigestMap(); digestMap = this.statementInformation.getDigestMap();
if (!digestMap.isEmpty()) { if (!digestMap.isEmpty()) {
for(String key : digestMap.keySet()) { for (String key : digestMap.keySet()) {
Integer value = (Integer)digestMap.get(key); Integer value = digestMap.get(key);
if (value < whereLocation) { if (value.intValue() < whereLocation)
whereLocation = value; whereLocation = value.intValue();
}
} }
if (parameterIndex >= whereLocation)
if (parameterIndex >= whereLocation) {
where = true; where = true;
} }
}
} catch (Exception exception) { } catch (Exception exception) {
exception.printStackTrace(); exception.printStackTrace();
} }
try { try {
this.sqlBuffer.setValue(9, parameterIndex, (Object)x, (Object)x1); this.sqlBuffer.setValue(9, parameterIndex, x, x1);
this.delegate.setString(parameterIndex, x); this.delegate.setString(parameterIndex, x);
RuleLoadUtil.writeLog("@@插件@@---PreparedStatementWrapper--digestMap:" + digestMap); RuleLoadUtil.writeLog("@@"+ digestMap);
RuleLoadUtil.writeLog("@@插件@@---PreparedStatementWrapper--where:" + where); RuleLoadUtil.writeLog("@@"+ where);
if (digestMap != null && !digestMap.isEmpty() && !where && map != null && map.get("tableAndColumnName") != null && digestMap.get(map.get("tableAndColumnName")) != null) { if (digestMap != null && !digestMap.isEmpty() && !where && map != null && map.get("tableAndColumnName") != null && digestMap.get(map.get("tableAndColumnName")) != null)
try { try {
String digestValue = this.abstractData((String)map.get("mathKey"), x); String digestValue = abstractData(map.get("mathKey"), x);
this.sqlBuffer.setValue(9, (Integer)digestMap.get(map.get("tableAndColumnName")), (Object)digestValue, null); this.sqlBuffer.setValue(9, ((Integer)digestMap.get(map.get("tableAndColumnName"))).intValue(), digestValue, null);
this.delegate.setString((Integer)digestMap.get(map.get("tableAndColumnName")), digestValue); this.delegate.setString(((Integer)digestMap.get(map.get("tableAndColumnName"))).intValue(), digestValue);
} catch (Exception exception) { } catch (Exception exception) {
exception.printStackTrace(); exception.printStackTrace();
} }
}
} catch (SQLException sqle) { } catch (SQLException sqle) {
e = sqle; e = sqle;
throw sqle; throw e;
} finally { } finally {
this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, x, e); this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, x, e);
} }
} }
public String clobToString(Clob clob) throws Exception { public String clobToString(Clob clob) throws Exception {
StringWriter writer = new StringWriter(); StringWriter writer = new StringWriter();
Reader reader = null; Reader reader = null;
try { try {
reader = clob.getCharacterStream(); reader = clob.getCharacterStream();
char[] buffer = new char[1024]; char[] buffer = new char[1024];
int bytesRead; int bytesRead;
while((bytesRead = reader.read(buffer)) != -1) { while ((bytesRead = reader.read(buffer)) != -1)
writer.write(buffer, 0, bytesRead); writer.write(buffer, 0, bytesRead);
}
} finally { } finally {
if (reader != null) { if (reader != null)
reader.close(); reader.close();
} }
}
return writer.toString(); return writer.toString();
} }
public void setArray(int parameterIndex, Array x) throws SQLException { public void setArray(int parameterIndex, Array x) throws SQLException {
SQLException e = null; SQLException e = null;
try { try {
this.sqlBuffer.setValue(20, parameterIndex, x); this.sqlBuffer.setValue(20, parameterIndex, x);
this.delegate.setArray(parameterIndex, x); this.delegate.setArray(parameterIndex, x);
} catch (SQLException sqle) { } catch (SQLException sqle) {
e = sqle; e = sqle;
throw sqle; throw e;
} finally { } finally {
this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, x, e); this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, x, e);
} }
} }
public void setDate(int parameterIndex, Date x, Calendar cal) throws SQLException { public void setDate(int parameterIndex, Date x, Calendar cal) throws SQLException {
SQLException e = null; SQLException e = null;
try { try {
this.sqlBuffer.setValue(11, parameterIndex, (Date)x, (Calendar)cal); this.sqlBuffer.setValue(11, parameterIndex, x, cal);
this.delegate.setDate(parameterIndex, x, cal); this.delegate.setDate(parameterIndex, x, cal);
} catch (SQLException sqle) { } catch (SQLException sqle) {
e = sqle; e = sqle;
throw sqle; throw e;
} finally { } finally {
this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, x, e); this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, x, e);
} }
} }
public void setTime(int parameterIndex, Time x, Calendar cal) throws SQLException { public void setTime(int parameterIndex, Time x, Calendar cal) throws SQLException {
SQLException e = null; SQLException e = null;
try { try {
this.sqlBuffer.setValue(12, parameterIndex, (Time)x, (Calendar)cal); this.sqlBuffer.setValue(12, parameterIndex, x, cal);
this.delegate.setTime(parameterIndex, x, cal); this.delegate.setTime(parameterIndex, x, cal);
} catch (SQLException sqle) { } catch (SQLException sqle) {
e = sqle; e = sqle;
throw sqle; throw e;
} finally { } finally {
this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, x, e); this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, x, e);
} }
} }
public void setTimestamp(int parameterIndex, Timestamp x, Calendar cal) throws SQLException { public void setTimestamp(int parameterIndex, Timestamp x, Calendar cal) throws SQLException {
SQLException e = null; SQLException e = null;
try { try {
this.sqlBuffer.setValue(13, parameterIndex, (Timestamp)x, (Calendar)cal); this.sqlBuffer.setValue(13, parameterIndex, x, cal);
this.delegate.setTimestamp(parameterIndex, x, cal); this.delegate.setTimestamp(parameterIndex, x, cal);
} catch (SQLException sqle) { } catch (SQLException sqle) {
e = sqle; e = sqle;
throw sqle; throw e;
} finally { } finally {
this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, x, e); this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, x, e);
} }
} }
public void setNull(int parameterIndex, int sqlType, String typeName) throws SQLException { public void setNull(int parameterIndex, int sqlType, String typeName) throws SQLException {
SQLException e = null; SQLException e = null;
try { try {
this.sqlBuffer.setValue(0, parameterIndex, sqlType, typeName); this.sqlBuffer.setValue(0, parameterIndex, sqlType, typeName);
this.delegate.setNull(parameterIndex, sqlType, typeName); this.delegate.setNull(parameterIndex, sqlType, typeName);
} catch (SQLException sqle) { } catch (SQLException sqle) {
e = sqle; e = sqle;
throw sqle; throw e;
} finally { } finally {
this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, null, e); this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, null, e);
} }
} }
public void setURL(int parameterIndex, URL x) throws SQLException { public void setURL(int parameterIndex, URL x) throws SQLException {
SQLException e = null; SQLException e = null;
try { try {
this.sqlBuffer.setValue(21, parameterIndex, x); this.sqlBuffer.setValue(21, parameterIndex, x);
this.delegate.setURL(parameterIndex, x); this.delegate.setURL(parameterIndex, x);
} catch (SQLException sqle) { } catch (SQLException sqle) {
e = sqle; e = sqle;
throw sqle; throw e;
} finally { } finally {
this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, x, e); this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, x, e);
} }
} }
public void setRowId(int parameterIndex, RowId x) throws SQLException { public void setRowId(int parameterIndex, RowId x) throws SQLException {
SQLException e = null; SQLException e = null;
try { try {
this.sqlBuffer.setValue(17, parameterIndex, x); this.sqlBuffer.setValue(17, parameterIndex, x);
this.delegate.setRowId(parameterIndex, x); this.delegate.setRowId(parameterIndex, x);
} catch (SQLException sqle) { } catch (SQLException sqle) {
e = sqle; e = sqle;
throw sqle; throw e;
} finally { } finally {
this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, x, e); this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, x, e);
} }
} }
public void setNString(int parameterIndex, String value) throws SQLException { public void setNString(int parameterIndex, String value) throws SQLException {
SQLException e = null; SQLException e = null;
try { try {
this.sqlBuffer.setValue(9, parameterIndex, value); this.sqlBuffer.setValue(9, parameterIndex, value);
this.delegate.setNString(parameterIndex, value); this.delegate.setNString(parameterIndex, value);
} catch (SQLException sqle) { } catch (SQLException sqle) {
e = sqle; e = sqle;
throw sqle; throw e;
} finally { } finally {
this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, value, e); this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, value, e);
} }
} }
public void setNCharacterStream(int parameterIndex, Reader value, long length) throws SQLException { public void setNCharacterStream(int parameterIndex, Reader value, long length) throws SQLException {
SQLException e = null; SQLException e = null;
try { try {
this.sqlBuffer.setValue(15, parameterIndex, (Reader)value, length, "string"); this.sqlBuffer.setValue(15, parameterIndex, value, length, "string");
this.delegate.setNCharacterStream(parameterIndex, value, length); this.delegate.setNCharacterStream(parameterIndex, value, length);
} catch (SQLException sqle) { } catch (SQLException sqle) {
e = sqle; e = sqle;
throw sqle; throw e;
} finally { } finally {
this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, value, e); this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, value, e);
} }
} }
public void setNClob(int parameterIndex, NClob value) throws SQLException { public void setNClob(int parameterIndex, NClob value) throws SQLException {
SQLException e = null; SQLException e = null;
try { try {
this.sqlBuffer.setValue(22, parameterIndex, value); this.sqlBuffer.setValue(22, parameterIndex, value);
this.delegate.setNClob(parameterIndex, value); this.delegate.setNClob(parameterIndex, value);
} catch (SQLException sqle) { } catch (SQLException sqle) {
e = sqle; e = sqle;
throw sqle; throw e;
} finally { } finally {
this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, value, e); this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, value, e);
} }
} }
public void setClob(int parameterIndex, Reader reader, long length) throws SQLException { public void setClob(int parameterIndex, Reader reader, long length) throws SQLException {
SQLException e = null; SQLException e = null;
try { try {
this.sqlBuffer.setValue(19, parameterIndex, (Reader)reader, length, "string"); this.sqlBuffer.setValue(19, parameterIndex, reader, length, "string");
this.delegate.setClob(parameterIndex, reader, length); this.delegate.setClob(parameterIndex, reader, length);
} catch (SQLException sqle) { } catch (SQLException sqle) {
e = sqle; e = sqle;
throw sqle; throw e;
} finally { } finally {
this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, reader, e); this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, reader, e);
} }
} }
public void setBlob(int parameterIndex, InputStream inputStream, long length) throws SQLException { public void setBlob(int parameterIndex, InputStream inputStream, long length) throws SQLException {
SQLException e = null; SQLException e = null;
try { try {
this.sqlBuffer.setValue(14, parameterIndex, (InputStream)inputStream, length, "byte[]"); this.sqlBuffer.setValue(14, parameterIndex, inputStream, length, "byte[]");
this.delegate.setBlob(parameterIndex, inputStream, length); this.delegate.setBlob(parameterIndex, inputStream, length);
} catch (SQLException sqle) { } catch (SQLException sqle) {
e = sqle; e = sqle;
throw sqle; throw e;
} finally { } finally {
this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, inputStream, e); this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, inputStream, e);
} }
} }
public void setNClob(int parameterIndex, Reader reader, long length) throws SQLException { public void setNClob(int parameterIndex, Reader reader, long length) throws SQLException {
SQLException e = null; SQLException e = null;
try { try {
this.sqlBuffer.setValue(15, parameterIndex, (Reader)reader, length, "string"); this.sqlBuffer.setValue(15, parameterIndex, reader, length, "string");
this.delegate.setNClob(parameterIndex, reader, length); this.delegate.setNClob(parameterIndex, reader, length);
} catch (SQLException sqle) { } catch (SQLException sqle) {
e = sqle; e = sqle;
throw sqle; throw e;
} finally { } finally {
this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, reader, e); this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, reader, e);
} }
} }
public void setSQLXML(int parameterIndex, SQLXML xmlObject) throws SQLException { public void setSQLXML(int parameterIndex, SQLXML xmlObject) throws SQLException {
SQLException e = null; SQLException e = null;
try { try {
this.sqlBuffer.setValue(23, parameterIndex, xmlObject); this.sqlBuffer.setValue(23, parameterIndex, xmlObject);
this.delegate.setSQLXML(parameterIndex, xmlObject); this.delegate.setSQLXML(parameterIndex, xmlObject);
} catch (SQLException sqle) { } catch (SQLException sqle) {
e = sqle; e = sqle;
throw sqle; throw e;
} finally { } finally {
this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, xmlObject, e); this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, xmlObject, e);
} }
} }
public void setObject(int parameterIndex, Object x1, int targetSqlType, int scaleOrLength) throws SQLException { public void setObject(int parameterIndex, Object x1, int targetSqlType, int scaleOrLength) throws SQLException {
...@@ -1001,23 +874,26 @@ public class PreparedStatementWrapper extends StatementWrapper implements Prepar ...@@ -1001,23 +874,26 @@ public class PreparedStatementWrapper extends StatementWrapper implements Prepar
boolean where = false; boolean where = false;
String tableAndColumnName = null; String tableAndColumnName = null;
String mathKey = null; String mathKey = null;
try { try {
String sql = this.statementInformation.getSql(); String sql = this.statementInformation.getSql();
boolean needSqlParse = DbCache.isNeedSqlParse(sql, this.statementInformation); boolean needSqlParse = DbCache.isNeedSqlParse(sql, (StatementInformation)this.statementInformation);
if (needSqlParse) { if (!needSqlParse) {
Columninfo columninfo = (Columninfo)sqlIndexKeyMap.get(sql + "_" + parameterIndex); this.sqlBuffer.setValue(-1, parameterIndex, x1, x1, targetSqlType, scaleOrLength);
this.delegate.setObject(parameterIndex, x1, targetSqlType, scaleOrLength);
return;
}
Columninfo columninfo = sqlIndexKeyMap.get(sql + "_" + parameterIndex);
if (columninfo == null) { if (columninfo == null) {
if (x1 instanceof String) { if (x1 instanceof String) {
map = this.encData(this.statementInformation, parameterIndex, x1.toString()); map = encData(this.statementInformation, parameterIndex, x1.toString());
x = map.get("x"); x = map.get("x");
tableAndColumnName = (String)map.get("tableAndColumnName"); tableAndColumnName = map.get("tableAndColumnName");
mathKey = (String)map.get("mathKey"); mathKey = map.get("mathKey");
} else { } else {
x = x1; x = x1;
} }
} else if (columninfo.getSecretkey() != null) { } else if (columninfo.getSecretkey() != null) {
x = (String)EngineUtil.exeEngine(columninfo, (ConnectionInfo)null, false, x1, true); x = EngineUtil.exeEngine(columninfo, null, Boolean.valueOf(false), x1, Boolean.valueOf(true));
tableAndColumnName = columninfo.getColumnname(); tableAndColumnName = columninfo.getColumnname();
mathKey = columninfo.getId(); mathKey = columninfo.getId();
} else { } else {
...@@ -1025,199 +901,164 @@ public class PreparedStatementWrapper extends StatementWrapper implements Prepar ...@@ -1025,199 +901,164 @@ public class PreparedStatementWrapper extends StatementWrapper implements Prepar
tableAndColumnName = columninfo.getColumnname(); tableAndColumnName = columninfo.getColumnname();
mathKey = columninfo.getId(); mathKey = columninfo.getId();
} }
this.sqlBuffer.setValue(-1, parameterIndex, x, x1, targetSqlType, scaleOrLength); this.sqlBuffer.setValue(-1, parameterIndex, x, x1, targetSqlType, scaleOrLength);
this.delegate.setObject(parameterIndex, x, targetSqlType, scaleOrLength); this.delegate.setObject(parameterIndex, x, targetSqlType, scaleOrLength);
if (EngineUtil.digestMap.isEmpty()) { if (EngineUtil.digestMap.isEmpty())
return; return;
}
int whereLocation = 100000000; int whereLocation = 100000000;
digestMap = this.statementInformation.getDigestMap(); digestMap = this.statementInformation.getDigestMap();
if (!digestMap.isEmpty()) { if (!digestMap.isEmpty()) {
for(String key : digestMap.keySet()) { for (String key : digestMap.keySet()) {
Integer value = (Integer)digestMap.get(key); Integer value = digestMap.get(key);
if (value < whereLocation) { if (value.intValue() < whereLocation)
whereLocation = value; whereLocation = value.intValue();
} }
} if (parameterIndex >= whereLocation)
if (parameterIndex >= whereLocation) {
where = true; where = true;
} }
}
if (!digestMap.isEmpty() && !where && tableAndColumnName != null && digestMap.get(tableAndColumnName) != null) { if (!digestMap.isEmpty() && !where && tableAndColumnName != null && digestMap.get(tableAndColumnName) != null) {
String digestValue = this.abstractData(mathKey, x.toString()); String digestValue = abstractData(mathKey, x.toString());
this.sqlBuffer.setValue(-1, (Integer)digestMap.get(tableAndColumnName), (Object)digestValue, null); this.sqlBuffer.setValue(-1, ((Integer)digestMap.get(tableAndColumnName)).intValue(), digestValue, null);
this.delegate.setString((Integer)digestMap.get(tableAndColumnName), digestValue); this.delegate.setString(((Integer)digestMap.get(tableAndColumnName)).intValue(), digestValue);
}
return;
} }
this.sqlBuffer.setValue(-1, parameterIndex, x1, x1, targetSqlType, scaleOrLength);
this.delegate.setObject(parameterIndex, x1, targetSqlType, scaleOrLength);
} catch (SQLException sqle) { } catch (SQLException sqle) {
e = sqle; e = sqle;
throw sqle; throw e;
} catch (Exception ex) { } catch (Exception ex) {
ex.printStackTrace(); ex.printStackTrace();
return;
} finally { } finally {
this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, x, e); this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, x, e);
} }
} }
public void setAsciiStream(int parameterIndex, InputStream x, long length) throws SQLException { public void setAsciiStream(int parameterIndex, InputStream x, long length) throws SQLException {
SQLException e = null; SQLException e = null;
try { try {
this.sqlBuffer.setValue(14, parameterIndex, (InputStream)x, length, "byte[ascii]"); this.sqlBuffer.setValue(14, parameterIndex, x, length, "byte[ascii]");
this.delegate.setAsciiStream(parameterIndex, x, length); this.delegate.setAsciiStream(parameterIndex, x, length);
} catch (SQLException sqle) { } catch (SQLException sqle) {
e = sqle; e = sqle;
throw sqle; throw e;
} finally { } finally {
this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, x, e); this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, x, e);
} }
} }
public void setBinaryStream(int parameterIndex, InputStream x, long length) throws SQLException { public void setBinaryStream(int parameterIndex, InputStream x, long length) throws SQLException {
SQLException e = null; SQLException e = null;
try { try {
this.sqlBuffer.setValue(14, parameterIndex, (InputStream)x, length, "byte[]"); this.sqlBuffer.setValue(14, parameterIndex, x, length, "byte[]");
this.delegate.setBinaryStream(parameterIndex, x, length); this.delegate.setBinaryStream(parameterIndex, x, length);
} catch (SQLException sqle) { } catch (SQLException sqle) {
e = sqle; e = sqle;
throw sqle; throw e;
} finally { } finally {
this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, x, e); this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, x, e);
} }
} }
public void setCharacterStream(int parameterIndex, Reader reader, long length) throws SQLException { public void setCharacterStream(int parameterIndex, Reader reader, long length) throws SQLException {
SQLException e = null; SQLException e = null;
try { try {
this.sqlBuffer.setValue(15, parameterIndex, (Reader)reader, length, "byte[string]"); this.sqlBuffer.setValue(15, parameterIndex, reader, length, "byte[string]");
this.delegate.setCharacterStream(parameterIndex, reader, length); this.delegate.setCharacterStream(parameterIndex, reader, length);
} catch (SQLException sqle) { } catch (SQLException sqle) {
e = sqle; e = sqle;
throw sqle; throw e;
} finally { } finally {
this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, reader, e); this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, reader, e);
} }
} }
public void setAsciiStream(int parameterIndex, InputStream x) throws SQLException { public void setAsciiStream(int parameterIndex, InputStream x) throws SQLException {
SQLException e = null; SQLException e = null;
try { try {
this.sqlBuffer.setValue(14, parameterIndex, (InputStream)x, (String)"byte[ascii]"); this.sqlBuffer.setValue(14, parameterIndex, x, "byte[ascii]");
this.delegate.setAsciiStream(parameterIndex, x); this.delegate.setAsciiStream(parameterIndex, x);
} catch (SQLException sqle) { } catch (SQLException sqle) {
e = sqle; e = sqle;
throw sqle; throw e;
} finally { } finally {
this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, x, e); this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, x, e);
} }
} }
public void setBinaryStream(int parameterIndex, InputStream x) throws SQLException { public void setBinaryStream(int parameterIndex, InputStream x) throws SQLException {
SQLException e = null; SQLException e = null;
try { try {
this.sqlBuffer.setValue(14, parameterIndex, (InputStream)x, (String)"byte[]"); this.sqlBuffer.setValue(14, parameterIndex, x, "byte[]");
this.delegate.setBinaryStream(parameterIndex, x); this.delegate.setBinaryStream(parameterIndex, x);
} catch (SQLException sqle) { } catch (SQLException sqle) {
e = sqle; e = sqle;
throw sqle; throw e;
} finally { } finally {
this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, x, e); this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, x, e);
} }
} }
public void setCharacterStream(int parameterIndex, Reader reader) throws SQLException { public void setCharacterStream(int parameterIndex, Reader reader) throws SQLException {
SQLException e = null; SQLException e = null;
try { try {
this.sqlBuffer.setValue(15, parameterIndex, (Reader)reader, (String)"byte[string]"); this.sqlBuffer.setValue(15, parameterIndex, reader, "byte[string]");
this.delegate.setCharacterStream(parameterIndex, reader); this.delegate.setCharacterStream(parameterIndex, reader);
} catch (SQLException sqle) { } catch (SQLException sqle) {
e = sqle; e = sqle;
throw sqle; throw e;
} finally { } finally {
this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, reader, e); this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, reader, e);
} }
} }
public void setNCharacterStream(int parameterIndex, Reader value) throws SQLException { public void setNCharacterStream(int parameterIndex, Reader value) throws SQLException {
SQLException e = null; SQLException e = null;
try { try {
this.sqlBuffer.setValue(15, parameterIndex, (Reader)value, (String)"byte[string]"); this.sqlBuffer.setValue(15, parameterIndex, value, "byte[string]");
this.delegate.setNCharacterStream(parameterIndex, value); this.delegate.setNCharacterStream(parameterIndex, value);
} catch (SQLException sqle) { } catch (SQLException sqle) {
e = sqle; e = sqle;
throw sqle; throw e;
} finally { } finally {
this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, value, e); this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, value, e);
} }
} }
public void setClob(int parameterIndex, Reader reader) throws SQLException { public void setClob(int parameterIndex, Reader reader) throws SQLException {
SQLException e = null; SQLException e = null;
try { try {
this.sqlBuffer.setValue(15, parameterIndex, (Reader)reader, (String)"byte[string]"); this.sqlBuffer.setValue(15, parameterIndex, reader, "byte[string]");
this.delegate.setClob(parameterIndex, reader); this.delegate.setClob(parameterIndex, reader);
} catch (SQLException sqle) { } catch (SQLException sqle) {
e = sqle; e = sqle;
throw sqle; throw e;
} finally { } finally {
this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, reader, e); this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, reader, e);
} }
} }
public void setBlob(int parameterIndex, InputStream inputStream) throws SQLException { public void setBlob(int parameterIndex, InputStream inputStream) throws SQLException {
SQLException e = null; SQLException e = null;
try { try {
this.sqlBuffer.setValue(14, parameterIndex, (InputStream)inputStream, (String)"byte[]"); this.sqlBuffer.setValue(14, parameterIndex, inputStream, "byte[]");
this.delegate.setBlob(parameterIndex, inputStream); this.delegate.setBlob(parameterIndex, inputStream);
} catch (SQLException sqle) { } catch (SQLException sqle) {
e = sqle; e = sqle;
throw sqle; throw e;
} finally { } finally {
this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, inputStream, e); this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, inputStream, e);
} }
} }
public void setNClob(int parameterIndex, Reader reader) throws SQLException { public void setNClob(int parameterIndex, Reader reader) throws SQLException {
SQLException e = null; SQLException e = null;
try { try {
this.sqlBuffer.setValue(15, parameterIndex, (Reader)reader, (String)"byte[string]"); this.sqlBuffer.setValue(15, parameterIndex, reader, "byte[string]");
this.delegate.setNClob(parameterIndex, reader); this.delegate.setNClob(parameterIndex, reader);
} catch (SQLException sqle) { } catch (SQLException sqle) {
e = sqle; e = sqle;
throw sqle; throw e;
} finally { } finally {
this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, reader, e); this.eventListener.onAfterPreparedStatementSet(this.statementInformation, parameterIndex, reader, e);
} }
} }
public ParameterMetaData getParameterMetaData() throws SQLException { public ParameterMetaData getParameterMetaData() throws SQLException {
...@@ -1229,18 +1070,17 @@ public class PreparedStatementWrapper extends StatementWrapper implements Prepar ...@@ -1229,18 +1070,17 @@ public class PreparedStatementWrapper extends StatementWrapper implements Prepar
} }
public Map<String, String> encData(PreparedStatementInformation statementInformation, int parameterIndex, String x) throws Exception { public Map<String, String> encData(PreparedStatementInformation statementInformation, int parameterIndex, String x) throws Exception {
Map<String, String> encDataMap = new HashMap(); Map<String, String> encDataMap = new HashMap<String, String>();
encDataMap.put("x", x); encDataMap.put("x", x);
if (!GatewayContext.isPluginEnabled()) { if (!GatewayContext.isPluginEnabled())
return encDataMap; return encDataMap;
} else {
String dbType = ""; String dbType = "";
String urlDbType = statementInformation.getConnectionInformation().getUrl(); String urlDbType = statementInformation.getConnectionInformation().getUrl();
String driverName = statementInformation.getConnectionInformation().getConnection().getMetaData().getDriverName(); String driverName = statementInformation.getConnectionInformation().getConnection().getMetaData().getDriverName();
dbType = ConnectionWrapper.getDbType(driverName, urlDbType, dbType); dbType = ConnectionWrapper.getDbType(driverName, urlDbType, dbType);
List<Object> insertValueList = new ArrayList(); List<Object> insertValueList = new ArrayList();
try { try {
String sqlAll;
Connection connection = statementInformation.getConnectionInformation().getConnection(); Connection connection = statementInformation.getConnectionInformation().getConnection();
String urlTemp = connection.getMetaData().getURL(); String urlTemp = connection.getMetaData().getURL();
String ip = (String)TestJdbcEventListener.getIpAndPort(urlTemp).get("ip"); String ip = (String)TestJdbcEventListener.getIpAndPort(urlTemp).get("ip");
...@@ -1249,14 +1089,23 @@ public class PreparedStatementWrapper extends StatementWrapper implements Prepar ...@@ -1249,14 +1089,23 @@ public class PreparedStatementWrapper extends StatementWrapper implements Prepar
String tableName = ""; String tableName = "";
if ("oracle".equals(dbType)) { if ("oracle".equals(dbType)) {
schema = connection.getMetaData().getUserName(); schema = connection.getMetaData().getUserName();
} else if (!"postgresql".equals(dbType) && !"greenplum".equals(dbType) && !"gauss".equals(dbType) && !"gaussdb".equalsIgnoreCase(dbType)) { } else if ("postgresql".equals(dbType) || "greenplum".equals(dbType) || "gauss".equals(dbType) || "gaussdb".equalsIgnoreCase(dbType)) {
if ("sql server".equals(dbType)) { String url = connection.getMetaData().getURL();
if (url.indexOf("searchpath") > 0) {
schema = url.substring(url.indexOf("searchpath") + 11);
} else if (url.indexOf("currentSchema") > 0) {
schema = url.substring(url.indexOf("currentSchema") + 14);
} else if (url.toLowerCase().indexOf("schema=") > 0) {
schema = url.substring(url.indexOf("schema=") + 7);
} else {
schema = "public";
}
} else if ("sql server".equals(dbType)) {
String url = connection.getMetaData().getURL(); String url = connection.getMetaData().getURL();
if (url.indexOf("applicationName") > 0) { if (url.indexOf("applicationName") > 0) {
schema = url.substring(url.indexOf("applicationName") + "applicationName".length() + 1); schema = url.substring(url.indexOf("applicationName") + "applicationName".length() + 1);
if (schema.indexOf(";") != -1) { if (schema.indexOf(";") != -1)
schema = schema.substring(0, schema.indexOf(";")); schema = schema.substring(0, schema.indexOf(";"));
}
} else { } else {
schema = "dbo"; schema = "dbo";
} }
...@@ -1267,7 +1116,7 @@ public class PreparedStatementWrapper extends StatementWrapper implements Prepar ...@@ -1267,7 +1116,7 @@ public class PreparedStatementWrapper extends StatementWrapper implements Prepar
} else { } else {
int from = url.indexOf("://"); int from = url.indexOf("://");
int end = url.indexOf("?"); int end = url.indexOf("?");
String address = end == -1 ? url.substring(from + 3) : url.substring(from + 3, end); String address = (end == -1) ? url.substring(from + 3) : url.substring(from + 3, end);
int idx = address.lastIndexOf("/"); int idx = address.lastIndexOf("/");
schema = address.substring(idx + 1); schema = address.substring(idx + 1);
} }
...@@ -1279,7 +1128,6 @@ public class PreparedStatementWrapper extends StatementWrapper implements Prepar ...@@ -1279,7 +1128,6 @@ public class PreparedStatementWrapper extends StatementWrapper implements Prepar
} else { } else {
schema = connection.getMetaData().getUserName(); schema = connection.getMetaData().getUserName();
} }
rs.close(); rs.close();
stmt.close(); stmt.close();
} else if ("kingbase".equals(dbType)) { } else if ("kingbase".equals(dbType)) {
...@@ -1295,102 +1143,74 @@ public class PreparedStatementWrapper extends StatementWrapper implements Prepar ...@@ -1295,102 +1143,74 @@ public class PreparedStatementWrapper extends StatementWrapper implements Prepar
String url = connection.getMetaData().getURL(); String url = connection.getMetaData().getURL();
int from = url.indexOf("://"); int from = url.indexOf("://");
int end = url.indexOf("?"); int end = url.indexOf("?");
String address = end == -1 ? url.substring(from + 3) : url.substring(from + 3, end); String address = (end == -1) ? url.substring(from + 3) : url.substring(from + 3, end);
int idx = address.lastIndexOf("/"); int idx = address.lastIndexOf("/");
schema = address.substring(idx + 1); schema = address.substring(idx + 1);
} else if ("mariadb".equals(dbType)) { } else if ("mariadb".equals(dbType)) {
String url = connection.getMetaData().getURL(); String url = connection.getMetaData().getURL();
int from = url.indexOf("://"); int from = url.indexOf("://");
int end = url.indexOf("?"); int end = url.indexOf("?");
String address = end == -1 ? url.substring(from + 3) : url.substring(from + 3, end); String address = (end == -1) ? url.substring(from + 3) : url.substring(from + 3, end);
int idx = address.lastIndexOf("/"); int idx = address.lastIndexOf("/");
schema = address.substring(idx + 1); schema = address.substring(idx + 1);
} else if ("hive".equals(dbType)) { } else if ("hive".equals(dbType)) {
String url = connection.getMetaData().getURL(); String url = connection.getMetaData().getURL();
int from = url.indexOf("://"); int from = url.indexOf("://");
int end = url.indexOf("?"); int end = url.indexOf("?");
String address = end == -1 ? url.substring(from + 3) : url.substring(from + 3, end); String address = (end == -1) ? url.substring(from + 3) : url.substring(from + 3, end);
int idx = address.lastIndexOf("/"); int idx = address.lastIndexOf("/");
schema = address.substring(idx + 1); schema = address.substring(idx + 1);
if (schema.indexOf(";") > 0) { if (schema.indexOf(";") > 0)
schema = schema.substring(0, schema.indexOf(";")); schema = schema.substring(0, schema.indexOf(";"));
}
} else { } else {
schema = connection.getCatalog(); schema = connection.getCatalog();
} }
} else {
String url = connection.getMetaData().getURL();
if (url.indexOf("searchpath") > 0) {
schema = url.substring(url.indexOf("searchpath") + 11);
} else if (url.indexOf("currentSchema") > 0) {
schema = url.substring(url.indexOf("currentSchema") + 14);
} else if (url.toLowerCase().indexOf("schema=") > 0) {
schema = url.substring(url.indexOf("schema=") + 7);
} else {
schema = "public";
}
}
String sql1 = statementInformation.getSql(); String sql1 = statementInformation.getSql();
String sqlAll;
if (sql1.indexOf("-- appUsername=") > 0) { if (sql1.indexOf("-- appUsername=") > 0) {
sqlAll = sql1.substring(0, sql1.indexOf("-- appUsername=")).trim(); sqlAll = sql1.substring(0, sql1.indexOf("-- appUsername=")).trim();
} else { } else {
sqlAll = sql1; sqlAll = sql1;
} }
int indexColumnAll = 0; int indexColumnAll = 0;
int lastIndexColumn = 0; int lastIndexColumn = 0;
String[] split = sqlAll.split(";\r\n"); String[] split = sqlAll.split(";\r\n");
for (int i = 0; i < split.length; i++) {
for(int i = 0; i < split.length; ++i) {
String sql = split[i]; String sql = split[i];
SQLType sqlType = SQLParserUtils.getSQLType(sql, DbType.of(dbType)); SQLType sqlType = SQLParserUtils.getSQLType(sql, DbType.of(dbType));
int sqlParamNum = sql.concat("t").split("\\?").length - 1; int sqlParamNum = (sql.concat("t").split("\\?")).length - 1;
indexColumnAll += sqlParamNum; indexColumnAll += sqlParamNum;
lastIndexColumn = indexColumnAll - sqlParamNum; lastIndexColumn = indexColumnAll - sqlParamNum;
if (parameterIndex > lastIndexColumn && parameterIndex <= indexColumnAll) { if (parameterIndex > lastIndexColumn && parameterIndex <= indexColumnAll) {
new ArrayList(); ArrayList<Column> columnList = new ArrayList<Column>();
new ArrayList(); List<Map<String, Object>> whereList = new ArrayList<Map<String, Object>>();
List<Map<String, Object>> stringObjectMapList = (List)ConnectionWrapper.sqlParseMap.get(sqlAll); List<Map<String, Object>> stringObjectMapList = ConnectionWrapper.sqlParseMap.get(sqlAll);
if (stringObjectMapList == null || stringObjectMapList.isEmpty()) { if (stringObjectMapList == null || stringObjectMapList.isEmpty())
stringObjectMapList = statementInformation.sqlParse; stringObjectMapList = statementInformation.sqlParse;
} if (stringObjectMapList == null || stringObjectMapList.isEmpty())
stringObjectMapList = getColumns(statementInformation, sql, dbType, schema);
if (stringObjectMapList == null || stringObjectMapList.isEmpty()) { Map<String, Object> stringObjectMap = stringObjectMapList.get(0);
stringObjectMapList = this.getColumns(statementInformation, sql, dbType, schema); columnList = (ArrayList<Column>)stringObjectMap.get("columnList");
} if (columnList == null || columnList.isEmpty())
RuleLoadUtil.writeLog("@@");
Map<String, Object> stringObjectMap = (Map)stringObjectMapList.get(0); whereList = (List<Map<String, Object>>)stringObjectMap.get("whereList");
ArrayList<Column> columnList = (ArrayList)stringObjectMap.get("columnList"); if (whereList == null || whereList.isEmpty())
if (columnList == null || columnList.isEmpty()) { RuleLoadUtil.writeLog("@@");
RuleLoadUtil.writeLog("@@插件@@---PreparedstatementWrapper解析columnList为空-->");
}
List<Map<String, Object>> whereList = (List)stringObjectMap.get("whereList");
if (whereList == null || whereList.isEmpty()) {
RuleLoadUtil.writeLog("@@插件@@---PreparedstatementWrapper解析whereList为空-->");
}
Object value = null; Object value = null;
Boolean encFlag = false; Boolean encFlag = Boolean.valueOf(false);
parameterIndex -= lastIndexColumn; parameterIndex -= lastIndexColumn;
encDataMap = this.encryption(sql1, insertValueList, sqlType, ip, port, schema, tableName, columnList, value, encFlag, whereList, parameterIndex, x, statementInformation.getReplaceInfo()); encDataMap = encryption(sql1, insertValueList, sqlType, ip, port, schema, tableName, columnList, value, encFlag, whereList, parameterIndex, x, statementInformation.getReplaceInfo());
break; break;
} }
} }
return encDataMap;
} catch (Exception e1) { } catch (Exception e1) {
e1.printStackTrace(); e1.printStackTrace();
throw e1; throw e1;
} }
} return encDataMap;
} }
public String abstractData(String mathKey, String x) throws Exception { public String abstractData(String mathKey, String x) throws Exception {
String hashStr = ""; String hashStr = "";
try { try {
boolean isDigest = EngineUtil.digestMapBak.containsKey(mathKey); boolean isDigest = EngineUtil.digestMapBak.containsKey(mathKey);
if (isDigest) { if (isDigest) {
...@@ -1399,42 +1219,40 @@ public class PreparedStatementWrapper extends StatementWrapper implements Prepar ...@@ -1399,42 +1219,40 @@ public class PreparedStatementWrapper extends StatementWrapper implements Prepar
} else { } else {
hashStr = x; hashStr = x;
} }
return hashStr;
} catch (Exception e1) { } catch (Exception e1) {
e1.printStackTrace(); e1.printStackTrace();
throw e1; throw e1;
} }
return hashStr;
} }
private ArrayList<Column> sortColumns(ArrayList<Column> columnList, Collection<TableStat.Column> insertFields) { private ArrayList<Column> sortColumns(ArrayList<Column> columnList, Collection<TableStat.Column> insertFields) {
ArrayList<Column> sortColumnList = new ArrayList(); ArrayList<Column> sortColumnList = new ArrayList<Column>();
if (!(insertFields instanceof ArrayList)) { if (insertFields instanceof ArrayList) {
return columnList;
} else {
List<TableStat.Column> insertList = (ArrayList)insertFields; List<TableStat.Column> insertList = (ArrayList)insertFields;
for (int i = 0; i < insertList.size(); i++) {
for(int i = 0; i < insertList.size(); ++i) { for (Column column : columnList) {
for(Column column : columnList) {
if (column.getColumnName().equalsIgnoreCase(((TableStat.Column)insertList.get(i)).getName())) { if (column.getColumnName().equalsIgnoreCase(((TableStat.Column)insertList.get(i)).getName())) {
sortColumnList.add(column); sortColumnList.add(column);
break; break;
} }
} }
} }
return sortColumnList; return sortColumnList;
} }
return columnList;
} }
private void getUpdateSetFields(PreparedStatementInformation statementInformation, String dbType, String schema, String tableName, ArrayList<Column> updateList) throws SQLException { private void getUpdateSetFields(PreparedStatementInformation statementInformation, String dbType, String schema, String tableName, ArrayList<Column> updateList) throws SQLException {
List<Column> columnList = null; List<Column> columnList = null;
new ArrayList(); List<TableStat.Column> columnL = new ArrayList<TableStat.Column>();
if (!"mysql".equals(dbType) && !"mariadb".equals(dbType)) { if ("mysql".equals(dbType) || "mariadb".equals(dbType)) {
if ("oracle".equals(dbType)) { columnList = JdbcUtil.getColumnOfMysql(statementInformation.getConnectionInformation().getConnection().createStatement(), schema, tableName);
} else if ("oracle".equals(dbType)) {
columnList = JdbcUtil.getColumnOfOracle(statementInformation.getConnectionInformation().getConnection().createStatement(), schema, tableName); columnList = JdbcUtil.getColumnOfOracle(statementInformation.getConnectionInformation().getConnection().createStatement(), schema, tableName);
} else if (!"postgresql".equals(dbType) && !"greenplum".equals(dbType) && !"gauss".equals(dbType)) { } else if ("postgresql".equals(dbType) || "greenplum".equals(dbType) || "gauss".equals(dbType)) {
if ("hive".equals(dbType)) { columnList = JdbcUtil.getColumnOfPostgresql(statementInformation.getConnectionInformation().getConnection().createStatement(), schema, tableName);
} else if ("hive".equals(dbType)) {
columnList = JdbcUtil.getColumnOfHive(statementInformation.getConnectionInformation().getConnection().createStatement(), schema, tableName); columnList = JdbcUtil.getColumnOfHive(statementInformation.getConnectionInformation().getConnection().createStatement(), schema, tableName);
} else if ("dm".equals(dbType)) { } else if ("dm".equals(dbType)) {
columnList = JdbcUtil.getColumnOfDm(statementInformation.getConnectionInformation().getConnection().createStatement(), schema, tableName); columnList = JdbcUtil.getColumnOfDm(statementInformation.getConnectionInformation().getConnection().createStatement(), schema, tableName);
...@@ -1445,25 +1263,17 @@ public class PreparedStatementWrapper extends StatementWrapper implements Prepar ...@@ -1445,25 +1263,17 @@ public class PreparedStatementWrapper extends StatementWrapper implements Prepar
} else if ("kingbase".equals(dbType)) { } else if ("kingbase".equals(dbType)) {
columnList = JdbcUtil.getColumnOfKingbase(statementInformation.getConnectionInformation().getConnection().createStatement(), schema, tableName); columnList = JdbcUtil.getColumnOfKingbase(statementInformation.getConnectionInformation().getConnection().createStatement(), schema, tableName);
} else if ("gbase".equals(dbType)) { } else if ("gbase".equals(dbType)) {
}
} else {
columnList = JdbcUtil.getColumnOfPostgresql(statementInformation.getConnectionInformation().getConnection().createStatement(), schema, tableName);
}
} else {
columnList = JdbcUtil.getColumnOfMysql(statementInformation.getConnectionInformation().getConnection().createStatement(), schema, tableName);
}
}
ArrayList<Column> finalUpdateList = updateList; ArrayList<Column> finalUpdateList = updateList;
for (Column col : columnList) {
for(Column col : columnList) {
Column tm = new Column(col.getColumnName(), col.getSchema(), col.getTable(), col.getDataType()); Column tm = new Column(col.getColumnName(), col.getSchema(), col.getTable(), col.getDataType());
finalUpdateList.add(tm); finalUpdateList.add(tm);
} }
} }
private List<Map<String, Object>> getColumns(PreparedStatementInformation statementInformation, String sql, String dbType, String schema) throws SQLException { private List<Map<String, Object>> getColumns(PreparedStatementInformation statementInformation, String sql, String dbType, String schema) throws SQLException {
Map<String, String> params = new HashMap(); Map<String, String> params = new HashMap<String, String>();
params.put("sql", sql); params.put("sql", sql);
params.put("dbType", dbType); params.put("dbType", dbType);
params.put("schema", schema); params.put("schema", schema);
...@@ -1473,7 +1283,7 @@ public class PreparedStatementWrapper extends StatementWrapper implements Prepar ...@@ -1473,7 +1283,7 @@ public class PreparedStatementWrapper extends StatementWrapper implements Prepar
SqlUtil sqlUtil = new SqlUtil(); SqlUtil sqlUtil = new SqlUtil();
List<Map<String, Object>> maps = sqlUtil.parseSqlStructureEnc(params); List<Map<String, Object>> maps = sqlUtil.parseSqlStructureEnc(params);
if (maps != null && !maps.isEmpty()) { if (maps != null && !maps.isEmpty()) {
Map<String, Object> stringObjectMap = (Map)maps.get(0); Map<String, Object> stringObjectMap = maps.get(0);
if (!stringObjectMap.isEmpty()) { if (!stringObjectMap.isEmpty()) {
String trim = sql.toLowerCase().trim(); String trim = sql.toLowerCase().trim();
if ((trim.startsWith("insert") || trim.startsWith("update")) && trim.contains("?")) { if ((trim.startsWith("insert") || trim.startsWith("update")) && trim.contains("?")) {
...@@ -1481,20 +1291,17 @@ public class PreparedStatementWrapper extends StatementWrapper implements Prepar ...@@ -1481,20 +1291,17 @@ public class PreparedStatementWrapper extends StatementWrapper implements Prepar
} else if (trim.startsWith("select")) { } else if (trim.startsWith("select")) {
ConnectionWrapper.sqlParseMap.put(sql, maps); ConnectionWrapper.sqlParseMap.put(sql, maps);
} }
statementInformation.sqlParse = maps; statementInformation.sqlParse = maps;
} }
} }
return maps; return maps;
} }
private String getDbType(PreparedStatementInformation statementInformation, String dbType) throws Exception { private String getDbType(PreparedStatementInformation statementInformation, String dbType) throws Exception {
try { try {
String hiveurl = statementInformation.getConnectionInformation().getUrl(); String hiveurl = statementInformation.getConnectionInformation().getUrl();
if (hiveurl.toLowerCase().contains("hive")) { if (hiveurl.toLowerCase().contains("hive"))
return "hive"; return "hive";
} else {
String driverName = statementInformation.getConnectionInformation().getConnection().getMetaData().getDriverName(); String driverName = statementInformation.getConnectionInformation().getConnection().getMetaData().getDriverName();
if (driverName.toLowerCase().contains("mysql")) { if (driverName.toLowerCase().contains("mysql")) {
dbType = "mysql"; dbType = "mysql";
...@@ -1506,12 +1313,10 @@ public class PreparedStatementWrapper extends StatementWrapper implements Prepar ...@@ -1506,12 +1313,10 @@ public class PreparedStatementWrapper extends StatementWrapper implements Prepar
dbType = "gauss"; dbType = "gauss";
return dbType; return dbType;
} }
if (url.contains("greenplum")) { if (url.contains("greenplum")) {
dbType = "greenplum"; dbType = "greenplum";
return dbType; return dbType;
} }
dbType = "postgresql"; dbType = "postgresql";
} else if (driverName.toLowerCase().contains("hive")) { } else if (driverName.toLowerCase().contains("hive")) {
dbType = "hive"; dbType = "hive";
...@@ -1524,106 +1329,90 @@ public class PreparedStatementWrapper extends StatementWrapper implements Prepar ...@@ -1524,106 +1329,90 @@ public class PreparedStatementWrapper extends StatementWrapper implements Prepar
} else if (driverName.toLowerCase().contains("kingbase")) { } else if (driverName.toLowerCase().contains("kingbase")) {
dbType = "kingbase"; dbType = "kingbase";
} }
return dbType;
}
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
throw e; throw e;
} }
return dbType;
} }
public Boolean find(String empNumber, Collection<TableStat.Column> list) { public Boolean find(String empNumber, Collection<TableStat.Column> list) {
for(TableStat.Column column : list) { Iterator<TableStat.Column> iterator = list.iterator();
if (column.getName().equalsIgnoreCase(empNumber)) { while (iterator.hasNext()) {
return true; TableStat.Column column = iterator.next();
} if (column.getName().equalsIgnoreCase(empNumber))
return Boolean.valueOf(true);
} }
return Boolean.valueOf(false);
return false;
} }
private List<Object> getInsertSqlValueList(String sql, List<Object> valueList) { private List<Object> getInsertSqlValueList(String sql, List<Object> valueList) {
if (sql.indexOf("-- appUsername=") > 0) { if (sql.indexOf("-- appUsername=") > 0)
sql = sql.substring(0, sql.indexOf("-- appUsername=")).trim(); sql = sql.substring(0, sql.indexOf("-- appUsername=")).trim();
}
String lowerSql = sql.toLowerCase(); String lowerSql = sql.toLowerCase();
String[] split = lowerSql.split(";\r\n"); String[] split = lowerSql.split(";\r\n");
for (String s : split) {
for(String s : split) {
if (s.contains("values")) { if (s.contains("values")) {
String tempsql = s.substring(s.indexOf("values") + 6); String tempsql = s.substring(s.indexOf("values") + 6);
tempsql = tempsql.replaceFirst("\\(", ""); tempsql = tempsql.replaceFirst("\\(", "");
tempsql = tempsql.replaceFirst("[\\\\)]+$", ""); tempsql = tempsql.replaceFirst("[\\\\)]+$", "");
if (tempsql.trim().endsWith(";")) { if (tempsql.trim().endsWith(";"))
tempsql = tempsql.trim().substring(0, tempsql.trim().length() - 1); tempsql = tempsql.trim().substring(0, tempsql.trim().length() - 1);
} valueList.addAll(InsertSqlVaulesUtil.getTableColumnValueByMatchingSingleQuotes((Object[])tempsql.split(",")));
valueList.addAll(InsertSqlVaulesUtil.getTableColumnValueByMatchingSingleQuotes(tempsql.split(",")));
} else if (s.contains("value")) { } else if (s.contains("value")) {
String tempsql = s.substring(s.indexOf("value") + 5); String tempsql = s.substring(s.indexOf("value") + 5);
tempsql = tempsql.replaceFirst("\\(", ""); tempsql = tempsql.replaceFirst("\\(", "");
tempsql = tempsql.replaceFirst("[\\\\)]+$", ""); tempsql = tempsql.replaceFirst("[\\\\)]+$", "");
if (tempsql.trim().endsWith(";")) { if (tempsql.trim().endsWith(";"))
tempsql = tempsql.trim().substring(0, tempsql.trim().length() - 1); tempsql = tempsql.trim().substring(0, tempsql.trim().length() - 1);
} valueList = InsertSqlVaulesUtil.getTableColumnValueByMatchingSingleQuotes((Object[])tempsql.split(","));
valueList = InsertSqlVaulesUtil.getTableColumnValueByMatchingSingleQuotes(tempsql.split(","));
} }
} }
return valueList; return valueList;
} }
private Map<String, String> encryption(String sql, List<Object> insertValueList, SQLType sqlType, String ip, String port, String schema, String tableName, ArrayList<Column> columnList, Object value, Boolean encFlag, List<Map<String, Object>> whereList, int parameterIndex, String x, ReplaceInfo replaceInfo) throws SQLException { private Map<String, String> encryption(String sql, List<Object> insertValueList, SQLType sqlType, String ip, String port, String schema, String tableName, ArrayList<Column> columnList, Object value, Boolean encFlag, List<Map<String, Object>> whereList, int parameterIndex, String x, ReplaceInfo replaceInfo) throws SQLException {
Map hashMap = new HashMap(); Map<String, Object> whereMap;
Map<Object, Object> hashMap = new HashMap<Object, Object>();
boolean ismaksing = false; boolean ismaksing = false;
HashMap<Integer, Integer> ids = new HashMap(); HashMap<Integer, Integer> ids = new HashMap<Integer, Integer>();
int m = 1; int m = 1;
Column column = null; Column column = null;
if (sqlType == SQLType.INSERT) { if (sqlType == SQLType.INSERT);
} if (sqlType == SQLType.UPDATE)
for (int k = 0; k < columnList.size(); k++) {
if (sqlType == SQLType.UPDATE) {
for(int k = 0; k < columnList.size(); ++k) {
String v = ((Column)columnList.get(k)).getValue(); String v = ((Column)columnList.get(k)).getValue();
if (v != null && String.valueOf(((Column)columnList.get(k)).getValue()).trim().equals("?")) { if (v != null)
ids.put(m, k); if (String.valueOf(((Column)columnList.get(k)).getValue()).trim().equals("?")) {
++m; ids.put(Integer.valueOf(m), Integer.valueOf(k));
m++;
} }
} }
if (null != ids && ids.containsKey(Integer.valueOf(parameterIndex))) {
if (sqlType == SQLType.INSERT)
parameterIndex = (parameterIndex % ids.size() == 0) ? ids.size() : (parameterIndex % ids.size());
column = columnList.get(((Integer)ids.get(Integer.valueOf(parameterIndex))).intValue() % columnList.size());
} }
if (null != ids && ids.containsKey(parameterIndex)) {
if (sqlType == SQLType.INSERT) {
parameterIndex = parameterIndex % ids.size() == 0 ? ids.size() : parameterIndex % ids.size();
}
column = (Column)columnList.get((Integer)ids.get(parameterIndex) % columnList.size());
}
if (null != column) { if (null != column) {
String columnName = column.getColumnName().contains(".") ? column.getColumnName().split("\\.")[1] : column.getColumnName(); String str1 = column.getColumnName().contains(".") ? column.getColumnName().split("\\.")[1] : column.getColumnName();
String mathKey = (ip + "_" + port + "_" + schema + "_" + tableName + "_" + columnName).toLowerCase().replace("`", "").replace("\"", ""); String str2 = (ip + "_" + port + "_" + schema + "_" + tableName + "_" + str1).toLowerCase().replace("`", "").replace("\"", "");
RuleLoadUtil.writeLog("@@插件@@---PreparedstatementWrapper参数加密时获取的mathKey:-->" + mathKey); RuleLoadUtil.writeLog("@@"+ str2);
if (EngineUtil.encryptionMap.isEmpty()) { if (EngineUtil.encryptionMap.isEmpty())
EngineUtil.keyCacheFromFile(); EngineUtil.keyCacheFromFile();
} ismaksing = EngineUtil.encryptionMap.containsKey(str2);
ismaksing = EngineUtil.encryptionMap.containsKey(mathKey);
if (ismaksing) { if (ismaksing) {
Boolean flag = false; Boolean flag = Boolean.valueOf(false);
try { try {
Columninfo map = (Columninfo)EngineUtil.encryptionMap.get(mathKey); Columninfo map = (Columninfo)EngineUtil.encryptionMap.get(str2);
if (sqlType == SQLType.INSERT) { if (sqlType == SQLType.INSERT) {
RuleLoadUtil.writeLog("@@插件@@---PreparedstatementWrapper参数原值:-->" + x); value = x;
value = EngineUtil.exeEngine(map, (ConnectionInfo)null, flag, x, true); RuleLoadUtil.writeLog("@@"+ x);
value = EngineUtil.exeEngine(map, null, flag, value, Boolean.valueOf(true));
x = (String)value; x = (String)value;
RuleLoadUtil.writeLog("@@插件@@---PreparedstatementWrapper参数加密后的值:-->" + x); RuleLoadUtil.writeLog("@@"+ x);
} else if (sqlType == SQLType.UPDATE) { } else if (sqlType == SQLType.UPDATE) {
value = EngineUtil.exeEngine(map, (ConnectionInfo)null, flag, x, true); value = x;
value = EngineUtil.exeEngine(map, null, flag, value, Boolean.valueOf(true));
x = (String)value; x = (String)value;
} }
} catch (Exception e1) { } catch (Exception e1) {
...@@ -1633,79 +1422,78 @@ public class PreparedStatementWrapper extends StatementWrapper implements Prepar ...@@ -1633,79 +1422,78 @@ public class PreparedStatementWrapper extends StatementWrapper implements Prepar
hashMap.put("x", x); hashMap.put("x", x);
} }
} }
return (Map)hashMap;
return hashMap; }
} else {
int computeParameterIndex = parameterIndex - 1; int computeParameterIndex = parameterIndex - 1;
if (sqlType == SQLType.UPDATE) { if (sqlType == SQLType.UPDATE) {
for(int i = 0; i < columnList.size(); ++i) { for (int i = 0; i < columnList.size(); i++) {
Column column1 = (Column)columnList.get(i); Column column1 = columnList.get(i);
if (column1.getValue() != null && column1.getValue().equals("?")) { if (column1.getValue() != null)
Map<String, Object> whereMap = new HashMap(); if (column1.getValue().equals("?")) {
whereMap.put("column", schema + "." + column1.getColumnName()); Map<String, Object> map = new HashMap<String, Object>();
whereMap.put("columnValue", "?"); map.put("column", schema + "." + column1.getColumnName());
whereMap.put("type", "Equality"); map.put("columnValue", "?");
whereList.add(i, whereMap); map.put("type", "Equality");
whereList.add(i, map);
} }
} }
computeParameterIndex = parameterIndex - 1 - ids.size(); computeParameterIndex = parameterIndex - 1 - ids.size();
} }
if (whereList == null || whereList.isEmpty()) {
if (whereList != null && !whereList.isEmpty()) { hashMap.put("tableAndColumnName", "");
hashMap.put("x", x);
hashMap.put("mathKey", "");
return (Map)hashMap;
}
Iterator<Map<String, Object>> iterator = whereList.iterator(); Iterator<Map<String, Object>> iterator = whereList.iterator();
while (iterator.hasNext()) {
while(iterator.hasNext()) { Map<String, Object> y = iterator.next();
Map<String, Object> y = (Map)iterator.next(); if ((!(y.get("columnValue") instanceof String) || !y.get("columnValue").equals("?")) && (!(y.get("columnValue") instanceof SQLVariantRefExpr) || !((SQLVariantRefExpr)y.get("columnValue")).getName().equals("?")))
if ((!(y.get("columnValue") instanceof String) || !y.get("columnValue").equals("?")) && (!(y.get("columnValue") instanceof SQLVariantRefExpr) || !((SQLVariantRefExpr)y.get("columnValue")).getName().equals("?"))) {
iterator.remove(); iterator.remove();
} }
if (whereList == null || whereList.isEmpty()) {
hashMap.put("tableAndColumnName", "");
hashMap.put("x", x);
hashMap.put("mathKey", "");
return (Map)hashMap;
} }
if (whereList != null && !whereList.isEmpty()) {
Map<String, Object> whereMap;
if (computeParameterIndex >= whereList.size()) { if (computeParameterIndex >= whereList.size()) {
whereMap = (Map)whereList.get(whereList.size() - 1); whereMap = whereList.get(whereList.size() - 1);
} else { } else {
whereMap = (Map)whereList.get(computeParameterIndex); whereMap = whereList.get(computeParameterIndex);
} }
String key = (String)whereMap.get("column"); String key = (String)whereMap.get("column");
String columnName = key.contains(".") ? key.split("\\.")[2].replace("\"", "") : key.replace("\"", ""); String columnName = key.contains(".") ? key.split("\\.")[2].replace("\"", "") : key.replace("\"", "");
tableName = key.contains(".") ? key.split("\\.")[1] : tableName; tableName = key.contains(".") ? key.split("\\.")[1] : tableName;
schema = key.contains(".") ? key.split("\\.")[0] : schema; schema = key.contains(".") ? key.split("\\.")[0] : schema;
String mathKey = (ip + "_" + port + "_" + schema + "_" + tableName + "_" + columnName).toLowerCase().replace("`", "").replace("\"", ""); String mathKey = (ip + "_" + port + "_" + schema + "_" + tableName + "_" + columnName).toLowerCase().replace("`", "").replace("\"", "");
if (EngineUtil.encryptionMap.isEmpty()) { if (EngineUtil.encryptionMap.isEmpty())
EngineUtil.keyCacheFromFile(); EngineUtil.keyCacheFromFile();
} if ("1".equals(EncryptionGatewayManager.getParameterValue("replaceSql")) &&
replaceInfo != null) {
if ("1".equals(EncryptionGatewayManager.getParameterValue("replaceSql")) && replaceInfo != null) {
String replaceColumn = ip + "_" + port + "_" + replaceInfo.getPrefix() + "_" + replaceInfo.getColumnName(); String replaceColumn = ip + "_" + port + "_" + replaceInfo.getPrefix() + "_" + replaceInfo.getColumnName();
if (mathKey.equals(replaceColumn)) { if (mathKey.equals(replaceColumn)) {
hashMap.put("tableAndColumnName", (tableName + "@@" + columnName).toLowerCase()); hashMap.put("tableAndColumnName", (tableName + "@@" + columnName).toLowerCase());
hashMap.put("x", x); hashMap.put("x", x);
hashMap.put("mathKey", mathKey); hashMap.put("mathKey", mathKey);
return hashMap; return (Map)hashMap;
} }
} }
RuleLoadUtil.writeLog("@@"+ mathKey);
RuleLoadUtil.writeLog("@@插件@@---PreparedstatementWrapper参数加密22时获取的mathKey:-->" + mathKey);
ismaksing = EngineUtil.encryptionMap.containsKey(mathKey); ismaksing = EngineUtil.encryptionMap.containsKey(mathKey);
if (ismaksing) { if (ismaksing) {
Boolean flag = false; Boolean flag = Boolean.valueOf(false);
Columninfo map = (Columninfo)EngineUtil.encryptionMap.get(mathKey); Columninfo map = (Columninfo)EngineUtil.encryptionMap.get(mathKey);
map.setColumnname((tableName + "@@" + columnName).toLowerCase()); map.setColumnname((tableName + "@@" + columnName).toLowerCase());
map.setId(mathKey); map.setId(mathKey);
String type = (String)whereMap.get("type"); String type = (String)whereMap.get("type");
if (!type.toUpperCase().equals("LIKE")) { if (!type.toUpperCase().equals("LIKE"))
sqlIndexKeyMap.put(sql + "_" + parameterIndex, map); sqlIndexKeyMap.put(sql + "_" + parameterIndex, map);
} if (x != null && !"".equals(x))
if (x != null && !"".equals(x)) {
try { try {
value = x; value = x;
if (type.toUpperCase().equals("LIKE")) { if (type.toUpperCase().equals("LIKE")) {
String likeValue = ((String)x).trim(); String likeValue = ((String)value).trim();
boolean beforeLike = false; boolean beforeLike = false;
boolean afterLike = false; boolean afterLike = false;
if (!likeValue.equals("%%")) { if (!likeValue.equals("%%")) {
...@@ -1713,44 +1501,36 @@ public class PreparedStatementWrapper extends StatementWrapper implements Prepar ...@@ -1713,44 +1501,36 @@ public class PreparedStatementWrapper extends StatementWrapper implements Prepar
likeValue = likeValue.substring(1); likeValue = likeValue.substring(1);
beforeLike = true; beforeLike = true;
} }
if (likeValue.endsWith("%")) { if (likeValue.endsWith("%")) {
likeValue = likeValue.substring(0, likeValue.length() - 1); likeValue = likeValue.substring(0, likeValue.length() - 1);
afterLike = true; afterLike = true;
} }
value = likeValue;
value = EngineUtil.exeEngine(map, (ConnectionInfo)null, flag, likeValue, true); value = EngineUtil.exeEngine(map, null, flag, value, Boolean.valueOf(true));
if (afterLike) { if (afterLike)
value = value.toString().replace(ENCRYPT_SEPARATOR, ""); value = value.toString().replace(ENCRYPT_SEPARATOR, "");
}
if (ENCRYPT_LIKE_OPEN.equals(map.getIsLike())) { if (ENCRYPT_LIKE_OPEN.equals(map.getIsLike())) {
if (beforeLike) { if (beforeLike)
value = "%" + value; value = "%" + value;
} if (afterLike)
if (afterLike) {
value = value + "%"; value = value + "%";
} }
} }
}
} else { } else {
RuleLoadUtil.writeLog("@@插件@@---PreparedstatementWrapper参数22原值:-->" + x); RuleLoadUtil.writeLog("@@"+ value);
value = EngineUtil.exeEngine(map, (ConnectionInfo)null, flag, x, true); value = EngineUtil.exeEngine(map, null, flag, value, Boolean.valueOf(true));
RuleLoadUtil.writeLog("@@插件@@---PreparedstatementWrapper参数22加密后的值:-->" + value); RuleLoadUtil.writeLog("@@"+ value);
} }
x = (String)value; x = (String)value;
encFlag = true; return (Map)hashMap;
} catch (Exception e1) { } catch (Exception e1) {
e1.printStackTrace(); e1.printStackTrace();
throw new SQLException(e1); throw new SQLException(e1);
} finally { } finally {
Exception exception = null;
hashMap.put("tableAndColumnName", (tableName + "@@" + columnName).toLowerCase()); hashMap.put("tableAndColumnName", (tableName + "@@" + columnName).toLowerCase());
hashMap.put("x", x); hashMap.put("x", x);
hashMap.put("mathKey", mathKey); hashMap.put("mathKey", mathKey);
return hashMap;
}
} }
} else { } else {
Columninfo columninfo = new Columninfo(); Columninfo columninfo = new Columninfo();
...@@ -1758,24 +1538,10 @@ public class PreparedStatementWrapper extends StatementWrapper implements Prepar ...@@ -1758,24 +1538,10 @@ public class PreparedStatementWrapper extends StatementWrapper implements Prepar
columninfo.setId(mathKey); columninfo.setId(mathKey);
sqlIndexKeyMap.put(sql + "_" + parameterIndex, columninfo); sqlIndexKeyMap.put(sql + "_" + parameterIndex, columninfo);
} }
hashMap.put("tableAndColumnName", (tableName + "@@" + columnName).toLowerCase()); hashMap.put("tableAndColumnName", (tableName + "@@" + columnName).toLowerCase());
hashMap.put("x", x); hashMap.put("x", x);
hashMap.put("mathKey", mathKey); hashMap.put("mathKey", mathKey);
return hashMap; return (Map)hashMap;
} else {
hashMap.put("tableAndColumnName", "");
hashMap.put("x", x);
hashMap.put("mathKey", "");
return hashMap;
}
} else {
hashMap.put("tableAndColumnName", "");
hashMap.put("x", x);
hashMap.put("mathKey", "");
return hashMap;
}
}
} }
public static void main(String[] args) { public static void main(String[] args) {
......
...@@ -6,14 +6,14 @@ import java.util.Hashtable; ...@@ -6,14 +6,14 @@ import java.util.Hashtable;
public class LogFactory { public class LogFactory {
public static final String PRIORITY_KEY = "priority"; public static final String PRIORITY_KEY = "priority";
public static final String TCCL_KEY = "use_tccl"; public static final String TCCL_KEY = "use_tccl";
public static final String FACTORY_PROPERTY = "ghca.org.apache.commons.logging.LogFactory"; public static final String FACTORY_PROPERTY = "org.apache.commons.logging.LogFactory";
public static final String FACTORY_DEFAULT = "ghca.org.apache.commons.logging.impl.LogFactoryImpl"; public static final String FACTORY_DEFAULT = "org.apache.commons.logging.impl.LogFactoryImpl";
public static final String FACTORY_PROPERTIES = "commons-logging.properties"; public static final String FACTORY_PROPERTIES = "commons-logging.properties";
protected static final String SERVICE_ID = "META-INF/services/ghca.org.apache.commons.logging.LogFactory"; protected static final String SERVICE_ID = "META-INF/services/org.apache.commons.logging.LogFactory";
public static final String DIAGNOSTICS_DEST_PROPERTY = "ghca.org.apache.commons.logging.diagnostics.dest"; public static final String DIAGNOSTICS_DEST_PROPERTY = "org.apache.commons.logging.diagnostics.dest";
private static PrintStream diagnosticsStream = null; private static PrintStream diagnosticsStream = null;
public static final String HASHTABLE_IMPLEMENTATION_PROPERTY = "ghca.org.apache.commons.logging.LogFactory.HashtableImpl"; public static final String HASHTABLE_IMPLEMENTATION_PROPERTY = "org.apache.commons.logging.LogFactory.HashtableImpl";
private static final String WEAK_HASHTABLE_CLASSNAME = "ghca.org.apache.commons.logging.impl.WeakHashtable"; private static final String WEAK_HASHTABLE_CLASSNAME = "org.apache.commons.logging.impl.WeakHashtable";
protected static Hashtable factories = null; protected static Hashtable factories = null;
/** @deprecated */ /** @deprecated */
protected static volatile LogFactory nullClassLoaderFactory = null; protected static volatile LogFactory nullClassLoaderFactory = null;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论