Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
N
NsePlugin
概览
Overview
Details
Activity
Cycle Analytics
版本库
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
问题
0
Issues
0
列表
Board
标记
里程碑
合并请求
0
Merge Requests
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
Snippets
成员
Members
Collapse sidebar
Close sidebar
活动
图像
聊天
创建新问题
作业
提交
Issue Boards
Open sidebar
吴超
NsePlugin
Commits
1125fb35
Commit
1125fb35
authored
Aug 21, 2025
by
zinc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改获取ip端口的正则
parent
d3ea414e
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
637 行增加
和
1013 行删除
+637
-1013
src/main/java/com/palacesun/engine/test/TestJdbcEventListener.java
+270
-412
src/main/java/com/palacesun/engine/wrapper/PreparedStatementWrapper.java
+361
-595
src/main/java/org/apache/commons/logging/LogFactory.java
+6
-6
没有找到文件。
src/main/java/com/palacesun/engine/test/TestJdbcEventListener.java
View file @
1125fb35
package
com
.
palacesun
.
engine
.
test
;
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.PreparedStatementInformation
;
import
com.palacesun.engine.common.ResultSetInformation
;
...
...
@@ -10,11 +16,6 @@ import com.palacesun.engine.gateway.EncryptionGatewayManager;
import
com.palacesun.engine.gateway.GatewayContext
;
import
com.palacesun.engine.log.DblogClient
;
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.log.vo.EncryLogVO
;
import
com.palacesun.masking.tools.EngineUtil
;
...
...
@@ -24,34 +25,33 @@ import com.palacesun.masking.vo.ConnectionInfo;
import
com.palacesun.masking.vo.JsonRootBean
;
import
com.palacesun.masking.vo.TableInfo
;
import
com.palacesun.masking.vo.masking.MaskingColumnInfo
;
import
util.SqlUtil
;
import
java.sql.Connection
;
import
java.sql.ResultSet
;
import
java.sql.ResultSetMetaData
;
import
java.sql.SQLException
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
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.*
;
import
java.util.logging.Logger
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
import
util.SqlUtil
;
public
class
TestJdbcEventListener
extends
JdbcEventListener
{
private
static
final
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
private
ResultSetMetaData
metaData
;
private
volatile
String
flag
=
"0"
;
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
{
if
(
"0"
.
equals
(
this
.
flag
))
{
if
(
"0"
.
equals
(
this
.
flag
))
try
{
Class
.
forName
(
"com.palacesun.masking.tools.EngineUtil"
);
this
.
flag
=
"1"
;
...
...
@@ -61,13 +61,10 @@ public class TestJdbcEventListener extends JdbcEventListener {
}
}
}
public
void
onAfterGetConnection
(
ConnectionInformation
connectionInformation
,
SQLException
e
)
throws
SQLException
{
if
(
e
!=
null
)
{
if
(
e
!=
null
)
throw
e
;
}
}
public
void
onConnectionWrapped
(
ConnectionInformation
connectionInformation
)
{
}
...
...
@@ -120,7 +117,9 @@ public class TestJdbcEventListener extends JdbcEventListener {
private
String
sqlTypeAnalysis
(
String
sql
)
{
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
)
{
...
...
@@ -154,126 +153,104 @@ public class TestJdbcEventListener extends JdbcEventListener {
}
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
;
}
else
if
(
value
!=
null
&&
(!(
value
instanceof
String
)
||
!
StringUtils
.
isBlank
((
String
)
value
)))
{
String
encPrefix
=
EncryptionGatewayManager
.
getParameterValue
(
"encryption.label"
);
if
(
value
.
toString
().
contains
(
encPrefix
)
&&
GatewayContext
.
isCurrentUserCanSeeDecInfo
())
{
String
sqlTemplate
=
this
.
getSqlTemplate
(
resultSetInformation
);
RuleLoadUtil
.
writeLog
(
"@@
插件@@---TestJdbcEventListener--columnLabel--解密前的值:
"
+
value
);
value
=
this
.
getDecData
(
value
,
sqlTemplate
,
columnLabel
,
encPrefix
);
RuleLoadUtil
.
writeLog
(
"@@
插件@@---TestJdbcEventListener--columnLabel--解密前的值:
"
+
value
);
String
sqlTemplate
=
getSqlTemplate
(
resultSetInformation
);
RuleLoadUtil
.
writeLog
(
"@@"
+
value
);
value
=
getDecData
(
value
,
sqlTemplate
,
columnLabel
,
encPrefix
);
RuleLoadUtil
.
writeLog
(
"@@"
+
value
);
}
if
(!
EncryptionGatewayManager
.
checkParameterFlag
(
"maskingRule"
))
{
if
(!
EncryptionGatewayManager
.
checkParameterFlag
(
"maskingRule"
))
return
value
;
}
else
{
int
columnIndex
=
-
1
;
String
columnName
=
""
;
String
tableName
=
""
;
String
columnType
=
""
;
try
{
ResultSetMetaData
metaData
=
resultSetInformation
.
getResultSet
().
getMetaData
();
int
count
=
metaData
.
getColumnCount
();
for
(
int
i
=
1
;
i
<=
count
;
++
i
)
{
for
(
int
i
=
1
;
i
<=
count
;
i
++)
{
if
(
metaData
.
getColumnLabel
(
i
).
equalsIgnoreCase
(
columnLabel
))
{
columnIndex
=
i
;
columnName
=
metaData
.
getColumnLabel
(
i
);
columnType
=
metaData
.
getColumnTypeName
(
i
);
if
(
columnName
==
null
||
""
.
equals
(
columnName
))
{
if
(
columnName
==
null
||
""
.
equals
(
columnName
))
columnName
=
metaData
.
getColumnName
(
i
);
}
tableName
=
metaData
.
getTableName
(
i
);
tableName
=
metaData
.
getTableName
(
columnIndex
);
break
;
}
}
if
(
columnIndex
==
-
1
)
{
if
(
columnIndex
==
-
1
)
return
value
;
}
else
if
(
value
==
null
)
{
if
(
value
==
null
)
return
value
;
}
else
{
String
schema
=
metaData
.
getCatalogName
(
columnIndex
);
if
(
StringUtils
.
isEmpty
(
schema
))
{
if
(
StringUtils
.
isEmpty
(
schema
))
schema
=
metaData
.
getSchemaName
(
columnIndex
);
}
Connection
connection
=
resultSetInformation
.
getConnectionInformation
().
getConnection
();
String
urlTemp
=
connection
.
getMetaData
().
getURL
();
Map
<
String
,
String
>
ipAndPortMap
=
getIpAndPort
(
urlTemp
);
String
ip
=
(
String
)
ipAndPortMap
.
get
(
"ip"
);
String
port
=
(
String
)
ipAndPortMap
.
get
(
"port"
);
String
ip
=
ipAndPortMap
.
get
(
"ip"
);
String
port
=
ipAndPortMap
.
get
(
"port"
);
String
driverName
=
resultSetInformation
.
getConnectionInformation
().
getConnection
().
getMetaData
().
getDriverName
();
String
urlDbType
=
resultSetInformation
.
getConnectionInformation
().
getUrl
();
String
dbType
=
""
;
dbType
=
ConnectionWrapper
.
getDbType
(
driverName
,
urlDbType
,
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
();
}
schema
=
connection
.
getMetaData
().
getUserName
();
StatementInformation
statementInformation
=
resultSetInformation
.
getStatementInformation
();
String
sqlAll
=
statementInformation
.
getSql
();
if
(
sqlAll
.
indexOf
(
"-- appUsername="
)
>
0
)
{
if
(
sqlAll
.
indexOf
(
"-- appUsername="
)
>
0
)
sqlAll
=
sqlAll
.
substring
(
0
,
sqlAll
.
indexOf
(
"-- appUsername="
)).
trim
();
}
if
(
sqlAll
.
endsWith
(
";"
))
{
if
(
sqlAll
.
endsWith
(
";"
))
sqlAll
=
sqlAll
.
substring
(
0
,
sqlAll
.
length
()
-
1
);
}
String
[]
splitSql
=
sqlAll
.
split
(
";"
);
int
i
;
if
(
splitSql
.
length
==
1
)
{
i
=
0
;
j
=
0
;
}
else
{
for
(
i
=
0
;
i
<
splitSql
.
length
;
++
i
)
{
String
trim
=
splitSql
[
i
].
toLowerCase
().
trim
();
if
(
trim
.
startsWith
(
"select"
))
{
for
(
j
=
0
;
j
<
splitSql
.
length
;
j
++
)
{
String
trim
=
splitSql
[
j
].
toLowerCase
().
trim
();
if
(
trim
.
startsWith
(
"select"
))
break
;
}
if
(
trim
.
contains
(
"*/"
))
{
int
index
=
trim
.
indexOf
(
"*/"
);
trim
=
trim
.
substring
(
index
+
2
).
trim
();
if
(
trim
.
startsWith
(
"select"
))
{
if
(
trim
.
startsWith
(
"select"
))
break
;
}
}
if
(
j
==
splitSql
.
length
)
j
=
splitSql
.
length
-
1
;
}
if
(
i
==
splitSql
.
length
)
{
i
=
splitSql
.
length
-
1
;
}
}
List
<
Map
<
String
,
Object
>>
sqlParseList
=
(
List
)
ConnectionWrapper
.
sqlParseMap
.
get
(
sqlAll
);
if
(
sqlParseList
==
null
||
sqlParseList
.
isEmpty
())
{
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
())
{
if
(
sqlParseList
==
null
||
sqlParseList
.
isEmpty
())
return
value
;
}
Map
<
String
,
Object
>
sqlParse
=
(
Map
)
sqlParseList
.
get
(
i
);
Map
<
String
,
Object
>
sqlParse
=
sqlParseList
.
get
(
j
);
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
)
{
new
ArrayList
();
for
(
Column
col
:
cols
)
{
List
<
Column
>
idxCols
=
new
ArrayList
<
Column
>();
for
(
Column
col
:
cols
)
{
if
(
col
.
seq
==
columnIndex
)
{
String
table
=
col
.
getTable
();
if
(
table
!=
null
&&
table
.
length
()
!=
0
)
{
if
(
table
==
null
||
table
.
length
()
==
0
)
continue
;
String
fullname
=
col
.
getColumnName
();
if
(
fullname
!=
null
&&
fullname
.
length
()
!=
0
)
{
if
(
fullname
==
null
||
fullname
.
length
()
==
0
)
continue
;
int
idx
=
fullname
.
toLowerCase
().
indexOf
(
table
.
toLowerCase
());
if
(
idx
!=
-
1
)
{
if
(
idx
==
-
1
)
continue
;
String
cname
=
fullname
.
substring
(
idx
+
table
.
length
()
+
1
);
columnName
=
cname
;
tableName
=
table
;
...
...
@@ -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
(!
"postgresql"
.
equals
(
dbType
)
&&
!
"greenplum"
.
equals
(
dbType
)
&&
!
"gauss"
.
equals
(
dbType
))
{
if
(
"sql server"
.
equals
(
dbType
))
{
}
else
if
(
"sql server"
.
equals
(
dbType
))
{
String
url
=
connection
.
getMetaData
().
getURL
();
if
(
url
.
indexOf
(
"applicationName"
)
>
0
)
{
schema
=
url
.
substring
(
url
.
indexOf
(
"applicationName"
)
+
"applicationName"
.
length
()
+
1
);
if
(
schema
.
indexOf
(
";"
)
!=
-
1
)
{
if
(
schema
.
indexOf
(
";"
)
!=
-
1
)
schema
=
schema
.
substring
(
0
,
schema
.
indexOf
(
";"
));
}
}
else
{
schema
=
"dbo"
;
}
...
...
@@ -303,7 +284,7 @@ public class TestJdbcEventListener extends JdbcEventListener {
}
else
{
int
from
=
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
(
"/"
);
schema
=
address
.
substring
(
idx
+
1
);
}
...
...
@@ -327,152 +308,121 @@ public class TestJdbcEventListener extends JdbcEventListener {
String
url
=
connection
.
getMetaData
().
getURL
();
int
from
=
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
(
"/"
);
schema
=
address
.
substring
(
idx
+
1
);
}
else
if
(
"hive"
.
equals
(
dbType
))
{
String
url
=
connection
.
getMetaData
().
getURL
();
int
from
=
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
(
"/"
);
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
))
{
Map
<
String
,
String
>
map
=
this
.
getColumnNameAndTableNameByAlisaName
(
resultSetInformation
,
dbType
,
schema
,
tableName
,
columnName
);
columnName
=
(
String
)
map
.
get
(
"columnName"
);
tableName
=
(
String
)
map
.
get
(
"tableName"
);
schema
=
(
String
)
map
.
get
(
"schema"
);
Map
<
String
,
String
>
map
=
getColumnNameAndTableNameByAlisaName
(
resultSetInformation
,
dbType
,
schema
,
tableName
,
columnName
);
columnName
=
map
.
get
(
"columnName"
);
tableName
=
map
.
get
(
"tableName"
);
schema
=
map
.
get
(
"schema"
);
}
String
mathKey
=
(
ip
+
"_"
+
port
+
"_"
+
schema
+
"_"
+
tableName
+
"_"
+
columnName
).
toLowerCase
().
replace
(
"`"
,
""
).
replace
(
"\""
,
""
);
RuleLoadUtil
.
writeLog
(
"@@插件@@---TestJdbcEventListener--columnLabel--mathKey:
"
+
mathKey
);
if
(
EngineUtil
.
encryptionMap
.
isEmpty
())
{
RuleLoadUtil
.
writeLog
(
"@@
"
+
mathKey
);
if
(
EngineUtil
.
encryptionMap
.
isEmpty
())
EngineUtil
.
keyCacheFromFile
();
}
boolean
ismaksing
=
EngineUtil
.
encryptionMap
.
containsKey
(
mathKey
);
if
(
ismaksing
&&
(
EncryptionGatewayManager
.
getParameterValue
(
"projectid"
).
length
()
==
0
||
GatewayContext
.
isCurrentUserCanSeeDecInfo
()))
{
Columninfo
map
=
(
Columninfo
)
EngineUtil
.
encryptionMap
.
get
(
mathKey
);
RuleLoadUtil
.
writeLog
(
"@@插件@@---TestJdbcEventListener--columnLabel--解密前的值:
"
+
value
);
value
=
EngineUtil
.
exeEngine
(
map
,
(
ConnectionInfo
)
null
,
true
,
value
,
false
);
RuleLoadUtil
.
writeLog
(
"@@插件@@---TestJdbcEventListener--columnLabel--解密后的值:
"
+
value
);
Columninfo
map
=
(
Columninfo
)
EngineUtil
.
encryptionMap
.
get
(
mathKey
);
RuleLoadUtil
.
writeLog
(
"@@
"
+
value
);
value
=
EngineUtil
.
exeEngine
(
map
,
null
,
Boolean
.
valueOf
(
true
),
value
,
Boolean
.
valueOf
(
false
)
);
RuleLoadUtil
.
writeLog
(
"@@
"
+
value
);
EncryLogVO
encryLogVO
=
new
EncryLogVO
();
encryLogVO
.
setRalsql
(
resultSetInformation
.
getSql
());
encryLogVO
.
setStatus
(
"解密成功
"
);
encryLogVO
.
setStatus
(
"
"
);
encryLogVO
.
setRalsql
(
null
);
encryLogVO
.
setExeSql
(
null
);
encryLogVO
.
setAccessSqlType
(
null
);
encryLogVO
.
setDecrypt
(
mathKey
);
encryLogVO
.
setEncryFieldSet
((
Set
)
null
);
encryLogVO
.
setEncryFieldSet
(
null
);
DblogClient
.
inputAuditLog
(
encryLogVO
);
}
ismaksing
=
EngineUtil
.
maskingmap
.
containsKey
(
mathKey
);
if
(
ismaksing
&&
GatewayContext
.
isCurrentUserNeedMask
())
{
if
(
ismaksing
&&
GatewayContext
.
isCurrentUserNeedMask
())
try
{
MaskingColumnInfo
map
=
(
MaskingColumnInfo
)
EngineUtil
.
maskingmap
.
get
(
mathKey
);
if
(
null
!=
map
&&
null
!=
map
.
getExpression
()
&&
!
map
.
getExpression
().
trim
().
equals
(
""
))
{
MaskingColumnInfo
map
=
(
MaskingColumnInfo
)
EngineUtil
.
maskingmap
.
get
(
mathKey
);
if
(
null
!=
map
&&
null
!=
map
.
getExpression
()
&&
!
map
.
getExpression
().
trim
().
equals
(
""
))
value
=
EngineUtil
.
exeMaskingEngine
(
map
,
value
);
}
}
catch
(
Exception
e1
)
{
e1
.
printStackTrace
();
throw
e1
;
}
finally
{
;
}
}
return
value
;
}
}
catch
(
Exception
e1
)
{
e1
.
printStackTrace
();
throw
new
SQLException
(
e
);
}
finally
{
;
}
}
}
else
{
return
value
;
}
}
private
Object
getDecData
(
Object
value
,
String
sqlTemplate
,
Object
column
,
String
encPrefix
)
{
StringBuilder
stringBuilder
=
new
StringBuilder
();
if
(
GatewayContext
.
isCurrentUserCanSeeDecInfo
())
{
String
[]
split
=
value
.
toString
().
split
(
EncryptionGatewayManager
.
getParameterValue
(
"encryption.separator"
));
String
likeFlag
=
EncryptionGatewayManager
.
getParameterValue
(
"encryption.like.split"
);
Set
<
Columninfo
>
secretKeySet
=
new
HashSet
();
for
(
String
s
:
split
)
{
Set
<
Columninfo
>
secretKeySet
=
new
HashSet
<
Columninfo
>();
for
(
String
s
:
split
)
{
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
)
{
for
(
Columninfo
columninfo
:
columninfos
)
{
for
(
Columninfo
columninfo
:
columninfos
)
{
if
(
s
.
startsWith
(
encPrefix
))
{
if
(!
s
.
contains
(
likeFlag
)
||
!
"0"
.
equals
(
columninfo
.
getIsLike
()))
{
if
(
s
.
contains
(
likeFlag
)
&&
"0"
.
equals
(
columninfo
.
getIsLike
()))
continue
;
try
{
s
=
(
String
)
EngineUtil
.
exeEngine
(
columninfo
,
(
ConnectionInfo
)
null
,
true
,
s
,
false
);
}
catch
(
Exception
var21
)
{
s
=
(
String
)
EngineUtil
.
exeEngine
(
columninfo
,
null
,
Boolean
.
valueOf
(
true
),
s
,
Boolean
.
valueOf
(
false
)
);
}
catch
(
Exception
exception
)
{
}
if
(!
s
.
contains
(
encPrefix
))
{
if
(!
s
.
contains
(
encPrefix
))
break
;
continue
;
}
}
}
else
{
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
);
s
=
s
.
substring
(
s
.
indexOf
(
encPrefix
));
try
{
s
=
(
String
)
EngineUtil
.
exeEngine
(
columninfo
,
(
ConnectionInfo
)
null
,
true
,
s
,
false
);
}
catch
(
Exception
var20
)
{
s
=
(
String
)
EngineUtil
.
exeEngine
(
columninfo
,
null
,
Boolean
.
valueOf
(
true
),
s
,
Boolean
.
valueOf
(
false
)
);
}
catch
(
Exception
exception
)
{
}
if
(!
s
.
contains
(
encPrefix
))
{
if
(!
s
.
contains
(
encPrefix
))
break
;
}
}
}
}
}
else
{
for
(
Columninfo
columninfo
:
EngineUtil
.
encryptionSet
)
{
for
(
Columninfo
columninfo
:
EngineUtil
.
encryptionSet
)
{
if
(
s
.
startsWith
(
encPrefix
))
{
if
(!
s
.
contains
(
likeFlag
)
||
!
"0"
.
equals
(
columninfo
.
getIsLike
()))
{
if
(
s
.
contains
(
likeFlag
)
&&
"0"
.
equals
(
columninfo
.
getIsLike
()))
continue
;
try
{
s
=
(
String
)
EngineUtil
.
exeEngine
(
columninfo
,
(
ConnectionInfo
)
null
,
true
,
s
,
false
);
}
catch
(
Exception
var19
)
{
s
=
(
String
)
EngineUtil
.
exeEngine
(
columninfo
,
null
,
Boolean
.
valueOf
(
true
),
s
,
Boolean
.
valueOf
(
false
)
);
}
catch
(
Exception
exception
)
{
}
if
(!
s
.
contains
(
encPrefix
))
{
secretKeySet
.
add
(
columninfo
);
sqlColumSecretKeyMap
.
put
(
sqlTemplate
+
"_"
+
column
,
secretKeySet
);
break
;
}
continue
;
}
}
else
{
String
substring
=
s
.
substring
(
0
,
s
.
indexOf
(
encPrefix
));
stringBuilder
.
append
(
substring
);
s
=
s
.
substring
(
s
.
indexOf
(
encPrefix
));
if
(!
s
.
contains
(
likeFlag
)
||
!
"0"
.
equals
(
columninfo
.
getIsLike
()))
{
if
(
s
.
contains
(
likeFlag
)
&&
"0"
.
equals
(
columninfo
.
getIsLike
()))
continue
;
try
{
s
=
(
String
)
EngineUtil
.
exeEngine
(
columninfo
,
(
ConnectionInfo
)
null
,
true
,
s
,
false
);
}
catch
(
Exception
var18
)
{
s
=
(
String
)
EngineUtil
.
exeEngine
(
columninfo
,
null
,
Boolean
.
valueOf
(
true
),
s
,
Boolean
.
valueOf
(
false
)
);
}
catch
(
Exception
exception
)
{
}
if
(!
s
.
contains
(
encPrefix
))
{
secretKeySet
.
add
(
columninfo
);
sqlColumSecretKeyMap
.
put
(
sqlTemplate
+
"_"
+
column
,
secretKeySet
);
...
...
@@ -481,25 +431,18 @@ public class TestJdbcEventListener extends JdbcEventListener {
}
}
}
}
}
stringBuilder
.
append
(
s
);
}
value
=
stringBuilder
.
toString
();
}
return
value
;
}
private
String
getDbType
(
Connection
connection
,
String
dbType
)
{
try
{
String
hiveurl
=
connection
.
toString
();
if
(
hiveurl
.
toLowerCase
().
contains
(
"hive"
))
{
if
(
hiveurl
.
toLowerCase
().
contains
(
"hive"
))
return
"hive"
;
}
String
driverName
=
connection
.
getMetaData
().
getDriverName
();
if
(
driverName
.
toLowerCase
().
contains
(
"mysql"
))
{
dbType
=
"mysql"
;
...
...
@@ -512,7 +455,6 @@ public class TestJdbcEventListener extends JdbcEventListener {
dbType
=
"gauss"
;
return
dbType
;
}
if
(
url
.
contains
(
"greenplum"
))
{
dbType
=
"greenplum"
;
return
dbType
;
...
...
@@ -533,117 +475,164 @@ public class TestJdbcEventListener extends JdbcEventListener {
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
dbType
;
}
public
boolean
getParsedMetaInfo
(
StatementInformation
statementInformation
,
int
columnIndex
,
Map
<
String
,
String
>
out
)
{
List
<
Map
<
String
,
Object
>>
sqlParseList
=
statementInformation
.
sqlParse
;
Map
<
String
,
Object
>
sqlParse
=
(
Map
)
sqlParseList
.
get
(
0
);
if
(
sqlParse
!=
null
&&
sqlParse
.
size
()
!=
0
)
{
List
<
Column
>
cols
=
(
List
)
sqlParse
.
get
(
"output-cols"
);
if
(
cols
!=
null
&&
cols
.
size
()
!=
0
)
{
new
ArrayList
();
for
(
Column
col
:
cols
)
{
Map
<
String
,
Object
>
sqlParse
=
sqlParseList
.
get
(
0
);
if
(
sqlParse
==
null
||
sqlParse
.
size
()
==
0
)
return
false
;
List
<
Column
>
cols
=
(
List
<
Column
>)
sqlParse
.
get
(
"output-cols"
);
if
(
cols
==
null
||
cols
.
size
()
==
0
)
return
false
;
List
<
Column
>
idxCols
=
new
ArrayList
<
Column
>();
for
(
Column
col
:
cols
)
{
if
(
col
.
seq
==
columnIndex
)
{
String
table
=
col
.
getTable
();
if
(
table
!=
null
&&
table
.
length
()
!=
0
)
{
if
(
table
==
null
||
table
.
length
()
==
0
)
continue
;
String
fullname
=
col
.
getColumnName
();
if
(
fullname
!=
null
&&
fullname
.
length
()
!=
0
)
{
if
(
fullname
==
null
||
fullname
.
length
()
==
0
)
continue
;
int
idx
=
fullname
.
toLowerCase
().
indexOf
(
table
.
toLowerCase
());
if
(
idx
!=
-
1
)
{
if
(
idx
==
-
1
)
continue
;
String
cname
=
fullname
.
substring
(
idx
+
table
.
length
()
+
1
);
out
.
put
(
"columnName"
,
cname
);
out
.
put
(
"tableName"
,
table
);
return
true
;
}
}
}
}
}
return
false
;
}
else
{
return
false
;
}
}
else
{
return
false
;
}
}
public
String
getFieldTableName
(
String
sql
,
String
field
,
String
dbType
)
{
try
{
String
tableName
=
""
;
List
<
SQLStatement
>
stmtList
=
SQLUtils
.
parseStatements
(
sql
,
dbType
);
SchemaStatVisitor
visitor
=
SQLUtils
.
createSchemaStatVisitor
(
DbType
.
of
(
dbType
));
SQLStatement
sqlStatement
=
(
SQLStatement
)
stmtList
.
get
(
0
);
sqlStatement
.
accept
(
visitor
);
SQLStatement
sqlStatement
=
stmtList
.
get
(
0
);
sqlStatement
.
accept
((
SQLASTVisitor
)
visitor
);
Collection
<
TableStat
.
Column
>
columns
=
visitor
.
getColumns
();
for
(
TableStat
.
Column
column
:
columns
)
{
for
(
TableStat
.
Column
column
:
columns
)
{
if
(
column
.
getName
().
equalsIgnoreCase
(
field
))
{
tableName
=
column
.
getTable
();
break
;
}
}
if
((
tableName
==
null
||
tableName
.
length
()
==
0
)
&&
columns
.
size
()
>
0
)
{
tableName
=
((
TableStat
.
Column
)
columns
.
iterator
().
next
()).
getTable
();
}
if
(
tableName
.
contains
(
"."
))
{
if
((
tableName
==
null
||
tableName
.
length
()
==
0
)
&&
columns
.
size
()
>
0
)
tableName
=
((
TableStat
.
Column
)
columns
.
iterator
().
next
()).
getTable
();
if
(
tableName
.
contains
(
"."
))
tableName
=
tableName
.
split
(
"\\."
)[
1
];
}
return
tableName
;
}
catch
(
Exception
var11
)
{
}
catch
(
Exception
e
)
{
return
null
;
}
}
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
;
}
else
if
(
value
!=
null
&&
(!(
value
instanceof
String
)
||
!
StringUtils
.
isBlank
((
String
)
value
)))
{
String
encPrefix
=
EncryptionGatewayManager
.
getParameterValue
(
"encryption.label"
);
if
(
value
.
toString
().
contains
(
encPrefix
)
&&
GatewayContext
.
isCurrentUserCanSeeDecInfo
())
{
String
sqlTemplate
=
this
.
getSqlTemplate
(
resultSetInformation
);
RuleLoadUtil
.
writeLog
(
"@@
插件@@---TestJdbcEventListener--columnIndex--解密前的值:
"
+
value
);
value
=
this
.
getDecData
(
value
,
sqlTemplate
,
columnIndex
,
encPrefix
);
RuleLoadUtil
.
writeLog
(
"@@
插件@@---TestJdbcEventListener--columnIndex--解密后的值:
"
+
value
);
String
sqlTemplate
=
getSqlTemplate
(
resultSetInformation
);
RuleLoadUtil
.
writeLog
(
"@@"
+
value
);
value
=
getDecData
(
value
,
sqlTemplate
,
Integer
.
valueOf
(
columnIndex
)
,
encPrefix
);
RuleLoadUtil
.
writeLog
(
"@@"
+
value
);
}
if
(!
EncryptionGatewayManager
.
checkParameterFlag
(
"maskingRule"
))
{
if
(!
EncryptionGatewayManager
.
checkParameterFlag
(
"maskingRule"
))
return
value
;
}
else
{
ResultSetMetaData
metaData
=
resultSetInformation
.
getResultSet
().
getMetaData
();
String
schema
=
resultSetInformation
.
getResultSet
().
getMetaData
().
getCatalogName
(
columnIndex
);
String
tableName
=
metaData
.
getTableName
(
columnIndex
);
String
columnName
=
metaData
.
getColumnLabel
(
columnIndex
);
String
columnType
=
metaData
.
getColumnTypeName
(
columnIndex
);
if
(
columnName
==
null
||
""
.
equals
(
columnName
))
{
if
(
columnName
==
null
||
""
.
equals
(
columnName
))
columnName
=
metaData
.
getColumnName
(
columnIndex
);
}
Connection
connection
=
resultSetInformation
.
getConnectionInformation
().
getConnection
();
String
urlTemp
=
connection
.
getMetaData
().
getURL
();
Map
<
String
,
String
>
ipAndPortMap
=
getIpAndPort
(
urlTemp
);
String
ip
=
(
String
)
ipAndPortMap
.
get
(
"ip"
);
String
port
=
(
String
)
ipAndPortMap
.
get
(
"port"
);
String
ip
=
ipAndPortMap
.
get
(
"ip"
);
String
port
=
ipAndPortMap
.
get
(
"port"
);
String
driverName
=
resultSetInformation
.
getConnectionInformation
().
getConnection
().
getMetaData
().
getDriverName
();
String
urlDbType
=
resultSetInformation
.
getConnectionInformation
().
getUrl
();
String
dbType
=
""
;
dbType
=
ConnectionWrapper
.
getDbType
(
driverName
,
urlDbType
,
dbType
);
if
(!
"oracle"
.
equals
(
dbType
))
{
if
(!
"postgresql"
.
equals
(
dbType
)
&&
!
"greenplum"
.
equals
(
dbType
)
&&
!
"gauss"
.
equals
(
dbType
))
{
if
(
"sql server"
.
equals
(
dbType
))
{
if
(
"oracle"
.
equals
(
dbType
))
{
int
i
;
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
();
if
(
url
.
indexOf
(
"applicationName"
)
>
0
)
{
schema
=
url
.
substring
(
url
.
indexOf
(
"applicationName"
)
+
"applicationName"
.
length
()
+
1
);
if
(
schema
.
indexOf
(
";"
)
!=
-
1
)
{
if
(
schema
.
indexOf
(
";"
)
!=
-
1
)
schema
=
schema
.
substring
(
0
,
schema
.
indexOf
(
";"
));
}
}
else
{
schema
=
"dbo"
;
}
...
...
@@ -654,7 +643,7 @@ public class TestJdbcEventListener extends JdbcEventListener {
}
else
{
int
from
=
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
(
"/"
);
schema
=
address
.
substring
(
idx
+
1
);
}
...
...
@@ -678,181 +667,77 @@ public class TestJdbcEventListener extends JdbcEventListener {
String
url
=
connection
.
getMetaData
().
getURL
();
int
from
=
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
(
"/"
);
schema
=
address
.
substring
(
idx
+
1
);
}
else
if
(
"mariadb"
.
equals
(
dbType
))
{
String
url
=
connection
.
getMetaData
().
getURL
();
int
from
=
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
(
"/"
);
schema
=
address
.
substring
(
idx
+
1
);
}
else
if
(
"hive"
.
equals
(
dbType
))
{
String
url
=
connection
.
getMetaData
().
getURL
();
int
from
=
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
(
"/"
);
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"
;
}
}
}
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
)
{
if
(
value
==
null
)
return
value
;
}
else
{
if
(!
"oracle"
.
equals
(
dbType
))
{
Map
<
String
,
String
>
map
=
this
.
getColumnNameAndTableNameByAlisaName
(
resultSetInformation
,
dbType
,
schema
,
tableName
,
columnName
);
columnName
=
(
String
)
map
.
get
(
"columnName"
);
tableName
=
(
String
)
map
.
get
(
"tableName"
);
schema
=
(
String
)
map
.
get
(
"schema"
);
Map
<
String
,
String
>
map
=
getColumnNameAndTableNameByAlisaName
(
resultSetInformation
,
dbType
,
schema
,
tableName
,
columnName
);
columnName
=
map
.
get
(
"columnName"
);
tableName
=
map
.
get
(
"tableName"
);
schema
=
map
.
get
(
"schema"
);
}
String
mathKey
=
(
ip
+
"_"
+
port
+
"_"
+
schema
+
"_"
+
tableName
+
"_"
+
columnName
).
toLowerCase
().
replace
(
"`"
,
""
).
replace
(
"\""
,
""
);
RuleLoadUtil
.
writeLog
(
"@@插件@@---TestJdbcEventListener--columnIndex--mathKey:
"
+
mathKey
);
if
(
EngineUtil
.
encryptionMap
.
isEmpty
())
{
RuleLoadUtil
.
writeLog
(
"@@
"
+
mathKey
);
if
(
EngineUtil
.
encryptionMap
.
isEmpty
())
EngineUtil
.
keyCacheFromFile
();
}
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
{
Columninfo
map
=
(
Columninfo
)
EngineUtil
.
encryptionMap
.
get
(
mathKey
);
RuleLoadUtil
.
writeLog
(
"@@插件@@---TestJdbcEventListener--columnIndex--解密前的值:
"
+
value
);
value
=
EngineUtil
.
exeEngine
(
map
,
(
ConnectionInfo
)
null
,
true
,
value
,
false
);
RuleLoadUtil
.
writeLog
(
"@@插件@@---TestJdbcEventListener--columnIndex--解密后的值:
"
+
value
);
Columninfo
map
=
(
Columninfo
)
EngineUtil
.
encryptionMap
.
get
(
mathKey
);
RuleLoadUtil
.
writeLog
(
"@@
"
+
value
);
value
=
EngineUtil
.
exeEngine
(
map
,
null
,
Boolean
.
valueOf
(
true
),
value
,
Boolean
.
valueOf
(
false
)
);
RuleLoadUtil
.
writeLog
(
"@@
"
+
value
);
}
catch
(
Exception
e1
)
{
e1
.
printStackTrace
();
throw
new
SQLException
(
e1
);
}
finally
{
;
}
}
boolean
ismaksing
=
EngineUtil
.
maskingmap
.
containsKey
(
mathKey
);
if
(
ismaksing
&&
GatewayContext
.
isCurrentUserNeedMask
())
{
if
(
ismaksing
&&
GatewayContext
.
isCurrentUserNeedMask
())
try
{
MaskingColumnInfo
map
=
(
MaskingColumnInfo
)
EngineUtil
.
maskingmap
.
get
(
mathKey
);
if
(
null
!=
map
&&
null
!=
map
.
getExpression
()
&&
!
map
.
getExpression
().
trim
().
equals
(
""
))
{
MaskingColumnInfo
map
=
(
MaskingColumnInfo
)
EngineUtil
.
maskingmap
.
get
(
mathKey
);
if
(
null
!=
map
&&
null
!=
map
.
getExpression
()
&&
!
map
.
getExpression
().
trim
().
equals
(
""
))
value
=
EngineUtil
.
exeMaskingEngine
(
map
,
value
);
}
}
catch
(
Exception
e1
)
{
e1
.
printStackTrace
();
throw
e1
;
}
finally
{
;
}
}
return
value
;
}
}
}
else
{
return
value
;
}
}
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
();
String
sqlTemp
=
statementInformation
.
getSql
();
if
(
sqlTemp
.
indexOf
(
"-- appUsername="
)
>
0
)
{
if
(
sqlTemp
.
indexOf
(
"-- appUsername="
)
>
0
)
sqlTemp
=
sqlTemp
.
substring
(
0
,
sqlTemp
.
indexOf
(
"-- appUsername="
)).
trim
();
}
List
<
Map
<
String
,
Object
>>
sqlParseList
=
(
List
)
ConnectionWrapper
.
sqlParseMap
.
get
(
sqlTemp
);
if
(
sqlParseList
==
null
||
sqlParseList
.
isEmpty
())
{
List
<
Map
<
String
,
Object
>>
sqlParseList
=
(
List
<
Map
<
String
,
Object
>>)
ConnectionWrapper
.
sqlParseMap
.
get
(
sqlTemp
);
if
(
sqlParseList
==
null
||
sqlParseList
.
isEmpty
())
sqlParseList
=
statementInformation
.
sqlParse
;
}
if
(
sqlParseList
==
null
||
sqlParseList
.
isEmpty
())
{
try
{
ConnectionInformation
connectionInformation
=
resultSetInformation
.
getConnectionInformation
();
String
sql
=
resultSetInformation
.
getStatementInformation
().
getStatementQuery
();
Map
<
String
,
String
>
params
=
new
HashMap
();
String
str1
=
resultSetInformation
.
getStatementInformation
().
getStatementQuery
();
Map
<
String
,
String
>
params
=
new
HashMap
<
String
,
String
>
();
params
.
put
(
"sql"
,
sqlTemp
);
params
.
put
(
"dbType"
,
dbType
);
params
.
put
(
"schema"
,
schema
);
...
...
@@ -867,47 +752,35 @@ public class TestJdbcEventListener extends JdbcEventListener {
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
if
(
sqlParseList
==
null
||
sqlParseList
.
isEmpty
())
{
return
new
HashMap
();
if
(
sqlParseList
==
null
||
sqlParseList
.
isEmpty
())
return
new
HashMap
<
String
,
String
>();
}
}
String
sql
=
statementInformation
.
getStatementQuery
().
toLowerCase
();
String
sqlAll
=
statementInformation
.
getSql
().
trim
();
if
(
sqlAll
.
endsWith
(
";"
))
{
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
)
{
for
(
i
=
0
;
i
<
splitSql
.
length
;
i
++
)
{
String
trim
=
splitSql
[
i
].
toLowerCase
().
trim
();
if
(
trim
.
startsWith
(
"select"
))
{
if
(
trim
.
startsWith
(
"select"
))
break
;
}
if
(
trim
.
contains
(
"*/"
))
{
int
index
=
trim
.
indexOf
(
"*/"
);
trim
=
trim
.
substring
(
index
+
2
).
trim
();
if
(
trim
.
startsWith
(
"select"
))
{
if
(
trim
.
startsWith
(
"select"
))
break
;
}
}
}
if
(
i
==
splitSql
.
length
)
{
if
(
i
==
splitSql
.
length
)
i
=
splitSql
.
length
-
1
;
}
}
Map
<
String
,
Object
>
sqlParse
=
(
Map
)
sqlParseList
.
get
(
i
);
List
<
Column
>
list
=
(
List
)
sqlParse
.
get
(
"columnList"
);
if
(
list
!=
null
&&
list
.
size
()
>
0
)
{
for
(
Column
column
:
list
)
{
Map
<
String
,
Object
>
sqlParse
=
sqlParseList
.
get
(
i
);
List
<
Column
>
list
=
(
List
<
Column
>)
sqlParse
.
get
(
"columnList"
);
if
(
list
!=
null
&&
list
.
size
()
>
0
)
for
(
Column
column
:
list
)
{
if
(
columnName
.
equalsIgnoreCase
(
column
.
getColumnAlisa
()))
{
String
[]
split
=
column
.
getColumnName
().
split
(
"\\."
);
if
(
split
.
length
==
2
)
{
...
...
@@ -915,60 +788,51 @@ public class TestJdbcEventListener extends JdbcEventListener {
}
else
{
map
.
put
(
"columnName"
,
column
.
getColumnName
().
replace
(
"\""
,
""
));
}
map
.
put
(
"tableName"
,
column
.
getTable
());
map
.
put
(
"schema"
,
column
.
getSchema
());
return
map
;
}
}
}
map
.
put
(
"columnName"
,
columnName
);
map
.
put
(
"tableName"
,
tableName
);
map
.
put
(
"schema"
,
schema
);
String
columnNameTmp
=
""
;
if
(
list
!=
null
&&
list
.
size
()
>
0
)
{
for
(
Column
column
:
list
)
{
if
(
list
!=
null
&&
list
.
size
()
>
0
)
for
(
Column
column
:
list
)
{
String
[]
split
=
column
.
getColumnName
().
split
(
"\\."
);
if
(
split
.
length
==
2
)
{
columnNameTmp
=
column
.
getColumnName
().
split
(
"\\."
)[
1
].
replace
(
"\""
,
""
);
}
else
{
columnNameTmp
=
column
.
getColumnName
().
replace
(
"\""
,
""
);
}
if
(
columnNameTmp
.
equalsIgnoreCase
(
columnName
))
{
map
.
put
(
"tableName"
,
column
.
getTable
());
map
.
put
(
"schema"
,
column
.
getSchema
());
}
}
}
return
map
;
}
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
desensitizationexpression
=
"Sm4Util:true"
;
List
<
TableInfo
>
tableinfoList
=
authBean
.
getTableInfo
();
for
(
int
i
=
0
;
i
<
tableinfoList
.
size
();
++
i
)
{
List
<
Columninfo
>
fieldinfoList
=
((
TableInfo
)
tableinfoList
.
get
(
i
)).
getColumninfo
();
String
maskingTableName
=
((
TableInfo
)
tableinfoList
.
get
(
i
)).
getTablename
();
for
(
int
i
=
0
;
i
<
tableinfoList
.
size
();
i
++)
{
List
<
Columninfo
>
fieldinfoList
=
((
TableInfo
)
tableinfoList
.
get
(
i
)).
getColumninfo
();
String
maskingTableName
=
((
TableInfo
)
tableinfoList
.
get
(
i
)).
getTablename
();
String
maskingSchemaName
=
authBean
.
getSchema
();
for
(
int
j
=
0
;
j
<
fieldinfoList
.
size
();
++
j
)
{
Boolean
flag
=
false
;
Columninfo
fieldinfo
=
(
Columninfo
)
fieldinfoList
.
get
(
j
);
for
(
int
j
=
0
;
j
<
fieldinfoList
.
size
();
j
++)
{
Boolean
flag
=
Boolean
.
valueOf
(
false
);
Columninfo
fieldinfo
=
fieldinfoList
.
get
(
j
);
maskingColumnname
=
fieldinfo
.
getColumnname
();
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
;
}
}
}
}
return
value
;
}
...
...
@@ -978,34 +842,28 @@ public class TestJdbcEventListener extends JdbcEventListener {
}
public
static
Map
<
String
,
String
>
getIpAndPort
(
String
url
)
{
Map
<
String
,
String
>
ipMap
=
(
Map
)
ipPortMap
.
get
(
url
);
if
(
ipMap
!=
null
&&
ipMap
.
size
()
>
0
)
{
Map
<
String
,
String
>
ipMap
=
ipPortMap
.
get
(
url
);
if
(
ipMap
!=
null
&&
ipMap
.
size
()
>
0
)
return
ipMap
;
}
else
{
Map
<
String
,
String
>
map
=
new
HashMap
(
2
);
Pattern
p
=
Pattern
.
compile
(
"(\\d+\\.\\d+\\.\\d+\\.\\d+)\\
:(\\d+)"
);
Map
<
String
,
String
>
map
=
new
HashMap
<
String
,
String
>(
2
);
// 修改后的代码 - 支持IP、localhost和域名
Pattern
p
=
Pattern
.
compile
(
"//([^:/\\s]+)
:(\\d+)"
);
Matcher
m
=
p
.
matcher
(
url
);
while
(
m
.
find
())
{
while
(
m
.
find
())
{
map
.
put
(
"ip"
,
m
.
group
(
1
));
map
.
put
(
"port"
,
m
.
group
(
2
));
}
if
(
null
!=
EncryptionGatewayManager
.
getParameterValue
(
"dataBase.ip"
)
&&
!
""
.
equals
(
EncryptionGatewayManager
.
getParameterValue
(
"dataBase.ip"
)))
{
map
.
put
(
"ip"
,
EncryptionGatewayManager
.
getParameterValue
(
"dataBase.ip"
));
map
.
put
(
"port"
,
EncryptionGatewayManager
.
getParameterValue
(
"dataBase.port"
));
}
ipPortMap
.
put
(
url
,
map
);
return
map
;
}
}
public
String
getSqlTemplate
(
ResultSetInformation
resultSetInformation
)
{
if
(
null
==
resultSetInformation
.
getSqlTemplate
()
||
""
.
equals
(
resultSetInformation
.
getSql
()))
{
if
(
null
==
resultSetInformation
.
getSqlTemplate
()
||
""
.
equals
(
resultSetInformation
.
getSql
()))
resultSetInformation
.
setSqlTemplate
(
resultSetInformation
.
getSql
());
}
return
resultSetInformation
.
getSqlTemplate
();
}
...
...
src/main/java/com/palacesun/engine/wrapper/PreparedStatementWrapper.java
View file @
1125fb35
...
...
@@ -3,6 +3,7 @@ package com.palacesun.engine.wrapper;
import
bean.Column
;
import
com.palacesun.engine.common.PreparedStatementInformation
;
import
com.palacesun.engine.common.ResultSetInformation
;
import
com.palacesun.engine.common.StatementInformation
;
import
com.palacesun.engine.event.JdbcEventListener
;
import
com.palacesun.engine.gateway.EncryptionGatewayManager
;
import
com.palacesun.engine.gateway.GatewayContext
;
...
...
@@ -58,207 +59,186 @@ import util.sqlparse.visitor.common.scope.ReplaceInfo;
public
class
PreparedStatementWrapper
extends
StatementWrapper
implements
PreparedStatement
{
private
final
PreparedStatement
delegate
;
private
final
PreparedStatementInformation
statementInformation
;
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_SEPARATOR
=
EncryptionGatewayManager
.
getParameterValue
(
"encryption.separator"
);
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
)
{
super
(
delegate
,
preparedStatementInformation
,
eventListener
);
super
(
delegate
,
(
StatementInformation
)
preparedStatementInformation
,
eventListener
);
this
.
delegate
=
delegate
;
this
.
statementInformation
=
preparedStatementInformation
;
if
(
this
.
statementInformation
.
context
==
null
)
{
this
.
statementInformation
.
context
=
new
AccessContext
(
this
.
statementInformation
);
}
if
(
this
.
statementInformation
.
context
==
null
)
this
.
statementInformation
.
context
=
new
AccessContext
((
StatementInformation
)
this
.
statementInformation
);
this
.
sqlBuffer
=
this
.
statementInformation
.
context
.
getBuffer
();
}
public
ResultSet
executeQuery
()
throws
SQLException
{
SQLException
e
=
null
;
long
start
=
System
.
nanoTime
();
ResultSet
var4
;
try
{
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
)
{
e
=
sqle
;
throw
sql
e
;
throw
e
;
}
finally
{
this
.
eventListener
.
onAfterExecuteQuery
(
this
.
statementInformation
,
System
.
nanoTime
()
-
start
,
e
);
}
return
var4
;
}
public
int
executeUpdate
()
throws
SQLException
{
SQLException
e
=
null
;
long
start
=
System
.
nanoTime
();
int
rowCount
=
0
;
int
var5
;
try
{
this
.
eventListener
.
onBeforeExecuteUpdate
(
this
.
statementInformation
);
rowCount
=
this
.
delegate
.
executeUpdate
();
var5
=
rowCount
;
return
rowCount
;
}
catch
(
SQLException
sqle
)
{
e
=
sqle
;
throw
sql
e
;
throw
e
;
}
finally
{
this
.
eventListener
.
onAfterExecuteUpdate
(
this
.
statementInformation
,
System
.
nanoTime
()
-
start
,
rowCount
,
e
);
}
return
var5
;
}
public
void
setNull
(
int
parameterIndex
,
int
sqlType
)
throws
SQLException
{
SQLException
e
=
null
;
try
{
parameterIndex
=
this
.
getParameterIndex
(
parameterIndex
);
parameterIndex
=
getParameterIndex
(
parameterIndex
);
this
.
sqlBuffer
.
setValueSqlType
(
0
,
parameterIndex
,
sqlType
);
this
.
delegate
.
setNull
(
parameterIndex
,
sqlType
);
}
catch
(
SQLException
sqle
)
{
e
=
sqle
;
throw
sql
e
;
throw
e
;
}
finally
{
this
.
eventListener
.
onAfterPreparedStatementSet
(
this
.
statementInformation
,
parameterIndex
,
null
,
e
);
}
}
public
void
setBoolean
(
int
parameterIndex
,
boolean
x
)
throws
SQLException
{
SQLException
e
=
null
;
try
{
parameterIndex
=
this
.
getParameterIndex
(
parameterIndex
);
this
.
sqlBuffer
.
setValue
(
1
,
parameterIndex
,
x
);
parameterIndex
=
getParameterIndex
(
parameterIndex
);
this
.
sqlBuffer
.
setValue
(
1
,
parameterIndex
,
Boolean
.
valueOf
(
x
)
);
this
.
delegate
.
setBoolean
(
parameterIndex
,
x
);
}
catch
(
SQLException
sqle
)
{
e
=
sqle
;
throw
sql
e
;
throw
e
;
}
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
{
SQLException
e
=
null
;
try
{
parameterIndex
=
this
.
getParameterIndex
(
parameterIndex
);
this
.
sqlBuffer
.
setValue
(
2
,
parameterIndex
,
x
);
parameterIndex
=
getParameterIndex
(
parameterIndex
);
this
.
sqlBuffer
.
setValue
(
2
,
parameterIndex
,
Byte
.
valueOf
(
x
)
);
this
.
delegate
.
setByte
(
parameterIndex
,
x
);
}
catch
(
SQLException
sqle
)
{
e
=
sqle
;
throw
sql
e
;
throw
e
;
}
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
{
SQLException
e
=
null
;
try
{
parameterIndex
=
this
.
getParameterIndex
(
parameterIndex
);
this
.
sqlBuffer
.
setValue
(
7
,
parameterIndex
,
x
);
parameterIndex
=
getParameterIndex
(
parameterIndex
);
this
.
sqlBuffer
.
setValue
(
7
,
parameterIndex
,
Short
.
valueOf
(
x
)
);
this
.
delegate
.
setShort
(
parameterIndex
,
x
);
}
catch
(
SQLException
sqle
)
{
e
=
sqle
;
throw
sql
e
;
throw
e
;
}
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
{
SQLException
e
=
null
;
try
{
parameterIndex
=
this
.
getParameterIndex
(
parameterIndex
);
this
.
sqlBuffer
.
setValue
(
4
,
parameterIndex
,
x
);
parameterIndex
=
getParameterIndex
(
parameterIndex
);
this
.
sqlBuffer
.
setValue
(
4
,
parameterIndex
,
Integer
.
valueOf
(
x
)
);
this
.
delegate
.
setInt
(
parameterIndex
,
x
);
}
catch
(
SQLException
sqle
)
{
e
=
sqle
;
throw
sql
e
;
throw
e
;
}
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
{
SQLException
e
=
null
;
try
{
parameterIndex
=
this
.
getParameterIndex
(
parameterIndex
);
this
.
sqlBuffer
.
setValue
(
3
,
parameterIndex
,
x
);
parameterIndex
=
getParameterIndex
(
parameterIndex
);
this
.
sqlBuffer
.
setValue
(
3
,
parameterIndex
,
Long
.
valueOf
(
x
)
);
this
.
delegate
.
setLong
(
parameterIndex
,
x
);
}
catch
(
SQLException
sqle
)
{
e
=
sqle
;
throw
sql
e
;
throw
e
;
}
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
{
SQLException
e
=
null
;
try
{
parameterIndex
=
this
.
getParameterIndex
(
parameterIndex
);
this
.
sqlBuffer
.
setValue
(
5
,
parameterIndex
,
x
);
parameterIndex
=
getParameterIndex
(
parameterIndex
);
this
.
sqlBuffer
.
setValue
(
5
,
parameterIndex
,
Float
.
valueOf
(
x
)
);
this
.
delegate
.
setFloat
(
parameterIndex
,
x
);
}
catch
(
SQLException
sqle
)
{
e
=
sqle
;
throw
sql
e
;
throw
e
;
}
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
{
SQLException
e
=
null
;
try
{
parameterIndex
=
this
.
getParameterIndex
(
parameterIndex
);
this
.
sqlBuffer
.
setValue
(
6
,
parameterIndex
,
x
);
parameterIndex
=
getParameterIndex
(
parameterIndex
);
this
.
sqlBuffer
.
setValue
(
6
,
parameterIndex
,
Double
.
valueOf
(
x
)
);
this
.
delegate
.
setDouble
(
parameterIndex
,
x
);
}
catch
(
SQLException
sqle
)
{
e
=
sqle
;
throw
sql
e
;
throw
e
;
}
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
{
SQLException
e
=
null
;
try
{
parameterIndex
=
this
.
getParameterIndex
(
parameterIndex
);
parameterIndex
=
getParameterIndex
(
parameterIndex
);
this
.
sqlBuffer
.
setValue
(
8
,
parameterIndex
,
x
);
this
.
delegate
.
setBigDecimal
(
parameterIndex
,
x
);
}
catch
(
SQLException
sqle
)
{
e
=
sqle
;
throw
sql
e
;
throw
e
;
}
finally
{
this
.
eventListener
.
onAfterPreparedStatementSet
(
this
.
statementInformation
,
parameterIndex
,
x
,
e
);
}
}
private
int
getParameterIndex
(
int
parameterIndex
)
{
...
...
@@ -266,22 +246,16 @@ public class PreparedStatementWrapper extends StatementWrapper implements Prepar
boolean
where
=
false
;
Map
<
String
,
Integer
>
digestMap
=
this
.
statementInformation
.
getDigestMap
();
if
(!
digestMap
.
isEmpty
())
{
for
(
String
key
:
digestMap
.
keySet
())
{
Integer
value
=
(
Integer
)
digestMap
.
get
(
key
);
if
(
value
<
whereLocation
)
{
whereLocation
=
value
;
for
(
String
key
:
digestMap
.
keySet
())
{
Integer
value
=
digestMap
.
get
(
key
);
if
(
value
.
intValue
()
<
whereLocation
)
whereLocation
=
value
.
intValue
()
;
}
}
if
(
parameterIndex
>=
whereLocation
)
{
if
(
parameterIndex
>=
whereLocation
)
where
=
true
;
}
}
if
(
where
)
{
if
(
where
)
parameterIndex
+=
digestMap
.
size
();
}
return
parameterIndex
;
}
...
...
@@ -293,26 +267,24 @@ public class PreparedStatementWrapper extends StatementWrapper implements Prepar
boolean
where
=
false
;
String
tableAndColumnName
=
null
;
String
mathKey
=
null
;
try
{
String
sql
=
this
.
statementInformation
.
getSql
();
boolean
needSqlParse
=
DbCache
.
isNeedSqlParse
(
sql
,
this
.
statementInformation
);
RuleLoadUtil
.
writeLog
(
"@@插件@@---PreparedstatementWrapper解析setString-->"
+
sql
);
RuleLoadUtil
.
writeLog
(
"@@插件@@---PreparedstatementWrapper解析setString-needSqlParse->"
+
needSqlParse
);
boolean
needSqlParse
=
DbCache
.
isNeedSqlParse
(
sql
,
(
StatementInformation
)
this
.
statementInformation
);
RuleLoadUtil
.
writeLog
(
"@@"
+
sql
);
RuleLoadUtil
.
writeLog
(
"@@"
+
needSqlParse
);
if
(!
needSqlParse
)
{
this
.
sqlBuffer
.
setValue
(
9
,
parameterIndex
,
(
Object
)
x1
,
(
Object
)
x1
);
this
.
sqlBuffer
.
setValue
(
9
,
parameterIndex
,
x1
,
x1
);
this
.
delegate
.
setString
(
parameterIndex
,
x1
);
return
;
}
Columninfo
columninfo
=
(
Columninfo
)
sqlIndexKeyMap
.
get
(
sql
+
"_"
+
parameterIndex
);
Columninfo
columninfo
=
sqlIndexKeyMap
.
get
(
sql
+
"_"
+
parameterIndex
);
if
(
columninfo
==
null
)
{
map
=
this
.
encData
(
this
.
statementInformation
,
parameterIndex
,
x1
);
x
=
(
String
)
map
.
get
(
"x"
);
tableAndColumnName
=
(
String
)
map
.
get
(
"tableAndColumnName"
);
mathKey
=
(
String
)
map
.
get
(
"mathKey"
);
map
=
encData
(
this
.
statementInformation
,
parameterIndex
,
x1
);
x
=
map
.
get
(
"x"
);
tableAndColumnName
=
map
.
get
(
"tableAndColumnName"
);
mathKey
=
map
.
get
(
"mathKey"
);
}
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
();
mathKey
=
columninfo
.
getId
();
}
else
{
...
...
@@ -320,157 +292,135 @@ public class PreparedStatementWrapper extends StatementWrapper implements Prepar
tableAndColumnName
=
columninfo
.
getColumnname
();
mathKey
=
columninfo
.
getId
();
}
this
.
sqlBuffer
.
setValue
(
9
,
parameterIndex
,
(
Object
)
x
,
(
Object
)
x1
);
this
.
sqlBuffer
.
setValue
(
9
,
parameterIndex
,
x
,
x1
);
this
.
delegate
.
setString
(
parameterIndex
,
x
);
if
(
EngineUtil
.
digestMap
.
isEmpty
())
{
if
(
EngineUtil
.
digestMap
.
isEmpty
())
return
;
}
int
whereLocation
=
100000000
;
digestMap
=
this
.
statementInformation
.
getDigestMap
();
if
(!
digestMap
.
isEmpty
())
{
for
(
String
key
:
digestMap
.
keySet
())
{
Integer
value
=
(
Integer
)
digestMap
.
get
(
key
);
if
(
value
<
whereLocation
)
{
whereLocation
=
value
;
}
for
(
String
key
:
digestMap
.
keySet
())
{
Integer
value
=
digestMap
.
get
(
key
);
if
(
value
.
intValue
()
<
whereLocation
)
whereLocation
=
value
.
intValue
();
}
if
(
parameterIndex
>=
whereLocation
)
{
if
(
parameterIndex
>=
whereLocation
)
where
=
true
;
}
}
}
catch
(
Exception
exception
)
{
exception
.
printStackTrace
();
}
try
{
this
.
sqlBuffer
.
setValue
(
9
,
parameterIndex
,
(
Object
)
x
,
(
Object
)
x1
);
this
.
sqlBuffer
.
setValue
(
9
,
parameterIndex
,
x
,
x1
);
this
.
delegate
.
setString
(
parameterIndex
,
x
);
if
(!
digestMap
.
isEmpty
()
&&
!
where
&&
tableAndColumnName
!=
null
&&
digestMap
.
get
(
tableAndColumnName
)
!=
null
)
{
String
digestValue
=
this
.
abstractData
(
mathKey
,
x
);
this
.
sqlBuffer
.
setValue
(
9
,
(
Integer
)
digestMap
.
get
(
tableAndColumnName
),
(
Object
)
digestValue
,
null
);
this
.
delegate
.
setString
((
Integer
)
digestMap
.
get
(
tableAndColumnName
),
digestValue
);
String
digestValue
=
abstractData
(
mathKey
,
x
);
this
.
sqlBuffer
.
setValue
(
9
,
((
Integer
)
digestMap
.
get
(
tableAndColumnName
)).
intValue
(),
digestValue
,
null
);
this
.
delegate
.
setString
(((
Integer
)
digestMap
.
get
(
tableAndColumnName
)).
intValue
(
),
digestValue
);
}
}
catch
(
SQLException
sqle
)
{
e
=
sqle
;
throw
sql
e
;
throw
e
;
}
catch
(
Exception
ex
)
{
ex
.
printStackTrace
();
}
finally
{
this
.
eventListener
.
onAfterPreparedStatementSet
(
this
.
statementInformation
,
parameterIndex
,
x
,
e
);
}
}
public
void
setBytes
(
int
parameterIndex
,
byte
[]
x
)
throws
SQLException
{
SQLException
e
=
null
;
try
{
parameterIndex
=
this
.
getParameterIndex
(
parameterIndex
);
parameterIndex
=
getParameterIndex
(
parameterIndex
);
this
.
sqlBuffer
.
setValue
(
10
,
parameterIndex
,
x
);
this
.
delegate
.
setBytes
(
parameterIndex
,
x
);
}
catch
(
SQLException
sqle
)
{
e
=
sqle
;
throw
sql
e
;
throw
e
;
}
finally
{
this
.
eventListener
.
onAfterPreparedStatementSet
(
this
.
statementInformation
,
parameterIndex
,
x
,
e
);
}
}
public
void
setDate
(
int
parameterIndex
,
Date
x
)
throws
SQLException
{
SQLException
e
=
null
;
try
{
parameterIndex
=
this
.
getParameterIndex
(
parameterIndex
);
parameterIndex
=
getParameterIndex
(
parameterIndex
);
this
.
sqlBuffer
.
setValue
(
11
,
parameterIndex
,
x
);
this
.
delegate
.
setDate
(
parameterIndex
,
x
);
}
catch
(
SQLException
sqle
)
{
e
=
sqle
;
throw
sql
e
;
throw
e
;
}
finally
{
this
.
eventListener
.
onAfterPreparedStatementSet
(
this
.
statementInformation
,
parameterIndex
,
x
,
e
);
}
}
public
void
setTime
(
int
parameterIndex
,
Time
x
)
throws
SQLException
{
SQLException
e
=
null
;
try
{
parameterIndex
=
this
.
getParameterIndex
(
parameterIndex
);
parameterIndex
=
getParameterIndex
(
parameterIndex
);
this
.
sqlBuffer
.
setValue
(
12
,
parameterIndex
,
x
);
this
.
delegate
.
setTime
(
parameterIndex
,
x
);
}
catch
(
SQLException
sqle
)
{
e
=
sqle
;
throw
sql
e
;
throw
e
;
}
finally
{
this
.
eventListener
.
onAfterPreparedStatementSet
(
this
.
statementInformation
,
parameterIndex
,
x
,
e
);
}
}
public
void
setTimestamp
(
int
parameterIndex
,
Timestamp
x
)
throws
SQLException
{
SQLException
e
=
null
;
try
{
parameterIndex
=
this
.
getParameterIndex
(
parameterIndex
);
parameterIndex
=
getParameterIndex
(
parameterIndex
);
this
.
sqlBuffer
.
setValue
(
13
,
parameterIndex
,
x
);
this
.
delegate
.
setTimestamp
(
parameterIndex
,
x
);
}
catch
(
SQLException
sqle
)
{
e
=
sqle
;
throw
sql
e
;
throw
e
;
}
finally
{
this
.
eventListener
.
onAfterPreparedStatementSet
(
this
.
statementInformation
,
parameterIndex
,
x
,
e
);
}
}
public
void
setAsciiStream
(
int
parameterIndex
,
InputStream
x
,
int
length
)
throws
SQLException
{
SQLException
e
=
null
;
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
);
}
catch
(
SQLException
sqle
)
{
e
=
sqle
;
throw
sql
e
;
throw
e
;
}
finally
{
this
.
eventListener
.
onAfterPreparedStatementSet
(
this
.
statementInformation
,
parameterIndex
,
x
,
e
);
}
}
public
void
setUnicodeStream
(
int
parameterIndex
,
InputStream
x
,
int
length
)
throws
SQLException
{
SQLException
e
=
null
;
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
);
}
catch
(
SQLException
sqle
)
{
e
=
sqle
;
throw
sql
e
;
throw
e
;
}
finally
{
this
.
eventListener
.
onAfterPreparedStatementSet
(
this
.
statementInformation
,
parameterIndex
,
x
,
e
);
}
}
public
void
setBinaryStream
(
int
parameterIndex
,
InputStream
x
,
int
length
)
throws
SQLException
{
SQLException
e
=
null
;
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
);
}
catch
(
SQLException
sqle
)
{
e
=
sqle
;
throw
sql
e
;
throw
e
;
}
finally
{
this
.
eventListener
.
onAfterPreparedStatementSet
(
this
.
statementInformation
,
parameterIndex
,
x
,
e
);
}
}
public
void
clearParameters
()
throws
SQLException
{
...
...
@@ -485,21 +435,20 @@ public class PreparedStatementWrapper extends StatementWrapper implements Prepar
boolean
where
=
false
;
String
tableAndColumnName
=
null
;
String
mathKey
=
null
;
try
{
String
sql
=
this
.
statementInformation
.
getSql
();
Columninfo
columninfo
=
(
Columninfo
)
sqlIndexKeyMap
.
get
(
sql
+
"_"
+
parameterIndex
);
Columninfo
columninfo
=
sqlIndexKeyMap
.
get
(
sql
+
"_"
+
parameterIndex
);
if
(
columninfo
==
null
)
{
if
(
x1
instanceof
String
)
{
map
=
this
.
encData
(
this
.
statementInformation
,
parameterIndex
,
x1
.
toString
());
map
=
encData
(
this
.
statementInformation
,
parameterIndex
,
x1
.
toString
());
x
=
map
.
get
(
"x"
);
tableAndColumnName
=
(
String
)
map
.
get
(
"tableAndColumnName"
);
mathKey
=
(
String
)
map
.
get
(
"mathKey"
);
tableAndColumnName
=
map
.
get
(
"tableAndColumnName"
);
mathKey
=
map
.
get
(
"mathKey"
);
}
else
{
x
=
x1
;
}
}
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
();
mathKey
=
columninfo
.
getId
();
}
else
{
...
...
@@ -507,43 +456,34 @@ public class PreparedStatementWrapper extends StatementWrapper implements Prepar
tableAndColumnName
=
columninfo
.
getColumnname
();
mathKey
=
columninfo
.
getId
();
}
this
.
sqlBuffer
.
setValue
(-
1
,
parameterIndex
,
(
Object
)
x
,
(
Object
)
x1
,
targetSqlType
);
this
.
sqlBuffer
.
setValue
(-
1
,
parameterIndex
,
x
,
x1
,
targetSqlType
);
this
.
delegate
.
setObject
(
parameterIndex
,
x
,
targetSqlType
);
if
(!
EngineUtil
.
digestMap
.
isEmpty
())
{
if
(
EngineUtil
.
digestMap
.
isEmpty
())
return
;
int
whereLocation
=
100000000
;
digestMap
=
this
.
statementInformation
.
getDigestMap
();
if
(!
digestMap
.
isEmpty
())
{
for
(
String
key
:
digestMap
.
keySet
())
{
Integer
value
=
(
Integer
)
digestMap
.
get
(
key
);
if
(
value
<
whereLocation
)
{
whereLocation
=
value
;
}
for
(
String
key
:
digestMap
.
keySet
())
{
Integer
value
=
digestMap
.
get
(
key
);
if
(
value
.
intValue
()
<
whereLocation
)
whereLocation
=
value
.
intValue
();
}
if
(
parameterIndex
>=
whereLocation
)
{
if
(
parameterIndex
>=
whereLocation
)
where
=
true
;
}
}
if
(!
digestMap
.
isEmpty
()
&&
!
where
&&
tableAndColumnName
!=
null
&&
digestMap
.
get
(
tableAndColumnName
)
!=
null
)
{
String
digestValue
=
this
.
abstractData
(
mathKey
,
x
.
toString
());
this
.
sqlBuffer
.
setValue
(-
1
,
(
Integer
)
digestMap
.
get
(
tableAndColumnName
),
(
Object
)
digestValue
,
null
);
this
.
delegate
.
setString
((
Integer
)
digestMap
.
get
(
tableAndColumnName
),
digestValue
);
}
return
;
String
digestValue
=
abstractData
(
mathKey
,
x
.
toString
());
this
.
sqlBuffer
.
setValue
(-
1
,
((
Integer
)
digestMap
.
get
(
tableAndColumnName
)).
intValue
(),
digestValue
,
null
);
this
.
delegate
.
setString
(((
Integer
)
digestMap
.
get
(
tableAndColumnName
)).
intValue
(),
digestValue
);
}
}
catch
(
SQLException
sqle
)
{
e
=
sqle
;
throw
sql
e
;
throw
e
;
}
catch
(
Exception
ex
)
{
ex
.
printStackTrace
();
return
;
}
finally
{
this
.
eventListener
.
onAfterPreparedStatementSet
(
this
.
statementInformation
,
parameterIndex
,
x
,
e
);
}
}
public
void
setObject
(
int
parameterIndex
,
Object
x1
)
throws
SQLException
{
...
...
@@ -554,23 +494,26 @@ public class PreparedStatementWrapper extends StatementWrapper implements Prepar
boolean
where
=
false
;
String
tableAndColumnName
=
null
;
String
mathKey
=
null
;
try
{
String
sql
=
this
.
statementInformation
.
getSql
();
boolean
needSqlParse
=
DbCache
.
isNeedSqlParse
(
sql
,
this
.
statementInformation
);
if
(
needSqlParse
)
{
Columninfo
columninfo
=
(
Columninfo
)
sqlIndexKeyMap
.
get
(
sql
+
"_"
+
parameterIndex
);
boolean
needSqlParse
=
DbCache
.
isNeedSqlParse
(
sql
,
(
StatementInformation
)
this
.
statementInformation
);
if
(!
needSqlParse
)
{
this
.
sqlBuffer
.
setValue
(-
1
,
parameterIndex
,
x1
,
x1
);
this
.
delegate
.
setObject
(
parameterIndex
,
x1
);
return
;
}
Columninfo
columninfo
=
sqlIndexKeyMap
.
get
(
sql
+
"_"
+
parameterIndex
);
if
(
columninfo
==
null
)
{
if
(
x1
instanceof
String
)
{
map
=
this
.
encData
(
this
.
statementInformation
,
parameterIndex
,
x1
.
toString
());
map
=
encData
(
this
.
statementInformation
,
parameterIndex
,
x1
.
toString
());
x
=
map
.
get
(
"x"
);
tableAndColumnName
=
(
String
)
map
.
get
(
"tableAndColumnName"
);
mathKey
=
(
String
)
map
.
get
(
"mathKey"
);
tableAndColumnName
=
map
.
get
(
"tableAndColumnName"
);
mathKey
=
map
.
get
(
"mathKey"
);
}
else
{
x
=
x1
;
}
}
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
();
mathKey
=
columninfo
.
getId
();
}
else
{
...
...
@@ -578,419 +521,349 @@ public class PreparedStatementWrapper extends StatementWrapper implements Prepar
tableAndColumnName
=
columninfo
.
getColumnname
();
mathKey
=
columninfo
.
getId
();
}
this
.
sqlBuffer
.
setValue
(-
1
,
parameterIndex
,
(
Object
)
x
,
(
Object
)
x1
);
this
.
sqlBuffer
.
setValue
(-
1
,
parameterIndex
,
x
,
x1
);
this
.
delegate
.
setObject
(
parameterIndex
,
x
);
if
(
EngineUtil
.
digestMap
.
isEmpty
())
{
if
(
EngineUtil
.
digestMap
.
isEmpty
())
return
;
}
int
whereLocation
=
100000000
;
digestMap
=
this
.
statementInformation
.
getDigestMap
();
if
(!
digestMap
.
isEmpty
())
{
for
(
String
key
:
digestMap
.
keySet
())
{
Integer
value
=
(
Integer
)
digestMap
.
get
(
key
);
if
(
value
<
whereLocation
)
{
whereLocation
=
value
;
}
for
(
String
key
:
digestMap
.
keySet
())
{
Integer
value
=
digestMap
.
get
(
key
);
if
(
value
.
intValue
()
<
whereLocation
)
whereLocation
=
value
.
intValue
();
}
if
(
parameterIndex
>=
whereLocation
)
{
if
(
parameterIndex
>=
whereLocation
)
where
=
true
;
}
}
if
(!
digestMap
.
isEmpty
()
&&
!
where
&&
tableAndColumnName
!=
null
&&
digestMap
.
get
(
tableAndColumnName
)
!=
null
)
{
String
digestValue
=
this
.
abstractData
(
mathKey
,
x
.
toString
());
this
.
sqlBuffer
.
setValue
(-
1
,
(
Integer
)
digestMap
.
get
(
tableAndColumnName
),
(
Object
)
digestValue
,
null
);
this
.
delegate
.
setString
((
Integer
)
digestMap
.
get
(
tableAndColumnName
),
digestValue
);
String
digestValue
=
abstractData
(
mathKey
,
x
.
toString
());
this
.
sqlBuffer
.
setValue
(-
1
,
((
Integer
)
digestMap
.
get
(
tableAndColumnName
)).
intValue
(),
digestValue
,
null
);
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
)
{
e
=
sqle
;
throw
sql
e
;
throw
e
;
}
catch
(
Exception
ex
)
{
ex
.
printStackTrace
();
return
;
}
finally
{
this
.
eventListener
.
onAfterPreparedStatementSet
(
this
.
statementInformation
,
parameterIndex
,
x
,
e
);
}
}
public
boolean
execute
()
throws
SQLException
{
SQLException
e
=
null
;
long
start
=
System
.
nanoTime
();
boolean
var4
;
try
{
this
.
eventListener
.
onBeforeExecute
(
this
.
statementInformation
);
var4
=
this
.
delegate
.
execute
();
return
this
.
delegate
.
execute
();
}
catch
(
SQLException
sqle
)
{
e
=
sqle
;
throw
sql
e
;
throw
e
;
}
finally
{
this
.
eventListener
.
onAfterExecute
(
this
.
statementInformation
,
System
.
nanoTime
()
-
start
,
e
);
}
return
var4
;
}
public
void
addBatch
()
throws
SQLException
{
SQLException
e
=
null
;
long
start
=
System
.
nanoTime
();
try
{
this
.
eventListener
.
onBeforeAddBatch
(
this
.
statementInformation
);
this
.
delegate
.
addBatch
();
}
catch
(
SQLException
sqle
)
{
e
=
sqle
;
throw
sql
e
;
throw
e
;
}
finally
{
this
.
eventListener
.
onAfterAddBatch
(
this
.
statementInformation
,
System
.
nanoTime
()
-
start
,
e
);
}
}
public
void
setCharacterStream
(
int
parameterIndex
,
Reader
reader
,
int
length
)
throws
SQLException
{
SQLException
e
=
null
;
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
);
}
catch
(
SQLException
sqle
)
{
e
=
sqle
;
throw
sql
e
;
throw
e
;
}
finally
{
this
.
eventListener
.
onAfterPreparedStatementSet
(
this
.
statementInformation
,
parameterIndex
,
reader
,
e
);
}
}
public
void
setRef
(
int
parameterIndex
,
Ref
x
)
throws
SQLException
{
SQLException
e
=
null
;
try
{
this
.
sqlBuffer
.
setValue
(
16
,
parameterIndex
,
x
);
this
.
delegate
.
setRef
(
parameterIndex
,
x
);
}
catch
(
SQLException
sqle
)
{
e
=
sqle
;
throw
sql
e
;
throw
e
;
}
finally
{
this
.
eventListener
.
onAfterPreparedStatementSet
(
this
.
statementInformation
,
parameterIndex
,
x
,
e
);
}
}
public
void
setBlob
(
int
parameterIndex
,
Blob
x
)
throws
SQLException
{
SQLException
e
=
null
;
try
{
this
.
sqlBuffer
.
setValue
(
18
,
parameterIndex
,
x
);
this
.
delegate
.
setBlob
(
parameterIndex
,
x
);
}
catch
(
SQLException
sqle
)
{
e
=
sqle
;
throw
sql
e
;
throw
e
;
}
finally
{
this
.
eventListener
.
onAfterPreparedStatementSet
(
this
.
statementInformation
,
parameterIndex
,
x
,
e
);
}
}
public
void
setClob
(
int
parameterIndex
,
Clob
x2
)
throws
SQLException
{
SQLException
e
=
null
;
String
x
=
null
;
String
x1
=
null
;
try
{
x1
=
this
.
clobToString
(
x2
);
x1
=
clobToString
(
x2
);
}
catch
(
Exception
exception
)
{
exception
.
printStackTrace
();
}
Map
<
String
,
Integer
>
digestMap
=
null
;
Map
<
String
,
String
>
map
=
null
;
boolean
where
=
false
;
try
{
map
=
this
.
encData
(
this
.
statementInformation
,
parameterIndex
,
x1
);
x
=
(
String
)
map
.
get
(
"x"
);
map
=
encData
(
this
.
statementInformation
,
parameterIndex
,
x1
);
x
=
map
.
get
(
"x"
);
int
whereLocation
=
100000000
;
digestMap
=
this
.
statementInformation
.
getDigestMap
();
if
(!
digestMap
.
isEmpty
())
{
for
(
String
key
:
digestMap
.
keySet
())
{
Integer
value
=
(
Integer
)
digestMap
.
get
(
key
);
if
(
value
<
whereLocation
)
{
whereLocation
=
value
;
}
for
(
String
key
:
digestMap
.
keySet
())
{
Integer
value
=
digestMap
.
get
(
key
);
if
(
value
.
intValue
()
<
whereLocation
)
whereLocation
=
value
.
intValue
();
}
if
(
parameterIndex
>=
whereLocation
)
{
if
(
parameterIndex
>=
whereLocation
)
where
=
true
;
}
}
}
catch
(
Exception
exception
)
{
exception
.
printStackTrace
();
}
try
{
this
.
sqlBuffer
.
setValue
(
9
,
parameterIndex
,
(
Object
)
x
,
(
Object
)
x1
);
this
.
sqlBuffer
.
setValue
(
9
,
parameterIndex
,
x
,
x1
);
this
.
delegate
.
setString
(
parameterIndex
,
x
);
RuleLoadUtil
.
writeLog
(
"@@插件@@---PreparedStatementWrapper--digestMap:"
+
digestMap
);
RuleLoadUtil
.
writeLog
(
"@@插件@@---PreparedStatementWrapper--where:"
+
where
);
if
(
digestMap
!=
null
&&
!
digestMap
.
isEmpty
()
&&
!
where
&&
map
!=
null
&&
map
.
get
(
"tableAndColumnName"
)
!=
null
&&
digestMap
.
get
(
map
.
get
(
"tableAndColumnName"
))
!=
null
)
{
RuleLoadUtil
.
writeLog
(
"@@"
+
digestMap
);
RuleLoadUtil
.
writeLog
(
"@@"
+
where
);
if
(
digestMap
!=
null
&&
!
digestMap
.
isEmpty
()
&&
!
where
&&
map
!=
null
&&
map
.
get
(
"tableAndColumnName"
)
!=
null
&&
digestMap
.
get
(
map
.
get
(
"tableAndColumnName"
))
!=
null
)
try
{
String
digestValue
=
this
.
abstractData
((
String
)
map
.
get
(
"mathKey"
),
x
);
this
.
sqlBuffer
.
setValue
(
9
,
(
Integer
)
digestMap
.
get
(
map
.
get
(
"tableAndColumnName"
)),
(
Object
)
digestValue
,
null
);
this
.
delegate
.
setString
((
Integer
)
digestMap
.
get
(
map
.
get
(
"tableAndColumnName"
)
),
digestValue
);
String
digestValue
=
abstractData
(
map
.
get
(
"mathKey"
),
x
);
this
.
sqlBuffer
.
setValue
(
9
,
((
Integer
)
digestMap
.
get
(
map
.
get
(
"tableAndColumnName"
))).
intValue
(),
digestValue
,
null
);
this
.
delegate
.
setString
(((
Integer
)
digestMap
.
get
(
map
.
get
(
"tableAndColumnName"
))).
intValue
(
),
digestValue
);
}
catch
(
Exception
exception
)
{
exception
.
printStackTrace
();
}
}
}
catch
(
SQLException
sqle
)
{
e
=
sqle
;
throw
sql
e
;
throw
e
;
}
finally
{
this
.
eventListener
.
onAfterPreparedStatementSet
(
this
.
statementInformation
,
parameterIndex
,
x
,
e
);
}
}
public
String
clobToString
(
Clob
clob
)
throws
Exception
{
StringWriter
writer
=
new
StringWriter
();
Reader
reader
=
null
;
try
{
reader
=
clob
.
getCharacterStream
();
char
[]
buffer
=
new
char
[
1024
];
int
bytesRead
;
while
((
bytesRead
=
reader
.
read
(
buffer
))
!=
-
1
)
{
while
((
bytesRead
=
reader
.
read
(
buffer
))
!=
-
1
)
writer
.
write
(
buffer
,
0
,
bytesRead
);
}
}
finally
{
if
(
reader
!=
null
)
{
if
(
reader
!=
null
)
reader
.
close
();
}
}
return
writer
.
toString
();
}
public
void
setArray
(
int
parameterIndex
,
Array
x
)
throws
SQLException
{
SQLException
e
=
null
;
try
{
this
.
sqlBuffer
.
setValue
(
20
,
parameterIndex
,
x
);
this
.
delegate
.
setArray
(
parameterIndex
,
x
);
}
catch
(
SQLException
sqle
)
{
e
=
sqle
;
throw
sql
e
;
throw
e
;
}
finally
{
this
.
eventListener
.
onAfterPreparedStatementSet
(
this
.
statementInformation
,
parameterIndex
,
x
,
e
);
}
}
public
void
setDate
(
int
parameterIndex
,
Date
x
,
Calendar
cal
)
throws
SQLException
{
SQLException
e
=
null
;
try
{
this
.
sqlBuffer
.
setValue
(
11
,
parameterIndex
,
(
Date
)
x
,
(
Calendar
)
cal
);
this
.
sqlBuffer
.
setValue
(
11
,
parameterIndex
,
x
,
cal
);
this
.
delegate
.
setDate
(
parameterIndex
,
x
,
cal
);
}
catch
(
SQLException
sqle
)
{
e
=
sqle
;
throw
sql
e
;
throw
e
;
}
finally
{
this
.
eventListener
.
onAfterPreparedStatementSet
(
this
.
statementInformation
,
parameterIndex
,
x
,
e
);
}
}
public
void
setTime
(
int
parameterIndex
,
Time
x
,
Calendar
cal
)
throws
SQLException
{
SQLException
e
=
null
;
try
{
this
.
sqlBuffer
.
setValue
(
12
,
parameterIndex
,
(
Time
)
x
,
(
Calendar
)
cal
);
this
.
sqlBuffer
.
setValue
(
12
,
parameterIndex
,
x
,
cal
);
this
.
delegate
.
setTime
(
parameterIndex
,
x
,
cal
);
}
catch
(
SQLException
sqle
)
{
e
=
sqle
;
throw
sql
e
;
throw
e
;
}
finally
{
this
.
eventListener
.
onAfterPreparedStatementSet
(
this
.
statementInformation
,
parameterIndex
,
x
,
e
);
}
}
public
void
setTimestamp
(
int
parameterIndex
,
Timestamp
x
,
Calendar
cal
)
throws
SQLException
{
SQLException
e
=
null
;
try
{
this
.
sqlBuffer
.
setValue
(
13
,
parameterIndex
,
(
Timestamp
)
x
,
(
Calendar
)
cal
);
this
.
sqlBuffer
.
setValue
(
13
,
parameterIndex
,
x
,
cal
);
this
.
delegate
.
setTimestamp
(
parameterIndex
,
x
,
cal
);
}
catch
(
SQLException
sqle
)
{
e
=
sqle
;
throw
sql
e
;
throw
e
;
}
finally
{
this
.
eventListener
.
onAfterPreparedStatementSet
(
this
.
statementInformation
,
parameterIndex
,
x
,
e
);
}
}
public
void
setNull
(
int
parameterIndex
,
int
sqlType
,
String
typeName
)
throws
SQLException
{
SQLException
e
=
null
;
try
{
this
.
sqlBuffer
.
setValue
(
0
,
parameterIndex
,
sqlType
,
typeName
);
this
.
delegate
.
setNull
(
parameterIndex
,
sqlType
,
typeName
);
}
catch
(
SQLException
sqle
)
{
e
=
sqle
;
throw
sql
e
;
throw
e
;
}
finally
{
this
.
eventListener
.
onAfterPreparedStatementSet
(
this
.
statementInformation
,
parameterIndex
,
null
,
e
);
}
}
public
void
setURL
(
int
parameterIndex
,
URL
x
)
throws
SQLException
{
SQLException
e
=
null
;
try
{
this
.
sqlBuffer
.
setValue
(
21
,
parameterIndex
,
x
);
this
.
delegate
.
setURL
(
parameterIndex
,
x
);
}
catch
(
SQLException
sqle
)
{
e
=
sqle
;
throw
sql
e
;
throw
e
;
}
finally
{
this
.
eventListener
.
onAfterPreparedStatementSet
(
this
.
statementInformation
,
parameterIndex
,
x
,
e
);
}
}
public
void
setRowId
(
int
parameterIndex
,
RowId
x
)
throws
SQLException
{
SQLException
e
=
null
;
try
{
this
.
sqlBuffer
.
setValue
(
17
,
parameterIndex
,
x
);
this
.
delegate
.
setRowId
(
parameterIndex
,
x
);
}
catch
(
SQLException
sqle
)
{
e
=
sqle
;
throw
sql
e
;
throw
e
;
}
finally
{
this
.
eventListener
.
onAfterPreparedStatementSet
(
this
.
statementInformation
,
parameterIndex
,
x
,
e
);
}
}
public
void
setNString
(
int
parameterIndex
,
String
value
)
throws
SQLException
{
SQLException
e
=
null
;
try
{
this
.
sqlBuffer
.
setValue
(
9
,
parameterIndex
,
value
);
this
.
delegate
.
setNString
(
parameterIndex
,
value
);
}
catch
(
SQLException
sqle
)
{
e
=
sqle
;
throw
sql
e
;
throw
e
;
}
finally
{
this
.
eventListener
.
onAfterPreparedStatementSet
(
this
.
statementInformation
,
parameterIndex
,
value
,
e
);
}
}
public
void
setNCharacterStream
(
int
parameterIndex
,
Reader
value
,
long
length
)
throws
SQLException
{
SQLException
e
=
null
;
try
{
this
.
sqlBuffer
.
setValue
(
15
,
parameterIndex
,
(
Reader
)
value
,
length
,
"string"
);
this
.
sqlBuffer
.
setValue
(
15
,
parameterIndex
,
value
,
length
,
"string"
);
this
.
delegate
.
setNCharacterStream
(
parameterIndex
,
value
,
length
);
}
catch
(
SQLException
sqle
)
{
e
=
sqle
;
throw
sql
e
;
throw
e
;
}
finally
{
this
.
eventListener
.
onAfterPreparedStatementSet
(
this
.
statementInformation
,
parameterIndex
,
value
,
e
);
}
}
public
void
setNClob
(
int
parameterIndex
,
NClob
value
)
throws
SQLException
{
SQLException
e
=
null
;
try
{
this
.
sqlBuffer
.
setValue
(
22
,
parameterIndex
,
value
);
this
.
delegate
.
setNClob
(
parameterIndex
,
value
);
}
catch
(
SQLException
sqle
)
{
e
=
sqle
;
throw
sql
e
;
throw
e
;
}
finally
{
this
.
eventListener
.
onAfterPreparedStatementSet
(
this
.
statementInformation
,
parameterIndex
,
value
,
e
);
}
}
public
void
setClob
(
int
parameterIndex
,
Reader
reader
,
long
length
)
throws
SQLException
{
SQLException
e
=
null
;
try
{
this
.
sqlBuffer
.
setValue
(
19
,
parameterIndex
,
(
Reader
)
reader
,
length
,
"string"
);
this
.
sqlBuffer
.
setValue
(
19
,
parameterIndex
,
reader
,
length
,
"string"
);
this
.
delegate
.
setClob
(
parameterIndex
,
reader
,
length
);
}
catch
(
SQLException
sqle
)
{
e
=
sqle
;
throw
sql
e
;
throw
e
;
}
finally
{
this
.
eventListener
.
onAfterPreparedStatementSet
(
this
.
statementInformation
,
parameterIndex
,
reader
,
e
);
}
}
public
void
setBlob
(
int
parameterIndex
,
InputStream
inputStream
,
long
length
)
throws
SQLException
{
SQLException
e
=
null
;
try
{
this
.
sqlBuffer
.
setValue
(
14
,
parameterIndex
,
(
InputStream
)
inputStream
,
length
,
"byte[]"
);
this
.
sqlBuffer
.
setValue
(
14
,
parameterIndex
,
inputStream
,
length
,
"byte[]"
);
this
.
delegate
.
setBlob
(
parameterIndex
,
inputStream
,
length
);
}
catch
(
SQLException
sqle
)
{
e
=
sqle
;
throw
sql
e
;
throw
e
;
}
finally
{
this
.
eventListener
.
onAfterPreparedStatementSet
(
this
.
statementInformation
,
parameterIndex
,
inputStream
,
e
);
}
}
public
void
setNClob
(
int
parameterIndex
,
Reader
reader
,
long
length
)
throws
SQLException
{
SQLException
e
=
null
;
try
{
this
.
sqlBuffer
.
setValue
(
15
,
parameterIndex
,
(
Reader
)
reader
,
length
,
"string"
);
this
.
sqlBuffer
.
setValue
(
15
,
parameterIndex
,
reader
,
length
,
"string"
);
this
.
delegate
.
setNClob
(
parameterIndex
,
reader
,
length
);
}
catch
(
SQLException
sqle
)
{
e
=
sqle
;
throw
sql
e
;
throw
e
;
}
finally
{
this
.
eventListener
.
onAfterPreparedStatementSet
(
this
.
statementInformation
,
parameterIndex
,
reader
,
e
);
}
}
public
void
setSQLXML
(
int
parameterIndex
,
SQLXML
xmlObject
)
throws
SQLException
{
SQLException
e
=
null
;
try
{
this
.
sqlBuffer
.
setValue
(
23
,
parameterIndex
,
xmlObject
);
this
.
delegate
.
setSQLXML
(
parameterIndex
,
xmlObject
);
}
catch
(
SQLException
sqle
)
{
e
=
sqle
;
throw
sql
e
;
throw
e
;
}
finally
{
this
.
eventListener
.
onAfterPreparedStatementSet
(
this
.
statementInformation
,
parameterIndex
,
xmlObject
,
e
);
}
}
public
void
setObject
(
int
parameterIndex
,
Object
x1
,
int
targetSqlType
,
int
scaleOrLength
)
throws
SQLException
{
...
...
@@ -1001,23 +874,26 @@ public class PreparedStatementWrapper extends StatementWrapper implements Prepar
boolean
where
=
false
;
String
tableAndColumnName
=
null
;
String
mathKey
=
null
;
try
{
String
sql
=
this
.
statementInformation
.
getSql
();
boolean
needSqlParse
=
DbCache
.
isNeedSqlParse
(
sql
,
this
.
statementInformation
);
if
(
needSqlParse
)
{
Columninfo
columninfo
=
(
Columninfo
)
sqlIndexKeyMap
.
get
(
sql
+
"_"
+
parameterIndex
);
boolean
needSqlParse
=
DbCache
.
isNeedSqlParse
(
sql
,
(
StatementInformation
)
this
.
statementInformation
);
if
(!
needSqlParse
)
{
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
(
x1
instanceof
String
)
{
map
=
this
.
encData
(
this
.
statementInformation
,
parameterIndex
,
x1
.
toString
());
map
=
encData
(
this
.
statementInformation
,
parameterIndex
,
x1
.
toString
());
x
=
map
.
get
(
"x"
);
tableAndColumnName
=
(
String
)
map
.
get
(
"tableAndColumnName"
);
mathKey
=
(
String
)
map
.
get
(
"mathKey"
);
tableAndColumnName
=
map
.
get
(
"tableAndColumnName"
);
mathKey
=
map
.
get
(
"mathKey"
);
}
else
{
x
=
x1
;
}
}
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
();
mathKey
=
columninfo
.
getId
();
}
else
{
...
...
@@ -1025,199 +901,164 @@ public class PreparedStatementWrapper extends StatementWrapper implements Prepar
tableAndColumnName
=
columninfo
.
getColumnname
();
mathKey
=
columninfo
.
getId
();
}
this
.
sqlBuffer
.
setValue
(-
1
,
parameterIndex
,
x
,
x1
,
targetSqlType
,
scaleOrLength
);
this
.
delegate
.
setObject
(
parameterIndex
,
x
,
targetSqlType
,
scaleOrLength
);
if
(
EngineUtil
.
digestMap
.
isEmpty
())
{
if
(
EngineUtil
.
digestMap
.
isEmpty
())
return
;
}
int
whereLocation
=
100000000
;
digestMap
=
this
.
statementInformation
.
getDigestMap
();
if
(!
digestMap
.
isEmpty
())
{
for
(
String
key
:
digestMap
.
keySet
())
{
Integer
value
=
(
Integer
)
digestMap
.
get
(
key
);
if
(
value
<
whereLocation
)
{
whereLocation
=
value
;
for
(
String
key
:
digestMap
.
keySet
())
{
Integer
value
=
digestMap
.
get
(
key
);
if
(
value
.
intValue
()
<
whereLocation
)
whereLocation
=
value
.
intValue
()
;
}
}
if
(
parameterIndex
>=
whereLocation
)
{
if
(
parameterIndex
>=
whereLocation
)
where
=
true
;
}
}
if
(!
digestMap
.
isEmpty
()
&&
!
where
&&
tableAndColumnName
!=
null
&&
digestMap
.
get
(
tableAndColumnName
)
!=
null
)
{
String
digestValue
=
this
.
abstractData
(
mathKey
,
x
.
toString
());
this
.
sqlBuffer
.
setValue
(-
1
,
(
Integer
)
digestMap
.
get
(
tableAndColumnName
),
(
Object
)
digestValue
,
null
);
this
.
delegate
.
setString
((
Integer
)
digestMap
.
get
(
tableAndColumnName
),
digestValue
);
}
return
;
String
digestValue
=
abstractData
(
mathKey
,
x
.
toString
());
this
.
sqlBuffer
.
setValue
(-
1
,
((
Integer
)
digestMap
.
get
(
tableAndColumnName
)).
intValue
(),
digestValue
,
null
);
this
.
delegate
.
setString
(((
Integer
)
digestMap
.
get
(
tableAndColumnName
)).
intValue
(),
digestValue
);
}
this
.
sqlBuffer
.
setValue
(-
1
,
parameterIndex
,
x1
,
x1
,
targetSqlType
,
scaleOrLength
);
this
.
delegate
.
setObject
(
parameterIndex
,
x1
,
targetSqlType
,
scaleOrLength
);
}
catch
(
SQLException
sqle
)
{
e
=
sqle
;
throw
sql
e
;
throw
e
;
}
catch
(
Exception
ex
)
{
ex
.
printStackTrace
();
return
;
}
finally
{
this
.
eventListener
.
onAfterPreparedStatementSet
(
this
.
statementInformation
,
parameterIndex
,
x
,
e
);
}
}
public
void
setAsciiStream
(
int
parameterIndex
,
InputStream
x
,
long
length
)
throws
SQLException
{
SQLException
e
=
null
;
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
);
}
catch
(
SQLException
sqle
)
{
e
=
sqle
;
throw
sql
e
;
throw
e
;
}
finally
{
this
.
eventListener
.
onAfterPreparedStatementSet
(
this
.
statementInformation
,
parameterIndex
,
x
,
e
);
}
}
public
void
setBinaryStream
(
int
parameterIndex
,
InputStream
x
,
long
length
)
throws
SQLException
{
SQLException
e
=
null
;
try
{
this
.
sqlBuffer
.
setValue
(
14
,
parameterIndex
,
(
InputStream
)
x
,
length
,
"byte[]"
);
this
.
sqlBuffer
.
setValue
(
14
,
parameterIndex
,
x
,
length
,
"byte[]"
);
this
.
delegate
.
setBinaryStream
(
parameterIndex
,
x
,
length
);
}
catch
(
SQLException
sqle
)
{
e
=
sqle
;
throw
sql
e
;
throw
e
;
}
finally
{
this
.
eventListener
.
onAfterPreparedStatementSet
(
this
.
statementInformation
,
parameterIndex
,
x
,
e
);
}
}
public
void
setCharacterStream
(
int
parameterIndex
,
Reader
reader
,
long
length
)
throws
SQLException
{
SQLException
e
=
null
;
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
);
}
catch
(
SQLException
sqle
)
{
e
=
sqle
;
throw
sql
e
;
throw
e
;
}
finally
{
this
.
eventListener
.
onAfterPreparedStatementSet
(
this
.
statementInformation
,
parameterIndex
,
reader
,
e
);
}
}
public
void
setAsciiStream
(
int
parameterIndex
,
InputStream
x
)
throws
SQLException
{
SQLException
e
=
null
;
try
{
this
.
sqlBuffer
.
setValue
(
14
,
parameterIndex
,
(
InputStream
)
x
,
(
String
)
"byte[ascii]"
);
this
.
sqlBuffer
.
setValue
(
14
,
parameterIndex
,
x
,
"byte[ascii]"
);
this
.
delegate
.
setAsciiStream
(
parameterIndex
,
x
);
}
catch
(
SQLException
sqle
)
{
e
=
sqle
;
throw
sql
e
;
throw
e
;
}
finally
{
this
.
eventListener
.
onAfterPreparedStatementSet
(
this
.
statementInformation
,
parameterIndex
,
x
,
e
);
}
}
public
void
setBinaryStream
(
int
parameterIndex
,
InputStream
x
)
throws
SQLException
{
SQLException
e
=
null
;
try
{
this
.
sqlBuffer
.
setValue
(
14
,
parameterIndex
,
(
InputStream
)
x
,
(
String
)
"byte[]"
);
this
.
sqlBuffer
.
setValue
(
14
,
parameterIndex
,
x
,
"byte[]"
);
this
.
delegate
.
setBinaryStream
(
parameterIndex
,
x
);
}
catch
(
SQLException
sqle
)
{
e
=
sqle
;
throw
sql
e
;
throw
e
;
}
finally
{
this
.
eventListener
.
onAfterPreparedStatementSet
(
this
.
statementInformation
,
parameterIndex
,
x
,
e
);
}
}
public
void
setCharacterStream
(
int
parameterIndex
,
Reader
reader
)
throws
SQLException
{
SQLException
e
=
null
;
try
{
this
.
sqlBuffer
.
setValue
(
15
,
parameterIndex
,
(
Reader
)
reader
,
(
String
)
"byte[string]"
);
this
.
sqlBuffer
.
setValue
(
15
,
parameterIndex
,
reader
,
"byte[string]"
);
this
.
delegate
.
setCharacterStream
(
parameterIndex
,
reader
);
}
catch
(
SQLException
sqle
)
{
e
=
sqle
;
throw
sql
e
;
throw
e
;
}
finally
{
this
.
eventListener
.
onAfterPreparedStatementSet
(
this
.
statementInformation
,
parameterIndex
,
reader
,
e
);
}
}
public
void
setNCharacterStream
(
int
parameterIndex
,
Reader
value
)
throws
SQLException
{
SQLException
e
=
null
;
try
{
this
.
sqlBuffer
.
setValue
(
15
,
parameterIndex
,
(
Reader
)
value
,
(
String
)
"byte[string]"
);
this
.
sqlBuffer
.
setValue
(
15
,
parameterIndex
,
value
,
"byte[string]"
);
this
.
delegate
.
setNCharacterStream
(
parameterIndex
,
value
);
}
catch
(
SQLException
sqle
)
{
e
=
sqle
;
throw
sql
e
;
throw
e
;
}
finally
{
this
.
eventListener
.
onAfterPreparedStatementSet
(
this
.
statementInformation
,
parameterIndex
,
value
,
e
);
}
}
public
void
setClob
(
int
parameterIndex
,
Reader
reader
)
throws
SQLException
{
SQLException
e
=
null
;
try
{
this
.
sqlBuffer
.
setValue
(
15
,
parameterIndex
,
(
Reader
)
reader
,
(
String
)
"byte[string]"
);
this
.
sqlBuffer
.
setValue
(
15
,
parameterIndex
,
reader
,
"byte[string]"
);
this
.
delegate
.
setClob
(
parameterIndex
,
reader
);
}
catch
(
SQLException
sqle
)
{
e
=
sqle
;
throw
sql
e
;
throw
e
;
}
finally
{
this
.
eventListener
.
onAfterPreparedStatementSet
(
this
.
statementInformation
,
parameterIndex
,
reader
,
e
);
}
}
public
void
setBlob
(
int
parameterIndex
,
InputStream
inputStream
)
throws
SQLException
{
SQLException
e
=
null
;
try
{
this
.
sqlBuffer
.
setValue
(
14
,
parameterIndex
,
(
InputStream
)
inputStream
,
(
String
)
"byte[]"
);
this
.
sqlBuffer
.
setValue
(
14
,
parameterIndex
,
inputStream
,
"byte[]"
);
this
.
delegate
.
setBlob
(
parameterIndex
,
inputStream
);
}
catch
(
SQLException
sqle
)
{
e
=
sqle
;
throw
sql
e
;
throw
e
;
}
finally
{
this
.
eventListener
.
onAfterPreparedStatementSet
(
this
.
statementInformation
,
parameterIndex
,
inputStream
,
e
);
}
}
public
void
setNClob
(
int
parameterIndex
,
Reader
reader
)
throws
SQLException
{
SQLException
e
=
null
;
try
{
this
.
sqlBuffer
.
setValue
(
15
,
parameterIndex
,
(
Reader
)
reader
,
(
String
)
"byte[string]"
);
this
.
sqlBuffer
.
setValue
(
15
,
parameterIndex
,
reader
,
"byte[string]"
);
this
.
delegate
.
setNClob
(
parameterIndex
,
reader
);
}
catch
(
SQLException
sqle
)
{
e
=
sqle
;
throw
sql
e
;
throw
e
;
}
finally
{
this
.
eventListener
.
onAfterPreparedStatementSet
(
this
.
statementInformation
,
parameterIndex
,
reader
,
e
);
}
}
public
ParameterMetaData
getParameterMetaData
()
throws
SQLException
{
...
...
@@ -1229,18 +1070,17 @@ public class PreparedStatementWrapper extends StatementWrapper implements Prepar
}
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
);
if
(!
GatewayContext
.
isPluginEnabled
())
{
if
(!
GatewayContext
.
isPluginEnabled
())
return
encDataMap
;
}
else
{
String
dbType
=
""
;
String
urlDbType
=
statementInformation
.
getConnectionInformation
().
getUrl
();
String
driverName
=
statementInformation
.
getConnectionInformation
().
getConnection
().
getMetaData
().
getDriverName
();
dbType
=
ConnectionWrapper
.
getDbType
(
driverName
,
urlDbType
,
dbType
);
List
<
Object
>
insertValueList
=
new
ArrayList
();
try
{
String
sqlAll
;
Connection
connection
=
statementInformation
.
getConnectionInformation
().
getConnection
();
String
urlTemp
=
connection
.
getMetaData
().
getURL
();
String
ip
=
(
String
)
TestJdbcEventListener
.
getIpAndPort
(
urlTemp
).
get
(
"ip"
);
...
...
@@ -1249,14 +1089,23 @@ public class PreparedStatementWrapper extends StatementWrapper implements Prepar
String
tableName
=
""
;
if
(
"oracle"
.
equals
(
dbType
))
{
schema
=
connection
.
getMetaData
().
getUserName
();
}
else
if
(!
"postgresql"
.
equals
(
dbType
)
&&
!
"greenplum"
.
equals
(
dbType
)
&&
!
"gauss"
.
equals
(
dbType
)
&&
!
"gaussdb"
.
equalsIgnoreCase
(
dbType
))
{
if
(
"sql server"
.
equals
(
dbType
))
{
}
else
if
(
"postgresql"
.
equals
(
dbType
)
||
"greenplum"
.
equals
(
dbType
)
||
"gauss"
.
equals
(
dbType
)
||
"gaussdb"
.
equalsIgnoreCase
(
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
();
if
(
url
.
indexOf
(
"applicationName"
)
>
0
)
{
schema
=
url
.
substring
(
url
.
indexOf
(
"applicationName"
)
+
"applicationName"
.
length
()
+
1
);
if
(
schema
.
indexOf
(
";"
)
!=
-
1
)
{
if
(
schema
.
indexOf
(
";"
)
!=
-
1
)
schema
=
schema
.
substring
(
0
,
schema
.
indexOf
(
";"
));
}
}
else
{
schema
=
"dbo"
;
}
...
...
@@ -1267,7 +1116,7 @@ public class PreparedStatementWrapper extends StatementWrapper implements Prepar
}
else
{
int
from
=
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
(
"/"
);
schema
=
address
.
substring
(
idx
+
1
);
}
...
...
@@ -1279,7 +1128,6 @@ public class PreparedStatementWrapper extends StatementWrapper implements Prepar
}
else
{
schema
=
connection
.
getMetaData
().
getUserName
();
}
rs
.
close
();
stmt
.
close
();
}
else
if
(
"kingbase"
.
equals
(
dbType
))
{
...
...
@@ -1295,102 +1143,74 @@ public class PreparedStatementWrapper extends StatementWrapper implements Prepar
String
url
=
connection
.
getMetaData
().
getURL
();
int
from
=
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
(
"/"
);
schema
=
address
.
substring
(
idx
+
1
);
}
else
if
(
"mariadb"
.
equals
(
dbType
))
{
String
url
=
connection
.
getMetaData
().
getURL
();
int
from
=
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
(
"/"
);
schema
=
address
.
substring
(
idx
+
1
);
}
else
if
(
"hive"
.
equals
(
dbType
))
{
String
url
=
connection
.
getMetaData
().
getURL
();
int
from
=
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
(
"/"
);
schema
=
address
.
substring
(
idx
+
1
);
if
(
schema
.
indexOf
(
";"
)
>
0
)
{
if
(
schema
.
indexOf
(
";"
)
>
0
)
schema
=
schema
.
substring
(
0
,
schema
.
indexOf
(
";"
));
}
}
else
{
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
sqlAll
;
if
(
sql1
.
indexOf
(
"-- appUsername="
)
>
0
)
{
sqlAll
=
sql1
.
substring
(
0
,
sql1
.
indexOf
(
"-- appUsername="
)).
trim
();
}
else
{
sqlAll
=
sql1
;
}
int
indexColumnAll
=
0
;
int
lastIndexColumn
=
0
;
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
];
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
;
lastIndexColumn
=
indexColumnAll
-
sqlParamNum
;
if
(
parameterIndex
>
lastIndexColumn
&&
parameterIndex
<=
indexColumnAll
)
{
new
ArrayList
();
new
ArrayList
();
List
<
Map
<
String
,
Object
>>
stringObjectMapList
=
(
List
)
ConnectionWrapper
.
sqlParseMap
.
get
(
sqlAll
);
if
(
stringObjectMapList
==
null
||
stringObjectMapList
.
isEmpty
())
{
ArrayList
<
Column
>
columnList
=
new
ArrayList
<
Column
>
();
List
<
Map
<
String
,
Object
>>
whereList
=
new
ArrayList
<
Map
<
String
,
Object
>>
();
List
<
Map
<
String
,
Object
>>
stringObjectMapList
=
ConnectionWrapper
.
sqlParseMap
.
get
(
sqlAll
);
if
(
stringObjectMapList
==
null
||
stringObjectMapList
.
isEmpty
())
stringObjectMapList
=
statementInformation
.
sqlParse
;
}
if
(
stringObjectMapList
==
null
||
stringObjectMapList
.
isEmpty
())
{
stringObjectMapList
=
this
.
getColumns
(
statementInformation
,
sql
,
dbType
,
schema
);
}
Map
<
String
,
Object
>
stringObjectMap
=
(
Map
)
stringObjectMapList
.
get
(
0
);
ArrayList
<
Column
>
columnList
=
(
ArrayList
)
stringObjectMap
.
get
(
"columnList"
);
if
(
columnList
==
null
||
columnList
.
isEmpty
())
{
RuleLoadUtil
.
writeLog
(
"@@插件@@---PreparedstatementWrapper解析columnList为空-->"
);
}
List
<
Map
<
String
,
Object
>>
whereList
=
(
List
)
stringObjectMap
.
get
(
"whereList"
);
if
(
whereList
==
null
||
whereList
.
isEmpty
())
{
RuleLoadUtil
.
writeLog
(
"@@插件@@---PreparedstatementWrapper解析whereList为空-->"
);
}
if
(
stringObjectMapList
==
null
||
stringObjectMapList
.
isEmpty
())
stringObjectMapList
=
getColumns
(
statementInformation
,
sql
,
dbType
,
schema
);
Map
<
String
,
Object
>
stringObjectMap
=
stringObjectMapList
.
get
(
0
);
columnList
=
(
ArrayList
<
Column
>)
stringObjectMap
.
get
(
"columnList"
);
if
(
columnList
==
null
||
columnList
.
isEmpty
())
RuleLoadUtil
.
writeLog
(
"@@"
);
whereList
=
(
List
<
Map
<
String
,
Object
>>)
stringObjectMap
.
get
(
"whereList"
);
if
(
whereList
==
null
||
whereList
.
isEmpty
())
RuleLoadUtil
.
writeLog
(
"@@"
);
Object
value
=
null
;
Boolean
encFlag
=
false
;
Boolean
encFlag
=
Boolean
.
valueOf
(
false
)
;
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
;
}
}
return
encDataMap
;
}
catch
(
Exception
e1
)
{
e1
.
printStackTrace
();
throw
e1
;
}
}
return
encDataMap
;
}
public
String
abstractData
(
String
mathKey
,
String
x
)
throws
Exception
{
String
hashStr
=
""
;
try
{
boolean
isDigest
=
EngineUtil
.
digestMapBak
.
containsKey
(
mathKey
);
if
(
isDigest
)
{
...
...
@@ -1399,42 +1219,40 @@ public class PreparedStatementWrapper extends StatementWrapper implements Prepar
}
else
{
hashStr
=
x
;
}
return
hashStr
;
}
catch
(
Exception
e1
)
{
e1
.
printStackTrace
();
throw
e1
;
}
return
hashStr
;
}
private
ArrayList
<
Column
>
sortColumns
(
ArrayList
<
Column
>
columnList
,
Collection
<
TableStat
.
Column
>
insertFields
)
{
ArrayList
<
Column
>
sortColumnList
=
new
ArrayList
();
if
(!(
insertFields
instanceof
ArrayList
))
{
return
columnList
;
}
else
{
ArrayList
<
Column
>
sortColumnList
=
new
ArrayList
<
Column
>();
if
(
insertFields
instanceof
ArrayList
)
{
List
<
TableStat
.
Column
>
insertList
=
(
ArrayList
)
insertFields
;
for
(
int
i
=
0
;
i
<
insertList
.
size
();
++
i
)
{
for
(
Column
column
:
columnList
)
{
for
(
int
i
=
0
;
i
<
insertList
.
size
();
i
++)
{
for
(
Column
column
:
columnList
)
{
if
(
column
.
getColumnName
().
equalsIgnoreCase
(((
TableStat
.
Column
)
insertList
.
get
(
i
)).
getName
()))
{
sortColumnList
.
add
(
column
);
break
;
}
}
}
return
sortColumnList
;
}
return
columnList
;
}
private
void
getUpdateSetFields
(
PreparedStatementInformation
statementInformation
,
String
dbType
,
String
schema
,
String
tableName
,
ArrayList
<
Column
>
updateList
)
throws
SQLException
{
List
<
Column
>
columnList
=
null
;
new
ArrayList
();
if
(!
"mysql"
.
equals
(
dbType
)
&&
!
"mariadb"
.
equals
(
dbType
))
{
if
(
"oracle"
.
equals
(
dbType
))
{
List
<
TableStat
.
Column
>
columnL
=
new
ArrayList
<
TableStat
.
Column
>();
if
(
"mysql"
.
equals
(
dbType
)
||
"mariadb"
.
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
);
}
else
if
(!
"postgresql"
.
equals
(
dbType
)
&&
!
"greenplum"
.
equals
(
dbType
)
&&
!
"gauss"
.
equals
(
dbType
))
{
if
(
"hive"
.
equals
(
dbType
))
{
}
else
if
(
"postgresql"
.
equals
(
dbType
)
||
"greenplum"
.
equals
(
dbType
)
||
"gauss"
.
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
);
}
else
if
(
"dm"
.
equals
(
dbType
))
{
columnList
=
JdbcUtil
.
getColumnOfDm
(
statementInformation
.
getConnectionInformation
().
getConnection
().
createStatement
(),
schema
,
tableName
);
...
...
@@ -1445,25 +1263,17 @@ public class PreparedStatementWrapper extends StatementWrapper implements Prepar
}
else
if
(
"kingbase"
.
equals
(
dbType
))
{
columnList
=
JdbcUtil
.
getColumnOfKingbase
(
statementInformation
.
getConnectionInformation
().
getConnection
().
createStatement
(),
schema
,
tableName
);
}
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
;
for
(
Column
col
:
columnList
)
{
for
(
Column
col
:
columnList
)
{
Column
tm
=
new
Column
(
col
.
getColumnName
(),
col
.
getSchema
(),
col
.
getTable
(),
col
.
getDataType
());
finalUpdateList
.
add
(
tm
);
}
}
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
(
"dbType"
,
dbType
);
params
.
put
(
"schema"
,
schema
);
...
...
@@ -1473,7 +1283,7 @@ public class PreparedStatementWrapper extends StatementWrapper implements Prepar
SqlUtil
sqlUtil
=
new
SqlUtil
();
List
<
Map
<
String
,
Object
>>
maps
=
sqlUtil
.
parseSqlStructureEnc
(
params
);
if
(
maps
!=
null
&&
!
maps
.
isEmpty
())
{
Map
<
String
,
Object
>
stringObjectMap
=
(
Map
)
maps
.
get
(
0
);
Map
<
String
,
Object
>
stringObjectMap
=
maps
.
get
(
0
);
if
(!
stringObjectMap
.
isEmpty
())
{
String
trim
=
sql
.
toLowerCase
().
trim
();
if
((
trim
.
startsWith
(
"insert"
)
||
trim
.
startsWith
(
"update"
))
&&
trim
.
contains
(
"?"
))
{
...
...
@@ -1481,20 +1291,17 @@ public class PreparedStatementWrapper extends StatementWrapper implements Prepar
}
else
if
(
trim
.
startsWith
(
"select"
))
{
ConnectionWrapper
.
sqlParseMap
.
put
(
sql
,
maps
);
}
statementInformation
.
sqlParse
=
maps
;
}
}
return
maps
;
}
private
String
getDbType
(
PreparedStatementInformation
statementInformation
,
String
dbType
)
throws
Exception
{
try
{
String
hiveurl
=
statementInformation
.
getConnectionInformation
().
getUrl
();
if
(
hiveurl
.
toLowerCase
().
contains
(
"hive"
))
{
if
(
hiveurl
.
toLowerCase
().
contains
(
"hive"
))
return
"hive"
;
}
else
{
String
driverName
=
statementInformation
.
getConnectionInformation
().
getConnection
().
getMetaData
().
getDriverName
();
if
(
driverName
.
toLowerCase
().
contains
(
"mysql"
))
{
dbType
=
"mysql"
;
...
...
@@ -1506,12 +1313,10 @@ public class PreparedStatementWrapper extends StatementWrapper implements Prepar
dbType
=
"gauss"
;
return
dbType
;
}
if
(
url
.
contains
(
"greenplum"
))
{
dbType
=
"greenplum"
;
return
dbType
;
}
dbType
=
"postgresql"
;
}
else
if
(
driverName
.
toLowerCase
().
contains
(
"hive"
))
{
dbType
=
"hive"
;
...
...
@@ -1524,106 +1329,90 @@ public class PreparedStatementWrapper extends StatementWrapper implements Prepar
}
else
if
(
driverName
.
toLowerCase
().
contains
(
"kingbase"
))
{
dbType
=
"kingbase"
;
}
return
dbType
;
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
e
;
}
return
dbType
;
}
public
Boolean
find
(
String
empNumber
,
Collection
<
TableStat
.
Column
>
list
)
{
for
(
TableStat
.
Column
column
:
list
)
{
if
(
column
.
getName
().
equalsIgnoreCase
(
empNumber
))
{
return
true
;
}
Iterator
<
TableStat
.
Column
>
iterator
=
list
.
iterator
();
while
(
iterator
.
hasNext
())
{
TableStat
.
Column
column
=
iterator
.
next
();
if
(
column
.
getName
().
equalsIgnoreCase
(
empNumber
))
return
Boolean
.
valueOf
(
true
);
}
return
false
;
return
Boolean
.
valueOf
(
false
);
}
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
();
}
String
lowerSql
=
sql
.
toLowerCase
();
String
[]
split
=
lowerSql
.
split
(
";\r\n"
);
for
(
String
s
:
split
)
{
for
(
String
s
:
split
)
{
if
(
s
.
contains
(
"values"
))
{
String
tempsql
=
s
.
substring
(
s
.
indexOf
(
"values"
)
+
6
);
tempsql
=
tempsql
.
replaceFirst
(
"\\("
,
""
);
tempsql
=
tempsql
.
replaceFirst
(
"[\\\\)]+$"
,
""
);
if
(
tempsql
.
trim
().
endsWith
(
";"
))
{
if
(
tempsql
.
trim
().
endsWith
(
";"
))
tempsql
=
tempsql
.
trim
().
substring
(
0
,
tempsql
.
trim
().
length
()
-
1
);
}
valueList
.
addAll
(
InsertSqlVaulesUtil
.
getTableColumnValueByMatchingSingleQuotes
(
tempsql
.
split
(
","
)));
valueList
.
addAll
(
InsertSqlVaulesUtil
.
getTableColumnValueByMatchingSingleQuotes
((
Object
[])
tempsql
.
split
(
","
)));
}
else
if
(
s
.
contains
(
"value"
))
{
String
tempsql
=
s
.
substring
(
s
.
indexOf
(
"value"
)
+
5
);
tempsql
=
tempsql
.
replaceFirst
(
"\\("
,
""
);
tempsql
=
tempsql
.
replaceFirst
(
"[\\\\)]+$"
,
""
);
if
(
tempsql
.
trim
().
endsWith
(
";"
))
{
if
(
tempsql
.
trim
().
endsWith
(
";"
))
tempsql
=
tempsql
.
trim
().
substring
(
0
,
tempsql
.
trim
().
length
()
-
1
);
}
valueList
=
InsertSqlVaulesUtil
.
getTableColumnValueByMatchingSingleQuotes
(
tempsql
.
split
(
","
));
valueList
=
InsertSqlVaulesUtil
.
getTableColumnValueByMatchingSingleQuotes
((
Object
[])
tempsql
.
split
(
","
));
}
}
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
{
Map
hashMap
=
new
HashMap
();
Map
<
String
,
Object
>
whereMap
;
Map
<
Object
,
Object
>
hashMap
=
new
HashMap
<
Object
,
Object
>();
boolean
ismaksing
=
false
;
HashMap
<
Integer
,
Integer
>
ids
=
new
HashMap
();
HashMap
<
Integer
,
Integer
>
ids
=
new
HashMap
<
Integer
,
Integer
>
();
int
m
=
1
;
Column
column
=
null
;
if
(
sqlType
==
SQLType
.
INSERT
)
{
}
if
(
sqlType
==
SQLType
.
UPDATE
)
{
for
(
int
k
=
0
;
k
<
columnList
.
size
();
++
k
)
{
if
(
sqlType
==
SQLType
.
INSERT
);
if
(
sqlType
==
SQLType
.
UPDATE
)
for
(
int
k
=
0
;
k
<
columnList
.
size
();
k
++)
{
String
v
=
((
Column
)
columnList
.
get
(
k
)).
getValue
();
if
(
v
!=
null
&&
String
.
valueOf
(((
Column
)
columnList
.
get
(
k
)).
getValue
()).
trim
().
equals
(
"?"
))
{
ids
.
put
(
m
,
k
);
++
m
;
if
(
v
!=
null
)
if
(
String
.
valueOf
(((
Column
)
columnList
.
get
(
k
)).
getValue
()).
trim
().
equals
(
"?"
))
{
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
)
{
String
columnName
=
column
.
getColumnName
().
contains
(
"."
)
?
column
.
getColumnName
().
split
(
"\\."
)[
1
]
:
column
.
getColumnName
();
String
mathKey
=
(
ip
+
"_"
+
port
+
"_"
+
schema
+
"_"
+
tableName
+
"_"
+
columnName
).
toLowerCase
().
replace
(
"`"
,
""
).
replace
(
"\""
,
""
);
RuleLoadUtil
.
writeLog
(
"@@插件@@---PreparedstatementWrapper参数加密时获取的mathKey:-->"
+
mathKey
);
if
(
EngineUtil
.
encryptionMap
.
isEmpty
())
{
String
str1
=
column
.
getColumnName
().
contains
(
"."
)
?
column
.
getColumnName
().
split
(
"\\."
)[
1
]
:
column
.
getColumnName
();
String
str2
=
(
ip
+
"_"
+
port
+
"_"
+
schema
+
"_"
+
tableName
+
"_"
+
str1
).
toLowerCase
().
replace
(
"`"
,
""
).
replace
(
"\""
,
""
);
RuleLoadUtil
.
writeLog
(
"@@"
+
str2
);
if
(
EngineUtil
.
encryptionMap
.
isEmpty
())
EngineUtil
.
keyCacheFromFile
();
}
ismaksing
=
EngineUtil
.
encryptionMap
.
containsKey
(
mathKey
);
ismaksing
=
EngineUtil
.
encryptionMap
.
containsKey
(
str2
);
if
(
ismaksing
)
{
Boolean
flag
=
false
;
Boolean
flag
=
Boolean
.
valueOf
(
false
);
try
{
Columninfo
map
=
(
Columninfo
)
EngineUtil
.
encryptionMap
.
get
(
mathKey
);
Columninfo
map
=
(
Columninfo
)
EngineUtil
.
encryptionMap
.
get
(
str2
);
if
(
sqlType
==
SQLType
.
INSERT
)
{
RuleLoadUtil
.
writeLog
(
"@@插件@@---PreparedstatementWrapper参数原值:-->"
+
x
);
value
=
EngineUtil
.
exeEngine
(
map
,
(
ConnectionInfo
)
null
,
flag
,
x
,
true
);
value
=
x
;
RuleLoadUtil
.
writeLog
(
"@@"
+
x
);
value
=
EngineUtil
.
exeEngine
(
map
,
null
,
flag
,
value
,
Boolean
.
valueOf
(
true
));
x
=
(
String
)
value
;
RuleLoadUtil
.
writeLog
(
"@@插件@@---PreparedstatementWrapper参数加密后的值:-->"
+
x
);
RuleLoadUtil
.
writeLog
(
"@@"
+
x
);
}
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
;
}
}
catch
(
Exception
e1
)
{
...
...
@@ -1633,79 +1422,78 @@ public class PreparedStatementWrapper extends StatementWrapper implements Prepar
hashMap
.
put
(
"x"
,
x
);
}
}
return
hashMap
;
}
else
{
return
(
Map
)
hashMap
;
}
int
computeParameterIndex
=
parameterIndex
-
1
;
if
(
sqlType
==
SQLType
.
UPDATE
)
{
for
(
int
i
=
0
;
i
<
columnList
.
size
();
++
i
)
{
Column
column1
=
(
Column
)
columnList
.
get
(
i
);
if
(
column1
.
getValue
()
!=
null
&&
column1
.
getValue
().
equals
(
"?"
))
{
Map
<
String
,
Object
>
whereMap
=
new
HashMap
();
whereMap
.
put
(
"column"
,
schema
+
"."
+
column1
.
getColumnName
());
whereMap
.
put
(
"columnValue"
,
"?"
);
whereMap
.
put
(
"type"
,
"Equality"
);
whereList
.
add
(
i
,
whereMap
);
for
(
int
i
=
0
;
i
<
columnList
.
size
();
i
++)
{
Column
column1
=
columnList
.
get
(
i
);
if
(
column1
.
getValue
()
!=
null
)
if
(
column1
.
getValue
().
equals
(
"?"
))
{
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
map
.
put
(
"column"
,
schema
+
"."
+
column1
.
getColumnName
());
map
.
put
(
"columnValue"
,
"?"
);
map
.
put
(
"type"
,
"Equality"
);
whereList
.
add
(
i
,
map
);
}
}
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
();
while
(
iterator
.
hasNext
())
{
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
(
"?"
)))
{
while
(
iterator
.
hasNext
())
{
Map
<
String
,
Object
>
y
=
iterator
.
next
();
if
((!(
y
.
get
(
"columnValue"
)
instanceof
String
)
||
!
y
.
get
(
"columnValue"
).
equals
(
"?"
))
&&
(!(
y
.
get
(
"columnValue"
)
instanceof
SQLVariantRefExpr
)
||
!((
SQLVariantRefExpr
)
y
.
get
(
"columnValue"
)).
getName
().
equals
(
"?"
)))
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
())
{
whereMap
=
(
Map
)
whereList
.
get
(
whereList
.
size
()
-
1
);
whereMap
=
whereList
.
get
(
whereList
.
size
()
-
1
);
}
else
{
whereMap
=
(
Map
)
whereList
.
get
(
computeParameterIndex
);
whereMap
=
whereList
.
get
(
computeParameterIndex
);
}
String
key
=
(
String
)
whereMap
.
get
(
"column"
);
String
columnName
=
key
.
contains
(
"."
)
?
key
.
split
(
"\\."
)[
2
].
replace
(
"\""
,
""
)
:
key
.
replace
(
"\""
,
""
);
tableName
=
key
.
contains
(
"."
)
?
key
.
split
(
"\\."
)[
1
]
:
tableName
;
schema
=
key
.
contains
(
"."
)
?
key
.
split
(
"\\."
)[
0
]
:
schema
;
String
mathKey
=
(
ip
+
"_"
+
port
+
"_"
+
schema
+
"_"
+
tableName
+
"_"
+
columnName
).
toLowerCase
().
replace
(
"`"
,
""
).
replace
(
"\""
,
""
);
if
(
EngineUtil
.
encryptionMap
.
isEmpty
())
{
if
(
EngineUtil
.
encryptionMap
.
isEmpty
())
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
();
if
(
mathKey
.
equals
(
replaceColumn
))
{
hashMap
.
put
(
"tableAndColumnName"
,
(
tableName
+
"@@"
+
columnName
).
toLowerCase
());
hashMap
.
put
(
"x"
,
x
);
hashMap
.
put
(
"mathKey"
,
mathKey
);
return
hashMap
;
return
(
Map
)
hashMap
;
}
}
RuleLoadUtil
.
writeLog
(
"@@插件@@---PreparedstatementWrapper参数加密22时获取的mathKey:-->"
+
mathKey
);
RuleLoadUtil
.
writeLog
(
"@@"
+
mathKey
);
ismaksing
=
EngineUtil
.
encryptionMap
.
containsKey
(
mathKey
);
if
(
ismaksing
)
{
Boolean
flag
=
false
;
Boolean
flag
=
Boolean
.
valueOf
(
false
)
;
Columninfo
map
=
(
Columninfo
)
EngineUtil
.
encryptionMap
.
get
(
mathKey
);
map
.
setColumnname
((
tableName
+
"@@"
+
columnName
).
toLowerCase
());
map
.
setId
(
mathKey
);
String
type
=
(
String
)
whereMap
.
get
(
"type"
);
if
(!
type
.
toUpperCase
().
equals
(
"LIKE"
))
{
if
(!
type
.
toUpperCase
().
equals
(
"LIKE"
))
sqlIndexKeyMap
.
put
(
sql
+
"_"
+
parameterIndex
,
map
);
}
if
(
x
!=
null
&&
!
""
.
equals
(
x
))
{
if
(
x
!=
null
&&
!
""
.
equals
(
x
))
try
{
value
=
x
;
if
(
type
.
toUpperCase
().
equals
(
"LIKE"
))
{
String
likeValue
=
((
String
)
x
).
trim
();
String
likeValue
=
((
String
)
value
).
trim
();
boolean
beforeLike
=
false
;
boolean
afterLike
=
false
;
if
(!
likeValue
.
equals
(
"%%"
))
{
...
...
@@ -1713,44 +1501,36 @@ public class PreparedStatementWrapper extends StatementWrapper implements Prepar
likeValue
=
likeValue
.
substring
(
1
);
beforeLike
=
true
;
}
if
(
likeValue
.
endsWith
(
"%"
))
{
likeValue
=
likeValue
.
substring
(
0
,
likeValue
.
length
()
-
1
);
afterLike
=
true
;
}
value
=
EngineUtil
.
exeEngine
(
map
,
(
ConnectionInfo
)
null
,
flag
,
likeValue
,
true
);
if
(
afterLike
)
{
value
=
likeValue
;
value
=
EngineUtil
.
exeEngine
(
map
,
null
,
flag
,
value
,
Boolean
.
valueOf
(
true
)
);
if
(
afterLike
)
value
=
value
.
toString
().
replace
(
ENCRYPT_SEPARATOR
,
""
);
}
if
(
ENCRYPT_LIKE_OPEN
.
equals
(
map
.
getIsLike
()))
{
if
(
beforeLike
)
{
if
(
beforeLike
)
value
=
"%"
+
value
;
}
if
(
afterLike
)
{
if
(
afterLike
)
value
=
value
+
"%"
;
}
}
}
}
else
{
RuleLoadUtil
.
writeLog
(
"@@插件@@---PreparedstatementWrapper参数22原值:-->"
+
x
);
value
=
EngineUtil
.
exeEngine
(
map
,
(
ConnectionInfo
)
null
,
flag
,
x
,
true
);
RuleLoadUtil
.
writeLog
(
"@@插件@@---PreparedstatementWrapper参数22加密后的值:-->"
+
value
);
RuleLoadUtil
.
writeLog
(
"@@"
+
value
);
value
=
EngineUtil
.
exeEngine
(
map
,
null
,
flag
,
value
,
Boolean
.
valueOf
(
true
)
);
RuleLoadUtil
.
writeLog
(
"@@"
+
value
);
}
x
=
(
String
)
value
;
encFlag
=
true
;
return
(
Map
)
hashMap
;
}
catch
(
Exception
e1
)
{
e1
.
printStackTrace
();
throw
new
SQLException
(
e1
);
}
finally
{
Exception
exception
=
null
;
hashMap
.
put
(
"tableAndColumnName"
,
(
tableName
+
"@@"
+
columnName
).
toLowerCase
());
hashMap
.
put
(
"x"
,
x
);
hashMap
.
put
(
"mathKey"
,
mathKey
);
return
hashMap
;
}
}
}
else
{
Columninfo
columninfo
=
new
Columninfo
();
...
...
@@ -1758,24 +1538,10 @@ public class PreparedStatementWrapper extends StatementWrapper implements Prepar
columninfo
.
setId
(
mathKey
);
sqlIndexKeyMap
.
put
(
sql
+
"_"
+
parameterIndex
,
columninfo
);
}
hashMap
.
put
(
"tableAndColumnName"
,
(
tableName
+
"@@"
+
columnName
).
toLowerCase
());
hashMap
.
put
(
"x"
,
x
);
hashMap
.
put
(
"mathKey"
,
mathKey
);
return
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
;
}
}
return
(
Map
)
hashMap
;
}
public
static
void
main
(
String
[]
args
)
{
...
...
src/main/java/org/apache/commons/logging/LogFactory.java
View file @
1125fb35
...
...
@@ -6,14 +6,14 @@ import java.util.Hashtable;
public
class
LogFactory
{
public
static
final
String
PRIORITY_KEY
=
"priority"
;
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_DEFAULT
=
"
ghca.
org.apache.commons.logging.impl.LogFactoryImpl"
;
public
static
final
String
FACTORY_PROPERTY
=
"org.apache.commons.logging.LogFactory"
;
public
static
final
String
FACTORY_DEFAULT
=
"org.apache.commons.logging.impl.LogFactoryImpl"
;
public
static
final
String
FACTORY_PROPERTIES
=
"commons-logging.properties"
;
protected
static
final
String
SERVICE_ID
=
"META-INF/services/
ghca.
org.apache.commons.logging.LogFactory"
;
public
static
final
String
DIAGNOSTICS_DEST_PROPERTY
=
"
ghca.
org.apache.commons.logging.diagnostics.dest"
;
protected
static
final
String
SERVICE_ID
=
"META-INF/services/org.apache.commons.logging.LogFactory"
;
public
static
final
String
DIAGNOSTICS_DEST_PROPERTY
=
"org.apache.commons.logging.diagnostics.dest"
;
private
static
PrintStream
diagnosticsStream
=
null
;
public
static
final
String
HASHTABLE_IMPLEMENTATION_PROPERTY
=
"
ghca.
org.apache.commons.logging.LogFactory.HashtableImpl"
;
private
static
final
String
WEAK_HASHTABLE_CLASSNAME
=
"
ghca.
org.apache.commons.logging.impl.WeakHashtable"
;
public
static
final
String
HASHTABLE_IMPLEMENTATION_PROPERTY
=
"org.apache.commons.logging.LogFactory.HashtableImpl"
;
private
static
final
String
WEAK_HASHTABLE_CLASSNAME
=
"org.apache.commons.logging.impl.WeakHashtable"
;
protected
static
Hashtable
factories
=
null
;
/** @deprecated */
protected
static
volatile
LogFactory
nullClassLoaderFactory
=
null
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论