Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
Shardingsphere
提交
eb29dfd6
Shardingsphere
项目概览
apache
/
Shardingsphere
通知
56
Star
3
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Shardingsphere
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
eb29dfd6
编写于
5月 22, 2020
作者:
Z
zhyee
提交者:
GitHub
5月 22, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add encrypt shadow example (#5746)
上级
df08f42a
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
140 addition
and
7 deletion
+140
-7
examples/example-core/config-utility/src/main/java/org/apache/shardingsphere/example/type/ShardingType.java
.../org/apache/shardingsphere/example/type/ShardingType.java
+2
-0
examples/shardingsphere-jdbc-example/other-feature-example/shadow-example/shadow-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/shadow/table/raw/jdbc/JavaConfigurationExampleMain.java
...e/shadow/table/raw/jdbc/JavaConfigurationExampleMain.java
+1
-0
examples/shardingsphere-jdbc-example/other-feature-example/shadow-example/shadow-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/shadow/table/raw/jdbc/YamlConfigurationExampleMain.java
...e/shadow/table/raw/jdbc/YamlConfigurationExampleMain.java
+1
-0
examples/shardingsphere-jdbc-example/other-feature-example/shadow-example/shadow-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/shadow/table/raw/jdbc/config/EncryptShadowDatabasesConfiguration.java
.../raw/jdbc/config/EncryptShadowDatabasesConfiguration.java
+71
-0
examples/shardingsphere-jdbc-example/other-feature-example/shadow-example/shadow-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/shadow/table/raw/jdbc/config/ShadowDatabasesConfiguration.java
...w/table/raw/jdbc/config/ShadowDatabasesConfiguration.java
+2
-7
examples/shardingsphere-jdbc-example/other-feature-example/shadow-example/shadow-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/shadow/table/raw/jdbc/factory/DataSourceFactory.java
...mple/shadow/table/raw/jdbc/factory/DataSourceFactory.java
+3
-0
examples/shardingsphere-jdbc-example/other-feature-example/shadow-example/shadow-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/shadow/table/raw/jdbc/factory/YamlDataSourceFactory.java
.../shadow/table/raw/jdbc/factory/YamlDataSourceFactory.java
+2
-0
examples/shardingsphere-jdbc-example/other-feature-example/shadow-example/shadow-raw-jdbc-example/src/main/resources/META-INF/encrypt-shadow-databases.yaml
...src/main/resources/META-INF/encrypt-shadow-databases.yaml
+58
-0
未找到文件。
examples/example-core/config-utility/src/main/java/org/apache/shardingsphere/example/type/ShardingType.java
浏览文件 @
eb29dfd6
...
...
@@ -27,6 +27,8 @@ public enum ShardingType {
SHARDING_SHADOW_DATABASES
,
ENCRYPT_SHADOW
,
MASTER_SLAVE
,
SHARDING_MASTER_SLAVE
,
...
...
examples/shardingsphere-jdbc-example/other-feature-example/shadow-example/shadow-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/shadow/table/raw/jdbc/JavaConfigurationExampleMain.java
浏览文件 @
eb29dfd6
...
...
@@ -34,6 +34,7 @@ import java.sql.SQLException;
public
class
JavaConfigurationExampleMain
{
private
static
ShardingType
shardingType
=
ShardingType
.
SHADOW
;
//private static ShardingType shardingType = ShardingType.ENCRYPT_SHADOW;
// private static ShardingType shardingType = ShardingType.SHARDING_SHADOW_DATABASES;
public
static
void
main
(
final
String
[]
args
)
throws
SQLException
{
...
...
examples/shardingsphere-jdbc-example/other-feature-example/shadow-example/shadow-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/shadow/table/raw/jdbc/YamlConfigurationExampleMain.java
浏览文件 @
eb29dfd6
...
...
@@ -31,6 +31,7 @@ import java.sql.SQLException;
public
class
YamlConfigurationExampleMain
{
private
static
ShardingType
shardingType
=
ShardingType
.
SHADOW
;
// private static ShardingType shardingType = ShardingType.ENCRYPT_SHADOW;
// private static ShardingType shardingType = ShardingType.SHARDING_SHADOW_DATABASES;
public
static
void
main
(
final
String
[]
args
)
throws
SQLException
,
IOException
{
...
...
examples/shardingsphere-jdbc-example/other-feature-example/shadow-example/shadow-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/shadow/table/raw/jdbc/config/EncryptShadowDatabasesConfiguration.java
0 → 100644
浏览文件 @
eb29dfd6
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.apache.shardingsphere.example.shadow.table.raw.jdbc.config
;
import
org.apache.shardingsphere.driver.api.ShardingSphereDataSourceFactory
;
import
org.apache.shardingsphere.encrypt.api.config.EncryptColumnRuleConfiguration
;
import
org.apache.shardingsphere.encrypt.api.config.EncryptRuleConfiguration
;
import
org.apache.shardingsphere.encrypt.api.config.EncryptTableRuleConfiguration
;
import
org.apache.shardingsphere.encrypt.api.config.EncryptorRuleConfiguration
;
import
org.apache.shardingsphere.example.config.ExampleConfiguration
;
import
org.apache.shardingsphere.example.core.api.DataSourceUtil
;
import
org.apache.shardingsphere.shadow.api.config.ShadowRuleConfiguration
;
import
javax.sql.DataSource
;
import
java.sql.SQLException
;
import
java.util.Arrays
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Properties
;
public
final
class
EncryptShadowDatabasesConfiguration
implements
ExampleConfiguration
{
@Override
public
DataSource
getDataSource
()
throws
SQLException
{
ShadowRuleConfiguration
shadowRuleConfiguration
=
new
ShadowRuleConfiguration
(
"shadow"
,
Collections
.
singletonMap
(
"ds"
,
"ds_0"
));
Map
<
String
,
DataSource
>
dataSourceMap
=
new
HashMap
<>();
dataSourceMap
.
put
(
"ds"
,
DataSourceUtil
.
createDataSource
(
"demo_ds"
));
dataSourceMap
.
put
(
"ds_0"
,
DataSourceUtil
.
createDataSource
(
"shadow_demo_ds"
));
EncryptRuleConfiguration
encryptRuleConfiguration
=
new
EncryptRuleConfiguration
(
getEncryptorRuleConfiguration
(),
getEncryptTableRuleConfiguration
());
Properties
properties
=
new
Properties
();
properties
.
setProperty
(
"sql.show"
,
"true"
);
properties
.
setProperty
(
"query.with.cipher.column"
,
"true"
);
return
ShardingSphereDataSourceFactory
.
createDataSource
(
dataSourceMap
,
Arrays
.
asList
(
shadowRuleConfiguration
,
encryptRuleConfiguration
),
properties
);
}
private
Map
<
String
,
EncryptorRuleConfiguration
>
getEncryptorRuleConfiguration
()
{
Map
<
String
,
EncryptorRuleConfiguration
>
result
=
new
HashMap
<>();
Properties
properties
=
new
Properties
();
properties
.
setProperty
(
"aes.key.value"
,
"123456"
);
EncryptorRuleConfiguration
nameEncryptorRuleConfiguration
=
new
EncryptorRuleConfiguration
(
"aes"
,
properties
);
EncryptorRuleConfiguration
pwdEncryptorRuleConfiguration
=
new
EncryptorRuleConfiguration
(
"assistedTest"
,
null
);
result
.
put
(
"name_encryptror"
,
nameEncryptorRuleConfiguration
);
result
.
put
(
"pwd_encryptror"
,
pwdEncryptorRuleConfiguration
);
return
result
;
}
private
Map
<
String
,
EncryptTableRuleConfiguration
>
getEncryptTableRuleConfiguration
()
{
Map
<
String
,
EncryptTableRuleConfiguration
>
result
=
new
HashMap
<>();
Map
<
String
,
EncryptColumnRuleConfiguration
>
columns
=
new
HashMap
<>();
columns
.
put
(
"user_name"
,
new
EncryptColumnRuleConfiguration
(
"user_name_plain"
,
"user_name"
,
""
,
"name_encryptror"
));
columns
.
put
(
"pwd"
,
new
EncryptColumnRuleConfiguration
(
""
,
"pwd"
,
"assisted_query_pwd"
,
"pwd_encryptror"
));
result
.
put
(
"t_user"
,
new
EncryptTableRuleConfiguration
(
columns
));
return
result
;
}
}
examples/shardingsphere-jdbc-example/other-feature-example/shadow-example/shadow-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/shadow/table/raw/jdbc/config/ShadowDatabasesConfiguration.java
浏览文件 @
eb29dfd6
...
...
@@ -31,16 +31,11 @@ import java.util.Map;
public
final
class
ShadowDatabasesConfiguration
implements
ExampleConfiguration
{
@Override
public
DataSource
getDataSource
()
{
public
DataSource
getDataSource
()
throws
SQLException
{
ShadowRuleConfiguration
shadowRuleConfiguration
=
new
ShadowRuleConfiguration
(
"shadow"
,
Collections
.
singletonMap
(
"ds"
,
"ds_0"
));
Map
<
String
,
DataSource
>
dataSourceMap
=
new
HashMap
<>();
dataSourceMap
.
put
(
"ds"
,
DataSourceUtil
.
createDataSource
(
"demo_ds"
));
dataSourceMap
.
put
(
"ds_0"
,
DataSourceUtil
.
createDataSource
(
"shadow_demo_ds"
));
try
{
return
ShardingSphereDataSourceFactory
.
createDataSource
(
dataSourceMap
,
Collections
.
singleton
(
shadowRuleConfiguration
),
null
);
}
catch
(
final
SQLException
ex
)
{
ex
.
printStackTrace
();
return
null
;
}
return
ShardingSphereDataSourceFactory
.
createDataSource
(
dataSourceMap
,
Collections
.
singleton
(
shadowRuleConfiguration
),
null
);
}
}
examples/shardingsphere-jdbc-example/other-feature-example/shadow-example/shadow-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/shadow/table/raw/jdbc/factory/DataSourceFactory.java
浏览文件 @
eb29dfd6
...
...
@@ -17,6 +17,7 @@
package
org.apache.shardingsphere.example.shadow.table.raw.jdbc.factory
;
import
org.apache.shardingsphere.example.shadow.table.raw.jdbc.config.EncryptShadowDatabasesConfiguration
;
import
org.apache.shardingsphere.example.shadow.table.raw.jdbc.config.ShadowDatabasesConfiguration
;
import
org.apache.shardingsphere.example.shadow.table.raw.jdbc.config.ShardingShadowDatabasesConfiguration
;
import
org.apache.shardingsphere.example.type.ShardingType
;
...
...
@@ -32,6 +33,8 @@ public class DataSourceFactory {
return
new
ShadowDatabasesConfiguration
().
getDataSource
();
case
SHARDING_SHADOW_DATABASES:
return
new
ShardingShadowDatabasesConfiguration
().
getDataSource
();
case
ENCRYPT_SHADOW:
return
new
EncryptShadowDatabasesConfiguration
().
getDataSource
();
default
:
throw
new
UnsupportedOperationException
(
shardingType
.
name
());
}
...
...
examples/shardingsphere-jdbc-example/other-feature-example/shadow-example/shadow-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/shadow/table/raw/jdbc/factory/YamlDataSourceFactory.java
浏览文件 @
eb29dfd6
...
...
@@ -33,6 +33,8 @@ public class YamlDataSourceFactory {
return
YamlShardingSphereDataSourceFactory
.
createDataSource
(
getFile
(
"/META-INF/sharding-shadow-databases.yaml"
));
case
SHADOW:
return
YamlShardingSphereDataSourceFactory
.
createDataSource
(
getFile
(
"/META-INF/shadow-databases.yaml"
));
case
ENCRYPT_SHADOW:
return
YamlShardingSphereDataSourceFactory
.
createDataSource
(
getFile
(
"/META-INF/encrypt-shadow-databases.yaml"
));
default
:
throw
new
UnsupportedOperationException
(
shardingType
.
name
());
}
...
...
examples/shardingsphere-jdbc-example/other-feature-example/shadow-example/shadow-raw-jdbc-example/src/main/resources/META-INF/encrypt-shadow-databases.yaml
0 → 100644
浏览文件 @
eb29dfd6
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
dataSources
:
ds
:
!!com.zaxxer.hikari.HikariDataSource
driverClassName
:
com.mysql.jdbc.Driver
jdbcUrl
:
jdbc:mysql://localhost:3306/demo_ds?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
username
:
root
password
:
ds_0
:
!!com.zaxxer.hikari.HikariDataSource
driverClassName
:
com.mysql.jdbc.Driver
jdbcUrl
:
jdbc:mysql://localhost:3306/shadow_demo_ds?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
username
:
root
password
:
rules
:
-
!SHADOW
column
:
shadow
shadowMappings
:
ds
:
ds_0
-
!ENCRYPT
encryptors
:
name_encryptror
:
type
:
aes
props
:
aes.key.value
:
123456
pwd_encryptror
:
type
:
assistedTest
tables
:
t_user
:
columns
:
user_name
:
plainColumn
:
user_name_plain
cipherColumn
:
user_name
encryptor
:
name_encryptror
pwd
:
cipherColumn
:
pwd
encryptor
:
pwd_encryptror
assistedQueryColumn
:
assisted_query_pwd
props
:
query.with.cipher.column
:
true
sql.show
:
true
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录