You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by pa...@apache.org on 2023/05/09 01:16:34 UTC
[shardingsphere] branch master updated: Merge like encryptor spi to encryptor spi (#25528)
This is an automated email from the ASF dual-hosted git repository.
panjuan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 93606ea3b27 Merge like encryptor spi to encryptor spi (#25528)
93606ea3b27 is described below
commit 93606ea3b2754ba3e52f65625ccc9871c61dc3c4
Author: Zhengqiang Duan <du...@apache.org>
AuthorDate: Tue May 9 09:16:17 2023 +0800
Merge like encryptor spi to encryptor spi (#25528)
---
...herColumn__ShardingSphere_5.3.0_Deep_Dive.en.md | 5 ++--
docs/document/content/dev-manual/encrypt.cn.md | 17 +----------
docs/document/content/dev-manual/encrypt.en.md | 15 ----------
.../common-config/builtin-algorithm/encrypt.cn.md | 9 +++---
.../common-config/builtin-algorithm/encrypt.en.md | 9 +++---
.../java-api/rules/encrypt.cn.md | 5 ++--
.../java-api/rules/encrypt.en.md | 5 ++--
.../shardingsphere-jdbc/java-api/rules/mix.cn.md | 11 ++++---
.../shardingsphere-jdbc/java-api/rules/mix.en.md | 5 ++--
.../yaml-config/rules/encrypt.cn.md | 5 ++--
.../yaml-config/rules/encrypt.en.md | 5 ++--
.../yaml-config/rules/mix.cn.md | 1 -
.../yaml-config/rules/mix.en.md | 1 -
.../TestQueryAssistedShardingEncryptAlgorithm.java | 4 +--
.../api/config/EncryptRuleConfiguration.java | 7 -----
.../encrypt/like}/LikeEncryptAlgorithm.java | 16 ++--------
.../standard/StandardEncryptAlgorithm.java} | 16 +++++-----
.../encrypt/spi/EncryptAlgorithm.java | 11 +------
.../algorithm/encrypt/AESEncryptAlgorithm.java | 4 +--
.../algorithm/encrypt/MD5EncryptAlgorithm.java | 4 +--
.../algorithm/encrypt/RC4EncryptAlgorithm.java | 4 +--
.../like/CharDigestLikeEncryptAlgorithm.java | 4 +--
.../checker/EncryptRuleConfigurationChecker.java | 7 ++---
.../merge/dql/EncryptAlgorithmMetaData.java | 6 ++--
.../encrypt/merge/dql/EncryptMergedResult.java | 4 +--
...OnDuplicateKeyUpdateValueParameterRewriter.java | 10 +++----
.../EncryptInsertValueParameterRewriter.java | 10 +++----
.../generator/EncryptAlterTableTokenGenerator.java | 16 +++++-----
.../EncryptCreateTableTokenGenerator.java | 4 +--
.../EncryptInsertValuesTokenGenerator.java | 10 +++----
.../shardingsphere/encrypt/rule/EncryptRule.java | 35 ++++++++++++++--------
.../yaml/config/YamlEncryptRuleConfiguration.java | 2 --
.../YamlEncryptRuleConfigurationSwapper.java | 11 +------
...che.shardingsphere.encrypt.spi.EncryptAlgorithm | 1 +
...shardingsphere.encrypt.spi.LikeEncryptAlgorithm | 18 -----------
.../algorithm/encrypt/AESEncryptAlgorithmTest.java | 7 +++--
.../algorithm/encrypt/MD5EncryptAlgorithmTest.java | 5 ++--
.../algorithm/encrypt/RC4EncryptAlgorithmTest.java | 7 +++--
.../like/CharDigestLikeEncryptAlgorithmTest.java | 9 +++---
.../fixture/CoreEncryptAlgorithmFixture.java | 4 +--
.../CoreQueryAssistedEncryptAlgorithmFixture.java | 4 +--
.../CoreQueryLikeEncryptAlgorithmFixture.java | 2 +-
.../merge/dql/EncryptAlgorithmMetaDataTest.java | 11 +++----
.../impl/EncryptAlterTableTokenGeneratorTest.java | 4 +--
.../impl/EncryptCreateTableTokenGeneratorTest.java | 4 +--
.../impl/EncryptOrderByItemTokenGeneratorTest.java | 4 +--
.../EncryptInsertOnUpdateTokenGeneratorTest.java | 6 ++--
.../EncryptAssignmentTokenGeneratorTest.java | 4 +--
.../fixture/EncryptGeneratorFixtureBuilder.java | 8 +++--
.../encrypt/rule/EncryptRuleTest.java | 16 +++++-----
.../yaml/EncryptRuleConfigurationYamlIT.java | 6 ----
...che.shardingsphere.encrypt.spi.EncryptAlgorithm | 1 +
...shardingsphere.encrypt.spi.LikeEncryptAlgorithm | 18 -----------
.../converter/EncryptRuleStatementConverter.java | 11 +------
.../handler/query/ShowEncryptRuleExecutor.java | 7 ++---
.../update/AlterEncryptRuleStatementUpdater.java | 9 +-----
.../update/CreateEncryptRuleStatementUpdater.java | 9 +-----
.../src/main/antlr4/imports/encrypt/BaseRule.g4 | 7 ++---
.../encrypt/sm/algorithm/SM3EncryptAlgorithm.java | 4 +--
.../encrypt/sm/algorithm/SM4EncryptAlgorithm.java | 6 ++--
.../sm/algorithm/SM3EncryptAlgorithmTest.java | 5 ++--
.../sm/algorithm/SM4EncryptAlgorithmTest.java | 15 +++++-----
.../ConvertYamlConfigurationExecutor.java | 12 ++++----
.../resources/conf/convert/config-encrypt.yaml | 1 -
.../test/resources/conf/convert/config-mix.yaml | 3 +-
.../encrypt/JDBCEncryptAlgorithmFixture.java | 4 +--
.../JDBCQueryAssistedEncryptAlgorithmFixture.java | 4 +--
.../encrypt/proxy/conf/mysql/config-encrypt.yaml | 1 -
.../proxy/conf/opengauss/config-encrypt.yaml | 1 -
.../proxy/conf/postgresql/config-encrypt.yaml | 1 -
.../test/resources/env/scenario/encrypt/rules.yaml | 1 -
.../RewriteNormalEncryptAlgorithmFixture.java | 4 +--
...ewriteQueryAssistedEncryptAlgorithmFixture.java | 4 +--
.../RewriteQueryLikeEncryptAlgorithmFixture.java | 2 +-
...che.shardingsphere.encrypt.spi.EncryptAlgorithm | 1 +
...shardingsphere.encrypt.spi.LikeEncryptAlgorithm | 18 -----------
.../scenario/encrypt/config/query-with-cipher.yaml | 1 -
77 files changed, 197 insertions(+), 351 deletions(-)
diff --git a/docs/blog/content/material/2022_12_28_Fuzzy_query_for_CipherColumn__ShardingSphere_5.3.0_Deep_Dive.en.md b/docs/blog/content/material/2022_12_28_Fuzzy_query_for_CipherColumn__ShardingSphere_5.3.0_Deep_Dive.en.md
index 2b26d4d051b..0d6976c54de 100644
--- a/docs/blog/content/material/2022_12_28_Fuzzy_query_for_CipherColumn__ShardingSphere_5.3.0_Deep_Dive.en.md
+++ b/docs/blog/content/material/2022_12_28_Fuzzy_query_for_CipherColumn__ShardingSphere_5.3.0_Deep_Dive.en.md
@@ -317,13 +317,12 @@ dataSources:
rules:
- !ENCRYPT
encryptors:
+ like_encryptor:
+ type: CHAR_DIGEST_LIKE
aes_encryptor:
type: AES
props:
aes-key-value: 123456abc
- likeEncryptors:
- like_encryptor:
- type: CHAR_DIGEST_LIKE
tables:
user:
columns:
diff --git a/docs/document/content/dev-manual/encrypt.cn.md b/docs/document/content/dev-manual/encrypt.cn.md
index 2230c59e16f..f8060033b7e 100644
--- a/docs/document/content/dev-manual/encrypt.cn.md
+++ b/docs/document/content/dev-manual/encrypt.cn.md
@@ -24,19 +24,4 @@ chapter = true
| RC4 | 基于 RC4 的数据加密算法 | [`org.apache.shardingsphere.encrypt.algorithm.encrypt.RC4EncryptAlgorithm`](https://github.com/apache/shardingsphere/blob/master/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/encrypt/RC4EncryptAlgorithm.java) |
| SM3 | 基于 SM3 的数据加密算法 | [`org.apache.shardingsphere.encrypt.sm.algorithm.SM3EncryptAlgorithm`](https://github.com/apache/shardingsphere/blob/master/features/encrypt/plugin/sm/src/main/java/org/apache/shardingsphere/encrypt/sm/algorithm/SM3EncryptAlgorithm.java) |
| SM4 | 基于 SM4 的数据加密算法 | [`org.apache.shardingsphere.encrypt.sm.algorithm.SM4EncryptAlgorithm`](https://github.com/apache/shardingsphere/blob/master/features/encrypt/plugin/sm/src/main/java/org/apache/shardingsphere/encrypt/sm/algorithm/SM4EncryptAlgorithm.java) |
-
-## LikeEncryptAlgorithm
-
-### 全限定类名
-
-[`org.apache.shardingsphere.encrypt.spi.LikeEncryptAlgorithm`](https://github.com/apache/shardingsphere/blob/master/features/encrypt/api/src/main/java/org/apache/shardingsphere/encrypt/spi/LikeEncryptAlgorithm.java)
-
-### 定义
-
-数据模糊查询辅助算法
-
-### 已知实现
-
-| *配置标识* | *详细说明* | *全限定类名* |
-|------------------|----------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
-| CHAR_DIGEST_LIKE | 用于模糊查询的数据加密算法 | [`org.apache.shardingsphere.encrypt.algorithm.like.CharDigestLikeEncryptAlgorithm`](https://github.com/apache/shardingsphere/blob/master/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/like/CharDigestLikeEncryptAlgorithm.java) |
\ No newline at end of file
+| CHAR_DIGEST_LIKE | 用于模糊查询的数据加密算法 | [`org.apache.shardingsphere.encrypt.algorithm.like.CharDigestLikeEncryptAlgorithm`](https://github.com/apache/shardingsphere/blob/master/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/like/CharDigestLikeEncryptAlgorithm.java) |
diff --git a/docs/document/content/dev-manual/encrypt.en.md b/docs/document/content/dev-manual/encrypt.en.md
index 053fb4ee7fd..25a8cad37f4 100644
--- a/docs/document/content/dev-manual/encrypt.en.md
+++ b/docs/document/content/dev-manual/encrypt.en.md
@@ -24,19 +24,4 @@ Data encrypt algorithm definition
| RC4 | RC4 data encrypt algorithm | [`org.apache.shardingsphere.encrypt.algorithm.encrypt.RC4EncryptAlgorithm`](https://github.com/apache/shardingsphere/blob/master/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/encrypt/RC4EncryptAlgorithm.java) |
| SM3 | SM3 data encrypt algorithm | [`org.apache.shardingsphere.encrypt.sm.algorithm.SM3EncryptAlgorithm`](https://github.com/apache/shardingsphere/blob/master/features/encrypt/plugin/sm/src/main/java/org/apache/shardingsphere/encrypt/sm/algorithm/SM3EncryptAlgorithm.java) |
| SM4 | SM4 data encrypt algorithm | [`org.apache.shardingsphere.encrypt.sm.algorithm.SM4EncryptAlgorithm`](https://github.com/apache/shardingsphere/blob/master/features/encrypt/plugin/sm/src/main/java/org/apache/shardingsphere/encrypt/sm/algorithm/SM4EncryptAlgorithm.java) |
-
-## LikeEncryptAlgorithm
-
-### Fully-qualified class name
-
-[`org.apache.shardingsphere.encrypt.spi.LikeEncryptAlgorithm`](https://github.com/apache/shardingsphere/blob/master/features/encrypt/api/src/main/java/org/apache/shardingsphere/encrypt/spi/LikeEncryptAlgorithm.java)
-
-### Definition
-
-Data like assist query algorithm definition
-
-### Implementation classes
-
-| *Configuration Type* | *Description* | *Fully-qualified class name* |
-|----------------------|---------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| CHAR_DIGEST_LIKE | Data encryption algorithms for like queries | [`org.apache.shardingsphere.encrypt.algorithm.like.CharDigestLikeEncryptAlgorithm`](https://github.com/apache/shardingsphere/blob/master/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/like/CharDigestLikeEncryptAlgorithm.java) |
diff --git a/docs/document/content/user-manual/common-config/builtin-algorithm/encrypt.cn.md b/docs/document/content/user-manual/common-config/builtin-algorithm/encrypt.cn.md
index 85961c6080b..5481105fa0c 100644
--- a/docs/document/content/user-manual/common-config/builtin-algorithm/encrypt.cn.md
+++ b/docs/document/content/user-manual/common-config/builtin-algorithm/encrypt.cn.md
@@ -64,9 +64,9 @@ weight = 5
| sm4-iv | String | SM4 使用的 IV (MODE 为 CBC 时需指定,16 Bytes) |
| sm4-padding | String | SM4 使用的 PADDING (PKCS5Padding 或 PKCS7Padding,暂不支持 NoPadding) |
-### 模糊查询辅助算法
+### 模糊加密算法
-#### 单字符摘要模糊查询辅助算法
+#### 单字符摘要模糊加密算法
类型:CHAR_DIGEST_LIKE
@@ -97,13 +97,12 @@ rules:
likeQueryColumn: name_like
likeQueryEncryptorName: like_encryptor
encryptors:
+ like_encryptor:
+ type: CHAR_DIGEST_LIKE
name_encryptor:
type: AES
props:
aes-key-value: 123456abc
- likeEncryptors:
- like_encryptor:
- type: CHAR_DIGEST_LIKE
```
## 相关参考
diff --git a/docs/document/content/user-manual/common-config/builtin-algorithm/encrypt.en.md b/docs/document/content/user-manual/common-config/builtin-algorithm/encrypt.en.md
index 937112e503c..003453af8b4 100644
--- a/docs/document/content/user-manual/common-config/builtin-algorithm/encrypt.en.md
+++ b/docs/document/content/user-manual/common-config/builtin-algorithm/encrypt.en.md
@@ -64,9 +64,9 @@ Attributes:
| sm4-iv | String | SM4 IV (should be specified on CBC, 16 bytes long) |
| sm4-padding | String | SM4 PADDING (should be PKCS5Padding or PKCS7Padding, NoPadding excepted) |
-### Like Assist Query Algorithm
+### Like Encrypt Algorithm
-#### CharDigestLike Like Assist Query Algorithm
+#### CharDigestLike Encrypt Algorithm
Type:CHAR_DIGEST_LIKE
@@ -97,13 +97,12 @@ rules:
likeQueryColumn: name_like
likeQueryEncryptorName: like_encryptor
encryptors:
+ like_encryptor:
+ type: CHAR_DIGEST_LIKE
name_encryptor:
type: AES
props:
aes-key-value: 123456abc
- likeEncryptors:
- like_encryptor:
- type: CHAR_DIGEST_LIKE
```
## Related References
diff --git a/docs/document/content/user-manual/shardingsphere-jdbc/java-api/rules/encrypt.cn.md b/docs/document/content/user-manual/shardingsphere-jdbc/java-api/rules/encrypt.cn.md
index 7b698b45774..c669843e010 100644
--- a/docs/document/content/user-manual/shardingsphere-jdbc/java-api/rules/encrypt.cn.md
+++ b/docs/document/content/user-manual/shardingsphere-jdbc/java-api/rules/encrypt.cn.md
@@ -81,9 +81,8 @@ public final class EncryptDatabasesConfiguration {
Map<String, AlgorithmConfiguration> encryptAlgorithmConfigs = new HashMap<>();
encryptAlgorithmConfigs.put("name_encryptor", new AlgorithmConfiguration("AES", props));
encryptAlgorithmConfigs.put("pwd_encryptor", new AlgorithmConfiguration("assistedTest", props));
- Map<String, AlgorithmConfiguration> likeEncryptAlgorithmConfigs = new HashMap<>();
- likeEncryptAlgorithmConfigs.put("like_encryptor", new AlgorithmConfiguration("CHAR_DIGEST_LIKE", new Properties()));
- EncryptRuleConfiguration encryptRuleConfig = new EncryptRuleConfiguration(Collections.singleton(encryptTableRuleConfig), encryptAlgorithmConfigs, likeEncryptAlgorithmConfigs);
+ encryptAlgorithmConfigs.put("like_encryptor", new AlgorithmConfiguration("CHAR_DIGEST_LIKE", new Properties()));
+ EncryptRuleConfiguration encryptRuleConfig = new EncryptRuleConfiguration(Collections.singleton(encryptTableRuleConfig), encryptAlgorithmConfigs);
return ShardingSphereDataSourceFactory.createDataSource(DataSourceUtil.createDataSource("demo_ds"), Collections.singleton(encryptRuleConfig), props);
}
}
diff --git a/docs/document/content/user-manual/shardingsphere-jdbc/java-api/rules/encrypt.en.md b/docs/document/content/user-manual/shardingsphere-jdbc/java-api/rules/encrypt.en.md
index e95bd87e389..caee7caa475 100644
--- a/docs/document/content/user-manual/shardingsphere-jdbc/java-api/rules/encrypt.en.md
+++ b/docs/document/content/user-manual/shardingsphere-jdbc/java-api/rules/encrypt.en.md
@@ -81,9 +81,8 @@ public final class EncryptDatabasesConfiguration {
Map<String, AlgorithmConfiguration> encryptAlgorithmConfigs = new HashMap<>();
encryptAlgorithmConfigs.put("name_encryptor", new AlgorithmConfiguration("AES", props));
encryptAlgorithmConfigs.put("pwd_encryptor", new AlgorithmConfiguration("assistedTest", props));
- Map<String, AlgorithmConfiguration> likeEncryptAlgorithmConfigs = new HashMap<>();
- likeEncryptAlgorithmConfigs.put("like_encryptor", new AlgorithmConfiguration("CHAR_DIGEST_LIKE", new Properties()));
- EncryptRuleConfiguration encryptRuleConfig = new EncryptRuleConfiguration(Collections.singleton(encryptTableRuleConfig), encryptAlgorithmConfigs, likeEncryptAlgorithmConfigs);
+ encryptAlgorithmConfigs.put("like_encryptor", new AlgorithmConfiguration("CHAR_DIGEST_LIKE", new Properties()));
+ EncryptRuleConfiguration encryptRuleConfig = new EncryptRuleConfiguration(Collections.singleton(encryptTableRuleConfig), encryptAlgorithmConfigs);
return ShardingSphereDataSourceFactory.createDataSource(DataSourceUtil.createDataSource("demo_ds"), Collections.singleton(encryptRuleConfig), props);
}
}
diff --git a/docs/document/content/user-manual/shardingsphere-jdbc/java-api/rules/mix.cn.md b/docs/document/content/user-manual/shardingsphere-jdbc/java-api/rules/mix.cn.md
index 54c044336f0..e667cc471da 100644
--- a/docs/document/content/user-manual/shardingsphere-jdbc/java-api/rules/mix.cn.md
+++ b/docs/document/content/user-manual/shardingsphere-jdbc/java-api/rules/mix.cn.md
@@ -44,14 +44,13 @@ private static ReadwriteSplittingRuleConfiguration createReadwriteSplittingConfi
public EncryptRuleConfiguration createEncryptRuleConfiguration() {
Properties props = new Properties();
props.setProperty("aes-key-value", "123456");
- EncryptColumnRuleConfiguration columnConfigAes = new EncryptColumnRuleConfiguration("username", "username", "", "", "username_plain", "name_encryptor", null);
- EncryptColumnRuleConfiguration columnConfigTest = new EncryptColumnRuleConfiguration("pwd", "pwd", "assisted_query_pwd", "like_pwd", "", "pwd_encryptor", null);
- EncryptTableRuleConfiguration encryptTableRuleConfig = new EncryptTableRuleConfiguration("t_user", Arrays.asList(columnConfigAes, columnConfigTest), null);
+ EncryptColumnRuleConfiguration columnConfigAes = new EncryptColumnRuleConfiguration("username", "username", "", "", "name_encryptor");
+ EncryptColumnRuleConfiguration columnConfigTest = new EncryptColumnRuleConfiguration("pwd", "pwd", "assisted_query_pwd", "like_pwd", "pwd_encryptor");
+ EncryptTableRuleConfiguration encryptTableRuleConfig = new EncryptTableRuleConfiguration("t_user", Arrays.asList(columnConfigAes, columnConfigTest));
Map<String, AlgorithmConfiguration> encryptAlgorithmConfigs = new HashMap<>();
encryptAlgorithmConfigs.put("name_encryptor", new AlgorithmConfiguration("AES", props));
encryptAlgorithmConfigs.put("pwd_encryptor", new AlgorithmConfiguration("assistedTest", props));
- Map<String, AlgorithmConfiguration> likeEncryptAlgorithmConfigs = new HashMap<>();
- likeEncryptAlgorithmConfigs.put("like_encryptor", new AlgorithmConfiguration("CHAR_DIGEST_LIKE", new Properties()));
- return new EncryptRuleConfiguration(Collections.singleton(encryptTableRuleConfig), encryptAlgorithmConfigs, likeEncryptAlgorithmConfigs);
+ encryptAlgorithmConfigs.put("like_encryptor", new AlgorithmConfiguration("CHAR_DIGEST_LIKE", new Properties()));
+ return new EncryptRuleConfiguration(Collections.singleton(encryptTableRuleConfig), encryptAlgorithmConfigs);
}
```
diff --git a/docs/document/content/user-manual/shardingsphere-jdbc/java-api/rules/mix.en.md b/docs/document/content/user-manual/shardingsphere-jdbc/java-api/rules/mix.en.md
index e7df0471a5e..d235242074b 100644
--- a/docs/document/content/user-manual/shardingsphere-jdbc/java-api/rules/mix.en.md
+++ b/docs/document/content/user-manual/shardingsphere-jdbc/java-api/rules/mix.en.md
@@ -51,8 +51,7 @@ public EncryptRuleConfiguration createEncryptRuleConfiguration() {
Map<String, AlgorithmConfiguration> encryptAlgorithmConfigs = new HashMap<>();
encryptAlgorithmConfigs.put("name_encryptor", new AlgorithmConfiguration("AES", props));
encryptAlgorithmConfigs.put("pwd_encryptor", new AlgorithmConfiguration("assistedTest", props));
- Map<String, AlgorithmConfiguration> likeEncryptAlgorithmConfigs = new HashMap<>();
- likeEncryptAlgorithmConfigs.put("like_encryptor", new AlgorithmConfiguration("CHAR_DIGEST_LIKE", new Properties()));
- return new EncryptRuleConfiguration(Collections.singleton(encryptTableRuleConfig), encryptAlgorithmConfigs, likeEncryptAlgorithmConfigs);
+ encryptAlgorithmConfigs.put("like_encryptor", new AlgorithmConfiguration("CHAR_DIGEST_LIKE", new Properties()));
+ return new EncryptRuleConfiguration(Collections.singleton(encryptTableRuleConfig), encryptAlgorithmConfigs);
}
```
diff --git a/docs/document/content/user-manual/shardingsphere-jdbc/yaml-config/rules/encrypt.cn.md b/docs/document/content/user-manual/shardingsphere-jdbc/yaml-config/rules/encrypt.cn.md
index 0ea60e1f03c..b940e932e2c 100644
--- a/docs/document/content/user-manual/shardingsphere-jdbc/yaml-config/rules/encrypt.cn.md
+++ b/docs/document/content/user-manual/shardingsphere-jdbc/yaml-config/rules/encrypt.cn.md
@@ -77,11 +77,10 @@ rules:
type: AES
props:
aes-key-value: 123456abc
- pwd_encryptor:
- type: MD5
- likeEncryptors:
like_encryptor:
type: CHAR_DIGEST_LIKE
+ pwd_encryptor:
+ type: MD5
```
然后通过 YamlShardingSphereDataSourceFactory 的 createDataSource 方法创建数据源。
diff --git a/docs/document/content/user-manual/shardingsphere-jdbc/yaml-config/rules/encrypt.en.md b/docs/document/content/user-manual/shardingsphere-jdbc/yaml-config/rules/encrypt.en.md
index 43366b66f19..bdd187c5dae 100644
--- a/docs/document/content/user-manual/shardingsphere-jdbc/yaml-config/rules/encrypt.en.md
+++ b/docs/document/content/user-manual/shardingsphere-jdbc/yaml-config/rules/encrypt.en.md
@@ -78,11 +78,10 @@ rules:
type: AES
props:
aes-key-value: 123456abc
- pwd_encryptor:
- type: MD5
- likeEncryptors:
like_encryptor:
type: CHAR_DIGEST_LIKE
+ pwd_encryptor:
+ type: MD5
```
Read the YAML configuration to create a data source according to the createDataSource method of YamlShardingSphereDataSourceFactory.
diff --git a/docs/document/content/user-manual/shardingsphere-jdbc/yaml-config/rules/mix.cn.md b/docs/document/content/user-manual/shardingsphere-jdbc/yaml-config/rules/mix.cn.md
index e67b8ef7ca9..e7490a159ed 100644
--- a/docs/document/content/user-manual/shardingsphere-jdbc/yaml-config/rules/mix.cn.md
+++ b/docs/document/content/user-manual/shardingsphere-jdbc/yaml-config/rules/mix.cn.md
@@ -101,7 +101,6 @@ rules:
aes-key-value: 123456abc
md5_encryptor:
type: MD5
- likeEncryptors:
like_encryptor:
type: CHAR_DIGEST_LIKE
tables:
diff --git a/docs/document/content/user-manual/shardingsphere-jdbc/yaml-config/rules/mix.en.md b/docs/document/content/user-manual/shardingsphere-jdbc/yaml-config/rules/mix.en.md
index 7cd822fd3ed..56c0eb789f7 100644
--- a/docs/document/content/user-manual/shardingsphere-jdbc/yaml-config/rules/mix.en.md
+++ b/docs/document/content/user-manual/shardingsphere-jdbc/yaml-config/rules/mix.en.md
@@ -102,7 +102,6 @@ rules:
aes-key-value: 123456abc
md5_encryptor:
type: MD5
- likeEncryptors:
like_encryptor:
type: CHAR_DIGEST_LIKE
tables:
diff --git a/examples/example-core/config-utility/src/main/java/org/apache/shardingsphere/example/fixture/TestQueryAssistedShardingEncryptAlgorithm.java b/examples/example-core/config-utility/src/main/java/org/apache/shardingsphere/example/fixture/TestQueryAssistedShardingEncryptAlgorithm.java
index 68da21735de..d35977ea543 100644
--- a/examples/example-core/config-utility/src/main/java/org/apache/shardingsphere/example/fixture/TestQueryAssistedShardingEncryptAlgorithm.java
+++ b/examples/example-core/config-utility/src/main/java/org/apache/shardingsphere/example/fixture/TestQueryAssistedShardingEncryptAlgorithm.java
@@ -17,10 +17,10 @@
package org.apache.shardingsphere.example.fixture;
-import org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm;
import org.apache.shardingsphere.encrypt.api.context.EncryptContext;
+import org.apache.shardingsphere.encrypt.api.encrypt.standard.StandardEncryptAlgorithm;
-public final class TestQueryAssistedShardingEncryptAlgorithm implements EncryptAlgorithm<Object, String> {
+public final class TestQueryAssistedShardingEncryptAlgorithm implements StandardEncryptAlgorithm<Object, String> {
@Override
public String encrypt(final Object plainValue, final EncryptContext encryptContext) {
diff --git a/features/encrypt/api/src/main/java/org/apache/shardingsphere/encrypt/api/config/EncryptRuleConfiguration.java b/features/encrypt/api/src/main/java/org/apache/shardingsphere/encrypt/api/config/EncryptRuleConfiguration.java
index 69916a4466f..108fd51b1ee 100644
--- a/features/encrypt/api/src/main/java/org/apache/shardingsphere/encrypt/api/config/EncryptRuleConfiguration.java
+++ b/features/encrypt/api/src/main/java/org/apache/shardingsphere/encrypt/api/config/EncryptRuleConfiguration.java
@@ -25,7 +25,6 @@ import org.apache.shardingsphere.infra.config.rule.function.EnhancedRuleConfigur
import org.apache.shardingsphere.infra.config.rule.scope.DatabaseRuleConfiguration;
import java.util.Collection;
-import java.util.Collections;
import java.util.Map;
/**
@@ -38,10 +37,4 @@ public final class EncryptRuleConfiguration implements DatabaseRuleConfiguration
private final Collection<EncryptTableRuleConfiguration> tables;
private final Map<String, AlgorithmConfiguration> encryptors;
-
- private final Map<String, AlgorithmConfiguration> likeEncryptors;
-
- public EncryptRuleConfiguration(final Collection<EncryptTableRuleConfiguration> tables, final Map<String, AlgorithmConfiguration> encryptors) {
- this(tables, encryptors, Collections.emptyMap());
- }
}
diff --git a/features/encrypt/api/src/main/java/org/apache/shardingsphere/encrypt/spi/LikeEncryptAlgorithm.java b/features/encrypt/api/src/main/java/org/apache/shardingsphere/encrypt/api/encrypt/like/LikeEncryptAlgorithm.java
similarity index 64%
copy from features/encrypt/api/src/main/java/org/apache/shardingsphere/encrypt/spi/LikeEncryptAlgorithm.java
copy to features/encrypt/api/src/main/java/org/apache/shardingsphere/encrypt/api/encrypt/like/LikeEncryptAlgorithm.java
index 976be1d2078..d79902da884 100644
--- a/features/encrypt/api/src/main/java/org/apache/shardingsphere/encrypt/spi/LikeEncryptAlgorithm.java
+++ b/features/encrypt/api/src/main/java/org/apache/shardingsphere/encrypt/api/encrypt/like/LikeEncryptAlgorithm.java
@@ -15,10 +15,9 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.encrypt.spi;
+package org.apache.shardingsphere.encrypt.api.encrypt.like;
-import org.apache.shardingsphere.encrypt.api.context.EncryptContext;
-import org.apache.shardingsphere.infra.util.spi.type.typed.algorithm.ShardingSphereAlgorithm;
+import org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm;
/**
* Like encrypt algorithm.
@@ -26,14 +25,5 @@ import org.apache.shardingsphere.infra.util.spi.type.typed.algorithm.ShardingSph
* @param <I> type of plain value
* @param <O> type of cipher value
*/
-public interface LikeEncryptAlgorithm<I, O> extends ShardingSphereAlgorithm {
-
- /**
- * Encrypt.
- *
- * @param plainValue plain value
- * @param encryptContext encrypt context
- * @return cipher value
- */
- O encrypt(I plainValue, EncryptContext encryptContext);
+public interface LikeEncryptAlgorithm<I, O> extends EncryptAlgorithm<I, O> {
}
diff --git a/features/encrypt/api/src/main/java/org/apache/shardingsphere/encrypt/spi/LikeEncryptAlgorithm.java b/features/encrypt/api/src/main/java/org/apache/shardingsphere/encrypt/api/encrypt/standard/StandardEncryptAlgorithm.java
similarity index 72%
rename from features/encrypt/api/src/main/java/org/apache/shardingsphere/encrypt/spi/LikeEncryptAlgorithm.java
rename to features/encrypt/api/src/main/java/org/apache/shardingsphere/encrypt/api/encrypt/standard/StandardEncryptAlgorithm.java
index 976be1d2078..7b2de2ed64e 100644
--- a/features/encrypt/api/src/main/java/org/apache/shardingsphere/encrypt/spi/LikeEncryptAlgorithm.java
+++ b/features/encrypt/api/src/main/java/org/apache/shardingsphere/encrypt/api/encrypt/standard/StandardEncryptAlgorithm.java
@@ -15,25 +15,25 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.encrypt.spi;
+package org.apache.shardingsphere.encrypt.api.encrypt.standard;
import org.apache.shardingsphere.encrypt.api.context.EncryptContext;
-import org.apache.shardingsphere.infra.util.spi.type.typed.algorithm.ShardingSphereAlgorithm;
+import org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm;
/**
- * Like encrypt algorithm.
+ * Standard encrypt algorithm.
*
* @param <I> type of plain value
* @param <O> type of cipher value
*/
-public interface LikeEncryptAlgorithm<I, O> extends ShardingSphereAlgorithm {
+public interface StandardEncryptAlgorithm<I, O> extends EncryptAlgorithm<I, O> {
/**
- * Encrypt.
+ * Decrypt.
*
- * @param plainValue plain value
+ * @param cipherValue cipher value
* @param encryptContext encrypt context
- * @return cipher value
+ * @return plain value
*/
- O encrypt(I plainValue, EncryptContext encryptContext);
+ I decrypt(O cipherValue, EncryptContext encryptContext);
}
diff --git a/features/encrypt/api/src/main/java/org/apache/shardingsphere/encrypt/spi/EncryptAlgorithm.java b/features/encrypt/api/src/main/java/org/apache/shardingsphere/encrypt/spi/EncryptAlgorithm.java
index 9ca1a7f05a5..3b915f53dac 100644
--- a/features/encrypt/api/src/main/java/org/apache/shardingsphere/encrypt/spi/EncryptAlgorithm.java
+++ b/features/encrypt/api/src/main/java/org/apache/shardingsphere/encrypt/spi/EncryptAlgorithm.java
@@ -22,7 +22,7 @@ import org.apache.shardingsphere.infra.util.spi.type.typed.algorithm.ShardingSph
/**
* Encrypt algorithm.
- *
+ *
* @param <I> type of plain value
* @param <O> type of cipher value
*/
@@ -36,13 +36,4 @@ public interface EncryptAlgorithm<I, O> extends ShardingSphereAlgorithm {
* @return cipher value
*/
O encrypt(I plainValue, EncryptContext encryptContext);
-
- /**
- * Decrypt.
- *
- * @param cipherValue cipher value
- * @param encryptContext encrypt context
- * @return plain value
- */
- I decrypt(O cipherValue, EncryptContext encryptContext);
}
diff --git a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/encrypt/AESEncryptAlgorithm.java b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/encrypt/AESEncryptAlgorithm.java
index 0ae4978161e..0bdfb4a8ca9 100644
--- a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/encrypt/AESEncryptAlgorithm.java
+++ b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/encrypt/AESEncryptAlgorithm.java
@@ -20,7 +20,7 @@ package org.apache.shardingsphere.encrypt.algorithm.encrypt;
import com.google.common.base.Strings;
import lombok.SneakyThrows;
import org.apache.commons.codec.digest.DigestUtils;
-import org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm;
+import org.apache.shardingsphere.encrypt.api.encrypt.standard.StandardEncryptAlgorithm;
import org.apache.shardingsphere.encrypt.exception.algorithm.EncryptAlgorithmInitializationException;
import org.apache.shardingsphere.encrypt.api.context.EncryptContext;
import org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
@@ -39,7 +39,7 @@ import java.util.Properties;
/**
* AES encrypt algorithm.
*/
-public final class AESEncryptAlgorithm implements EncryptAlgorithm<Object, String> {
+public final class AESEncryptAlgorithm implements StandardEncryptAlgorithm<Object, String> {
private static final String AES_KEY = "aes-key-value";
diff --git a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/encrypt/MD5EncryptAlgorithm.java b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/encrypt/MD5EncryptAlgorithm.java
index c1a7d85a834..48bdb4e8536 100644
--- a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/encrypt/MD5EncryptAlgorithm.java
+++ b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/encrypt/MD5EncryptAlgorithm.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.encrypt.algorithm.encrypt;
import org.apache.commons.codec.digest.DigestUtils;
-import org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm;
+import org.apache.shardingsphere.encrypt.api.encrypt.standard.StandardEncryptAlgorithm;
import org.apache.shardingsphere.encrypt.api.context.EncryptContext;
import java.util.Properties;
@@ -26,7 +26,7 @@ import java.util.Properties;
/**
* MD5 encrypt algorithm.
*/
-public final class MD5EncryptAlgorithm implements EncryptAlgorithm<Object, String> {
+public final class MD5EncryptAlgorithm implements StandardEncryptAlgorithm<Object, String> {
private static final String SALT = "salt";
diff --git a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/encrypt/RC4EncryptAlgorithm.java b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/encrypt/RC4EncryptAlgorithm.java
index 3e56cf4c367..901e5944451 100644
--- a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/encrypt/RC4EncryptAlgorithm.java
+++ b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/encrypt/RC4EncryptAlgorithm.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.encrypt.algorithm.encrypt;
import org.apache.commons.codec.binary.Base64;
-import org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm;
+import org.apache.shardingsphere.encrypt.api.encrypt.standard.StandardEncryptAlgorithm;
import org.apache.shardingsphere.encrypt.exception.algorithm.EncryptAlgorithmInitializationException;
import org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
import org.apache.shardingsphere.encrypt.api.context.EncryptContext;
@@ -30,7 +30,7 @@ import java.util.Properties;
/**
* RC4 encrypt algorithm.
*/
-public final class RC4EncryptAlgorithm implements EncryptAlgorithm<Object, String> {
+public final class RC4EncryptAlgorithm implements StandardEncryptAlgorithm<Object, String> {
private static final String RC4_KEY = "rc4-key-value";
diff --git a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/like/CharDigestLikeEncryptAlgorithm.java b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/like/CharDigestLikeEncryptAlgorithm.java
index 65cf6c6a55a..b5b69fecefb 100644
--- a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/like/CharDigestLikeEncryptAlgorithm.java
+++ b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/like/CharDigestLikeEncryptAlgorithm.java
@@ -19,9 +19,9 @@ package org.apache.shardingsphere.encrypt.algorithm.like;
import com.google.common.base.Strings;
import lombok.SneakyThrows;
-import org.apache.shardingsphere.encrypt.api.context.EncryptContext;
+import org.apache.shardingsphere.encrypt.api.encrypt.like.LikeEncryptAlgorithm;
import org.apache.shardingsphere.encrypt.exception.algorithm.EncryptAlgorithmInitializationException;
-import org.apache.shardingsphere.encrypt.spi.LikeEncryptAlgorithm;
+import org.apache.shardingsphere.encrypt.api.context.EncryptContext;
import java.io.IOException;
import java.io.InputStream;
diff --git a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/checker/EncryptRuleConfigurationChecker.java b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/checker/EncryptRuleConfigurationChecker.java
index 24aa3058e44..84dbdd314eb 100644
--- a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/checker/EncryptRuleConfigurationChecker.java
+++ b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/checker/EncryptRuleConfigurationChecker.java
@@ -43,16 +43,15 @@ public final class EncryptRuleConfigurationChecker implements RuleConfigurationC
@Override
public void check(final String databaseName, final EncryptRuleConfiguration config, final Map<String, DataSource> dataSourceMap, final Collection<ShardingSphereRule> rules) {
- checkTableConfiguration(databaseName, config.getTables(), config.getEncryptors().keySet(), config.getLikeEncryptors().keySet());
+ checkTableConfiguration(databaseName, config.getTables(), config.getEncryptors().keySet());
}
- private void checkTableConfiguration(final String databaseName,
- final Collection<EncryptTableRuleConfiguration> tables, final Collection<String> encryptors, final Collection<String> likeEncryptors) {
+ private void checkTableConfiguration(final String databaseName, final Collection<EncryptTableRuleConfiguration> tables, final Collection<String> encryptors) {
for (EncryptTableRuleConfiguration each : tables) {
for (EncryptColumnRuleConfiguration column : each.getColumns()) {
checkCipherColumnConfiguration(databaseName, encryptors, column);
checkAssistColumnConfiguration(databaseName, encryptors, column);
- checkLikeColumnConfiguration(databaseName, likeEncryptors, column);
+ checkLikeColumnConfiguration(databaseName, encryptors, column);
}
}
}
diff --git a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/merge/dql/EncryptAlgorithmMetaData.java b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/merge/dql/EncryptAlgorithmMetaData.java
index 67a22116a9f..9b0e2acd508 100644
--- a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/merge/dql/EncryptAlgorithmMetaData.java
+++ b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/merge/dql/EncryptAlgorithmMetaData.java
@@ -18,10 +18,10 @@
package org.apache.shardingsphere.encrypt.merge.dql;
import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.encrypt.api.context.EncryptContext;
+import org.apache.shardingsphere.encrypt.api.encrypt.standard.StandardEncryptAlgorithm;
import org.apache.shardingsphere.encrypt.context.EncryptContextBuilder;
import org.apache.shardingsphere.encrypt.rule.EncryptRule;
-import org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm;
+import org.apache.shardingsphere.encrypt.api.context.EncryptContext;
import org.apache.shardingsphere.infra.binder.segment.select.projection.Projection;
import org.apache.shardingsphere.infra.binder.segment.select.projection.impl.ColumnProjection;
import org.apache.shardingsphere.infra.binder.segment.table.TablesContext;
@@ -54,7 +54,7 @@ public final class EncryptAlgorithmMetaData {
* @param columnName column name
* @return encryptor
*/
- public Optional<EncryptAlgorithm> findEncryptor(final String tableName, final String columnName) {
+ public Optional<StandardEncryptAlgorithm> findEncryptor(final String tableName, final String columnName) {
return encryptRule.findEncryptor(tableName, columnName);
}
diff --git a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/merge/dql/EncryptMergedResult.java b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/merge/dql/EncryptMergedResult.java
index 9cc66287b04..ff691b15be9 100644
--- a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/merge/dql/EncryptMergedResult.java
+++ b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/merge/dql/EncryptMergedResult.java
@@ -18,8 +18,8 @@
package org.apache.shardingsphere.encrypt.merge.dql;
import lombok.RequiredArgsConstructor;
+import org.apache.shardingsphere.encrypt.api.encrypt.standard.StandardEncryptAlgorithm;
import org.apache.shardingsphere.encrypt.api.context.EncryptContext;
-import org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm;
import org.apache.shardingsphere.infra.merge.result.MergedResult;
import java.io.InputStream;
@@ -49,7 +49,7 @@ public final class EncryptMergedResult implements MergedResult {
if (!encryptContext.isPresent()) {
return mergedResult.getValue(columnIndex, type);
}
- Optional<EncryptAlgorithm> encryptAlgorithm = metaData.findEncryptor(encryptContext.get().getTableName(), encryptContext.get().getColumnName());
+ Optional<StandardEncryptAlgorithm> encryptAlgorithm = metaData.findEncryptor(encryptContext.get().getTableName(), encryptContext.get().getColumnName());
if (!encryptAlgorithm.isPresent()) {
return mergedResult.getValue(columnIndex, type);
}
diff --git a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/parameter/rewriter/EncryptInsertOnDuplicateKeyUpdateValueParameterRewriter.java b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/parameter/rewriter/EncryptInsertOnDuplicateKeyUpdateValueParameterRewriter.java
index f99784637b3..f74daa13e39 100644
--- a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/parameter/rewriter/EncryptInsertOnDuplicateKeyUpdateValueParameterRewriter.java
+++ b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/parameter/rewriter/EncryptInsertOnDuplicateKeyUpdateValueParameterRewriter.java
@@ -19,13 +19,13 @@ package org.apache.shardingsphere.encrypt.rewrite.parameter.rewriter;
import com.google.common.base.Preconditions;
import lombok.Setter;
-import org.apache.shardingsphere.encrypt.api.context.EncryptContext;
+import org.apache.shardingsphere.encrypt.api.encrypt.like.LikeEncryptAlgorithm;
+import org.apache.shardingsphere.encrypt.api.encrypt.standard.StandardEncryptAlgorithm;
import org.apache.shardingsphere.encrypt.context.EncryptContextBuilder;
import org.apache.shardingsphere.encrypt.rewrite.aware.DatabaseNameAware;
import org.apache.shardingsphere.encrypt.rewrite.aware.EncryptRuleAware;
import org.apache.shardingsphere.encrypt.rule.EncryptRule;
-import org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm;
-import org.apache.shardingsphere.encrypt.spi.LikeEncryptAlgorithm;
+import org.apache.shardingsphere.encrypt.api.context.EncryptContext;
import org.apache.shardingsphere.infra.binder.segment.insert.values.OnDuplicateUpdateContext;
import org.apache.shardingsphere.infra.binder.statement.SQLStatementContext;
import org.apache.shardingsphere.infra.binder.statement.dml.InsertStatementContext;
@@ -66,7 +66,7 @@ public final class EncryptInsertOnDuplicateKeyUpdateValueParameterRewriter imple
String schemaName = insertStatementContext.getTablesContext().getSchemaName().orElseGet(() -> DatabaseTypeEngine.getDefaultSchemaName(insertStatementContext.getDatabaseType(), databaseName));
for (int index = 0; index < onDuplicateKeyUpdateValueContext.getValueExpressions().size(); index++) {
String encryptLogicColumnName = onDuplicateKeyUpdateValueContext.getColumn(index).getIdentifier().getValue();
- Optional<EncryptAlgorithm> encryptor = encryptRule.findEncryptor(tableName, encryptLogicColumnName);
+ Optional<StandardEncryptAlgorithm> encryptor = encryptRule.findEncryptor(tableName, encryptLogicColumnName);
if (!encryptor.isPresent()) {
continue;
}
@@ -90,7 +90,7 @@ public final class EncryptInsertOnDuplicateKeyUpdateValueParameterRewriter imple
@SuppressWarnings({"rawtypes", "unchecked"})
private Collection<Object> buildAddedParams(final String tableName, final String logicColumnName, final Object plainValue, final EncryptContext encryptContext) {
Collection<Object> result = new LinkedList<>();
- Optional<EncryptAlgorithm> assistedQueryEncryptor = encryptRule.findAssistedQueryEncryptor(tableName, logicColumnName);
+ Optional<StandardEncryptAlgorithm> assistedQueryEncryptor = encryptRule.findAssistedQueryEncryptor(tableName, logicColumnName);
if (assistedQueryEncryptor.isPresent()) {
Optional<String> assistedColumnName = encryptRule.findAssistedQueryColumn(tableName, logicColumnName);
Preconditions.checkArgument(assistedColumnName.isPresent(), "Can not find assisted query Column Name");
diff --git a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/parameter/rewriter/EncryptInsertValueParameterRewriter.java b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/parameter/rewriter/EncryptInsertValueParameterRewriter.java
index b2854a118c0..fbc3889c72e 100644
--- a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/parameter/rewriter/EncryptInsertValueParameterRewriter.java
+++ b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/parameter/rewriter/EncryptInsertValueParameterRewriter.java
@@ -18,15 +18,15 @@
package org.apache.shardingsphere.encrypt.rewrite.parameter.rewriter;
import lombok.Setter;
-import org.apache.shardingsphere.encrypt.api.context.EncryptContext;
+import org.apache.shardingsphere.encrypt.api.encrypt.like.LikeEncryptAlgorithm;
+import org.apache.shardingsphere.encrypt.api.encrypt.standard.StandardEncryptAlgorithm;
import org.apache.shardingsphere.encrypt.context.EncryptContextBuilder;
import org.apache.shardingsphere.encrypt.exception.metadata.EncryptAssistedQueryColumnNotFoundException;
import org.apache.shardingsphere.encrypt.exception.metadata.EncryptLikeQueryColumnNotFoundException;
import org.apache.shardingsphere.encrypt.rewrite.aware.DatabaseNameAware;
import org.apache.shardingsphere.encrypt.rewrite.aware.EncryptRuleAware;
import org.apache.shardingsphere.encrypt.rule.EncryptRule;
-import org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm;
-import org.apache.shardingsphere.encrypt.spi.LikeEncryptAlgorithm;
+import org.apache.shardingsphere.encrypt.api.context.EncryptContext;
import org.apache.shardingsphere.infra.binder.statement.SQLStatementContext;
import org.apache.shardingsphere.infra.binder.statement.dml.InsertStatementContext;
import org.apache.shardingsphere.infra.database.type.DatabaseTypeEngine;
@@ -78,7 +78,7 @@ public final class EncryptInsertValueParameterRewriter implements ParameterRewri
}
private void encryptInsertValues(final GroupedParameterBuilder paramBuilder, final InsertStatementContext insertStatementContext,
- final EncryptAlgorithm encryptAlgorithm, final EncryptAlgorithm assistEncryptAlgorithm,
+ final StandardEncryptAlgorithm encryptAlgorithm, final StandardEncryptAlgorithm assistEncryptAlgorithm,
final LikeEncryptAlgorithm likeEncryptAlgorithm, final EncryptContext encryptContext) {
int columnIndex = getColumnIndex(paramBuilder, insertStatementContext, encryptContext.getColumnName());
int count = 0;
@@ -109,7 +109,7 @@ public final class EncryptInsertValueParameterRewriter implements ParameterRewri
}
@SuppressWarnings({"rawtypes", "unchecked"})
- private void encryptInsertValue(final EncryptAlgorithm encryptor, final EncryptAlgorithm assistEncryptor, final LikeEncryptAlgorithm likeEncryptor,
+ private void encryptInsertValue(final StandardEncryptAlgorithm encryptor, final StandardEncryptAlgorithm assistEncryptor, final LikeEncryptAlgorithm likeEncryptor,
final int paramIndex, final Object originalValue, final StandardParameterBuilder paramBuilder,
final EncryptContext encryptContext) {
paramBuilder.addReplacedParameters(paramIndex, encryptor.encrypt(originalValue, encryptContext));
diff --git a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/EncryptAlterTableTokenGenerator.java b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/EncryptAlterTableTokenGenerator.java
index c6180e9e258..8a6a58e710b 100644
--- a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/EncryptAlterTableTokenGenerator.java
+++ b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/EncryptAlterTableTokenGenerator.java
@@ -18,13 +18,13 @@
package org.apache.shardingsphere.encrypt.rewrite.token.generator;
import lombok.Setter;
+import org.apache.shardingsphere.encrypt.api.encrypt.standard.StandardEncryptAlgorithm;
import org.apache.shardingsphere.encrypt.exception.metadata.EncryptColumnAlterException;
import org.apache.shardingsphere.encrypt.exception.metadata.EncryptColumnNotFoundException;
import org.apache.shardingsphere.encrypt.rewrite.aware.EncryptRuleAware;
import org.apache.shardingsphere.encrypt.rewrite.token.pojo.EncryptAlterTableToken;
import org.apache.shardingsphere.encrypt.rule.EncryptColumn;
import org.apache.shardingsphere.encrypt.rule.EncryptRule;
-import org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm;
import org.apache.shardingsphere.infra.binder.statement.SQLStatementContext;
import org.apache.shardingsphere.infra.binder.statement.ddl.AlterTableStatementContext;
import org.apache.shardingsphere.infra.rewrite.sql.token.generator.CollectionSQLTokenGenerator;
@@ -110,7 +110,7 @@ public final class EncryptAlterTableTokenGenerator implements CollectionSQLToken
Collection<SQLToken> result = new LinkedList<>();
for (ColumnDefinitionSegment each : addColumnDefinitionSegment.getColumnDefinitions()) {
String columnName = each.getColumnName().getIdentifier().getValue();
- Optional<EncryptAlgorithm> encryptor = encryptRule.findEncryptor(tableName, columnName);
+ Optional<StandardEncryptAlgorithm> encryptor = encryptRule.findEncryptor(tableName, columnName);
if (encryptor.isPresent()) {
result.addAll(getAddColumnTokens(tableName, columnName, addColumnDefinitionSegment, each));
}
@@ -140,7 +140,7 @@ public final class EncryptAlterTableTokenGenerator implements CollectionSQLToken
@SuppressWarnings("rawtypes")
private Optional<SQLToken> getAddColumnPositionToken(final String tableName, final AddColumnDefinitionSegment addColumnDefinitionSegment) {
- Optional<EncryptAlgorithm> encryptor = addColumnDefinitionSegment.getColumnPosition().filter(optional -> null != optional.getColumnName())
+ Optional<StandardEncryptAlgorithm> encryptor = addColumnDefinitionSegment.getColumnPosition().filter(optional -> null != optional.getColumnName())
.flatMap(optional -> encryptRule.findEncryptor(tableName, optional.getColumnName().getIdentifier().getValue()));
if (encryptor.isPresent()) {
return Optional.of(getPositionColumnToken(addColumnDefinitionSegment.getColumnPosition().get(), tableName));
@@ -159,7 +159,7 @@ public final class EncryptAlterTableTokenGenerator implements CollectionSQLToken
for (ModifyColumnDefinitionSegment each : columnDefinitionSegments) {
ColumnDefinitionSegment segment = each.getColumnDefinition();
String columnName = segment.getColumnName().getIdentifier().getValue();
- Optional<EncryptAlgorithm> encryptor = encryptRule.findEncryptor(tableName, columnName);
+ Optional<StandardEncryptAlgorithm> encryptor = encryptRule.findEncryptor(tableName, columnName);
if (encryptor.isPresent()) {
result.addAll(getModifyColumnTokens(tableName, columnName, each));
}
@@ -184,7 +184,7 @@ public final class EncryptAlterTableTokenGenerator implements CollectionSQLToken
@SuppressWarnings("rawtypes")
private Optional<SQLToken> getColumnPositionToken(final String tableName, final ColumnPositionSegment columnPositionSegment) {
- Optional<EncryptAlgorithm> encryptor = Optional.of(columnPositionSegment).filter(optional -> null != optional.getColumnName())
+ Optional<StandardEncryptAlgorithm> encryptor = Optional.of(columnPositionSegment).filter(optional -> null != optional.getColumnName())
.flatMap(optional -> encryptRule.findEncryptor(tableName, optional.getColumnName().getIdentifier().getValue()));
return encryptor.isPresent() ? Optional.of(getPositionColumnToken(columnPositionSegment, tableName)) : Optional.empty();
}
@@ -212,8 +212,8 @@ public final class EncryptAlterTableTokenGenerator implements CollectionSQLToken
@SuppressWarnings("rawtypes")
private void isSameEncryptColumn(final String tableName, final ChangeColumnDefinitionSegment segment) {
- Optional<EncryptAlgorithm> previousAlgorithm = encryptRule.findEncryptor(tableName, segment.getPreviousColumn().getIdentifier().getValue());
- Optional<EncryptAlgorithm> currentAlgorithm = encryptRule.findEncryptor(tableName, segment.getColumnDefinition().getColumnName().getIdentifier().getValue());
+ Optional<StandardEncryptAlgorithm> previousAlgorithm = encryptRule.findEncryptor(tableName, segment.getPreviousColumn().getIdentifier().getValue());
+ Optional<StandardEncryptAlgorithm> currentAlgorithm = encryptRule.findEncryptor(tableName, segment.getColumnDefinition().getColumnName().getIdentifier().getValue());
if (!previousAlgorithm.isPresent() && !currentAlgorithm.isPresent()) {
return;
}
@@ -274,7 +274,7 @@ public final class EncryptAlterTableTokenGenerator implements CollectionSQLToken
Collection<SQLToken> result = new LinkedList<>();
for (ColumnSegment each : dropColumnDefinitionSegment.getColumns()) {
String columnName = each.getQualifiedName();
- Optional<EncryptAlgorithm> encryptor = encryptRule.findEncryptor(tableName, columnName);
+ Optional<StandardEncryptAlgorithm> encryptor = encryptRule.findEncryptor(tableName, columnName);
if (encryptor.isPresent()) {
result.addAll(getDropColumnTokens(tableName, columnName, each, dropColumnDefinitionSegment));
}
diff --git a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/EncryptCreateTableTokenGenerator.java b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/EncryptCreateTableTokenGenerator.java
index 824e182adf9..43edb863eb5 100644
--- a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/EncryptCreateTableTokenGenerator.java
+++ b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/EncryptCreateTableTokenGenerator.java
@@ -18,9 +18,9 @@
package org.apache.shardingsphere.encrypt.rewrite.token.generator;
import lombok.Setter;
+import org.apache.shardingsphere.encrypt.api.encrypt.standard.StandardEncryptAlgorithm;
import org.apache.shardingsphere.encrypt.rewrite.aware.EncryptRuleAware;
import org.apache.shardingsphere.encrypt.rule.EncryptRule;
-import org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm;
import org.apache.shardingsphere.infra.binder.segment.select.projection.impl.ColumnProjection;
import org.apache.shardingsphere.infra.binder.statement.SQLStatementContext;
import org.apache.shardingsphere.infra.binder.statement.ddl.CreateTableStatementContext;
@@ -59,7 +59,7 @@ public final class EncryptCreateTableTokenGenerator implements CollectionSQLToke
for (int index = 0; index < columns.size(); index++) {
ColumnDefinitionSegment each = columns.get(index);
String columnName = each.getColumnName().getIdentifier().getValue();
- Optional<EncryptAlgorithm> encryptor = encryptRule.findEncryptor(tableName, columnName);
+ Optional<StandardEncryptAlgorithm> encryptor = encryptRule.findEncryptor(tableName, columnName);
if (encryptor.isPresent()) {
result.addAll(getColumnTokens(tableName, columnName, each, columns, index));
}
diff --git a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/EncryptInsertValuesTokenGenerator.java b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/EncryptInsertValuesTokenGenerator.java
index 61b4ce86b90..1db417be3d4 100644
--- a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/EncryptInsertValuesTokenGenerator.java
+++ b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/EncryptInsertValuesTokenGenerator.java
@@ -18,8 +18,8 @@
package org.apache.shardingsphere.encrypt.rewrite.token.generator;
import lombok.Setter;
-import org.apache.shardingsphere.encrypt.spi.LikeEncryptAlgorithm;
-import org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm;
+import org.apache.shardingsphere.encrypt.api.encrypt.like.LikeEncryptAlgorithm;
+import org.apache.shardingsphere.encrypt.api.encrypt.standard.StandardEncryptAlgorithm;
import org.apache.shardingsphere.encrypt.context.EncryptContextBuilder;
import org.apache.shardingsphere.encrypt.rewrite.aware.DatabaseNameAware;
import org.apache.shardingsphere.encrypt.rewrite.aware.EncryptRuleAware;
@@ -131,7 +131,7 @@ public final class EncryptInsertValuesTokenGenerator implements OptionalSQLToken
Iterator<String> descendingColumnNames = insertStatementContext.getDescendingColumnNames();
while (descendingColumnNames.hasNext()) {
String columnName = descendingColumnNames.next();
- Optional<EncryptAlgorithm> encryptor = encryptRule.findEncryptor(tableName, columnName);
+ Optional<StandardEncryptAlgorithm> encryptor = encryptRule.findEncryptor(tableName, columnName);
if (encryptor.isPresent()) {
int columnIndex = useDefaultInsertColumnsToken.map(optional -> ((UseDefaultInsertColumnsToken) optional).getColumns().indexOf(columnName))
.orElseGet(() -> insertStatementContext.getColumnNames().indexOf(columnName));
@@ -152,7 +152,7 @@ public final class EncryptInsertValuesTokenGenerator implements OptionalSQLToken
}
}
- private void addAssistedQueryColumn(final InsertValue insertValueToken, final EncryptAlgorithm encryptAlgorithm, final int columnIndex,
+ private void addAssistedQueryColumn(final InsertValue insertValueToken, final StandardEncryptAlgorithm encryptAlgorithm, final int columnIndex,
final EncryptContext encryptContext, final InsertValueContext insertValueContext,
final Object originalValue, final int indexDelta) {
if (encryptRule.findAssistedQueryColumn(encryptContext.getTableName(), encryptContext.getColumnName()).isPresent()) {
@@ -189,7 +189,7 @@ public final class EncryptInsertValuesTokenGenerator implements OptionalSQLToken
return result;
}
- private void setCipherColumn(final InsertValue insertValueToken, final EncryptAlgorithm encryptAlgorithm, final int columnIndex,
+ private void setCipherColumn(final InsertValue insertValueToken, final StandardEncryptAlgorithm encryptAlgorithm, final int columnIndex,
final EncryptContext encryptContext, final ExpressionSegment valueExpression, final Object originalValue) {
if (valueExpression instanceof LiteralExpressionSegment) {
insertValueToken.getValues().set(columnIndex, new LiteralExpressionSegment(
diff --git a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rule/EncryptRule.java b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rule/EncryptRule.java
index 12938de36ec..a4b4eb78f8a 100644
--- a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rule/EncryptRule.java
+++ b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rule/EncryptRule.java
@@ -19,13 +19,14 @@ package org.apache.shardingsphere.encrypt.rule;
import lombok.Getter;
import org.apache.shardingsphere.encrypt.api.config.EncryptRuleConfiguration;
-import org.apache.shardingsphere.encrypt.api.context.EncryptContext;
+import org.apache.shardingsphere.encrypt.api.encrypt.like.LikeEncryptAlgorithm;
+import org.apache.shardingsphere.encrypt.api.encrypt.standard.StandardEncryptAlgorithm;
import org.apache.shardingsphere.encrypt.context.EncryptContextBuilder;
import org.apache.shardingsphere.encrypt.exception.metadata.EncryptAssistedQueryEncryptorNotFoundException;
import org.apache.shardingsphere.encrypt.exception.metadata.EncryptEncryptorNotFoundException;
import org.apache.shardingsphere.encrypt.exception.metadata.EncryptLikeQueryEncryptorNotFoundException;
import org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm;
-import org.apache.shardingsphere.encrypt.spi.LikeEncryptAlgorithm;
+import org.apache.shardingsphere.encrypt.api.context.EncryptContext;
import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
import org.apache.shardingsphere.infra.rule.identifier.scope.DatabaseRule;
import org.apache.shardingsphere.infra.rule.identifier.type.ColumnContainedRule;
@@ -50,7 +51,7 @@ public final class EncryptRule implements DatabaseRule, TableContainedRule, Colu
private final RuleConfiguration configuration;
@SuppressWarnings("rawtypes")
- private final Map<String, EncryptAlgorithm> encryptors = new LinkedHashMap<>();
+ private final Map<String, StandardEncryptAlgorithm> standardEncryptors = new LinkedHashMap<>();
@SuppressWarnings("rawtypes")
private final Map<String, LikeEncryptAlgorithm> likeEncryptors = new LinkedHashMap<>();
@@ -59,11 +60,19 @@ public final class EncryptRule implements DatabaseRule, TableContainedRule, Colu
public EncryptRule(final EncryptRuleConfiguration ruleConfig) {
configuration = ruleConfig;
- ruleConfig.getEncryptors().forEach((key, value) -> encryptors.put(key, TypedSPILoader.getService(EncryptAlgorithm.class, value.getType(), value.getProps())));
- ruleConfig.getLikeEncryptors().forEach((key, value) -> likeEncryptors.put(key, TypedSPILoader.getService(LikeEncryptAlgorithm.class, value.getType(), value.getProps())));
+ ruleConfig.getEncryptors().forEach((key, value) -> putAllEncryptors(key, TypedSPILoader.getService(EncryptAlgorithm.class, value.getType(), value.getProps())));
ruleConfig.getTables().forEach(each -> tables.put(each.getName().toLowerCase(), new EncryptTable(each)));
}
+ @SuppressWarnings("rawtypes")
+ private void putAllEncryptors(final String encryptorName, final EncryptAlgorithm algorithm) {
+ if (algorithm instanceof StandardEncryptAlgorithm) {
+ standardEncryptors.put(encryptorName, (StandardEncryptAlgorithm) algorithm);
+ } else {
+ likeEncryptors.put(encryptorName, (LikeEncryptAlgorithm) algorithm);
+ }
+ }
+
/**
* Find encrypt table.
*
@@ -93,9 +102,9 @@ public final class EncryptRule implements DatabaseRule, TableContainedRule, Colu
* @return encryptor
*/
@SuppressWarnings("rawtypes")
- public Optional<EncryptAlgorithm> findEncryptor(final String logicTable, final String logicColumn) {
+ public Optional<StandardEncryptAlgorithm> findEncryptor(final String logicTable, final String logicColumn) {
String lowerCaseLogicTable = logicTable.toLowerCase();
- return tables.containsKey(lowerCaseLogicTable) ? tables.get(lowerCaseLogicTable).findEncryptorName(logicColumn).map(encryptors::get) : Optional.empty();
+ return tables.containsKey(lowerCaseLogicTable) ? tables.get(lowerCaseLogicTable).findEncryptorName(logicColumn).map(standardEncryptors::get) : Optional.empty();
}
/**
@@ -106,9 +115,9 @@ public final class EncryptRule implements DatabaseRule, TableContainedRule, Colu
* @return encryptor
*/
@SuppressWarnings("rawtypes")
- public Optional<EncryptAlgorithm> findAssistedQueryEncryptor(final String logicTable, final String logicColumn) {
+ public Optional<StandardEncryptAlgorithm> findAssistedQueryEncryptor(final String logicTable, final String logicColumn) {
String lowerCaseLogicTable = logicTable.toLowerCase();
- return tables.containsKey(lowerCaseLogicTable) ? tables.get(lowerCaseLogicTable).findAssistedQueryEncryptorName(logicColumn).map(encryptors::get) : Optional.empty();
+ return tables.containsKey(lowerCaseLogicTable) ? tables.get(lowerCaseLogicTable).findAssistedQueryEncryptorName(logicColumn).map(standardEncryptors::get) : Optional.empty();
}
/**
@@ -136,7 +145,7 @@ public final class EncryptRule implements DatabaseRule, TableContainedRule, Colu
*/
public List<Object> getEncryptValues(final String databaseName, final String schemaName, final String logicTable, final String logicColumn, final List<Object> originalValues) {
@SuppressWarnings("rawtypes")
- Optional<EncryptAlgorithm> encryptor = findEncryptor(logicTable, logicColumn);
+ Optional<StandardEncryptAlgorithm> encryptor = findEncryptor(logicTable, logicColumn);
EncryptContext encryptContext = EncryptContextBuilder.build(databaseName, schemaName, logicTable, logicColumn);
ShardingSpherePreconditions.checkState(encryptor.isPresent(),
() -> new EncryptEncryptorNotFoundException(String.format("Can not find StandardEncryptAlgorithm by %s.%s.", logicTable, logicColumn)));
@@ -144,7 +153,7 @@ public final class EncryptRule implements DatabaseRule, TableContainedRule, Colu
}
@SuppressWarnings("unchecked")
- private List<Object> getEncryptValues(@SuppressWarnings("rawtypes") final EncryptAlgorithm encryptor, final List<Object> originalValues, final EncryptContext encryptContext) {
+ private List<Object> getEncryptValues(@SuppressWarnings("rawtypes") final StandardEncryptAlgorithm encryptor, final List<Object> originalValues, final EncryptContext encryptContext) {
List<Object> result = new LinkedList<>();
for (Object each : originalValues) {
Object encryptValue = null == each ? null : encryptor.encrypt(each, encryptContext);
@@ -221,7 +230,7 @@ public final class EncryptRule implements DatabaseRule, TableContainedRule, Colu
*/
public List<Object> getEncryptAssistedQueryValues(final String databaseName, final String schemaName, final String logicTable, final String logicColumn, final List<Object> originalValues) {
@SuppressWarnings("rawtypes")
- Optional<EncryptAlgorithm> encryptor = findAssistedQueryEncryptor(logicTable, logicColumn);
+ Optional<StandardEncryptAlgorithm> encryptor = findAssistedQueryEncryptor(logicTable, logicColumn);
EncryptContext encryptContext = EncryptContextBuilder.build(databaseName, schemaName, logicTable, logicColumn);
ShardingSpherePreconditions.checkState(encryptor.isPresent(),
() -> new EncryptAssistedQueryEncryptorNotFoundException(String.format("Can not find assist encryptor by %s.%s.", logicTable, logicColumn)));
@@ -229,7 +238,7 @@ public final class EncryptRule implements DatabaseRule, TableContainedRule, Colu
}
@SuppressWarnings("unchecked")
- private List<Object> getEncryptAssistedQueryValues(@SuppressWarnings("rawtypes") final EncryptAlgorithm encryptor,
+ private List<Object> getEncryptAssistedQueryValues(@SuppressWarnings("rawtypes") final StandardEncryptAlgorithm encryptor,
final List<Object> originalValues, final EncryptContext encryptContext) {
List<Object> result = new LinkedList<>();
for (Object each : originalValues) {
diff --git a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/yaml/config/YamlEncryptRuleConfiguration.java b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/yaml/config/YamlEncryptRuleConfiguration.java
index 5a73265332a..36fdaa96ba7 100644
--- a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/yaml/config/YamlEncryptRuleConfiguration.java
+++ b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/yaml/config/YamlEncryptRuleConfiguration.java
@@ -38,8 +38,6 @@ public final class YamlEncryptRuleConfiguration implements YamlRuleConfiguration
private Map<String, YamlAlgorithmConfiguration> encryptors = new LinkedHashMap<>();
- private Map<String, YamlAlgorithmConfiguration> likeEncryptors = new LinkedHashMap<>();
-
@Override
public Class<EncryptRuleConfiguration> getRuleConfigurationType() {
return EncryptRuleConfiguration.class;
diff --git a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/yaml/swapper/YamlEncryptRuleConfigurationSwapper.java b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/yaml/swapper/YamlEncryptRuleConfigurationSwapper.java
index 85a9f3f1c53..a32dd1b8334 100644
--- a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/yaml/swapper/YamlEncryptRuleConfigurationSwapper.java
+++ b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/yaml/swapper/YamlEncryptRuleConfigurationSwapper.java
@@ -48,13 +48,12 @@ public final class YamlEncryptRuleConfigurationSwapper implements YamlRuleConfig
YamlEncryptRuleConfiguration result = new YamlEncryptRuleConfiguration();
data.getTables().forEach(each -> result.getTables().put(each.getName(), tableSwapper.swapToYamlConfiguration(each)));
data.getEncryptors().forEach((key, value) -> result.getEncryptors().put(key, algorithmSwapper.swapToYamlConfiguration(value)));
- data.getLikeEncryptors().forEach((key, value) -> result.getLikeEncryptors().put(key, algorithmSwapper.swapToYamlConfiguration(value)));
return result;
}
@Override
public EncryptRuleConfiguration swapToObject(final YamlEncryptRuleConfiguration yamlConfig) {
- return new EncryptRuleConfiguration(swapTables(yamlConfig), swapEncryptAlgorithm(yamlConfig), swapLikeEncryptAlgorithm(yamlConfig));
+ return new EncryptRuleConfiguration(swapTables(yamlConfig), swapEncryptAlgorithm(yamlConfig));
}
private Collection<EncryptTableRuleConfiguration> swapTables(final YamlEncryptRuleConfiguration yamlConfig) {
@@ -75,14 +74,6 @@ public final class YamlEncryptRuleConfigurationSwapper implements YamlRuleConfig
return result;
}
- private Map<String, AlgorithmConfiguration> swapLikeEncryptAlgorithm(final YamlEncryptRuleConfiguration yamlConfig) {
- Map<String, AlgorithmConfiguration> result = new LinkedHashMap<>(yamlConfig.getLikeEncryptors().size(), 1);
- for (Entry<String, YamlAlgorithmConfiguration> entry : yamlConfig.getLikeEncryptors().entrySet()) {
- result.put(entry.getKey(), algorithmSwapper.swapToObject(entry.getValue()));
- }
- return result;
- }
-
@Override
public Class<EncryptRuleConfiguration> getTypeClass() {
return EncryptRuleConfiguration.class;
diff --git a/features/encrypt/core/src/main/resources/META-INF/services/org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm b/features/encrypt/core/src/main/resources/META-INF/services/org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm
index fa91903fccb..bc088cee521 100644
--- a/features/encrypt/core/src/main/resources/META-INF/services/org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm
+++ b/features/encrypt/core/src/main/resources/META-INF/services/org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm
@@ -18,3 +18,4 @@
org.apache.shardingsphere.encrypt.algorithm.encrypt.MD5EncryptAlgorithm
org.apache.shardingsphere.encrypt.algorithm.encrypt.AESEncryptAlgorithm
org.apache.shardingsphere.encrypt.algorithm.encrypt.RC4EncryptAlgorithm
+org.apache.shardingsphere.encrypt.algorithm.like.CharDigestLikeEncryptAlgorithm
diff --git a/features/encrypt/core/src/main/resources/META-INF/services/org.apache.shardingsphere.encrypt.spi.LikeEncryptAlgorithm b/features/encrypt/core/src/main/resources/META-INF/services/org.apache.shardingsphere.encrypt.spi.LikeEncryptAlgorithm
deleted file mode 100644
index 14fe7f5c01e..00000000000
--- a/features/encrypt/core/src/main/resources/META-INF/services/org.apache.shardingsphere.encrypt.spi.LikeEncryptAlgorithm
+++ /dev/null
@@ -1,18 +0,0 @@
-#
-# 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.
-#
-
-org.apache.shardingsphere.encrypt.algorithm.like.CharDigestLikeEncryptAlgorithm
diff --git a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/algorithm/encrypt/AESEncryptAlgorithmTest.java b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/algorithm/encrypt/AESEncryptAlgorithmTest.java
index 655d667bd1f..638c6f965df 100644
--- a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/algorithm/encrypt/AESEncryptAlgorithmTest.java
+++ b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/algorithm/encrypt/AESEncryptAlgorithmTest.java
@@ -17,8 +17,9 @@
package org.apache.shardingsphere.encrypt.algorithm.encrypt;
-import org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm;
+import org.apache.shardingsphere.encrypt.api.encrypt.standard.StandardEncryptAlgorithm;
import org.apache.shardingsphere.encrypt.exception.algorithm.EncryptAlgorithmInitializationException;
+import org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm;
import org.apache.shardingsphere.encrypt.api.context.EncryptContext;
import org.apache.shardingsphere.infra.util.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.test.util.PropertiesBuilder;
@@ -34,12 +35,12 @@ import static org.mockito.Mockito.mock;
class AESEncryptAlgorithmTest {
- private EncryptAlgorithm<Object, String> encryptAlgorithm;
+ private StandardEncryptAlgorithm<Object, String> encryptAlgorithm;
@SuppressWarnings("unchecked")
@BeforeEach
void setUp() {
- encryptAlgorithm = (EncryptAlgorithm<Object, String>) TypedSPILoader.getService(EncryptAlgorithm.class, "AES", PropertiesBuilder.build(new Property("aes-key-value", "test")));
+ encryptAlgorithm = (StandardEncryptAlgorithm<Object, String>) TypedSPILoader.getService(EncryptAlgorithm.class, "AES", PropertiesBuilder.build(new Property("aes-key-value", "test")));
}
@Test
diff --git a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/algorithm/encrypt/MD5EncryptAlgorithmTest.java b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/algorithm/encrypt/MD5EncryptAlgorithmTest.java
index 297ca5ead6a..baa527fafc7 100644
--- a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/algorithm/encrypt/MD5EncryptAlgorithmTest.java
+++ b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/algorithm/encrypt/MD5EncryptAlgorithmTest.java
@@ -17,6 +17,7 @@
package org.apache.shardingsphere.encrypt.algorithm.encrypt;
+import org.apache.shardingsphere.encrypt.api.encrypt.standard.StandardEncryptAlgorithm;
import org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm;
import org.apache.shardingsphere.encrypt.api.context.EncryptContext;
import org.apache.shardingsphere.infra.util.spi.type.typed.TypedSPILoader;
@@ -32,12 +33,12 @@ import static org.mockito.Mockito.mock;
class MD5EncryptAlgorithmTest {
- private EncryptAlgorithm<Object, String> encryptAlgorithm;
+ private StandardEncryptAlgorithm<Object, String> encryptAlgorithm;
@SuppressWarnings("unchecked")
@BeforeEach
void setUp() {
- encryptAlgorithm = (EncryptAlgorithm<Object, String>) TypedSPILoader.getService(EncryptAlgorithm.class, "MD5");
+ encryptAlgorithm = (StandardEncryptAlgorithm<Object, String>) TypedSPILoader.getService(EncryptAlgorithm.class, "MD5");
}
@Test
diff --git a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/algorithm/encrypt/RC4EncryptAlgorithmTest.java b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/algorithm/encrypt/RC4EncryptAlgorithmTest.java
index a5c1b801ff8..36ebc1e12e9 100644
--- a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/algorithm/encrypt/RC4EncryptAlgorithmTest.java
+++ b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/algorithm/encrypt/RC4EncryptAlgorithmTest.java
@@ -17,8 +17,9 @@
package org.apache.shardingsphere.encrypt.algorithm.encrypt;
-import org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm;
+import org.apache.shardingsphere.encrypt.api.encrypt.standard.StandardEncryptAlgorithm;
import org.apache.shardingsphere.encrypt.exception.algorithm.EncryptAlgorithmInitializationException;
+import org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm;
import org.apache.shardingsphere.encrypt.api.context.EncryptContext;
import org.apache.shardingsphere.infra.util.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.test.util.PropertiesBuilder;
@@ -37,12 +38,12 @@ import static org.mockito.Mockito.mock;
class RC4EncryptAlgorithmTest {
- private EncryptAlgorithm<Object, String> encryptAlgorithm;
+ private StandardEncryptAlgorithm<Object, String> encryptAlgorithm;
@SuppressWarnings("unchecked")
@BeforeEach
void setUp() {
- encryptAlgorithm = (EncryptAlgorithm<Object, String>) TypedSPILoader.getService(EncryptAlgorithm.class, "RC4", PropertiesBuilder.build(new Property("rc4-key-value", "test-sharding")));
+ encryptAlgorithm = (StandardEncryptAlgorithm<Object, String>) TypedSPILoader.getService(EncryptAlgorithm.class, "RC4", PropertiesBuilder.build(new Property("rc4-key-value", "test-sharding")));
}
@Test
diff --git a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/algorithm/like/CharDigestLikeEncryptAlgorithmTest.java b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/algorithm/like/CharDigestLikeEncryptAlgorithmTest.java
index 4863a97896d..4b7a95a4a21 100644
--- a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/algorithm/like/CharDigestLikeEncryptAlgorithmTest.java
+++ b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/algorithm/like/CharDigestLikeEncryptAlgorithmTest.java
@@ -17,8 +17,9 @@
package org.apache.shardingsphere.encrypt.algorithm.like;
+import org.apache.shardingsphere.encrypt.api.encrypt.like.LikeEncryptAlgorithm;
+import org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm;
import org.apache.shardingsphere.encrypt.api.context.EncryptContext;
-import org.apache.shardingsphere.encrypt.spi.LikeEncryptAlgorithm;
import org.apache.shardingsphere.infra.util.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.test.util.PropertiesBuilder;
import org.apache.shardingsphere.test.util.PropertiesBuilder.Property;
@@ -41,9 +42,9 @@ class CharDigestLikeEncryptAlgorithmTest {
@SuppressWarnings("unchecked")
@BeforeEach
void setUp() {
- englishLikeEncryptAlgorithm = (LikeEncryptAlgorithm<Object, String>) TypedSPILoader.getService(LikeEncryptAlgorithm.class, "CHAR_DIGEST_LIKE");
- chineseLikeEncryptAlgorithm = (LikeEncryptAlgorithm<Object, String>) TypedSPILoader.getService(LikeEncryptAlgorithm.class, "CHAR_DIGEST_LIKE");
- koreanLikeEncryptAlgorithm = (LikeEncryptAlgorithm<Object, String>) TypedSPILoader.getService(LikeEncryptAlgorithm.class,
+ englishLikeEncryptAlgorithm = (LikeEncryptAlgorithm<Object, String>) TypedSPILoader.getService(EncryptAlgorithm.class, "CHAR_DIGEST_LIKE");
+ chineseLikeEncryptAlgorithm = (LikeEncryptAlgorithm<Object, String>) TypedSPILoader.getService(EncryptAlgorithm.class, "CHAR_DIGEST_LIKE");
+ koreanLikeEncryptAlgorithm = (LikeEncryptAlgorithm<Object, String>) TypedSPILoader.getService(EncryptAlgorithm.class,
"CHAR_DIGEST_LIKE", PropertiesBuilder.build(new Property("dict", "한국어시험"), new Property("start", "44032")));
}
diff --git a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/fixture/CoreEncryptAlgorithmFixture.java b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/fixture/CoreEncryptAlgorithmFixture.java
index 4938e2cce07..dedd55e1164 100644
--- a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/fixture/CoreEncryptAlgorithmFixture.java
+++ b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/fixture/CoreEncryptAlgorithmFixture.java
@@ -17,10 +17,10 @@
package org.apache.shardingsphere.encrypt.fixture;
-import org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm;
+import org.apache.shardingsphere.encrypt.api.encrypt.standard.StandardEncryptAlgorithm;
import org.apache.shardingsphere.encrypt.api.context.EncryptContext;
-public final class CoreEncryptAlgorithmFixture implements EncryptAlgorithm<Object, String> {
+public final class CoreEncryptAlgorithmFixture implements StandardEncryptAlgorithm<Object, String> {
@Override
public String encrypt(final Object plainValue, final EncryptContext encryptContext) {
diff --git a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/fixture/CoreQueryAssistedEncryptAlgorithmFixture.java b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/fixture/CoreQueryAssistedEncryptAlgorithmFixture.java
index 2569bc0b408..7dda76b9dbd 100644
--- a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/fixture/CoreQueryAssistedEncryptAlgorithmFixture.java
+++ b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/fixture/CoreQueryAssistedEncryptAlgorithmFixture.java
@@ -17,10 +17,10 @@
package org.apache.shardingsphere.encrypt.fixture;
-import org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm;
+import org.apache.shardingsphere.encrypt.api.encrypt.standard.StandardEncryptAlgorithm;
import org.apache.shardingsphere.encrypt.api.context.EncryptContext;
-public final class CoreQueryAssistedEncryptAlgorithmFixture implements EncryptAlgorithm<Object, String> {
+public final class CoreQueryAssistedEncryptAlgorithmFixture implements StandardEncryptAlgorithm<Object, String> {
@Override
public String encrypt(final Object plainValue, final EncryptContext encryptContext) {
diff --git a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/fixture/CoreQueryLikeEncryptAlgorithmFixture.java b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/fixture/CoreQueryLikeEncryptAlgorithmFixture.java
index ed8553236a8..f9bce86ec61 100644
--- a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/fixture/CoreQueryLikeEncryptAlgorithmFixture.java
+++ b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/fixture/CoreQueryLikeEncryptAlgorithmFixture.java
@@ -17,7 +17,7 @@
package org.apache.shardingsphere.encrypt.fixture;
-import org.apache.shardingsphere.encrypt.spi.LikeEncryptAlgorithm;
+import org.apache.shardingsphere.encrypt.api.encrypt.like.LikeEncryptAlgorithm;
import org.apache.shardingsphere.encrypt.api.context.EncryptContext;
public final class CoreQueryLikeEncryptAlgorithmFixture implements LikeEncryptAlgorithm<Object, String> {
diff --git a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/merge/dql/EncryptAlgorithmMetaDataTest.java b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/merge/dql/EncryptAlgorithmMetaDataTest.java
index 8bf37f83ff1..7af648afeae 100644
--- a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/merge/dql/EncryptAlgorithmMetaDataTest.java
+++ b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/merge/dql/EncryptAlgorithmMetaDataTest.java
@@ -17,9 +17,10 @@
package org.apache.shardingsphere.encrypt.merge.dql;
-import org.apache.shardingsphere.encrypt.api.context.EncryptContext;
-import org.apache.shardingsphere.encrypt.rule.EncryptRule;
+import org.apache.shardingsphere.encrypt.api.encrypt.standard.StandardEncryptAlgorithm;
import org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm;
+import org.apache.shardingsphere.encrypt.rule.EncryptRule;
+import org.apache.shardingsphere.encrypt.api.context.EncryptContext;
import org.apache.shardingsphere.infra.binder.segment.select.projection.ProjectionsContext;
import org.apache.shardingsphere.infra.binder.segment.select.projection.impl.ColumnProjection;
import org.apache.shardingsphere.infra.binder.segment.select.projection.impl.DerivedProjection;
@@ -77,7 +78,7 @@ class EncryptAlgorithmMetaDataTest {
@Mock
private ProjectionsContext projectionsContext;
- private EncryptAlgorithm<?, ?> encryptAlgorithm;
+ private StandardEncryptAlgorithm<?, ?> encryptAlgorithm;
@BeforeEach
void setUp() {
@@ -89,7 +90,7 @@ class EncryptAlgorithmMetaDataTest {
when(selectStatementContext.getDatabaseType()).thenReturn(new MySQLDatabaseType());
when(database.getName()).thenReturn(DefaultDatabase.LOGIC_NAME);
when(database.getSchema(DefaultDatabase.LOGIC_NAME)).thenReturn(schema);
- encryptAlgorithm = (EncryptAlgorithm<?, ?>) TypedSPILoader.getService(EncryptAlgorithm.class, "MD5");
+ encryptAlgorithm = (StandardEncryptAlgorithm<?, ?>) TypedSPILoader.getService(EncryptAlgorithm.class, "MD5");
}
@Test
@@ -131,7 +132,7 @@ class EncryptAlgorithmMetaDataTest {
void assertFindEncryptor() {
when(encryptRule.findEncryptor("t_order", "id")).thenReturn(Optional.of(encryptAlgorithm));
EncryptAlgorithmMetaData encryptAlgorithmMetaData = new EncryptAlgorithmMetaData(database, encryptRule, selectStatementContext);
- Optional<EncryptAlgorithm> actualEncryptor = encryptAlgorithmMetaData.findEncryptor("t_order", "id");
+ Optional<StandardEncryptAlgorithm> actualEncryptor = encryptAlgorithmMetaData.findEncryptor("t_order", "id");
assertTrue(actualEncryptor.isPresent());
assertThat(actualEncryptor.get().getType(), is("MD5"));
}
diff --git a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/impl/EncryptAlterTableTokenGeneratorTest.java b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/impl/EncryptAlterTableTokenGeneratorTest.java
index 89ed11acc43..e3a44585ad1 100644
--- a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/impl/EncryptAlterTableTokenGeneratorTest.java
+++ b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/impl/EncryptAlterTableTokenGeneratorTest.java
@@ -17,12 +17,12 @@
package org.apache.shardingsphere.encrypt.rewrite.impl;
+import org.apache.shardingsphere.encrypt.api.encrypt.standard.StandardEncryptAlgorithm;
import org.apache.shardingsphere.encrypt.rewrite.token.generator.EncryptAlterTableTokenGenerator;
import org.apache.shardingsphere.encrypt.rewrite.token.pojo.EncryptAlterTableToken;
import org.apache.shardingsphere.encrypt.rule.EncryptColumn;
import org.apache.shardingsphere.encrypt.rule.EncryptRule;
import org.apache.shardingsphere.encrypt.rule.EncryptTable;
-import org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm;
import org.apache.shardingsphere.infra.binder.statement.ddl.AlterTableStatementContext;
import org.apache.shardingsphere.infra.rewrite.sql.token.pojo.SQLToken;
import org.apache.shardingsphere.infra.rewrite.sql.token.pojo.generic.RemoveToken;
@@ -65,7 +65,7 @@ class EncryptAlterTableTokenGeneratorTest {
when(result.findLikeQueryColumn("t_encrypt", "certificate_number")).thenReturn(Optional.of("like_certificate_number"));
EncryptTable encryptTable = mock(EncryptTable.class);
when(encryptTable.getLogicColumns()).thenReturn(Collections.singleton("t_encrypt"));
- EncryptAlgorithm<?, ?> encryptAlgorithm = mock(EncryptAlgorithm.class);
+ StandardEncryptAlgorithm<?, ?> encryptAlgorithm = mock(StandardEncryptAlgorithm.class);
when(result.findEncryptor("t_encrypt", "certificate_number")).thenReturn(Optional.of(encryptAlgorithm));
when(result.findEncryptor("t_encrypt", "certificate_number_new")).thenReturn(Optional.of(encryptAlgorithm));
when(result.findEncryptTable("t_encrypt")).thenReturn(Optional.of(encryptTable));
diff --git a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/impl/EncryptCreateTableTokenGeneratorTest.java b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/impl/EncryptCreateTableTokenGeneratorTest.java
index d9f1fb61bd6..14b6c5848d0 100644
--- a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/impl/EncryptCreateTableTokenGeneratorTest.java
+++ b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/impl/EncryptCreateTableTokenGeneratorTest.java
@@ -17,11 +17,11 @@
package org.apache.shardingsphere.encrypt.rewrite.impl;
+import org.apache.shardingsphere.encrypt.api.encrypt.standard.StandardEncryptAlgorithm;
import org.apache.shardingsphere.encrypt.rewrite.token.generator.EncryptCreateTableTokenGenerator;
import org.apache.shardingsphere.encrypt.rule.EncryptColumn;
import org.apache.shardingsphere.encrypt.rule.EncryptRule;
import org.apache.shardingsphere.encrypt.rule.EncryptTable;
-import org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm;
import org.apache.shardingsphere.infra.binder.statement.ddl.CreateTableStatementContext;
import org.apache.shardingsphere.infra.rewrite.sql.token.pojo.SQLToken;
import org.apache.shardingsphere.infra.rewrite.sql.token.pojo.generic.RemoveToken;
@@ -89,7 +89,7 @@ class EncryptCreateTableTokenGeneratorTest {
EncryptRule result = mock(EncryptRule.class);
EncryptTable encryptTable = mock(EncryptTable.class);
when(encryptTable.getLogicColumns()).thenReturn(Collections.singletonList("t_encrypt"));
- when(result.findEncryptor("t_encrypt", "certificate_number")).thenReturn(Optional.of(mock(EncryptAlgorithm.class)));
+ when(result.findEncryptor("t_encrypt", "certificate_number")).thenReturn(Optional.of(mock(StandardEncryptAlgorithm.class)));
when(result.findEncryptTable("t_encrypt")).thenReturn(Optional.of(encryptTable));
EncryptColumn column = mockEncryptColumn();
when(result.getCipherColumn("t_encrypt", "certificate_number")).thenReturn(column.getCipherColumn());
diff --git a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/impl/EncryptOrderByItemTokenGeneratorTest.java b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/impl/EncryptOrderByItemTokenGeneratorTest.java
index 096044a9a1e..bb22e95df53 100644
--- a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/impl/EncryptOrderByItemTokenGeneratorTest.java
+++ b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/impl/EncryptOrderByItemTokenGeneratorTest.java
@@ -17,7 +17,7 @@
package org.apache.shardingsphere.encrypt.rewrite.impl;
-import org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm;
+import org.apache.shardingsphere.encrypt.api.encrypt.standard.StandardEncryptAlgorithm;
import org.apache.shardingsphere.encrypt.rewrite.token.generator.EncryptOrderByItemTokenGenerator;
import org.apache.shardingsphere.encrypt.rule.EncryptRule;
import org.apache.shardingsphere.encrypt.rule.EncryptTable;
@@ -85,7 +85,7 @@ class EncryptOrderByItemTokenGeneratorTest {
when(result.getCipherColumn("t_encrypt", "certificate_number")).thenReturn("cipher_certificate_number");
when(result.findAssistedQueryColumn("t_encrypt", "certificate_number")).thenReturn(Optional.of("assisted_certificate_number"));
when(encryptTable.findEncryptorName("certificate_number")).thenReturn(Optional.of("encryptor_name"));
- when(result.findEncryptor("t_encrypt", "certificate_number")).thenReturn(Optional.of(mock(EncryptAlgorithm.class)));
+ when(result.findEncryptor("t_encrypt", "certificate_number")).thenReturn(Optional.of(mock(StandardEncryptAlgorithm.class)));
when(result.findEncryptTable("t_encrypt")).thenReturn(Optional.of(encryptTable));
return result;
}
diff --git a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/EncryptInsertOnUpdateTokenGeneratorTest.java b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/EncryptInsertOnUpdateTokenGeneratorTest.java
index be751a2da67..b5ab573edb5 100644
--- a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/EncryptInsertOnUpdateTokenGeneratorTest.java
+++ b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/EncryptInsertOnUpdateTokenGeneratorTest.java
@@ -17,7 +17,7 @@
package org.apache.shardingsphere.encrypt.rewrite.token;
-import org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm;
+import org.apache.shardingsphere.encrypt.api.encrypt.standard.StandardEncryptAlgorithm;
import org.apache.shardingsphere.encrypt.rewrite.token.generator.EncryptInsertOnUpdateTokenGenerator;
import org.apache.shardingsphere.encrypt.rewrite.token.pojo.EncryptAssignmentToken;
import org.apache.shardingsphere.encrypt.rule.EncryptRule;
@@ -64,8 +64,8 @@ class EncryptInsertOnUpdateTokenGeneratorTest {
private EncryptRule mockEncryptRule() {
EncryptRule result = mock(EncryptRule.class);
when(result.getCipherColumn("t_user", "mobile")).thenReturn("cipher_mobile");
- when(result.findEncryptor("t_user", "mobile")).thenReturn(Optional.of(mock(EncryptAlgorithm.class)));
- when(result.findEncryptor("t_user", "cipher_mobile")).thenReturn(Optional.of(mock(EncryptAlgorithm.class)));
+ when(result.findEncryptor("t_user", "mobile")).thenReturn(Optional.of(mock(StandardEncryptAlgorithm.class)));
+ when(result.findEncryptor("t_user", "cipher_mobile")).thenReturn(Optional.of(mock(StandardEncryptAlgorithm.class)));
when(result.getEncryptValues(null, "db_test", "t_user", "mobile", Collections.singletonList(0))).thenReturn(Collections.singletonList("encryptValue"));
return result;
}
diff --git a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/EncryptAssignmentTokenGeneratorTest.java b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/EncryptAssignmentTokenGeneratorTest.java
index 53d641bb9c6..14517841641 100644
--- a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/EncryptAssignmentTokenGeneratorTest.java
+++ b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/EncryptAssignmentTokenGeneratorTest.java
@@ -17,7 +17,7 @@
package org.apache.shardingsphere.encrypt.rewrite.token.generator;
-import org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm;
+import org.apache.shardingsphere.encrypt.api.encrypt.standard.StandardEncryptAlgorithm;
import org.apache.shardingsphere.encrypt.rule.EncryptRule;
import org.apache.shardingsphere.infra.binder.statement.dml.InsertStatementContext;
import org.apache.shardingsphere.infra.binder.statement.dml.UpdateStatementContext;
@@ -78,7 +78,7 @@ class EncryptAssignmentTokenGeneratorTest {
private EncryptRule mockEncryptRule() {
EncryptRule result = mock(EncryptRule.class, RETURNS_DEEP_STUBS);
- when(result.findEncryptor("table", "columns")).thenReturn(Optional.of(mock(EncryptAlgorithm.class)));
+ when(result.findEncryptor("table", "columns")).thenReturn(Optional.of(mock(StandardEncryptAlgorithm.class)));
return result;
}
diff --git a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/fixture/EncryptGeneratorFixtureBuilder.java b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/fixture/EncryptGeneratorFixtureBuilder.java
index ac9b27dc5c3..82a9042bd9b 100644
--- a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/fixture/EncryptGeneratorFixtureBuilder.java
+++ b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/fixture/EncryptGeneratorFixtureBuilder.java
@@ -55,6 +55,7 @@ import org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dml.MySQ
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
+import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
@@ -77,10 +78,11 @@ public final class EncryptGeneratorFixtureBuilder {
public static EncryptRule createEncryptRule() {
EncryptColumnRuleConfiguration pwdColumnConfig =
new EncryptColumnRuleConfiguration("pwd", "pwd_cipher", "pwd_assist", "pwd_like", "test_encryptor", "test_encryptor", "like_encryptor");
- Map<String, AlgorithmConfiguration> encryptors = Collections.singletonMap("test_encryptor", new AlgorithmConfiguration("CORE.QUERY_ASSISTED.FIXTURE", new Properties()));
- Map<String, AlgorithmConfiguration> likeEncryptors = Collections.singletonMap("like_encryptor", new AlgorithmConfiguration("CORE.QUERY_LIKE.FIXTURE", new Properties()));
+ Map<String, AlgorithmConfiguration> encryptors = new LinkedHashMap<>(2, 1);
+ encryptors.put("test_encryptor", new AlgorithmConfiguration("CORE.QUERY_ASSISTED.FIXTURE", new Properties()));
+ encryptors.put("like_encryptor", new AlgorithmConfiguration("CORE.QUERY_LIKE.FIXTURE", new Properties()));
return new EncryptRule(
- new EncryptRuleConfiguration(Collections.singleton(new EncryptTableRuleConfiguration("t_user", Collections.singletonList(pwdColumnConfig))), encryptors, likeEncryptors));
+ new EncryptRuleConfiguration(Collections.singleton(new EncryptTableRuleConfiguration("t_user", Collections.singletonList(pwdColumnConfig))), encryptors));
}
/**
diff --git a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rule/EncryptRuleTest.java b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rule/EncryptRuleTest.java
index e0f351d36e4..77695116071 100644
--- a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rule/EncryptRuleTest.java
+++ b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rule/EncryptRuleTest.java
@@ -27,6 +27,7 @@ import org.junit.jupiter.api.Test;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
@@ -137,7 +138,7 @@ class EncryptRuleTest {
new EncryptColumnRuleConfiguration("pwd", "pwd_cipher", "pwd_assist", "pwd_like", "test_encryptor", "test_encryptor", "like_encryptor");
EncryptColumnRuleConfiguration creditCardColumnConfig = new EncryptColumnRuleConfiguration("credit_card", "credit_card_cipher", "", "", "test_encryptor");
EncryptTableRuleConfiguration tableConfig = new EncryptTableRuleConfiguration("t_encrypt", Arrays.asList(pwdColumnConfig, creditCardColumnConfig));
- return new EncryptRuleConfiguration(Collections.singleton(tableConfig), getEncryptors(queryAssistedEncryptConfig), getLikeEncryptors(queryLikeEncryptConfig));
+ return new EncryptRuleConfiguration(Collections.singleton(tableConfig), getEncryptors(queryAssistedEncryptConfig, queryLikeEncryptConfig));
}
@Test
@@ -160,14 +161,13 @@ class EncryptRuleTest {
EncryptColumnRuleConfiguration pwdColumnConfig = new EncryptColumnRuleConfiguration("pwd", "pwd_cipher", "", "", "test_encryptor");
EncryptColumnRuleConfiguration creditCardColumnConfig = new EncryptColumnRuleConfiguration("credit_card", "credit_card_cipher", "", "", "test_encryptor");
EncryptTableRuleConfiguration tableConfig = new EncryptTableRuleConfiguration("T_ENCRYPT", Arrays.asList(pwdColumnConfig, creditCardColumnConfig));
- return new EncryptRuleConfiguration(Collections.singleton(tableConfig), getEncryptors(queryAssistedEncryptConfig), getLikeEncryptors(queryLikeEncryptConfig));
+ return new EncryptRuleConfiguration(Collections.singleton(tableConfig), getEncryptors(queryAssistedEncryptConfig, queryLikeEncryptConfig));
}
- private Map<String, AlgorithmConfiguration> getEncryptors(final AlgorithmConfiguration queryAssistedEncryptConfig) {
- return Collections.singletonMap("test_encryptor", queryAssistedEncryptConfig);
- }
-
- private Map<String, AlgorithmConfiguration> getLikeEncryptors(final AlgorithmConfiguration queryLikeEncryptConfig) {
- return Collections.singletonMap("like_encryptor", queryLikeEncryptConfig);
+ private Map<String, AlgorithmConfiguration> getEncryptors(final AlgorithmConfiguration queryAssistedEncryptConfig, final AlgorithmConfiguration queryLikeEncryptConfig) {
+ Map<String, AlgorithmConfiguration> result = new HashMap<>(2, 1);
+ result.put("test_encryptor", queryAssistedEncryptConfig);
+ result.put("like_encryptor", queryLikeEncryptConfig);
+ return result;
}
}
diff --git a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/yaml/EncryptRuleConfigurationYamlIT.java b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/yaml/EncryptRuleConfigurationYamlIT.java
index 7ccc1435e0c..d6283828b2d 100644
--- a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/yaml/EncryptRuleConfigurationYamlIT.java
+++ b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/yaml/EncryptRuleConfigurationYamlIT.java
@@ -38,7 +38,6 @@ class EncryptRuleConfigurationYamlIT extends YamlRuleConfigurationIT {
private void assertEncryptRule(final YamlEncryptRuleConfiguration actual) {
assertColumns(actual);
assertEncryptAlgorithm(actual);
- assertLikeEncryptAlgorithm(actual);
}
private void assertColumns(final YamlEncryptRuleConfiguration actual) {
@@ -57,9 +56,4 @@ class EncryptRuleConfigurationYamlIT extends YamlRuleConfigurationIT {
assertThat(actual.getEncryptors().get("username_encryptor").getType(), is("AES"));
assertThat(actual.getEncryptors().get("username_encryptor").getProps().get("aes-key-value"), is("123456abc"));
}
-
- private void assertLikeEncryptAlgorithm(final YamlEncryptRuleConfiguration actual) {
- assertThat(actual.getLikeEncryptors().size(), is(1));
- assertThat(actual.getLikeEncryptors().get("like_encryptor").getType(), is("CHAR_DIGEST_LIKE"));
- }
}
diff --git a/features/encrypt/core/src/test/resources/META-INF/services/org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm b/features/encrypt/core/src/test/resources/META-INF/services/org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm
index b7411910edb..774d1c039d2 100644
--- a/features/encrypt/core/src/test/resources/META-INF/services/org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm
+++ b/features/encrypt/core/src/test/resources/META-INF/services/org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm
@@ -17,3 +17,4 @@
org.apache.shardingsphere.encrypt.fixture.CoreEncryptAlgorithmFixture
org.apache.shardingsphere.encrypt.fixture.CoreQueryAssistedEncryptAlgorithmFixture
+org.apache.shardingsphere.encrypt.fixture.CoreQueryLikeEncryptAlgorithmFixture
diff --git a/features/encrypt/core/src/test/resources/META-INF/services/org.apache.shardingsphere.encrypt.spi.LikeEncryptAlgorithm b/features/encrypt/core/src/test/resources/META-INF/services/org.apache.shardingsphere.encrypt.spi.LikeEncryptAlgorithm
deleted file mode 100644
index cab3fccb006..00000000000
--- a/features/encrypt/core/src/test/resources/META-INF/services/org.apache.shardingsphere.encrypt.spi.LikeEncryptAlgorithm
+++ /dev/null
@@ -1,18 +0,0 @@
-#
-# 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.
-#
-
-org.apache.shardingsphere.encrypt.fixture.CoreQueryLikeEncryptAlgorithmFixture
diff --git a/features/encrypt/distsql/handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/converter/EncryptRuleStatementConverter.java b/features/encrypt/distsql/handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/converter/EncryptRuleStatementConverter.java
index 2e0807ad8dc..5ecc48f865f 100644
--- a/features/encrypt/distsql/handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/converter/EncryptRuleStatementConverter.java
+++ b/features/encrypt/distsql/handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/converter/EncryptRuleStatementConverter.java
@@ -46,13 +46,11 @@ public final class EncryptRuleStatementConverter {
public static EncryptRuleConfiguration convert(final Collection<EncryptRuleSegment> ruleSegments) {
Collection<EncryptTableRuleConfiguration> tables = new LinkedList<>();
Map<String, AlgorithmConfiguration> encryptors = new HashMap<>();
- Map<String, AlgorithmConfiguration> likeEncryptors = new HashMap<>();
for (EncryptRuleSegment each : ruleSegments) {
tables.add(createEncryptTableRuleConfiguration(each));
encryptors.putAll(createEncryptorConfigurations(each));
- likeEncryptors.putAll(createLikeEncryptorConfigurations(each));
}
- return new EncryptRuleConfiguration(tables, encryptors, likeEncryptors);
+ return new EncryptRuleConfiguration(tables, encryptors);
}
private static EncryptTableRuleConfiguration createEncryptTableRuleConfiguration(final EncryptRuleSegment ruleSegment) {
@@ -78,13 +76,6 @@ public final class EncryptRuleStatementConverter {
if (null != each.getAssistedQueryEncryptor()) {
result.put(getAssistedQueryEncryptorName(ruleSegment.getTableName(), each.getName()), createAssistedQueryEncryptorConfiguration(each));
}
- }
- return result;
- }
-
- private static Map<String, AlgorithmConfiguration> createLikeEncryptorConfigurations(final EncryptRuleSegment ruleSegment) {
- Map<String, AlgorithmConfiguration> result = new HashMap<>(ruleSegment.getColumns().size(), 1);
- for (EncryptColumnSegment each : ruleSegment.getColumns()) {
if (null != each.getLikeQueryEncryptor()) {
result.put(getLikeQueryEncryptorName(ruleSegment.getTableName(), each.getName()), createLikeQueryEncryptorConfiguration(each));
}
diff --git a/features/encrypt/distsql/handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/query/ShowEncryptRuleExecutor.java b/features/encrypt/distsql/handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/query/ShowEncryptRuleExecutor.java
index abf37cd1c9d..f9b09f98a2a 100644
--- a/features/encrypt/distsql/handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/query/ShowEncryptRuleExecutor.java
+++ b/features/encrypt/distsql/handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/query/ShowEncryptRuleExecutor.java
@@ -53,17 +53,16 @@ public final class ShowEncryptRuleExecutor implements RQLExecutor<ShowEncryptRul
private Collection<LocalDataQueryResultRow> buildData(final EncryptRuleConfiguration ruleConfig, final ShowEncryptRulesStatement sqlStatement) {
return ruleConfig.getTables().stream().filter(each -> Objects.isNull(sqlStatement.getTableName()) || each.getName().equals(sqlStatement.getTableName()))
- .map(each -> buildColumnData(each, ruleConfig.getEncryptors(), ruleConfig.getLikeEncryptors()))
+ .map(each -> buildColumnData(each, ruleConfig.getEncryptors()))
.flatMap(Collection::stream).collect(Collectors.toList());
}
- private Collection<LocalDataQueryResultRow> buildColumnData(final EncryptTableRuleConfiguration tableRuleConfig, final Map<String, AlgorithmConfiguration> encryptors,
- final Map<String, AlgorithmConfiguration> likeEncryptors) {
+ private Collection<LocalDataQueryResultRow> buildColumnData(final EncryptTableRuleConfiguration tableRuleConfig, final Map<String, AlgorithmConfiguration> encryptors) {
Collection<LocalDataQueryResultRow> result = new LinkedList<>();
for (EncryptColumnRuleConfiguration each : tableRuleConfig.getColumns()) {
AlgorithmConfiguration encryptorAlgorithmConfig = encryptors.get(each.getEncryptorName());
AlgorithmConfiguration assistedQueryEncryptorAlgorithmConfig = encryptors.get(each.getAssistedQueryEncryptorName());
- AlgorithmConfiguration likeQueryEncryptorAlgorithmConfig = likeEncryptors.get(each.getLikeQueryEncryptorName());
+ AlgorithmConfiguration likeQueryEncryptorAlgorithmConfig = encryptors.get(each.getLikeQueryEncryptorName());
result.add(new LocalDataQueryResultRow(Arrays.asList(
tableRuleConfig.getName(),
each.getLogicColumn(),
diff --git a/features/encrypt/distsql/handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/update/AlterEncryptRuleStatementUpdater.java b/features/encrypt/distsql/handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/update/AlterEncryptRuleStatementUpdater.java
index 508b176194b..4a80df60a6e 100644
--- a/features/encrypt/distsql/handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/update/AlterEncryptRuleStatementUpdater.java
+++ b/features/encrypt/distsql/handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/update/AlterEncryptRuleStatementUpdater.java
@@ -30,7 +30,6 @@ import org.apache.shardingsphere.encrypt.distsql.parser.segment.EncryptColumnSeg
import org.apache.shardingsphere.encrypt.distsql.parser.segment.EncryptRuleSegment;
import org.apache.shardingsphere.encrypt.distsql.parser.statement.AlterEncryptRuleStatement;
import org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm;
-import org.apache.shardingsphere.encrypt.spi.LikeEncryptAlgorithm;
import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
@@ -54,7 +53,6 @@ public final class AlterEncryptRuleStatementUpdater implements RuleDefinitionAlt
checkCurrentRuleConfiguration(databaseName, currentRuleConfig);
checkToBeAlteredRules(databaseName, sqlStatement, currentRuleConfig);
checkToBeAlteredEncryptors(sqlStatement);
- checkToBeAlteredLikeEncryptors(sqlStatement);
}
private void checkCurrentRuleConfiguration(final String databaseName, final EncryptRuleConfiguration currentRuleConfig) {
@@ -89,16 +87,11 @@ public final class AlterEncryptRuleStatementUpdater implements RuleDefinitionAlt
sqlStatement.getRules().forEach(each -> each.getColumns().forEach(column -> {
encryptors.add(column.getEncryptor());
encryptors.add(column.getAssistedQueryEncryptor());
+ encryptors.add(column.getLikeQueryEncryptor());
}));
encryptors.stream().filter(Objects::nonNull).forEach(each -> TypedSPILoader.checkService(EncryptAlgorithm.class, each.getName(), each.getProps()));
}
- private void checkToBeAlteredLikeEncryptors(final AlterEncryptRuleStatement sqlStatement) {
- Collection<AlgorithmSegment> likeEncryptors = new LinkedHashSet<>();
- sqlStatement.getRules().forEach(each -> each.getColumns().forEach(column -> likeEncryptors.add(column.getLikeQueryEncryptor())));
- likeEncryptors.stream().filter(Objects::nonNull).forEach(each -> TypedSPILoader.checkService(LikeEncryptAlgorithm.class, each.getName(), each.getProps()));
- }
-
@Override
public RuleConfiguration buildToBeAlteredRuleConfiguration(final AlterEncryptRuleStatement sqlStatement) {
return EncryptRuleStatementConverter.convert(sqlStatement.getRules());
diff --git a/features/encrypt/distsql/handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/update/CreateEncryptRuleStatementUpdater.java b/features/encrypt/distsql/handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/update/CreateEncryptRuleStatementUpdater.java
index eed6846d896..6fed87aead2 100644
--- a/features/encrypt/distsql/handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/update/CreateEncryptRuleStatementUpdater.java
+++ b/features/encrypt/distsql/handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/update/CreateEncryptRuleStatementUpdater.java
@@ -29,7 +29,6 @@ import org.apache.shardingsphere.encrypt.distsql.parser.segment.EncryptColumnSeg
import org.apache.shardingsphere.encrypt.distsql.parser.segment.EncryptRuleSegment;
import org.apache.shardingsphere.encrypt.distsql.parser.statement.CreateEncryptRuleStatement;
import org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm;
-import org.apache.shardingsphere.encrypt.spi.LikeEncryptAlgorithm;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
import org.apache.shardingsphere.infra.util.spi.type.typed.TypedSPILoader;
@@ -52,7 +51,6 @@ public final class CreateEncryptRuleStatementUpdater implements RuleDefinitionCr
}
checkDataType(sqlStatement);
checkToBeCreatedEncryptors(sqlStatement);
- checkToBeCreatedLikeEncryptors(sqlStatement);
checkDataSources(database);
}
@@ -100,16 +98,11 @@ public final class CreateEncryptRuleStatementUpdater implements RuleDefinitionCr
sqlStatement.getRules().forEach(each -> each.getColumns().forEach(column -> {
encryptors.add(column.getEncryptor());
encryptors.add(column.getAssistedQueryEncryptor());
+ encryptors.add(column.getLikeQueryEncryptor());
}));
encryptors.stream().filter(Objects::nonNull).forEach(each -> TypedSPILoader.checkService(EncryptAlgorithm.class, each.getName(), each.getProps()));
}
- private void checkToBeCreatedLikeEncryptors(final CreateEncryptRuleStatement sqlStatement) {
- Collection<AlgorithmSegment> likeEncryptors = new LinkedHashSet<>();
- sqlStatement.getRules().forEach(each -> each.getColumns().forEach(column -> likeEncryptors.add(column.getLikeQueryEncryptor())));
- likeEncryptors.stream().filter(Objects::nonNull).forEach(each -> TypedSPILoader.checkService(LikeEncryptAlgorithm.class, each.getName(), each.getProps()));
- }
-
private void checkDataSources(final ShardingSphereDatabase database) {
ShardingSpherePreconditions.checkState(!database.getResourceMetaData().getDataSources().isEmpty(), () -> new EmptyStorageUnitException(database.getName()));
}
diff --git a/features/encrypt/distsql/parser/src/main/antlr4/imports/encrypt/BaseRule.g4 b/features/encrypt/distsql/parser/src/main/antlr4/imports/encrypt/BaseRule.g4
index d6d927b5ec0..9dd14a52aa7 100644
--- a/features/encrypt/distsql/parser/src/main/antlr4/imports/encrypt/BaseRule.g4
+++ b/features/encrypt/distsql/parser/src/main/antlr4/imports/encrypt/BaseRule.g4
@@ -28,7 +28,7 @@ algorithmDefinition
;
algorithmTypeName
- : STRING_ | buildInEncryptAlgorithmType | buildInLikeEncryptAlgorithmType
+ : STRING_ | buildInEncryptAlgorithmType
;
buildInEncryptAlgorithmType
@@ -37,10 +37,7 @@ buildInEncryptAlgorithmType
| RC4
| SM3
| SM4
- ;
-
-buildInLikeEncryptAlgorithmType
- : CHAR_DIGEST_LIKE
+ | CHAR_DIGEST_LIKE
;
propertiesDefinition
diff --git a/features/encrypt/plugin/sm/src/main/java/org/apache/shardingsphere/encrypt/sm/algorithm/SM3EncryptAlgorithm.java b/features/encrypt/plugin/sm/src/main/java/org/apache/shardingsphere/encrypt/sm/algorithm/SM3EncryptAlgorithm.java
index 062e72e7462..b34d8d65014 100644
--- a/features/encrypt/plugin/sm/src/main/java/org/apache/shardingsphere/encrypt/sm/algorithm/SM3EncryptAlgorithm.java
+++ b/features/encrypt/plugin/sm/src/main/java/org/apache/shardingsphere/encrypt/sm/algorithm/SM3EncryptAlgorithm.java
@@ -17,7 +17,7 @@
package org.apache.shardingsphere.encrypt.sm.algorithm;
-import org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm;
+import org.apache.shardingsphere.encrypt.api.encrypt.standard.StandardEncryptAlgorithm;
import org.apache.shardingsphere.encrypt.exception.algorithm.EncryptAlgorithmInitializationException;
import org.apache.shardingsphere.encrypt.api.context.EncryptContext;
import org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
@@ -32,7 +32,7 @@ import java.util.Properties;
/**
* SM3 encrypt algorithm.
*/
-public final class SM3EncryptAlgorithm implements EncryptAlgorithm<Object, String> {
+public final class SM3EncryptAlgorithm implements StandardEncryptAlgorithm<Object, String> {
static {
Security.addProvider(new BouncyCastleProvider());
diff --git a/features/encrypt/plugin/sm/src/main/java/org/apache/shardingsphere/encrypt/sm/algorithm/SM4EncryptAlgorithm.java b/features/encrypt/plugin/sm/src/main/java/org/apache/shardingsphere/encrypt/sm/algorithm/SM4EncryptAlgorithm.java
index 748435b9688..3d4e407539e 100644
--- a/features/encrypt/plugin/sm/src/main/java/org/apache/shardingsphere/encrypt/sm/algorithm/SM4EncryptAlgorithm.java
+++ b/features/encrypt/plugin/sm/src/main/java/org/apache/shardingsphere/encrypt/sm/algorithm/SM4EncryptAlgorithm.java
@@ -18,9 +18,9 @@
package org.apache.shardingsphere.encrypt.sm.algorithm;
import lombok.SneakyThrows;
-import org.apache.shardingsphere.encrypt.api.context.EncryptContext;
+import org.apache.shardingsphere.encrypt.api.encrypt.standard.StandardEncryptAlgorithm;
import org.apache.shardingsphere.encrypt.exception.algorithm.EncryptAlgorithmInitializationException;
-import org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm;
+import org.apache.shardingsphere.encrypt.api.context.EncryptContext;
import org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.bouncycastle.pqc.math.linearalgebra.ByteUtils;
@@ -39,7 +39,7 @@ import java.util.Set;
/**
* SM4 encrypt algorithm.
*/
-public final class SM4EncryptAlgorithm implements EncryptAlgorithm<Object, String> {
+public final class SM4EncryptAlgorithm implements StandardEncryptAlgorithm<Object, String> {
static {
Security.addProvider(new BouncyCastleProvider());
diff --git a/features/encrypt/plugin/sm/src/test/java/org/apache/shardingsphere/encrypt/sm/algorithm/SM3EncryptAlgorithmTest.java b/features/encrypt/plugin/sm/src/test/java/org/apache/shardingsphere/encrypt/sm/algorithm/SM3EncryptAlgorithmTest.java
index 7920c4b84d0..644dddf5d7b 100644
--- a/features/encrypt/plugin/sm/src/test/java/org/apache/shardingsphere/encrypt/sm/algorithm/SM3EncryptAlgorithmTest.java
+++ b/features/encrypt/plugin/sm/src/test/java/org/apache/shardingsphere/encrypt/sm/algorithm/SM3EncryptAlgorithmTest.java
@@ -17,6 +17,7 @@
package org.apache.shardingsphere.encrypt.sm.algorithm;
+import org.apache.shardingsphere.encrypt.api.encrypt.standard.StandardEncryptAlgorithm;
import org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm;
import org.apache.shardingsphere.encrypt.api.context.EncryptContext;
import org.apache.shardingsphere.infra.util.spi.type.typed.TypedSPILoader;
@@ -34,12 +35,12 @@ import static org.mockito.Mockito.mock;
class SM3EncryptAlgorithmTest {
- private EncryptAlgorithm<Object, String> encryptAlgorithm;
+ private StandardEncryptAlgorithm<Object, String> encryptAlgorithm;
@SuppressWarnings("unchecked")
@BeforeEach
void setUp() {
- encryptAlgorithm = (EncryptAlgorithm<Object, String>) TypedSPILoader.getService(EncryptAlgorithm.class, "SM3", PropertiesBuilder.build(new Property("sm3-salt", "test1234")));
+ encryptAlgorithm = (StandardEncryptAlgorithm<Object, String>) TypedSPILoader.getService(EncryptAlgorithm.class, "SM3", PropertiesBuilder.build(new Property("sm3-salt", "test1234")));
}
@Test
diff --git a/features/encrypt/plugin/sm/src/test/java/org/apache/shardingsphere/encrypt/sm/algorithm/SM4EncryptAlgorithmTest.java b/features/encrypt/plugin/sm/src/test/java/org/apache/shardingsphere/encrypt/sm/algorithm/SM4EncryptAlgorithmTest.java
index 66f709f52bf..28234294585 100644
--- a/features/encrypt/plugin/sm/src/test/java/org/apache/shardingsphere/encrypt/sm/algorithm/SM4EncryptAlgorithmTest.java
+++ b/features/encrypt/plugin/sm/src/test/java/org/apache/shardingsphere/encrypt/sm/algorithm/SM4EncryptAlgorithmTest.java
@@ -17,8 +17,9 @@
package org.apache.shardingsphere.encrypt.sm.algorithm;
-import org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm;
+import org.apache.shardingsphere.encrypt.api.encrypt.standard.StandardEncryptAlgorithm;
import org.apache.shardingsphere.encrypt.exception.algorithm.EncryptAlgorithmInitializationException;
+import org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm;
import org.apache.shardingsphere.encrypt.api.context.EncryptContext;
import org.apache.shardingsphere.infra.util.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.test.util.PropertiesBuilder;
@@ -44,28 +45,28 @@ class SM4EncryptAlgorithmTest {
@SuppressWarnings("unchecked")
@Test
void assertEncryptNullValue() {
- EncryptAlgorithm<Object, String> algorithm = (EncryptAlgorithm<Object, String>) TypedSPILoader.getService(EncryptAlgorithm.class, "SM4", createECBProperties());
+ StandardEncryptAlgorithm<Object, String> algorithm = (StandardEncryptAlgorithm<Object, String>) TypedSPILoader.getService(EncryptAlgorithm.class, "SM4", createECBProperties());
assertNull(algorithm.encrypt(null, mock(EncryptContext.class)));
}
@SuppressWarnings("unchecked")
@Test
void assertEncryptWithECBMode() {
- EncryptAlgorithm<Object, String> algorithm = (EncryptAlgorithm<Object, String>) TypedSPILoader.getService(EncryptAlgorithm.class, "SM4", createECBProperties());
+ StandardEncryptAlgorithm<Object, String> algorithm = (StandardEncryptAlgorithm<Object, String>) TypedSPILoader.getService(EncryptAlgorithm.class, "SM4", createECBProperties());
assertThat(algorithm.encrypt("test", mock(EncryptContext.class)), is("028654f2ca4f575dee9e1faae85dadde"));
}
@SuppressWarnings("unchecked")
@Test
void assertDecryptNullValue() {
- EncryptAlgorithm<Object, String> algorithm = (EncryptAlgorithm<Object, String>) TypedSPILoader.getService(EncryptAlgorithm.class, "SM4", createECBProperties());
+ StandardEncryptAlgorithm<Object, String> algorithm = (StandardEncryptAlgorithm<Object, String>) TypedSPILoader.getService(EncryptAlgorithm.class, "SM4", createECBProperties());
assertNull(algorithm.decrypt(null, mock(EncryptContext.class)));
}
@SuppressWarnings("unchecked")
@Test
void assertDecryptWithECBMode() {
- EncryptAlgorithm<Object, String> algorithm = (EncryptAlgorithm<Object, String>) TypedSPILoader.getService(EncryptAlgorithm.class, "SM4", createECBProperties());
+ StandardEncryptAlgorithm<Object, String> algorithm = (StandardEncryptAlgorithm<Object, String>) TypedSPILoader.getService(EncryptAlgorithm.class, "SM4", createECBProperties());
assertThat(algorithm.decrypt("028654f2ca4f575dee9e1faae85dadde", mock(EncryptContext.class)).toString(), is("test"));
}
@@ -76,14 +77,14 @@ class SM4EncryptAlgorithmTest {
@SuppressWarnings("unchecked")
@Test
void assertEncryptWithCBCMode() {
- EncryptAlgorithm<Object, String> algorithm = (EncryptAlgorithm<Object, String>) TypedSPILoader.getService(EncryptAlgorithm.class, "SM4", createCBCProperties());
+ StandardEncryptAlgorithm<Object, String> algorithm = (StandardEncryptAlgorithm<Object, String>) TypedSPILoader.getService(EncryptAlgorithm.class, "SM4", createCBCProperties());
assertThat(algorithm.encrypt("test", mock(EncryptContext.class)), is("dca2127b57ba8cac36a0914e0208dc11"));
}
@SuppressWarnings("unchecked")
@Test
void assertDecrypt() {
- EncryptAlgorithm<Object, String> algorithm = (EncryptAlgorithm<Object, String>) TypedSPILoader.getService(EncryptAlgorithm.class, "SM4", createCBCProperties());
+ StandardEncryptAlgorithm<Object, String> algorithm = (StandardEncryptAlgorithm<Object, String>) TypedSPILoader.getService(EncryptAlgorithm.class, "SM4", createCBCProperties());
assertThat(algorithm.decrypt("dca2127b57ba8cac36a0914e0208dc11", mock(EncryptContext.class)).toString(), is("test"));
}
diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ConvertYamlConfigurationExecutor.java b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ConvertYamlConfigurationExecutor.java
index 406d2090bd5..4debc62b29a 100644
--- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ConvertYamlConfigurationExecutor.java
+++ b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ConvertYamlConfigurationExecutor.java
@@ -435,7 +435,7 @@ public final class ConvertYamlConfigurationExecutor implements QueryableRALExecu
while (iterator.hasNext()) {
EncryptTableRuleConfiguration tableRuleConfig = iterator.next();
stringBuilder.append(String.format(DistSQLScriptConstants.ENCRYPT, tableRuleConfig.getName(),
- getEncryptColumns(tableRuleConfig.getColumns(), ruleConfig.getEncryptors(), ruleConfig.getLikeEncryptors())));
+ getEncryptColumns(tableRuleConfig.getColumns(), ruleConfig.getEncryptors())));
if (iterator.hasNext()) {
stringBuilder.append(DistSQLScriptConstants.COMMA).append(System.lineSeparator());
}
@@ -443,14 +443,13 @@ public final class ConvertYamlConfigurationExecutor implements QueryableRALExecu
stringBuilder.append(DistSQLScriptConstants.SEMI).append(System.lineSeparator()).append(System.lineSeparator());
}
- private String getEncryptColumns(final Collection<EncryptColumnRuleConfiguration> ruleConfigs,
- final Map<String, AlgorithmConfiguration> encryptors, final Map<String, AlgorithmConfiguration> likeEncryptors) {
+ private String getEncryptColumns(final Collection<EncryptColumnRuleConfiguration> ruleConfigs, final Map<String, AlgorithmConfiguration> encryptors) {
StringBuilder result = new StringBuilder();
Iterator<EncryptColumnRuleConfiguration> iterator = ruleConfigs.iterator();
while (iterator.hasNext()) {
EncryptColumnRuleConfiguration columnRuleConfig = iterator.next();
result.append(String.format(DistSQLScriptConstants.ENCRYPT_COLUMN,
- columnRuleConfig.getLogicColumn(), getColumns(columnRuleConfig), getEncryptAlgorithms(columnRuleConfig, encryptors, likeEncryptors)));
+ columnRuleConfig.getLogicColumn(), getColumns(columnRuleConfig), getEncryptAlgorithms(columnRuleConfig, encryptors)));
if (iterator.hasNext()) {
result.append(DistSQLScriptConstants.COMMA).append(System.lineSeparator());
}
@@ -473,8 +472,7 @@ public final class ConvertYamlConfigurationExecutor implements QueryableRALExecu
return result.toString();
}
- private String getEncryptAlgorithms(final EncryptColumnRuleConfiguration ruleConfig,
- final Map<String, AlgorithmConfiguration> encryptors, final Map<String, AlgorithmConfiguration> likeEncryptors) {
+ private String getEncryptAlgorithms(final EncryptColumnRuleConfiguration ruleConfig, final Map<String, AlgorithmConfiguration> encryptors) {
StringBuilder result = new StringBuilder();
String cipherEncryptorName = ruleConfig.getEncryptorName();
String assistedQueryEncryptorName = ruleConfig.getAssistedQueryEncryptorName();
@@ -488,7 +486,7 @@ public final class ConvertYamlConfigurationExecutor implements QueryableRALExecu
}
if (null != likeQueryEncryptorName) {
result.append(DistSQLScriptConstants.COMMA).append(' ')
- .append(String.format(DistSQLScriptConstants.LIKE_QUERY_ALGORITHM, getAlgorithmType(likeEncryptors.get(likeQueryEncryptorName))));
+ .append(String.format(DistSQLScriptConstants.LIKE_QUERY_ALGORITHM, getAlgorithmType(encryptors.get(likeQueryEncryptorName))));
}
return result.toString();
}
diff --git a/proxy/backend/core/src/test/resources/conf/convert/config-encrypt.yaml b/proxy/backend/core/src/test/resources/conf/convert/config-encrypt.yaml
index f66d6cb6705..4bde8f92df5 100644
--- a/proxy/backend/core/src/test/resources/conf/convert/config-encrypt.yaml
+++ b/proxy/backend/core/src/test/resources/conf/convert/config-encrypt.yaml
@@ -46,7 +46,6 @@ rules:
aes-key-value: 123456abc
md5_encryptor:
type: MD5
- likeEncryptors:
like_encryptor:
type: CHAR_DIGEST_LIKE
tables:
diff --git a/proxy/backend/core/src/test/resources/conf/convert/config-mix.yaml b/proxy/backend/core/src/test/resources/conf/convert/config-mix.yaml
index a7a8970fa62..9a17666529d 100644
--- a/proxy/backend/core/src/test/resources/conf/convert/config-mix.yaml
+++ b/proxy/backend/core/src/test/resources/conf/convert/config-mix.yaml
@@ -125,9 +125,8 @@ rules:
aes-key-value: 123456abc
md5_encryptor:
type: MD5
- likeEncryptors:
like_encryptor:
- type: CHAR_DIGEST_LIKE
+ type: CHAR_DIGEST_LIKE
tables:
t_encrypt:
columns:
diff --git a/test/e2e/driver/src/test/java/org/apache/shardingsphere/test/e2e/driver/fixture/encrypt/JDBCEncryptAlgorithmFixture.java b/test/e2e/driver/src/test/java/org/apache/shardingsphere/test/e2e/driver/fixture/encrypt/JDBCEncryptAlgorithmFixture.java
index 226e5c21686..7b88cb7af67 100644
--- a/test/e2e/driver/src/test/java/org/apache/shardingsphere/test/e2e/driver/fixture/encrypt/JDBCEncryptAlgorithmFixture.java
+++ b/test/e2e/driver/src/test/java/org/apache/shardingsphere/test/e2e/driver/fixture/encrypt/JDBCEncryptAlgorithmFixture.java
@@ -17,10 +17,10 @@
package org.apache.shardingsphere.test.e2e.driver.fixture.encrypt;
-import org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm;
+import org.apache.shardingsphere.encrypt.api.encrypt.standard.StandardEncryptAlgorithm;
import org.apache.shardingsphere.encrypt.api.context.EncryptContext;
-public final class JDBCEncryptAlgorithmFixture implements EncryptAlgorithm<Object, String> {
+public final class JDBCEncryptAlgorithmFixture implements StandardEncryptAlgorithm<Object, String> {
@Override
public String encrypt(final Object plainValue, final EncryptContext encryptContext) {
diff --git a/test/e2e/driver/src/test/java/org/apache/shardingsphere/test/e2e/driver/fixture/encrypt/JDBCQueryAssistedEncryptAlgorithmFixture.java b/test/e2e/driver/src/test/java/org/apache/shardingsphere/test/e2e/driver/fixture/encrypt/JDBCQueryAssistedEncryptAlgorithmFixture.java
index f895cfa5487..70e385c247c 100644
--- a/test/e2e/driver/src/test/java/org/apache/shardingsphere/test/e2e/driver/fixture/encrypt/JDBCQueryAssistedEncryptAlgorithmFixture.java
+++ b/test/e2e/driver/src/test/java/org/apache/shardingsphere/test/e2e/driver/fixture/encrypt/JDBCQueryAssistedEncryptAlgorithmFixture.java
@@ -17,10 +17,10 @@
package org.apache.shardingsphere.test.e2e.driver.fixture.encrypt;
-import org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm;
+import org.apache.shardingsphere.encrypt.api.encrypt.standard.StandardEncryptAlgorithm;
import org.apache.shardingsphere.encrypt.api.context.EncryptContext;
-public final class JDBCQueryAssistedEncryptAlgorithmFixture implements EncryptAlgorithm<Object, String> {
+public final class JDBCQueryAssistedEncryptAlgorithmFixture implements StandardEncryptAlgorithm<Object, String> {
@Override
public String encrypt(final Object plainValue, final EncryptContext encryptContext) {
diff --git a/test/e2e/sql/src/test/resources/env/scenario/encrypt/proxy/conf/mysql/config-encrypt.yaml b/test/e2e/sql/src/test/resources/env/scenario/encrypt/proxy/conf/mysql/config-encrypt.yaml
index 5a5184dc4d8..c9d6124dbec 100644
--- a/test/e2e/sql/src/test/resources/env/scenario/encrypt/proxy/conf/mysql/config-encrypt.yaml
+++ b/test/e2e/sql/src/test/resources/env/scenario/encrypt/proxy/conf/mysql/config-encrypt.yaml
@@ -35,7 +35,6 @@ rules:
type: AES
props:
aes-key-value: 123456abc
- likeEncryptors:
like_encryptor:
type: CHAR_DIGEST_LIKE
props:
diff --git a/test/e2e/sql/src/test/resources/env/scenario/encrypt/proxy/conf/opengauss/config-encrypt.yaml b/test/e2e/sql/src/test/resources/env/scenario/encrypt/proxy/conf/opengauss/config-encrypt.yaml
index 7d34d62ff23..6e23a26232a 100644
--- a/test/e2e/sql/src/test/resources/env/scenario/encrypt/proxy/conf/opengauss/config-encrypt.yaml
+++ b/test/e2e/sql/src/test/resources/env/scenario/encrypt/proxy/conf/opengauss/config-encrypt.yaml
@@ -35,7 +35,6 @@ rules:
type: AES
props:
aes-key-value: 123456abc
- likeEncryptors:
like_encryptor:
type: CHAR_DIGEST_LIKE
props:
diff --git a/test/e2e/sql/src/test/resources/env/scenario/encrypt/proxy/conf/postgresql/config-encrypt.yaml b/test/e2e/sql/src/test/resources/env/scenario/encrypt/proxy/conf/postgresql/config-encrypt.yaml
index ba1576902f0..7e2f86ce58d 100644
--- a/test/e2e/sql/src/test/resources/env/scenario/encrypt/proxy/conf/postgresql/config-encrypt.yaml
+++ b/test/e2e/sql/src/test/resources/env/scenario/encrypt/proxy/conf/postgresql/config-encrypt.yaml
@@ -35,7 +35,6 @@ rules:
type: AES
props:
aes-key-value: 123456abc
- likeEncryptors:
like_encryptor:
type: CHAR_DIGEST_LIKE
props:
diff --git a/test/e2e/sql/src/test/resources/env/scenario/encrypt/rules.yaml b/test/e2e/sql/src/test/resources/env/scenario/encrypt/rules.yaml
index f6b4434939d..2bc0e15f52f 100644
--- a/test/e2e/sql/src/test/resources/env/scenario/encrypt/rules.yaml
+++ b/test/e2e/sql/src/test/resources/env/scenario/encrypt/rules.yaml
@@ -22,7 +22,6 @@ rules:
type: AES
props:
aes-key-value: 123456abc
- likeEncryptors:
like_encryptor:
type: CHAR_DIGEST_LIKE
props:
diff --git a/test/it/rewriter/src/test/java/org/apache/shardingsphere/test/it/rewrite/fixture/encrypt/RewriteNormalEncryptAlgorithmFixture.java b/test/it/rewriter/src/test/java/org/apache/shardingsphere/test/it/rewrite/fixture/encrypt/RewriteNormalEncryptAlgorithmFixture.java
index 9f3ba9ea290..8c6398531ac 100644
--- a/test/it/rewriter/src/test/java/org/apache/shardingsphere/test/it/rewrite/fixture/encrypt/RewriteNormalEncryptAlgorithmFixture.java
+++ b/test/it/rewriter/src/test/java/org/apache/shardingsphere/test/it/rewrite/fixture/encrypt/RewriteNormalEncryptAlgorithmFixture.java
@@ -17,10 +17,10 @@
package org.apache.shardingsphere.test.it.rewrite.fixture.encrypt;
-import org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm;
+import org.apache.shardingsphere.encrypt.api.encrypt.standard.StandardEncryptAlgorithm;
import org.apache.shardingsphere.encrypt.api.context.EncryptContext;
-public final class RewriteNormalEncryptAlgorithmFixture implements EncryptAlgorithm<Object, String> {
+public final class RewriteNormalEncryptAlgorithmFixture implements StandardEncryptAlgorithm<Object, String> {
@Override
public String encrypt(final Object plainValue, final EncryptContext encryptContext) {
diff --git a/test/it/rewriter/src/test/java/org/apache/shardingsphere/test/it/rewrite/fixture/encrypt/RewriteQueryAssistedEncryptAlgorithmFixture.java b/test/it/rewriter/src/test/java/org/apache/shardingsphere/test/it/rewrite/fixture/encrypt/RewriteQueryAssistedEncryptAlgorithmFixture.java
index 1cb929aa725..4fc354cf814 100644
--- a/test/it/rewriter/src/test/java/org/apache/shardingsphere/test/it/rewrite/fixture/encrypt/RewriteQueryAssistedEncryptAlgorithmFixture.java
+++ b/test/it/rewriter/src/test/java/org/apache/shardingsphere/test/it/rewrite/fixture/encrypt/RewriteQueryAssistedEncryptAlgorithmFixture.java
@@ -17,10 +17,10 @@
package org.apache.shardingsphere.test.it.rewrite.fixture.encrypt;
-import org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm;
+import org.apache.shardingsphere.encrypt.api.encrypt.standard.StandardEncryptAlgorithm;
import org.apache.shardingsphere.encrypt.api.context.EncryptContext;
-public final class RewriteQueryAssistedEncryptAlgorithmFixture implements EncryptAlgorithm<Object, String> {
+public final class RewriteQueryAssistedEncryptAlgorithmFixture implements StandardEncryptAlgorithm<Object, String> {
@Override
public String encrypt(final Object plainValue, final EncryptContext encryptContext) {
diff --git a/test/it/rewriter/src/test/java/org/apache/shardingsphere/test/it/rewrite/fixture/encrypt/RewriteQueryLikeEncryptAlgorithmFixture.java b/test/it/rewriter/src/test/java/org/apache/shardingsphere/test/it/rewrite/fixture/encrypt/RewriteQueryLikeEncryptAlgorithmFixture.java
index 52b991e1b32..2ab6a4dce13 100644
--- a/test/it/rewriter/src/test/java/org/apache/shardingsphere/test/it/rewrite/fixture/encrypt/RewriteQueryLikeEncryptAlgorithmFixture.java
+++ b/test/it/rewriter/src/test/java/org/apache/shardingsphere/test/it/rewrite/fixture/encrypt/RewriteQueryLikeEncryptAlgorithmFixture.java
@@ -17,7 +17,7 @@
package org.apache.shardingsphere.test.it.rewrite.fixture.encrypt;
-import org.apache.shardingsphere.encrypt.spi.LikeEncryptAlgorithm;
+import org.apache.shardingsphere.encrypt.api.encrypt.like.LikeEncryptAlgorithm;
import org.apache.shardingsphere.encrypt.api.context.EncryptContext;
public final class RewriteQueryLikeEncryptAlgorithmFixture implements LikeEncryptAlgorithm<Object, String> {
diff --git a/test/it/rewriter/src/test/resources/META-INF/services/org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm b/test/it/rewriter/src/test/resources/META-INF/services/org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm
index b9e2e7bc2ae..26255a18998 100644
--- a/test/it/rewriter/src/test/resources/META-INF/services/org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm
+++ b/test/it/rewriter/src/test/resources/META-INF/services/org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm
@@ -17,3 +17,4 @@
org.apache.shardingsphere.test.it.rewrite.fixture.encrypt.RewriteNormalEncryptAlgorithmFixture
org.apache.shardingsphere.test.it.rewrite.fixture.encrypt.RewriteQueryAssistedEncryptAlgorithmFixture
+org.apache.shardingsphere.test.it.rewrite.fixture.encrypt.RewriteQueryLikeEncryptAlgorithmFixture
diff --git a/test/it/rewriter/src/test/resources/META-INF/services/org.apache.shardingsphere.encrypt.spi.LikeEncryptAlgorithm b/test/it/rewriter/src/test/resources/META-INF/services/org.apache.shardingsphere.encrypt.spi.LikeEncryptAlgorithm
deleted file mode 100644
index 503acf70eb8..00000000000
--- a/test/it/rewriter/src/test/resources/META-INF/services/org.apache.shardingsphere.encrypt.spi.LikeEncryptAlgorithm
+++ /dev/null
@@ -1,18 +0,0 @@
-#
-# 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.
-#
-
-org.apache.shardingsphere.test.it.rewrite.fixture.encrypt.RewriteQueryLikeEncryptAlgorithmFixture
diff --git a/test/it/rewriter/src/test/resources/scenario/encrypt/config/query-with-cipher.yaml b/test/it/rewriter/src/test/resources/scenario/encrypt/config/query-with-cipher.yaml
index fa5efeccaf2..71761fb5bbc 100644
--- a/test/it/rewriter/src/test/resources/scenario/encrypt/config/query-with-cipher.yaml
+++ b/test/it/rewriter/src/test/resources/scenario/encrypt/config/query-with-cipher.yaml
@@ -94,6 +94,5 @@ rules:
type: REWRITE.NORMAL.FIXTURE
rewrite_assisted_query_fixture:
type: REWRITE.ASSISTED_QUERY.FIXTURE
- likeEncryptors:
rewrite_like_query_fixture:
type: REWRITE.LIKE_QUERY.FIXTURE