Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
076a2f92
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,发现更多精彩内容 >>
提交
076a2f92
编写于
8月 24, 2019
作者:
S
serge-rider
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#6599 Multiple secured credentials support
Former-commit-id:
be7a12a3
上级
d58885a1
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
38 addition
and
15 deletion
+38
-15
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/tools/project/ProjectExportWizard.java
.../org/jkiss/dbeaver/tools/project/ProjectExportWizard.java
+1
-1
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/app/DBPDataSourceRegistry.java
...rc/org/jkiss/dbeaver/model/app/DBPDataSourceRegistry.java
+2
-1
plugins/org.jkiss.dbeaver.registry/src/org/jkiss/dbeaver/registry/DataSourceOrigin.java
...stry/src/org/jkiss/dbeaver/registry/DataSourceOrigin.java
+16
-0
plugins/org.jkiss.dbeaver.registry/src/org/jkiss/dbeaver/registry/DataSourceRegistry.java
...ry/src/org/jkiss/dbeaver/registry/DataSourceRegistry.java
+1
-1
plugins/org.jkiss.dbeaver.registry/src/org/jkiss/dbeaver/registry/DataSourceSerializer.java
.../src/org/jkiss/dbeaver/registry/DataSourceSerializer.java
+1
-1
plugins/org.jkiss.dbeaver.registry/src/org/jkiss/dbeaver/registry/DataSourceSerializerLegacy.java
...rg/jkiss/dbeaver/registry/DataSourceSerializerLegacy.java
+3
-3
plugins/org.jkiss.dbeaver.registry/src/org/jkiss/dbeaver/registry/DataSourceSerializerModern.java
...rg/jkiss/dbeaver/registry/DataSourceSerializerModern.java
+14
-8
未找到文件。
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/tools/project/ProjectExportWizard.java
浏览文件 @
076a2f92
...
...
@@ -64,7 +64,7 @@ public class ProjectExportWizard extends Wizard implements IExportWizard {
static
{
IGNORED_RESOURCES
.
add
(
PROJECT_DESC_FILE
);
IGNORED_RESOURCES
.
add
(
DBPDataSourceRegistry
.
CREDENTIALS_CONFIG_FILE_
NAME
);
IGNORED_RESOURCES
.
add
(
DBPDataSourceRegistry
.
CREDENTIALS_CONFIG_FILE_
PREFIX
);
}
public
ProjectExportWizard
()
{
...
...
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/app/DBPDataSourceRegistry.java
浏览文件 @
076a2f92
...
...
@@ -41,7 +41,8 @@ public interface DBPDataSourceRegistry extends DBPObject {
String
MODERN_CONFIG_FILE_PREFIX
=
"data-sources"
;
//$NON-NLS-1$
String
MODERN_CONFIG_FILE_EXT
=
".json"
;
//$NON-NLS-1$
String
MODERN_CONFIG_FILE_NAME
=
MODERN_CONFIG_FILE_PREFIX
+
MODERN_CONFIG_FILE_EXT
;
String
CREDENTIALS_CONFIG_FILE_NAME
=
"credentials-config.json"
;
//$NON-NLS-1$
String
CREDENTIALS_CONFIG_FILE_PREFIX
=
"credentials-config"
;
//$NON-NLS-1$
String
CREDENTIALS_CONFIG_FILE_EXT
=
".json"
;
//$NON-NLS-1$
@NotNull
DBPPlatform
getPlatform
();
...
...
plugins/org.jkiss.dbeaver.registry/src/org/jkiss/dbeaver/registry/DataSourceOrigin.java
浏览文件 @
076a2f92
...
...
@@ -17,6 +17,7 @@
package
org.jkiss.dbeaver.registry
;
import
org.eclipse.core.resources.IFile
;
import
org.jkiss.dbeaver.model.app.DBPDataSourceRegistry
;
/**
* DataSourceOrigin
...
...
@@ -25,16 +26,31 @@ class DataSourceOrigin
{
private
final
IFile
sourceFile
;
private
final
boolean
isDefault
;
private
final
String
configSuffix
;
public
DataSourceOrigin
(
IFile
sourceFile
,
boolean
isDefault
)
{
this
.
sourceFile
=
sourceFile
;
this
.
isDefault
=
isDefault
;
if
(
isDefault
)
{
configSuffix
=
""
;
}
else
{
String
configFileName
=
sourceFile
.
getName
();
configSuffix
=
configFileName
.
substring
(
DBPDataSourceRegistry
.
MODERN_CONFIG_FILE_PREFIX
.
length
(),
configFileName
.
length
()
-
DBPDataSourceRegistry
.
MODERN_CONFIG_FILE_EXT
.
length
());
}
}
public
String
getName
()
{
return
sourceFile
.
getName
();
}
public
String
getConfigSuffix
()
{
return
configSuffix
;
}
public
boolean
isDefault
()
{
return
isDefault
;
}
...
...
plugins/org.jkiss.dbeaver.registry/src/org/jkiss/dbeaver/registry/DataSourceRegistry.java
浏览文件 @
076a2f92
...
...
@@ -666,7 +666,7 @@ public class DataSourceRegistry implements DBPDataSourceRegistry {
}
serializer
.
saveDataSources
(
monitor
,
origin
.
isDefault
()
,
origin
,
localDataSources
,
configFile
);
}
...
...
plugins/org.jkiss.dbeaver.registry/src/org/jkiss/dbeaver/registry/DataSourceSerializer.java
浏览文件 @
076a2f92
...
...
@@ -31,7 +31,7 @@ interface DataSourceSerializer
{
void
saveDataSources
(
DBRProgressMonitor
monitor
,
boolean
primaryConfig
,
DataSourceOrigin
origin
,
List
<
DataSourceDescriptor
>
localDataSources
,
IFile
configFile
)
throws
DBException
,
IOException
;
...
...
plugins/org.jkiss.dbeaver.registry/src/org/jkiss/dbeaver/registry/DataSourceSerializerLegacy.java
浏览文件 @
076a2f92
...
...
@@ -80,7 +80,7 @@ class DataSourceSerializerLegacy implements DataSourceSerializer
@Override
public
void
saveDataSources
(
DBRProgressMonitor
monitor
,
boolean
primaryConfig
,
DataSourceOrigin
origin
,
List
<
DataSourceDescriptor
>
localDataSources
,
IFile
configFile
)
throws
DBException
,
IOException
{
...
...
@@ -90,7 +90,7 @@ class DataSourceSerializerLegacy implements DataSourceSerializer
XMLBuilder
xml
=
new
XMLBuilder
(
tempStream
,
GeneralUtils
.
UTF8_ENCODING
);
xml
.
setButify
(
true
);
try
(
XMLBuilder
.
Element
el1
=
xml
.
startElement
(
"data-sources"
))
{
if
(
primaryConfig
)
{
if
(
origin
.
isDefault
()
)
{
// Folders (only for default origin)
for
(
DataSourceFolder
folder
:
registry
.
getAllFolders
())
{
saveFolder
(
xml
,
folder
);
...
...
@@ -106,7 +106,7 @@ class DataSourceSerializerLegacy implements DataSourceSerializer
}
// Filters
if
(
primaryConfig
)
{
if
(
origin
.
isDefault
()
)
{
try
(
XMLBuilder
.
Element
ignored
=
xml
.
startElement
(
RegistryConstants
.
TAG_FILTERS
))
{
for
(
DBSObjectFilter
cf
:
registry
.
getSavedFilters
())
{
if
(!
cf
.
isEmpty
())
{
...
...
plugins/org.jkiss.dbeaver.registry/src/org/jkiss/dbeaver/registry/DataSourceSerializerModern.java
浏览文件 @
076a2f92
...
...
@@ -91,9 +91,10 @@ class DataSourceSerializerModern implements DataSourceSerializer
@Override
public
void
saveDataSources
(
DBRProgressMonitor
monitor
,
boolean
primaryConfig
,
DataSourceOrigin
origin
,
List
<
DataSourceDescriptor
>
localDataSources
,
IFile
configFile
)
throws
DBException
,
IOException
{
IFile
configFile
)
throws
DBException
,
IOException
{
ByteArrayOutputStream
dsConfigBuffer
=
new
ByteArrayOutputStream
(
10000
);
try
(
OutputStreamWriter
osw
=
new
OutputStreamWriter
(
dsConfigBuffer
,
StandardCharsets
.
UTF_8
))
{
try
(
JsonWriter
jsonWriter
=
CONFIG_GSON
.
newJsonWriter
(
osw
))
{
...
...
@@ -101,7 +102,7 @@ class DataSourceSerializerModern implements DataSourceSerializer
jsonWriter
.
beginObject
();
// Save folders
if
(
primaryConfig
)
{
if
(
origin
.
isDefault
()
)
{
jsonWriter
.
name
(
"folders"
);
jsonWriter
.
beginObject
();
// Folders (only for default origin)
...
...
@@ -139,7 +140,7 @@ class DataSourceSerializerModern implements DataSourceSerializer
jsonWriter
.
endObject
();
}
if
(
primaryConfig
)
{
if
(
origin
.
isDefault
()
)
{
if
(!
virtualModels
.
isEmpty
())
{
// Save virtual models
jsonWriter
.
name
(
"virtual-models"
);
...
...
@@ -240,12 +241,17 @@ class DataSourceSerializerModern implements DataSourceSerializer
throw
new
IOException
(
"Error saving configuration to a file "
+
configFile
.
getFullPath
(),
e
);
}
saveSecureCredentialsFile
(
monitor
.
getNestedMonitor
(),
(
IFolder
)
configFile
.
getParent
());
{
saveSecureCredentialsFile
(
monitor
.
getNestedMonitor
(),
(
IFolder
)
configFile
.
getParent
(),
origin
);
}
}
private
void
saveSecureCredentialsFile
(
IProgressMonitor
monitor
,
IFolder
parent
)
{
private
void
saveSecureCredentialsFile
(
IProgressMonitor
monitor
,
IFolder
parent
,
DataSourceOrigin
origin
)
{
IFile
credFile
=
parent
.
getFile
(
DBPDataSourceRegistry
.
CREDENTIALS_CONFIG_FILE_
NAME
);
IFile
credFile
=
parent
.
getFile
(
DBPDataSourceRegistry
.
CREDENTIALS_CONFIG_FILE_
PREFIX
+
origin
.
getConfigSuffix
()
+
DBPDataSourceRegistry
.
CREDENTIALS_CONFIG_FILE_EXT
);
try
{
// Serialize and encrypt
String
jsonString
=
SECURE_GSON
.
toJson
(
secureProperties
,
Map
.
class
);
...
...
@@ -278,7 +284,7 @@ class DataSourceSerializerModern implements DataSourceSerializer
// Read secured creds file
IFolder
mdFolder
=
registry
.
getProject
().
getMetadataFolder
(
false
);
if
(
mdFolder
.
exists
())
{
IFile
credFile
=
mdFolder
.
getFile
(
DBPDataSourceRegistry
.
CREDENTIALS_CONFIG_FILE_
NAME
);
IFile
credFile
=
mdFolder
.
getFile
(
DBPDataSourceRegistry
.
CREDENTIALS_CONFIG_FILE_
PREFIX
+
origin
.
getConfigSuffix
()
+
DBPDataSourceRegistry
.
CREDENTIALS_CONFIG_FILE_EXT
);
if
(
credFile
.
exists
())
{
ByteArrayOutputStream
credBuffer
=
new
ByteArrayOutputStream
();
try
(
InputStream
crdStream
=
credFile
.
getContents
())
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录