Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
621f24fe
D
dbeaver
项目概览
suliangchun
/
dbeaver
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dbeaver
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
621f24fe
编写于
7月 23, 2021
作者:
S
ShadelessFox
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#11473 Network handler secure properties support
上级
6957426a
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
48 addition
and
9 deletion
+48
-9
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/net/DBWHandlerConfiguration.java
.../org/jkiss/dbeaver/model/net/DBWHandlerConfiguration.java
+34
-6
plugins/org.jkiss.dbeaver.registry/src/org/jkiss/dbeaver/registry/DataSourceSerializerModern.java
...rg/jkiss/dbeaver/registry/DataSourceSerializerModern.java
+6
-1
plugins/org.jkiss.dbeaver.registry/src/org/jkiss/dbeaver/registry/SecureCredentials.java
...try/src/org/jkiss/dbeaver/registry/SecureCredentials.java
+8
-2
未找到文件。
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/net/DBWHandlerConfiguration.java
浏览文件 @
621f24fe
...
...
@@ -44,11 +44,13 @@ public class DBWHandlerConfiguration {
private
String
password
;
private
boolean
savePassword
=
true
;
private
final
Map
<
String
,
Object
>
properties
;
private
final
Map
<
String
,
String
>
secureProperties
;
public
DBWHandlerConfiguration
(
@NotNull
DBWHandlerDescriptor
descriptor
,
DBPDataSourceContainer
dataSource
)
{
this
.
descriptor
=
descriptor
;
this
.
dataSource
=
dataSource
;
this
.
properties
=
new
HashMap
<>();
this
.
secureProperties
=
new
HashMap
<>();
}
public
DBWHandlerConfiguration
(
@NotNull
DBWHandlerConfiguration
configuration
)
{
...
...
@@ -59,6 +61,7 @@ public class DBWHandlerConfiguration {
this
.
password
=
configuration
.
password
;
this
.
savePassword
=
configuration
.
savePassword
;
this
.
properties
=
new
HashMap
<>(
configuration
.
properties
);
this
.
secureProperties
=
new
HashMap
<>(
configuration
.
secureProperties
);
}
@NotNull
...
...
@@ -175,6 +178,25 @@ public class DBWHandlerConfiguration {
this
.
properties
.
putAll
(
properties
);
}
@Nullable
public
String
getSecureProperty
(
@NotNull
String
name
)
{
return
secureProperties
.
get
(
name
);
}
@NotNull
public
Map
<
String
,
String
>
getSecureProperties
()
{
return
secureProperties
;
}
public
void
setSecureProperty
(
@NotNull
String
name
,
@Nullable
String
value
)
{
secureProperties
.
put
(
name
,
value
);
}
public
void
setSecureProperties
(
@NotNull
Map
<
String
,
String
>
secureProperties
)
{
this
.
secureProperties
.
clear
();
this
.
secureProperties
.
putAll
(
secureProperties
);
}
@Override
public
boolean
equals
(
Object
obj
)
{
if
(!(
obj
instanceof
DBWHandlerConfiguration
))
{
...
...
@@ -188,16 +210,21 @@ public class DBWHandlerConfiguration {
CommonUtils
.
equalObjects
(
this
.
userName
,
source
.
userName
)
&&
CommonUtils
.
equalObjects
(
this
.
password
,
source
.
password
)
&&
this
.
savePassword
==
source
.
savePassword
&&
CommonUtils
.
equalObjects
(
this
.
properties
,
source
.
properties
);
CommonUtils
.
equalObjects
(
this
.
properties
,
source
.
properties
)
&&
CommonUtils
.
equalObjects
(
this
.
secureProperties
,
source
.
secureProperties
);
}
public
void
resolveDynamicVariables
(
IVariableResolver
variableResolver
)
{
userName
=
GeneralUtils
.
replaceVariables
(
userName
,
variableResolver
);
password
=
GeneralUtils
.
replaceVariables
(
password
,
variableResolver
);
for
(
String
prop
:
this
.
properties
.
keySet
())
{
Object
value
=
this
.
properties
.
get
(
prop
);
if
(
value
instanceof
String
&&
!
CommonUtils
.
isEmpty
((
String
)
value
))
{
this
.
properties
.
put
(
prop
,
GeneralUtils
.
replaceVariables
((
String
)
value
,
variableResolver
));
for
(
Map
.
Entry
<
String
,
Object
>
prop
:
properties
.
entrySet
())
{
if
(
prop
.
getValue
()
instanceof
String
&&
CommonUtils
.
isNotEmpty
((
String
)
prop
.
getValue
()))
{
prop
.
setValue
(
GeneralUtils
.
replaceVariables
((
String
)
prop
.
getValue
(),
variableResolver
));
}
}
for
(
Map
.
Entry
<
String
,
String
>
prop
:
secureProperties
.
entrySet
())
{
if
(
CommonUtils
.
isNotEmpty
(
prop
.
getValue
()))
{
prop
.
setValue
(
GeneralUtils
.
replaceVariables
(
prop
.
getValue
(),
variableResolver
));
}
}
}
...
...
@@ -205,7 +232,8 @@ public class DBWHandlerConfiguration {
public
boolean
hasValuableInfo
()
{
return
!
CommonUtils
.
isEmpty
(
userName
)
||
!
CommonUtils
.
isEmpty
(
password
)
||
!
CommonUtils
.
isEmpty
(
properties
);
!
CommonUtils
.
isEmpty
(
properties
)
||
!
CommonUtils
.
isEmpty
(
secureProperties
);
}
@Override
...
...
plugins/org.jkiss.dbeaver.registry/src/org/jkiss/dbeaver/registry/DataSourceSerializerModern.java
浏览文件 @
621f24fe
...
...
@@ -700,6 +700,9 @@ class DataSourceSerializerModern implements DataSourceSerializer
if
(
curNetworkHandler
.
isSavePassword
())
{
curNetworkHandler
.
setPassword
(
creds
.
getUserPassword
());
}
if
(
creds
.
getProperties
()
!=
null
)
{
curNetworkHandler
.
setSecureProperties
(
creds
.
getProperties
());
}
}
{
// Still try to read credentials directly from configuration (#6564)
...
...
@@ -947,11 +950,13 @@ class DataSourceSerializerModern implements DataSourceSerializer
JSONUtils
.
field
(
json
,
RegistryConstants
.
ATTR_ENABLED
,
configuration
.
isEnabled
());
JSONUtils
.
field
(
json
,
RegistryConstants
.
ATTR_SAVE_PASSWORD
,
configuration
.
isSavePassword
());
if
(!
CommonUtils
.
isEmpty
(
configuration
.
getUserName
())
||
!
CommonUtils
.
isEmpty
(
configuration
.
getPassword
()))
{
final
SecureCredentials
credentials
=
new
SecureCredentials
(
configuration
);
credentials
.
setProperties
(
configuration
.
getSecureProperties
());
saveSecuredCredentials
(
dataSource
,
profile
,
"network/"
+
configuration
.
getId
()
+
(
profile
==
null
?
""
:
"/profile/"
+
profile
.
getProfileName
()),
new
SecureCredentials
(
configuration
)
);
credentials
);
}
JSONUtils
.
serializeProperties
(
json
,
RegistryConstants
.
TAG_PROPERTIES
,
configuration
.
getProperties
());
json
.
endObject
();
...
...
plugins/org.jkiss.dbeaver.registry/src/org/jkiss/dbeaver/registry/SecureCredentials.java
浏览文件 @
621f24fe
...
...
@@ -22,6 +22,7 @@ import org.jkiss.dbeaver.model.DBPDataSourceContainer;
import
org.jkiss.dbeaver.model.access.DBAAuthProfile
;
import
org.jkiss.dbeaver.model.net.DBWHandlerConfiguration
;
import
java.util.HashMap
;
import
java.util.LinkedHashMap
;
import
java.util.Map
;
...
...
@@ -76,8 +77,13 @@ class SecureCredentials {
return
properties
;
}
public
void
setProperties
(
@Nullable
Map
<
String
,
String
>
properties
)
{
this
.
properties
=
properties
;
public
void
setProperties
(
@NotNull
Map
<
String
,
String
>
properties
)
{
if
(
this
.
properties
!=
null
)
{
this
.
properties
.
clear
();
this
.
properties
.
putAll
(
properties
);
}
else
{
this
.
properties
=
new
HashMap
<>(
properties
);
}
}
public
void
setSecureProp
(
String
key
,
String
value
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录