Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
04c2c49b
D
dbeaver
项目概览
suliangchun
/
dbeaver
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
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,发现更多精彩内容 >>
提交
04c2c49b
编写于
12月 03, 2016
作者:
S
Serge Rider
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Datasources serialization fix. Secure model refactoring
Former-commit-id:
70d807e2
上级
f4f0db9e
变更
9
显示空白变更内容
内联
并排
Showing
9 changed file
with
82 addition
and
75 deletion
+82
-75
plugins/org.jkiss.dbeaver.core.application/src/org/jkiss/dbeaver/core/application/DBeaverApplication.java
...rg/jkiss/dbeaver/core/application/DBeaverApplication.java
+4
-4
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/core/DBeaverCore.java
....dbeaver.core/src/org/jkiss/dbeaver/core/DBeaverCore.java
+7
-4
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/core/EclipseApplication.java
...r.core/src/org/jkiss/dbeaver/core/EclipseApplication.java
+4
-4
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/DataSourceRegistry.java
...re/src/org/jkiss/dbeaver/registry/DataSourceRegistry.java
+48
-49
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/app/DBASecureStorage.java
...del/src/org/jkiss/dbeaver/model/app/DBASecureStorage.java
+1
-1
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/app/DBPApplication.java
...model/src/org/jkiss/dbeaver/model/app/DBPApplication.java
+1
-1
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/app/DBPPlatform.java
...er.model/src/org/jkiss/dbeaver/model/app/DBPPlatform.java
+3
-0
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/connection/DBPConnectionBootstrap.java
...kiss/dbeaver/model/connection/DBPConnectionBootstrap.java
+10
-0
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/impl/app/DefaultSecureStorage.java
...rg/jkiss/dbeaver/model/impl/app/DefaultSecureStorage.java
+4
-12
未找到文件。
plugins/org.jkiss.dbeaver.core.application/src/org/jkiss/dbeaver/core/application/DBeaverApplication.java
浏览文件 @
04c2c49b
...
...
@@ -41,9 +41,9 @@ import org.jkiss.dbeaver.core.DBeaverUI;
import
org.jkiss.dbeaver.core.application.rpc.DBeaverInstanceServer
;
import
org.jkiss.dbeaver.core.application.rpc.IInstanceController
;
import
org.jkiss.dbeaver.core.application.rpc.InstanceClient
;
import
org.jkiss.dbeaver.model.app.DBA
ClientSecurity
;
import
org.jkiss.dbeaver.model.app.DBA
SecureStorage
;
import
org.jkiss.dbeaver.model.app.DBPApplication
;
import
org.jkiss.dbeaver.model.impl.app.Default
ClientSecurity
;
import
org.jkiss.dbeaver.model.impl.app.Default
SecureStorage
;
import
org.jkiss.dbeaver.utils.GeneralUtils
;
import
org.jkiss.dbeaver.utils.SystemVariablesResolver
;
import
org.jkiss.utils.ArrayUtils
;
...
...
@@ -378,8 +378,8 @@ public class DBeaverApplication implements IApplication, DBPApplication {
@NotNull
@Override
public
DBA
ClientSecurity
getClientSecurity
()
{
return
Default
ClientSecurity
.
INSTANCE
;
public
DBA
SecureStorage
getSecureStorage
()
{
return
Default
SecureStorage
.
INSTANCE
;
}
private
class
ProxyPrintStream
extends
OutputStream
{
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/core/DBeaverCore.java
浏览文件 @
04c2c49b
...
...
@@ -29,10 +29,7 @@ import org.jkiss.code.NotNull;
import
org.jkiss.dbeaver.DBException
;
import
org.jkiss.dbeaver.Log
;
import
org.jkiss.dbeaver.model.*
;
import
org.jkiss.dbeaver.model.app.DBACertificateStorage
;
import
org.jkiss.dbeaver.model.app.DBPApplication
;
import
org.jkiss.dbeaver.model.app.DBPPlatform
;
import
org.jkiss.dbeaver.model.app.DBPProjectManager
;
import
org.jkiss.dbeaver.model.app.*
;
import
org.jkiss.dbeaver.model.data.DBDRegistry
;
import
org.jkiss.dbeaver.model.edit.DBERegistry
;
import
org.jkiss.dbeaver.model.impl.app.DefaultCertificateStorage
;
...
...
@@ -368,6 +365,12 @@ public class DBeaverCore implements DBPPlatform {
return
certificateStorage
;
}
@NotNull
@Override
public
DBASecureStorage
getSecureStorage
()
{
return
application
.
getSecureStorage
();
}
public
ProjectRegistry
getProjectRegistry
()
{
return
projectRegistry
;
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/core/EclipseApplication.java
浏览文件 @
04c2c49b
...
...
@@ -18,9 +18,9 @@
package
org.jkiss.dbeaver.core
;
import
org.jkiss.code.NotNull
;
import
org.jkiss.dbeaver.model.app.DBA
ClientSecurity
;
import
org.jkiss.dbeaver.model.app.DBA
SecureStorage
;
import
org.jkiss.dbeaver.model.app.DBPApplication
;
import
org.jkiss.dbeaver.model.impl.app.Default
ClientSecurity
;
import
org.jkiss.dbeaver.model.impl.app.Default
SecureStorage
;
/**
* EclipseApplication
...
...
@@ -34,7 +34,7 @@ class EclipseApplication implements DBPApplication {
@NotNull
@Override
public
DBA
ClientSecurity
getClientSecurity
()
{
return
Default
ClientSecurity
.
INSTANCE
;
public
DBA
SecureStorage
getSecureStorage
()
{
return
Default
SecureStorage
.
INSTANCE
;
}
}
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/DataSourceRegistry.java
浏览文件 @
04c2c49b
...
...
@@ -31,6 +31,7 @@ import org.jkiss.dbeaver.Log;
import
org.jkiss.dbeaver.core.DBeaverCore
;
import
org.jkiss.dbeaver.core.DBeaverNature
;
import
org.jkiss.dbeaver.model.*
;
import
org.jkiss.dbeaver.model.app.DBASecureStorage
;
import
org.jkiss.dbeaver.model.app.DBPDataSourceRegistry
;
import
org.jkiss.dbeaver.model.app.DBPPlatform
;
import
org.jkiss.dbeaver.model.connection.DBPConnectionBootstrap
;
...
...
@@ -542,13 +543,7 @@ public class DataSourceRegistry implements DBPDataSourceRegistry
clearSecuredPassword
(
dataSource
,
null
);
if
(
dataSource
.
isSavePassword
()
&&
!
CommonUtils
.
isEmpty
(
connectionInfo
.
getUserPassword
()))
{
if
(!
saveSecuredPassword
(
dataSource
,
null
,
connectionInfo
.
getUserPassword
()))
{
try
{
xml
.
addAttribute
(
RegistryConstants
.
ATTR_PASSWORD
,
ENCRYPTOR
.
encrypt
(
connectionInfo
.
getUserPassword
()));
}
catch
(
EncryptionException
e
)
{
log
.
error
(
"Error encrypting password"
,
e
);
}
}
saveSecuredPassword
(
xml
,
dataSource
,
null
,
connectionInfo
.
getUserPassword
());
}
if
(!
CommonUtils
.
isEmpty
(
connectionInfo
.
getClientHomeId
()))
{
xml
.
addAttribute
(
RegistryConstants
.
ATTR_HOME
,
connectionInfo
.
getClientHomeId
());
...
...
@@ -591,17 +586,8 @@ public class DataSourceRegistry implements DBPDataSourceRegistry
xml
.
addAttribute
(
RegistryConstants
.
ATTR_ENABLED
,
configuration
.
isEnabled
());
xml
.
addAttribute
(
RegistryConstants
.
ATTR_USER
,
CommonUtils
.
notEmpty
(
configuration
.
getUserName
()));
xml
.
addAttribute
(
RegistryConstants
.
ATTR_SAVE_PASSWORD
,
configuration
.
isSavePassword
());
if
(
configuration
.
isSavePassword
()
&&
!
CommonUtils
.
isEmpty
(
configuration
.
getPassword
()))
{
String
encPassword
=
configuration
.
getPassword
();
if
(!
CommonUtils
.
isEmpty
(
encPassword
))
{
try
{
encPassword
=
ENCRYPTOR
.
encrypt
(
encPassword
);
}
catch
(
EncryptionException
e
)
{
log
.
error
(
"Can't encrypt password. Save it as is"
,
e
);
}
}
xml
.
addAttribute
(
RegistryConstants
.
ATTR_PASSWORD
,
encPassword
);
if
(
configuration
.
isSavePassword
())
{
saveSecuredPassword
(
xml
,
dataSource
,
"network/"
+
configuration
.
getId
(),
configuration
.
getPassword
());
}
for
(
Map
.
Entry
<
String
,
String
>
entry
:
configuration
.
getProperties
().
entrySet
())
{
xml
.
startElement
(
RegistryConstants
.
TAG_PROPERTY
);
...
...
@@ -615,6 +601,7 @@ public class DataSourceRegistry implements DBPDataSourceRegistry
// Save bootstrap info
{
DBPConnectionBootstrap
bootstrap
=
connectionInfo
.
getBootstrap
();
if
(
bootstrap
.
hasData
())
{
xml
.
startElement
(
RegistryConstants
.
TAG_BOOTSTRAP
);
if
(
bootstrap
.
getDefaultAutoCommit
()
!=
null
)
{
xml
.
addAttribute
(
RegistryConstants
.
ATTR_AUTOCOMMIT
,
bootstrap
.
getDefaultAutoCommit
());
...
...
@@ -635,7 +622,7 @@ public class DataSourceRegistry implements DBPDataSourceRegistry
}
xml
.
endElement
();
}
}
xml
.
endElement
();
}
...
...
@@ -687,22 +674,34 @@ public class DataSourceRegistry implements DBPDataSourceRegistry
xml
.
endElement
();
}
private
boolean
saveSecuredPassword
(
DataSourceDescriptor
dataSource
,
String
subNode
,
String
password
)
{
private
void
saveSecuredPassword
(
XMLBuilder
xml
,
DataSourceDescriptor
dataSource
,
String
subNode
,
String
password
)
throws
IOException
{
boolean
saved
=
false
;
final
DBASecureStorage
secureStorage
=
getPlatform
().
getSecureStorage
();
if
(
secureStorage
.
useSecurePreferences
())
{
try
{
ISecurePreferences
prefNode
=
dataSource
.
getSecurePreferences
();
if
(
subNode
!=
null
)
{
prefNode
=
prefNode
.
node
(
subNode
);
for
(
String
nodeName
:
subNode
.
split
(
"/"
))
{
prefNode
=
prefNode
.
node
(
nodeName
);
}
}
if
(!
CommonUtils
.
isEmpty
(
password
))
{
prefNode
.
put
(
RegistryConstants
.
ATTR_PASSWORD
,
password
,
true
);
}
else
{
prefNode
.
remove
(
RegistryConstants
.
ATTR_PASSWORD
);
}
saved
=
true
;
}
catch
(
StorageException
e
)
{
log
.
error
(
"Can't save password in secure storage"
,
e
);
}
return
false
;
}
if
(!
saved
&&
!
CommonUtils
.
isEmpty
(
password
))
{
try
{
xml
.
addAttribute
(
RegistryConstants
.
ATTR_PASSWORD
,
ENCRYPTOR
.
encrypt
(
password
));
}
catch
(
EncryptionException
e
)
{
log
.
error
(
"Error encrypting password"
,
e
);
}
}
}
private
void
clearSecuredPassword
(
DataSourceDescriptor
dataSource
,
String
subNode
)
{
...
...
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/app/DBA
ClientSecurity
.java
→
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/app/DBA
SecureStorage
.java
浏览文件 @
04c2c49b
...
...
@@ -23,7 +23,7 @@ import org.eclipse.equinox.security.storage.ISecurePreferences;
/**
* Client security manager
*/
public
interface
DBA
ClientSecurity
public
interface
DBA
SecureStorage
{
boolean
useSecurePreferences
();
...
...
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/app/DBPApplication.java
浏览文件 @
04c2c49b
...
...
@@ -28,6 +28,6 @@ public interface DBPApplication
boolean
isStandalone
();
@NotNull
DBA
ClientSecurity
getClientSecurity
();
DBA
SecureStorage
getSecureStorage
();
}
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/app/DBPPlatform.java
浏览文件 @
04c2c49b
...
...
@@ -67,6 +67,9 @@ public interface DBPPlatform
@NotNull
DBACertificateStorage
getCertificateStorage
();
@NotNull
DBASecureStorage
getSecureStorage
();
@NotNull
File
getTempFolder
(
DBRProgressMonitor
monitor
,
String
name
)
throws
IOException
;
...
...
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/connection/DBPConnectionBootstrap.java
浏览文件 @
04c2c49b
...
...
@@ -17,6 +17,8 @@
*/
package
org.jkiss.dbeaver.model.connection
;
import
org.jkiss.utils.CommonUtils
;
import
java.util.*
;
/**
...
...
@@ -87,4 +89,12 @@ public class DBPConnectionBootstrap
this
.
ignoreErrors
=
ignoreErrors
;
}
public
boolean
hasData
()
{
return
defaultAutoCommit
!=
null
||
defaultTransactionIsolation
!=
null
||
!
CommonUtils
.
isEmpty
(
defaultObjectName
)
||
ignoreErrors
||
!
CommonUtils
.
isEmpty
(
initQueries
);
}
}
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/impl/app/Default
ClientSecurity
.java
→
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/impl/app/Default
SecureStorage
.java
浏览文件 @
04c2c49b
...
...
@@ -19,22 +19,14 @@ package org.jkiss.dbeaver.model.impl.app;
import
org.eclipse.equinox.security.storage.ISecurePreferences
;
import
org.eclipse.equinox.security.storage.SecurePreferencesFactory
;
import
org.jkiss.dbeaver.DBException
;
import
org.jkiss.dbeaver.Log
;
import
org.jkiss.dbeaver.model.app.DBACertificateStorage
;
import
org.jkiss.dbeaver.model.app.DBAClientSecurity
;
import
java.io.*
;
import
java.security.KeyStore
;
import
java.security.cert.Certificate
;
import
java.security.cert.CertificateFactory
;
import
org.jkiss.dbeaver.model.app.DBASecureStorage
;
/**
* Default
ClientSecurity
* Default
SecureStorage
*/
public
class
Default
ClientSecurity
implements
DBAClientSecurity
{
public
class
Default
SecureStorage
implements
DBASecureStorage
{
public
static
Default
ClientSecurity
INSTANCE
=
new
DefaultClientSecurity
();
public
static
Default
SecureStorage
INSTANCE
=
new
DefaultSecureStorage
();
@Override
public
boolean
useSecurePreferences
()
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录