You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by du...@apache.org on 2022/05/26 03:47:38 UTC
[shardingsphere] branch master updated: Support encrypt config queryWithCipherColumn with column levels (#17603)
This is an automated email from the ASF dual-hosted git repository.
duanzhengqiang 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 6e7a35f9139 Support encrypt config queryWithCipherColumn with column levels (#17603)
6e7a35f9139 is described below
commit 6e7a35f9139ffe51470d39e034cb358b66e20530
Author: zhaoguhong <zh...@163.com>
AuthorDate: Thu May 26 11:47:26 2022 +0800
Support encrypt config queryWithCipherColumn with column levels (#17603)
* Support encrypt config queryWithCipherColumn with column levels
* Fix checkstyle
* Fix encryptColumn constructor
* Refactor support encrypt config queryWithCipherColumn with column levels
* Refactor encrypt IsQueryWithCipherColumn UT
* Refactor support encrypt config queryWithCipherColumn with column levels
* Refactor support encrypt config queryWithCipherColumn with column levels
* Refactor support encrypt config queryWithCipherColumn with column levels
* Delete unnecessary comments
---
.../config/local/LocalEncryptConfiguration.java | 2 +-
.../jdbc/config/EncryptDatabasesConfiguration.java | 4 +--
.../jdbc/config/ShadowEncryptConfiguration.java | 4 +--
.../rule/EncryptColumnRuleConfiguration.java | 7 ++--
.../merge/dql/EncryptAlgorithmMetaData.java | 9 ++---
.../encrypt/merge/dql/EncryptMergedResult.java | 2 +-
.../EncryptPredicateParameterRewriter.java | 2 +-
.../EncryptOrderByItemTokenGenerator.java | 2 +-
.../EncryptPredicateColumnTokenGenerator.java | 2 +-
.../EncryptPredicateRightValueTokenGenerator.java | 2 +-
.../generator/EncryptProjectionTokenGenerator.java | 4 +--
.../shardingsphere/encrypt/rule/EncryptColumn.java | 2 ++
.../shardingsphere/encrypt/rule/EncryptRule.java | 11 +++---
.../shardingsphere/encrypt/rule/EncryptTable.java | 10 +++---
.../rule/YamlEncryptColumnRuleConfiguration.java | 2 ++
.../EncryptColumnRuleConfigurationYamlSwapper.java | 4 ++-
.../encrypt/context/EncryptContextBuilderTest.java | 2 +-
.../merge/dql/EncryptAlgorithmMetaDataTest.java | 4 +--
.../encrypt/merge/dql/EncryptMergedResultTest.java | 6 ++--
.../impl/EncryptAlterTableTokenGeneratorTest.java | 5 +--
.../impl/EncryptCreateTableTokenGeneratorTest.java | 2 +-
.../impl/EncryptProjectionTokenGeneratorTest.java | 2 +-
.../encrypt/rule/EncryptColumnTest.java | 4 +--
.../encrypt/rule/EncryptRuleTest.java | 42 +++++++++++++++-------
.../encrypt/rule/EncryptTableTest.java | 15 ++++++--
...ryptColumnRuleConfigurationYamlSwapperTest.java | 5 ++-
...cryptTableRuleConfigurationYamlSwapperTest.java | 6 ++--
.../converter/EncryptRuleStatementConverter.java | 2 +-
.../query/EncryptRuleQueryResultSetTest.java | 2 +-
.../DropEncryptRuleStatementUpdaterTest.java | 4 +--
.../parser/EncryptRuleBeanDefinitionParser.java | 1 +
.../main/resources/META-INF/namespace/encrypt.xsd | 1 +
.../namespace/EncryptSpringNamespaceTest.java | 3 ++
.../spring/encrypt-application-context.xml | 4 +--
34 files changed, 114 insertions(+), 65 deletions(-)
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/cluster-mode-example/cluster-mode-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/cluster/mode/raw/jdbc/config/local/LocalEncryptConfiguration.java b/examples/shardingsphere-jdbc-example/single-feature-example/cluster-mode-example/cluster-mode-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/cluster/mode/raw/jdbc/config/local/LocalEncryptConfiguration.java
index 3e5383db763..cc9c7bc4649 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/cluster-mode-example/cluster-mode-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/cluster/mode/raw/jdbc/config/local/LocalEncryptConfiguration.java
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/cluster-mode-example/cluster-mode-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/cluster/mode/raw/jdbc/config/local/LocalEncryptConfiguration.java
@@ -49,7 +49,7 @@ public final class LocalEncryptConfiguration implements ExampleConfiguration {
}
private EncryptTableRuleConfiguration createEncryptTableRuleConfiguration() {
- EncryptColumnRuleConfiguration encryptColumnRuleConfig = new EncryptColumnRuleConfiguration("status", "status", "", "", "status_encryptor");
+ EncryptColumnRuleConfiguration encryptColumnRuleConfig = new EncryptColumnRuleConfiguration("status", "status", "", "", "status_encryptor", null);
return new EncryptTableRuleConfiguration("t_order", Collections.singleton(encryptColumnRuleConfig), null);
}
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/encrypt-example/encrypt-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/encrypt/raw/jdbc/config/EncryptDatabasesConfiguration.java b/examples/shardingsphere-jdbc-example/single-feature-example/encrypt-example/encrypt-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/encrypt/raw/jdbc/config/EncryptDatabasesConfiguration.java
index eda528ffbc4..a352186c2e6 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/encrypt-example/encrypt-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/encrypt/raw/jdbc/config/EncryptDatabasesConfiguration.java
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/encrypt-example/encrypt-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/encrypt/raw/jdbc/config/EncryptDatabasesConfiguration.java
@@ -39,8 +39,8 @@ public final class EncryptDatabasesConfiguration implements ExampleConfiguration
public DataSource getDataSource() {
Properties props = new Properties();
props.setProperty("aes-key-value", "123456");
- EncryptColumnRuleConfiguration columnConfigAes = new EncryptColumnRuleConfiguration("username", "username", "", "username_plain", "name_encryptor");
- EncryptColumnRuleConfiguration columnConfigTest = new EncryptColumnRuleConfiguration("pwd", "pwd", "assisted_query_pwd", "", "pwd_encryptor");
+ EncryptColumnRuleConfiguration columnConfigAes = new EncryptColumnRuleConfiguration("username", "username", "", "username_plain", "name_encryptor", null);
+ EncryptColumnRuleConfiguration columnConfigTest = new EncryptColumnRuleConfiguration("pwd", "pwd", "assisted_query_pwd", "", "pwd_encryptor", null);
EncryptTableRuleConfiguration encryptTableRuleConfig = new EncryptTableRuleConfiguration("t_user", Arrays.asList(columnConfigAes, columnConfigTest), null);
Map<String, ShardingSphereAlgorithmConfiguration> encryptAlgorithmConfigs = new LinkedHashMap<>(2, 1);
encryptAlgorithmConfigs.put("name_encryptor", new ShardingSphereAlgorithmConfiguration("AES", props));
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/shadow-example/shadow-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/shadow/raw/jdbc/config/ShadowEncryptConfiguration.java b/examples/shardingsphere-jdbc-example/single-feature-example/shadow-example/shadow-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/shadow/raw/jdbc/config/ShadowEncryptConfiguration.java
index 2998b9e0547..550c6191ba1 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/shadow-example/shadow-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/shadow/raw/jdbc/config/ShadowEncryptConfiguration.java
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/shadow-example/shadow-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/shadow/raw/jdbc/config/ShadowEncryptConfiguration.java
@@ -80,8 +80,8 @@ public final class ShadowEncryptConfiguration extends BaseShadowConfiguration {
private Collection<EncryptTableRuleConfiguration> getEncryptTableRuleConfigurations() {
Collection<EncryptTableRuleConfiguration> result = new LinkedList<>();
Collection<EncryptColumnRuleConfiguration> columns = new LinkedList<>();
- columns.add(new EncryptColumnRuleConfiguration("username", "username", "", "username_plain", "name_encryptor"));
- columns.add(new EncryptColumnRuleConfiguration("pwd", "pwd", "assisted_query_pwd", "", "pwd_encryptor"));
+ columns.add(new EncryptColumnRuleConfiguration("username", "username", "", "username_plain", "name_encryptor", null));
+ columns.add(new EncryptColumnRuleConfiguration("pwd", "pwd", "assisted_query_pwd", "", "pwd_encryptor", null));
result.add(new EncryptTableRuleConfiguration("t_user", columns, null));
return result;
}
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-api/src/main/java/org/apache/shardingsphere/encrypt/api/config/rule/EncryptColumnRuleConfiguration.java b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-api/src/main/java/org/apache/shardingsphere/encrypt/api/config/rule/EncryptColumnRuleConfiguration.java
index 5c8f2d52750..f591a6a4648 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-api/src/main/java/org/apache/shardingsphere/encrypt/api/config/rule/EncryptColumnRuleConfiguration.java
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-api/src/main/java/org/apache/shardingsphere/encrypt/api/config/rule/EncryptColumnRuleConfiguration.java
@@ -45,7 +45,10 @@ public final class EncryptColumnRuleConfiguration {
private final String encryptorName;
- public EncryptColumnRuleConfiguration(final String logicColumn, final String cipherColumn, final String assistedQueryColumn, final String plainColumn, final String encryptorName) {
- this(logicColumn, null, cipherColumn, null, assistedQueryColumn, null, plainColumn, null, encryptorName);
+ private final Boolean queryWithCipherColumn;
+
+ public EncryptColumnRuleConfiguration(final String logicColumn, final String cipherColumn, final String assistedQueryColumn, final String plainColumn, final String encryptorName,
+ final Boolean queryWithCipherColumn) {
+ this(logicColumn, null, cipherColumn, null, assistedQueryColumn, null, plainColumn, null, encryptorName, queryWithCipherColumn);
}
}
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/merge/dql/EncryptAlgorithmMetaData.java b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/merge/dql/EncryptAlgorithmMetaData.java
index e52cf6e1005..df086485d6b 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/merge/dql/EncryptAlgorithmMetaData.java
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/merge/dql/EncryptAlgorithmMetaData.java
@@ -60,13 +60,14 @@ public final class EncryptAlgorithmMetaData {
}
/**
- * Judge whether table is support QueryWithCipherColumn or not.
+ * Judge whether column is support QueryWithCipherColumn or not.
*
* @param tableName table name
- * @return whether table is support QueryWithCipherColumn or not
+ * @param columnName column name
+ * @return whether column is support QueryWithCipherColumn or not
*/
- public boolean isQueryWithCipherColumn(final String tableName) {
- return encryptRule.isQueryWithCipherColumn(tableName);
+ public boolean isQueryWithCipherColumn(final String tableName, final String columnName) {
+ return encryptRule.isQueryWithCipherColumn(tableName, columnName);
}
/**
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/merge/dql/EncryptMergedResult.java b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/merge/dql/EncryptMergedResult.java
index a235e1f08b5..c3acd574b21 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/merge/dql/EncryptMergedResult.java
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/merge/dql/EncryptMergedResult.java
@@ -46,7 +46,7 @@ public final class EncryptMergedResult implements MergedResult {
@Override
public Object getValue(final int columnIndex, final Class<?> type) throws SQLException {
Optional<EncryptContext> encryptContext = metaData.findEncryptContext(columnIndex);
- if (!encryptContext.isPresent() || !metaData.isQueryWithCipherColumn(encryptContext.get().getTableName())) {
+ if (!encryptContext.isPresent() || !metaData.isQueryWithCipherColumn(encryptContext.get().getTableName(), encryptContext.get().getColumnName())) {
return mergedResult.getValue(columnIndex, type);
}
Optional<EncryptAlgorithm> encryptAlgorithm = metaData.findEncryptor(encryptContext.get().getTableName(), encryptContext.get().getColumnName());
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/parameter/rewriter/EncryptPredicateParameterRewriter.java b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/parameter/rewriter/EncryptPredicateParameterRewriter.java
index 5ef30cce53a..b5b81bf7416 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/parameter/rewriter/EncryptPredicateParameterRewriter.java
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/parameter/rewriter/EncryptPredicateParameterRewriter.java
@@ -56,7 +56,7 @@ public final class EncryptPredicateParameterRewriter implements ParameterRewrite
public void rewrite(final ParameterBuilder parameterBuilder, final SQLStatementContext<?> sqlStatementContext, final List<Object> parameters) {
String schemaName = sqlStatementContext.getTablesContext().getSchemaName().orElseGet(() -> DatabaseTypeEngine.getDefaultSchemaName(sqlStatementContext.getDatabaseType(), databaseName));
for (EncryptCondition each : encryptConditions) {
- boolean queryWithCipherColumn = encryptRule.isQueryWithCipherColumn(each.getTableName());
+ boolean queryWithCipherColumn = encryptRule.isQueryWithCipherColumn(each.getTableName(), each.getColumnName());
if (queryWithCipherColumn) {
encryptParameters(parameterBuilder, each.getPositionIndexMap(), getEncryptedValues(schemaName, each, each.getValues(parameters)));
}
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/EncryptOrderByItemTokenGenerator.java b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/EncryptOrderByItemTokenGenerator.java
index 0875f62948b..3919693bec5 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/EncryptOrderByItemTokenGenerator.java
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/EncryptOrderByItemTokenGenerator.java
@@ -84,7 +84,7 @@ public final class EncryptOrderByItemTokenGenerator implements CollectionSQLToke
}
int startIndex = column.getOwner().isPresent() ? column.getOwner().get().getStopIndex() + 2 : column.getStartIndex();
int stopIndex = column.getStopIndex();
- boolean queryWithCipherColumn = encryptRule.isQueryWithCipherColumn(tableName);
+ boolean queryWithCipherColumn = encryptRule.isQueryWithCipherColumn(tableName, column.getIdentifier().getValue());
if (!queryWithCipherColumn) {
Optional<String> plainColumn = encryptTable.get().findPlainColumn(column.getIdentifier().getValue());
if (plainColumn.isPresent()) {
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/EncryptPredicateColumnTokenGenerator.java b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/EncryptPredicateColumnTokenGenerator.java
index 2f306fb569f..350f27a4685 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/EncryptPredicateColumnTokenGenerator.java
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/EncryptPredicateColumnTokenGenerator.java
@@ -73,7 +73,7 @@ public final class EncryptPredicateColumnTokenGenerator implements CollectionSQL
}
int startIndex = each.getOwner().isPresent() ? each.getOwner().get().getStopIndex() + 2 : each.getStartIndex();
int stopIndex = each.getStopIndex();
- boolean queryWithCipherColumn = encryptRule.isQueryWithCipherColumn(tableName);
+ boolean queryWithCipherColumn = encryptRule.isQueryWithCipherColumn(tableName, each.getIdentifier().getValue());
if (!queryWithCipherColumn) {
Optional<String> plainColumn = encryptTable.get().findPlainColumn(each.getIdentifier().getValue());
if (plainColumn.isPresent()) {
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/EncryptPredicateRightValueTokenGenerator.java b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/EncryptPredicateRightValueTokenGenerator.java
index 1b03e22cfbb..d8b061ccac8 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/EncryptPredicateRightValueTokenGenerator.java
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/EncryptPredicateRightValueTokenGenerator.java
@@ -73,7 +73,7 @@ public final class EncryptPredicateRightValueTokenGenerator implements Collectio
private SQLToken generateSQLToken(final String schemaName, final EncryptCondition encryptCondition) {
List<Object> originalValues = encryptCondition.getValues(parameters);
int startIndex = encryptCondition.getStartIndex();
- boolean queryWithCipherColumn = encryptRule.isQueryWithCipherColumn(encryptCondition.getTableName());
+ boolean queryWithCipherColumn = encryptRule.isQueryWithCipherColumn(encryptCondition.getTableName(), encryptCondition.getColumnName());
return queryWithCipherColumn ? generateSQLTokenForQueryWithCipherColumn(schemaName, encryptCondition, originalValues, startIndex)
: generateSQLTokenForQueryWithoutCipherColumn(schemaName, encryptCondition, originalValues, startIndex);
}
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/EncryptProjectionTokenGenerator.java b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/EncryptProjectionTokenGenerator.java
index 98349c303cc..54cde261c47 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/EncryptProjectionTokenGenerator.java
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/EncryptProjectionTokenGenerator.java
@@ -167,7 +167,7 @@ public final class EncryptProjectionTokenGenerator implements CollectionSQLToken
}
private ColumnProjection generatePredicateSubqueryProjection(final String tableName, final ColumnProjection column) {
- boolean queryWithCipherColumn = encryptRule.isQueryWithCipherColumn(tableName);
+ boolean queryWithCipherColumn = encryptRule.isQueryWithCipherColumn(tableName, column.getName());
if (!queryWithCipherColumn) {
Optional<String> plainColumn = encryptRule.findPlainColumn(tableName, column.getName());
if (plainColumn.isPresent()) {
@@ -205,7 +205,7 @@ public final class EncryptProjectionTokenGenerator implements CollectionSQLToken
}
private String getEncryptColumnName(final String tableName, final String logicEncryptColumnName) {
- boolean queryWithCipherColumn = encryptRule.isQueryWithCipherColumn(tableName);
+ boolean queryWithCipherColumn = encryptRule.isQueryWithCipherColumn(tableName, logicEncryptColumnName);
if (!queryWithCipherColumn) {
return encryptRule.findPlainColumn(tableName, logicEncryptColumnName).orElseGet(() -> encryptRule.getCipherColumn(tableName, logicEncryptColumnName));
}
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/rule/EncryptColumn.java b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/rule/EncryptColumn.java
index b26188c326a..0c30c949f17 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/rule/EncryptColumn.java
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/rule/EncryptColumn.java
@@ -47,6 +47,8 @@ public final class EncryptColumn {
private final String encryptorName;
+ private final Boolean queryWithCipherColumn;
+
/**
* Get assisted query column.
*
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/rule/EncryptRule.java b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/rule/EncryptRule.java
index 8bedb679070..0518777c507 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/rule/EncryptRule.java
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/rule/EncryptRule.java
@@ -285,13 +285,14 @@ public final class EncryptRule implements SchemaRule, TableContainedRule {
}
/**
- * Judge whether table is support QueryWithCipherColumn or not.
+ * Judge whether column is support QueryWithCipherColumn or not.
*
- * @param tableName table name
- * @return whether table is support QueryWithCipherColumn or not
+ * @param logicTable logic table name
+ * @param logicColumn logic column name
+ * @return whether column is support QueryWithCipherColumn or not
*/
- public boolean isQueryWithCipherColumn(final String tableName) {
- return findEncryptTable(tableName).flatMap(EncryptTable::getQueryWithCipherColumn).orElse(queryWithCipherColumn);
+ public boolean isQueryWithCipherColumn(final String logicTable, final String logicColumn) {
+ return findEncryptTable(logicTable).flatMap(encryptTable -> encryptTable.getQueryWithCipherColumn(logicColumn)).orElse(queryWithCipherColumn);
}
private Optional<String> findOriginColumnName(final String logicTable, final String logicColumn) {
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/rule/EncryptTable.java b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/rule/EncryptTable.java
index 785021d6015..ffcf1ee62e2 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/rule/EncryptTable.java
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/rule/EncryptTable.java
@@ -48,7 +48,7 @@ public final class EncryptTable {
columns.put(each.getLogicColumn(), new EncryptColumn(getEncryptColumnDataType(each.getLogicDataType(), dataTypes), each.getCipherColumn(),
getEncryptColumnDataType(each.getCipherDataType(), dataTypes), each.getAssistedQueryColumn(), getEncryptColumnDataType(each.getAssistedQueryDataType(),
dataTypes),
- each.getPlainColumn(), getEncryptColumnDataType(each.getPlainDataType(), dataTypes), each.getEncryptorName()));
+ each.getPlainColumn(), getEncryptColumnDataType(each.getPlainDataType(), dataTypes), each.getEncryptorName(), each.getQueryWithCipherColumn()));
}
queryWithCipherColumn = config.getQueryWithCipherColumn();
}
@@ -180,11 +180,12 @@ public final class EncryptTable {
/**
* Get query with cipher column.
- *
+ *
+ * @param logicColumn logic column
* @return query with cipher column
*/
- public Optional<Boolean> getQueryWithCipherColumn() {
- return Optional.ofNullable(queryWithCipherColumn);
+ public Optional<Boolean> getQueryWithCipherColumn(final String logicColumn) {
+ return Optional.ofNullable(findEncryptColumn(logicColumn).map(EncryptColumn::getQueryWithCipherColumn).orElse(queryWithCipherColumn));
}
/**
@@ -196,4 +197,5 @@ public final class EncryptTable {
public Optional<EncryptColumn> findEncryptColumn(final String logicColumn) {
return Optional.ofNullable(columns.get(logicColumn));
}
+
}
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/yaml/config/rule/YamlEncryptColumnRuleConfiguration.java b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/yaml/config/rule/YamlEncryptColumnRuleConfiguration.java
index d6a6e6fa321..111869a3b69 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/yaml/config/rule/YamlEncryptColumnRuleConfiguration.java
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/yaml/config/rule/YamlEncryptColumnRuleConfiguration.java
@@ -37,4 +37,6 @@ public final class YamlEncryptColumnRuleConfiguration implements YamlConfigurati
private String plainColumn;
private String encryptorName;
+
+ private Boolean queryWithCipherColumn;
}
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/yaml/swapper/rule/EncryptColumnRuleConfigurationYamlSwapper.java b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/yaml/swapper/rule/EncryptColumnRuleConfigurationYamlSwapper.java
index a95f41dbfed..b1c3f1d58a0 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/yaml/swapper/rule/EncryptColumnRuleConfigurationYamlSwapper.java
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/yaml/swapper/rule/EncryptColumnRuleConfigurationYamlSwapper.java
@@ -33,12 +33,14 @@ public final class EncryptColumnRuleConfigurationYamlSwapper implements YamlConf
result.setCipherColumn(data.getCipherColumn());
result.setAssistedQueryColumn(data.getAssistedQueryColumn());
result.setEncryptorName(data.getEncryptorName());
+ result.setQueryWithCipherColumn(data.getQueryWithCipherColumn());
return result;
}
@Override
public EncryptColumnRuleConfiguration swapToObject(final YamlEncryptColumnRuleConfiguration yamlConfig) {
return new EncryptColumnRuleConfiguration(
- yamlConfig.getLogicColumn(), yamlConfig.getCipherColumn(), yamlConfig.getAssistedQueryColumn(), yamlConfig.getPlainColumn(), yamlConfig.getEncryptorName());
+ yamlConfig.getLogicColumn(), yamlConfig.getCipherColumn(), yamlConfig.getAssistedQueryColumn(), yamlConfig.getPlainColumn(), yamlConfig.getEncryptorName(),
+ yamlConfig.getQueryWithCipherColumn());
}
}
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/context/EncryptContextBuilderTest.java b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/context/EncryptContextBuilderTest.java
index 05358b8ab14..0c45bd89cb6 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/context/EncryptContextBuilderTest.java
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/context/EncryptContextBuilderTest.java
@@ -92,6 +92,6 @@ public final class EncryptContextBuilderTest {
EncryptColumnDataType assistedQueryDataType = new EncryptColumnDataType("varchar(200) not null", dataTypes);
EncryptColumnDataType plainDataType = new EncryptColumnDataType("int(20) unsigned not null default 0", dataTypes);
return new EncryptColumn(logicDataType, "cipher_certificate_number", cipherDataType, "assisted_certificate_number",
- assistedQueryDataType, "certificate_number_plain", plainDataType, "test");
+ assistedQueryDataType, "certificate_number_plain", plainDataType, "test", null);
}
}
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/merge/dql/EncryptAlgorithmMetaDataTest.java b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/merge/dql/EncryptAlgorithmMetaDataTest.java
index 400b0bcd4a1..f31479a4189 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/merge/dql/EncryptAlgorithmMetaDataTest.java
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/merge/dql/EncryptAlgorithmMetaDataTest.java
@@ -137,8 +137,8 @@ public final class EncryptAlgorithmMetaDataTest {
@Test
public void assertIsQueryWithCipherColumn() {
- when(encryptRule.isQueryWithCipherColumn("t_order")).thenReturn(true);
+ when(encryptRule.isQueryWithCipherColumn("t_order", "id")).thenReturn(true);
EncryptAlgorithmMetaData encryptAlgorithmMetaData = new EncryptAlgorithmMetaData(DefaultDatabase.LOGIC_NAME, database, encryptRule, selectStatementContext);
- assertTrue(encryptAlgorithmMetaData.isQueryWithCipherColumn("t_order"));
+ assertTrue(encryptAlgorithmMetaData.isQueryWithCipherColumn("t_order", "id"));
}
}
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/merge/dql/EncryptMergedResultTest.java b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/merge/dql/EncryptMergedResultTest.java
index 40add9e1f10..11d76658657 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/merge/dql/EncryptMergedResultTest.java
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/merge/dql/EncryptMergedResultTest.java
@@ -75,7 +75,7 @@ public final class EncryptMergedResultTest {
when(mergedResult.getValue(1, String.class)).thenReturn("VALUE");
EncryptContext encryptContext = EncryptContextBuilder.build(DefaultDatabase.LOGIC_NAME, DefaultDatabase.LOGIC_NAME, "t_encrypt", "order_id", mock(EncryptRule.class));
when(metaData.findEncryptContext(1)).thenReturn(Optional.of(encryptContext));
- when(metaData.isQueryWithCipherColumn("t_encrypt")).thenReturn(true);
+ when(metaData.isQueryWithCipherColumn("t_encrypt", "order_id")).thenReturn(true);
when(metaData.findEncryptor("t_encrypt", "order_id")).thenReturn(Optional.empty());
assertThat(new EncryptMergedResult(metaData, mergedResult).getValue(1, String.class), is("VALUE"));
}
@@ -88,7 +88,7 @@ public final class EncryptMergedResultTest {
EncryptContext encryptContext = EncryptContextBuilder.build(DefaultDatabase.LOGIC_NAME, DefaultDatabase.LOGIC_NAME, "t_encrypt", "order_id", mock(EncryptRule.class));
when(encryptAlgorithm.decrypt("VALUE", encryptContext)).thenReturn("ORIGINAL_VALUE");
when(metaData.findEncryptContext(1)).thenReturn(Optional.of(encryptContext));
- when(metaData.isQueryWithCipherColumn("t_encrypt")).thenReturn(true);
+ when(metaData.isQueryWithCipherColumn("t_encrypt", "order_id")).thenReturn(true);
when(metaData.findEncryptor("t_encrypt", "order_id")).thenReturn(Optional.of(encryptAlgorithm));
assertThat(new EncryptMergedResult(metaData, mergedResult).getValue(1, String.class), is("ORIGINAL_VALUE"));
}
@@ -99,7 +99,7 @@ public final class EncryptMergedResultTest {
EncryptAlgorithm<String, String> encryptAlgorithm = mock(EncryptAlgorithm.class);
EncryptContext encryptContext = EncryptContextBuilder.build(DefaultDatabase.LOGIC_NAME, DefaultDatabase.LOGIC_NAME, "t_encrypt", "order_id", mock(EncryptRule.class));
when(metaData.findEncryptContext(1)).thenReturn(Optional.of(encryptContext));
- when(metaData.isQueryWithCipherColumn("t_encrypt")).thenReturn(true);
+ when(metaData.isQueryWithCipherColumn("t_encrypt", "order_id")).thenReturn(true);
when(metaData.findEncryptor("t_encrypt", "order_id")).thenReturn(Optional.of(encryptAlgorithm));
assertNull(new EncryptMergedResult(metaData, mergedResult).getValue(1, String.class));
}
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/impl/EncryptAlterTableTokenGeneratorTest.java b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/impl/EncryptAlterTableTokenGeneratorTest.java
index 730c1f664db..0f58e1024ce 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/impl/EncryptAlterTableTokenGeneratorTest.java
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/impl/EncryptAlterTableTokenGeneratorTest.java
@@ -89,7 +89,8 @@ public final class EncryptAlterTableTokenGeneratorTest {
EncryptColumnDataType cipherDataType = new EncryptColumnDataType("varchar(200) not null default ''", dataTypes);
EncryptColumnDataType assistedQueryDataType = new EncryptColumnDataType("varchar(200) not null", dataTypes);
EncryptColumnDataType plainDataType = new EncryptColumnDataType("int(20) unsigned not null default 0", dataTypes);
- return new EncryptColumn(logicDataType, "cipher_certificate_number", cipherDataType, "assisted_certificate_number", assistedQueryDataType, "certificate_number_plain", plainDataType, "test");
+ return new EncryptColumn(logicDataType, "cipher_certificate_number", cipherDataType, "assisted_certificate_number", assistedQueryDataType, "certificate_number_plain", plainDataType,
+ "test", null);
}
private EncryptColumn mockNewEncryptColumn() {
@@ -101,7 +102,7 @@ public final class EncryptAlterTableTokenGeneratorTest {
EncryptColumnDataType assistedQueryDataType = new EncryptColumnDataType("varchar(200) not null", dataTypes);
EncryptColumnDataType plainDataType = new EncryptColumnDataType("int(20) unsigned not null default 0", dataTypes);
return new EncryptColumn(logicDataType, "cipher_certificate_number_new", cipherDataType,
- "assisted_certificate_number_new", assistedQueryDataType, "certificate_number_new_plain", plainDataType, "test");
+ "assisted_certificate_number_new", assistedQueryDataType, "certificate_number_new_plain", plainDataType, "test", null);
}
@Test
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/impl/EncryptCreateTableTokenGeneratorTest.java b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/impl/EncryptCreateTableTokenGeneratorTest.java
index dc7d5a05c6d..0eb8f60bb79 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/impl/EncryptCreateTableTokenGeneratorTest.java
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/impl/EncryptCreateTableTokenGeneratorTest.java
@@ -108,6 +108,6 @@ public final class EncryptCreateTableTokenGeneratorTest {
EncryptColumnDataType assistedQueryDataType = new EncryptColumnDataType("varchar(200) not null", dataTypes);
EncryptColumnDataType plainDataType = new EncryptColumnDataType("int(20) unsigned not null default 0", dataTypes);
return new EncryptColumn(logicDataType, "cipher_certificate_number", cipherDataType,
- "assisted_certificate_number", assistedQueryDataType, "certificate_number_plain", plainDataType, "test");
+ "assisted_certificate_number", assistedQueryDataType, "certificate_number_plain", plainDataType, "test", null);
}
}
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/impl/EncryptProjectionTokenGeneratorTest.java b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/impl/EncryptProjectionTokenGeneratorTest.java
index ce61796a056..923b7559611 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/impl/EncryptProjectionTokenGeneratorTest.java
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/impl/EncryptProjectionTokenGeneratorTest.java
@@ -70,7 +70,7 @@ public final class EncryptProjectionTokenGeneratorTest {
when(result.findPlainColumn("doctor1", "mobile")).thenReturn(Optional.of("Mobile"));
when(result.findEncryptTable("doctor")).thenReturn(Optional.of(encryptTable1));
when(result.findEncryptTable("doctor1")).thenReturn(Optional.of(encryptTable2));
- EncryptColumn column = new EncryptColumn(null, "mobile", null, null, null, "mobile", null, null);
+ EncryptColumn column = new EncryptColumn(null, "mobile", null, null, null, "mobile", null, null, null);
when(result.findEncryptColumn("doctor", "mobile")).thenReturn(Optional.of(column));
return result;
}
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/rule/EncryptColumnTest.java b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/rule/EncryptColumnTest.java
index d4d4a8b5b10..b3b13be3ce5 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/rule/EncryptColumnTest.java
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/rule/EncryptColumnTest.java
@@ -25,11 +25,11 @@ public final class EncryptColumnTest {
@Test
public void assertGetAssistedQueryColumn() {
- assertTrue(new EncryptColumn(null, "cipherColumn", null, "assistedQueryColumn", null, "plainColumn", null, "encryptorName").getAssistedQueryColumn().isPresent());
+ assertTrue(new EncryptColumn(null, "cipherColumn", null, "assistedQueryColumn", null, "plainColumn", null, "encryptorName", null).getAssistedQueryColumn().isPresent());
}
@Test
public void assertGetPlainColumn() {
- assertTrue(new EncryptColumn(null, "cipherColumn", null, "assistedQueryColumn", null, "plainColumn", null, "encryptorName").getPlainColumn().isPresent());
+ assertTrue(new EncryptColumn(null, "cipherColumn", null, "assistedQueryColumn", null, "plainColumn", null, "encryptorName", null).getPlainColumn().isPresent());
}
}
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/rule/EncryptRuleTest.java b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/rule/EncryptRuleTest.java
index a3206717de1..f98ab154348 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/rule/EncryptRuleTest.java
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/rule/EncryptRuleTest.java
@@ -50,7 +50,7 @@ public final class EncryptRuleTest {
@Test
public void assertNewInstanceWithAlgorithmProvidedEncryptRuleConfiguration() {
- EncryptColumnRuleConfiguration encryptColumnConfig = new EncryptColumnRuleConfiguration("encrypt_column", "encrypt_cipher", "", "", "test_encryptor");
+ EncryptColumnRuleConfiguration encryptColumnConfig = new EncryptColumnRuleConfiguration("encrypt_column", "encrypt_cipher", "", "", "test_encryptor", null);
EncryptTableRuleConfiguration tableConfig = new EncryptTableRuleConfiguration("t_encrypt", Collections.singletonList(encryptColumnConfig), null);
AlgorithmProvidedEncryptRuleConfiguration ruleConfig = new AlgorithmProvidedEncryptRuleConfiguration(
Collections.singleton(tableConfig), Collections.singletonMap("test_encryptor", new CoreEncryptAlgorithmFixture()), true);
@@ -61,7 +61,7 @@ public final class EncryptRuleTest {
@Test(expected = IllegalArgumentException.class)
public void assertNewInstanceWithInvalidConfiguration() {
ShardingSphereAlgorithmConfiguration encryptAlgorithmConfig = new ShardingSphereAlgorithmConfiguration("CORE.FIXTURE", new Properties());
- EncryptColumnRuleConfiguration encryptColumnConfig = new EncryptColumnRuleConfiguration("encrypt_column", "encrypt_cipher", "", "", "test_encryptor");
+ EncryptColumnRuleConfiguration encryptColumnConfig = new EncryptColumnRuleConfiguration("encrypt_column", "encrypt_cipher", "", "", "test_encryptor", null);
EncryptTableRuleConfiguration tableConfig = new EncryptTableRuleConfiguration("t_encrypt", Collections.singletonList(encryptColumnConfig), null);
EncryptRuleConfiguration ruleConfig = new EncryptRuleConfiguration(Collections.singleton(tableConfig), Collections.singletonMap("invalid_encryptor", encryptAlgorithmConfig));
new EncryptRule(ruleConfig, Collections.emptyMap());
@@ -69,7 +69,7 @@ public final class EncryptRuleTest {
@Test(expected = IllegalArgumentException.class)
public void assertNewInstanceWithInvalidAlgorithmProvidedEncryptRuleConfiguration() {
- EncryptColumnRuleConfiguration encryptColumnConfig = new EncryptColumnRuleConfiguration("encrypt_column", "encrypt_cipher", "", "", "test_encryptor");
+ EncryptColumnRuleConfiguration encryptColumnConfig = new EncryptColumnRuleConfiguration("encrypt_column", "encrypt_cipher", "", "", "test_encryptor", null);
EncryptTableRuleConfiguration tableConfig = new EncryptTableRuleConfiguration("t_encrypt", Collections.singletonList(encryptColumnConfig), null);
AlgorithmProvidedEncryptRuleConfiguration ruleConfig = new AlgorithmProvidedEncryptRuleConfiguration(
Collections.singleton(tableConfig), Collections.singletonMap("invalid_encryptor", new CoreEncryptAlgorithmFixture()), true);
@@ -143,12 +143,30 @@ public final class EncryptRuleTest {
@Test
public void assertIsQueryWithCipherColumn() {
- EncryptColumnRuleConfiguration encryptColumnConfig = new EncryptColumnRuleConfiguration("encrypt_column", "encrypt_cipher", "", "", "test_encryptor");
- EncryptTableRuleConfiguration tableConfig = new EncryptTableRuleConfiguration("t_encrypt", Collections.singletonList(encryptColumnConfig), true);
+ EncryptColumnRuleConfiguration encryptColumnConfig = new EncryptColumnRuleConfiguration("encrypt_column", "encrypt_cipher", "", "", "test_encryptor", null);
+ EncryptTableRuleConfiguration tableConfig = new EncryptTableRuleConfiguration("t_encrypt", Collections.singletonList(encryptColumnConfig), null);
AlgorithmProvidedEncryptRuleConfiguration ruleConfig = new AlgorithmProvidedEncryptRuleConfiguration(
Collections.singleton(tableConfig), Collections.singletonMap("test_encryptor", new CoreEncryptAlgorithmFixture()), true);
EncryptRule actual = new EncryptRule(ruleConfig, Collections.emptyMap());
- assertTrue(actual.isQueryWithCipherColumn("t_encrypt"));
+ assertTrue(actual.isQueryWithCipherColumn("t_encrypt", "encrypt_column"));
+
+ encryptColumnConfig = new EncryptColumnRuleConfiguration("encrypt_column", "encrypt_cipher", "", "", "test_encryptor", null);
+ tableConfig = new EncryptTableRuleConfiguration("t_encrypt", Collections.singletonList(encryptColumnConfig), false);
+ ruleConfig = new AlgorithmProvidedEncryptRuleConfiguration(Collections.singleton(tableConfig), Collections.singletonMap("test_encryptor", new CoreEncryptAlgorithmFixture()), true);
+ actual = new EncryptRule(ruleConfig, Collections.emptyMap());
+ assertFalse(actual.isQueryWithCipherColumn("t_encrypt", "encrypt_column"));
+
+ encryptColumnConfig = new EncryptColumnRuleConfiguration("encrypt_column", "encrypt_cipher", "", "", "test_encryptor", true);
+ tableConfig = new EncryptTableRuleConfiguration("t_encrypt", Collections.singletonList(encryptColumnConfig), false);
+ ruleConfig = new AlgorithmProvidedEncryptRuleConfiguration(Collections.singleton(tableConfig), Collections.singletonMap("test_encryptor", new CoreEncryptAlgorithmFixture()), true);
+ actual = new EncryptRule(ruleConfig, Collections.emptyMap());
+ assertTrue(actual.isQueryWithCipherColumn("t_encrypt", "encrypt_column"));
+
+ encryptColumnConfig = new EncryptColumnRuleConfiguration("encrypt_column", "encrypt_cipher", "", "", "test_encryptor", false);
+ tableConfig = new EncryptTableRuleConfiguration("t_encrypt", Collections.singletonList(encryptColumnConfig), null);
+ ruleConfig = new AlgorithmProvidedEncryptRuleConfiguration(Collections.singleton(tableConfig), Collections.singletonMap("test_encryptor", new CoreEncryptAlgorithmFixture()), true);
+ actual = new EncryptRule(ruleConfig, Collections.emptyMap());
+ assertFalse(actual.isQueryWithCipherColumn("t_encrypt", "encrypt_column"));
}
@Test
@@ -185,9 +203,9 @@ public final class EncryptRuleTest {
private EncryptRuleConfiguration createEncryptRuleConfiguration() {
ShardingSphereAlgorithmConfiguration queryAssistedEncryptConfig = new ShardingSphereAlgorithmConfiguration("CORE.QUERY_ASSISTED.FIXTURE", new Properties());
ShardingSphereAlgorithmConfiguration metaDataAwareEncryptConfig = new ShardingSphereAlgorithmConfiguration("CORE.METADATA_AWARE.FIXTURE", new Properties());
- EncryptColumnRuleConfiguration pwdColumnConfig = new EncryptColumnRuleConfiguration("pwd", "pwd_cipher", "", "pwd_plain", "test_encryptor");
- EncryptColumnRuleConfiguration creditCardColumnConfig = new EncryptColumnRuleConfiguration("credit_card", "credit_card_cipher", "", "credit_card_plain", "test_encryptor");
- EncryptColumnRuleConfiguration nameColumnConfig = new EncryptColumnRuleConfiguration("name", "name_cipher", "", "name_plain", "customized_encryptor");
+ EncryptColumnRuleConfiguration pwdColumnConfig = new EncryptColumnRuleConfiguration("pwd", "pwd_cipher", "", "pwd_plain", "test_encryptor", null);
+ EncryptColumnRuleConfiguration creditCardColumnConfig = new EncryptColumnRuleConfiguration("credit_card", "credit_card_cipher", "", "credit_card_plain", "test_encryptor", null);
+ EncryptColumnRuleConfiguration nameColumnConfig = new EncryptColumnRuleConfiguration("name", "name_cipher", "", "name_plain", "customized_encryptor", null);
EncryptTableRuleConfiguration tableConfig = new EncryptTableRuleConfiguration("t_encrypt", Arrays.asList(pwdColumnConfig, creditCardColumnConfig, nameColumnConfig), null);
return new EncryptRuleConfiguration(Collections.singleton(tableConfig), getEncryptors(queryAssistedEncryptConfig, metaDataAwareEncryptConfig));
}
@@ -195,9 +213,9 @@ public final class EncryptRuleTest {
private EncryptRuleConfiguration createEncryptRuleConfigurationWithUpperCaseLogicTable() {
ShardingSphereAlgorithmConfiguration queryAssistedEncryptConfig = new ShardingSphereAlgorithmConfiguration("CORE.QUERY_ASSISTED.FIXTURE", new Properties());
ShardingSphereAlgorithmConfiguration metaDataAwareEncryptConfig = new ShardingSphereAlgorithmConfiguration("CORE.METADATA_AWARE.FIXTURE", new Properties());
- EncryptColumnRuleConfiguration pwdColumnConfig = new EncryptColumnRuleConfiguration("pwd", "pwd_cipher", "", "pwd_plain", "test_encryptor");
- EncryptColumnRuleConfiguration creditCardColumnConfig = new EncryptColumnRuleConfiguration("credit_card", "credit_card_cipher", "", "credit_card_plain", "test_encryptor");
- EncryptColumnRuleConfiguration nameColumnConfig = new EncryptColumnRuleConfiguration("name", "name_cipher", "", "name_plain", "customized_encryptor");
+ EncryptColumnRuleConfiguration pwdColumnConfig = new EncryptColumnRuleConfiguration("pwd", "pwd_cipher", "", "pwd_plain", "test_encryptor", null);
+ EncryptColumnRuleConfiguration creditCardColumnConfig = new EncryptColumnRuleConfiguration("credit_card", "credit_card_cipher", "", "credit_card_plain", "test_encryptor", null);
+ EncryptColumnRuleConfiguration nameColumnConfig = new EncryptColumnRuleConfiguration("name", "name_cipher", "", "name_plain", "customized_encryptor", null);
EncryptTableRuleConfiguration tableConfig = new EncryptTableRuleConfiguration("T_ENCRYPT", Arrays.asList(pwdColumnConfig, creditCardColumnConfig, nameColumnConfig), null);
return new EncryptRuleConfiguration(Collections.singleton(tableConfig), getEncryptors(queryAssistedEncryptConfig, metaDataAwareEncryptConfig));
}
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/rule/EncryptTableTest.java b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/rule/EncryptTableTest.java
index 962c2a89135..3d4513b4c19 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/rule/EncryptTableTest.java
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/rule/EncryptTableTest.java
@@ -39,7 +39,7 @@ public final class EncryptTableTest {
@Before
public void setUp() {
encryptTable = new EncryptTable(new EncryptTableRuleConfiguration("t_encrypt",
- Collections.singleton(new EncryptColumnRuleConfiguration("logicColumn", "cipherColumn", "assistedQueryColumn", "plainColumn", "myEncryptor")), null), Collections.emptyMap());
+ Collections.singleton(new EncryptColumnRuleConfiguration("logicColumn", "cipherColumn", "assistedQueryColumn", "plainColumn", "myEncryptor", null)), null), Collections.emptyMap());
}
@Test
@@ -123,10 +123,19 @@ public final class EncryptTableTest {
@Test
public void assertGetQueryWithCipherColumn() {
+ Optional<Boolean> actual = encryptTable.getQueryWithCipherColumn("logicColumn");
+ assertFalse(actual.isPresent());
+
encryptTable = new EncryptTable(new EncryptTableRuleConfiguration("t_encrypt",
- Collections.singleton(new EncryptColumnRuleConfiguration("logicColumn", "cipherColumn", "assistedQueryColumn", "plainColumn", "myEncryptor")), true), Collections.emptyMap());
- Optional<Boolean> actual = encryptTable.getQueryWithCipherColumn();
+ Collections.singleton(new EncryptColumnRuleConfiguration("logicColumn", "cipherColumn", "assistedQueryColumn", "plainColumn", "myEncryptor", null)), true), Collections.emptyMap());
+ actual = encryptTable.getQueryWithCipherColumn("logicColumn");
assertTrue(actual.isPresent());
assertTrue(actual.get());
+
+ encryptTable = new EncryptTable(new EncryptTableRuleConfiguration("t_encrypt",
+ Collections.singleton(new EncryptColumnRuleConfiguration("logicColumn", "cipherColumn", "assistedQueryColumn", "plainColumn", "myEncryptor", false)), true), Collections.emptyMap());
+ actual = encryptTable.getQueryWithCipherColumn("logicColumn");
+ assertTrue(actual.isPresent());
+ assertFalse(actual.get());
}
}
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/yaml/swapper/rule/EncryptColumnRuleConfigurationYamlSwapperTest.java b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/yaml/swapper/rule/EncryptColumnRuleConfigurationYamlSwapperTest.java
index 5f69ae425d0..1aba7d1fd07 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/yaml/swapper/rule/EncryptColumnRuleConfigurationYamlSwapperTest.java
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/yaml/swapper/rule/EncryptColumnRuleConfigurationYamlSwapperTest.java
@@ -29,12 +29,13 @@ public final class EncryptColumnRuleConfigurationYamlSwapperTest {
@Test
public void assertSwapToYamlConfiguration() {
EncryptColumnRuleConfigurationYamlSwapper swapper = new EncryptColumnRuleConfigurationYamlSwapper();
- EncryptColumnRuleConfiguration encryptColumnRuleConfig = new EncryptColumnRuleConfiguration("logicColumn", "cipherColumn", "assistedQueryColumn", "plainColumn", "encryptorName");
+ EncryptColumnRuleConfiguration encryptColumnRuleConfig = new EncryptColumnRuleConfiguration("logicColumn", "cipherColumn", "assistedQueryColumn", "plainColumn", "encryptorName", true);
YamlEncryptColumnRuleConfiguration actual = swapper.swapToYamlConfiguration(encryptColumnRuleConfig);
assertThat(actual.getCipherColumn(), is("cipherColumn"));
assertThat(actual.getAssistedQueryColumn(), is("assistedQueryColumn"));
assertThat(actual.getPlainColumn(), is("plainColumn"));
assertThat(actual.getEncryptorName(), is("encryptorName"));
+ assertThat(actual.getQueryWithCipherColumn(), is(true));
}
@Test
@@ -46,11 +47,13 @@ public final class EncryptColumnRuleConfigurationYamlSwapperTest {
yamlEncryptColumnRuleConfig.setAssistedQueryColumn("assistedQueryColumn");
yamlEncryptColumnRuleConfig.setPlainColumn("plainColumn");
yamlEncryptColumnRuleConfig.setEncryptorName("encryptorName");
+ yamlEncryptColumnRuleConfig.setQueryWithCipherColumn(true);
EncryptColumnRuleConfiguration actual = swapper.swapToObject(yamlEncryptColumnRuleConfig);
assertThat(actual.getLogicColumn(), is("logicColumn"));
assertThat(actual.getCipherColumn(), is("cipherColumn"));
assertThat(actual.getAssistedQueryColumn(), is("assistedQueryColumn"));
assertThat(actual.getPlainColumn(), is("plainColumn"));
assertThat(actual.getEncryptorName(), is("encryptorName"));
+ assertThat(actual.getQueryWithCipherColumn(), is(true));
}
}
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/yaml/swapper/rule/EncryptTableRuleConfigurationYamlSwapperTest.java b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/yaml/swapper/rule/EncryptTableRuleConfigurationYamlSwapperTest.java
index 7bc89ee6258..62adebab4da 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/yaml/swapper/rule/EncryptTableRuleConfigurationYamlSwapperTest.java
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/yaml/swapper/rule/EncryptTableRuleConfigurationYamlSwapperTest.java
@@ -39,9 +39,9 @@ public final class EncryptTableRuleConfigurationYamlSwapperTest {
@Test
public void assertSwapToYamlConfiguration() {
Collection<EncryptColumnRuleConfiguration> encryptColumnRuleConfigs = Arrays.asList(
- new EncryptColumnRuleConfiguration("encrypt_column_1", "encrypt_cipher_1", "", "", "test_encryptor_1"),
- new EncryptColumnRuleConfiguration("encrypt_column_2", "encrypt_cipher_2", "", "", "test_encryptor_2"),
- new EncryptColumnRuleConfiguration("encrypt_column_3", "encrypt_cipher_3", "", "", "test_encryptor_3"));
+ new EncryptColumnRuleConfiguration("encrypt_column_1", "encrypt_cipher_1", "", "", "test_encryptor_1", null),
+ new EncryptColumnRuleConfiguration("encrypt_column_2", "encrypt_cipher_2", "", "", "test_encryptor_2", null),
+ new EncryptColumnRuleConfiguration("encrypt_column_3", "encrypt_cipher_3", "", "", "test_encryptor_3", null));
EncryptTableRuleConfiguration encryptTableRuleConfig = new EncryptTableRuleConfiguration("test_table", encryptColumnRuleConfigs, null);
YamlEncryptTableRuleConfiguration actualYamlEncryptTableRuleConfig = tableRuleConfigYamlSwapper.swapToYamlConfiguration(encryptTableRuleConfig);
Map<String, YamlEncryptColumnRuleConfiguration> actualColumns = actualYamlEncryptTableRuleConfig.getColumns();
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-distsql/shardingsphere-encrypt-distsql-handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/converter/EncryptRuleStatementConverter.java b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-distsql/shardingsphere-encrypt-distsql-handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/converter/EncryptRuleStatementConverter.java
index 370bce1e52b..84321f98f51 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-distsql/shardingsphere-encrypt-distsql-handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/converter/EncryptRuleStatementConverter.java
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-distsql/shardingsphere-encrypt-distsql-handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/converter/EncryptRuleStatementConverter.java
@@ -62,7 +62,7 @@ public final class EncryptRuleStatementConverter {
private static EncryptColumnRuleConfiguration createEncryptColumnRuleConfiguration(final String tableName, final EncryptColumnSegment columnSegment) {
return new EncryptColumnRuleConfiguration(columnSegment.getName(), columnSegment.getDataType(), columnSegment.getCipherColumn(),
columnSegment.getCipherDataType(), columnSegment.getAssistedQueryColumn(), columnSegment.getAssistedQueryDataType(),
- columnSegment.getPlainColumn(), columnSegment.getPlainDataType(), getEncryptorName(tableName, columnSegment.getName()));
+ columnSegment.getPlainColumn(), columnSegment.getPlainDataType(), getEncryptorName(tableName, columnSegment.getName()), null);
}
private static Map<String, ShardingSphereAlgorithmConfiguration> createEncryptorConfigurations(final EncryptRuleSegment ruleSegment) {
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-distsql/shardingsphere-encrypt-distsql-handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/query/EncryptRuleQueryResultSetTest.java b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-distsql/shardingsphere-encrypt-distsql-handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/query/EncryptRuleQueryResultSetTest.java
index fb278c45df1..1fe7edc6f24 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-distsql/shardingsphere-encrypt-distsql-handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/query/EncryptRuleQueryResultSetTest.java
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-distsql/shardingsphere-encrypt-distsql-handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/query/EncryptRuleQueryResultSetTest.java
@@ -59,7 +59,7 @@ public final class EncryptRuleQueryResultSetTest {
private RuleConfiguration getRuleConfiguration() {
EncryptColumnRuleConfiguration encryptColumnRuleConfig = new EncryptColumnRuleConfiguration("user_id", "varchar(10)", "user_cipher", "varchar(10)", null, null,
- "user_plain", "varchar(10)", "test");
+ "user_plain", "varchar(10)", "test", null);
EncryptTableRuleConfiguration encryptTableRuleConfig = new EncryptTableRuleConfiguration("t_encrypt", Collections.singleton(encryptColumnRuleConfig), null);
ShardingSphereAlgorithmConfiguration shardingSphereAlgorithmConfig = new ShardingSphereAlgorithmConfiguration("md5", new Properties());
return new EncryptRuleConfiguration(Collections.singleton(encryptTableRuleConfig), Collections.singletonMap("test", shardingSphereAlgorithmConfig));
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-distsql/shardingsphere-encrypt-distsql-handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/update/DropEncryptRuleStatementUpdaterTest.java b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-distsql/shardingsphere-encrypt-distsql-handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/update/DropEncryptRuleStatementUpdaterTest.java
index f83dee638a8..b9e01ba324c 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-distsql/shardingsphere-encrypt-distsql-handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/update/DropEncryptRuleStatementUpdaterTest.java
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-distsql/shardingsphere-encrypt-distsql-handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/update/DropEncryptRuleStatementUpdaterTest.java
@@ -91,7 +91,7 @@ public final class DropEncryptRuleStatementUpdaterTest {
}
private EncryptRuleConfiguration createCurrentRuleConfiguration() {
- EncryptColumnRuleConfiguration columnRuleConfig = new EncryptColumnRuleConfiguration("user_id", "user_cipher", "", "user_plain", "t_encrypt_user_id_MD5");
+ EncryptColumnRuleConfiguration columnRuleConfig = new EncryptColumnRuleConfiguration("user_id", "user_cipher", "", "user_plain", "t_encrypt_user_id_MD5", null);
EncryptTableRuleConfiguration tableRuleConfig = new EncryptTableRuleConfiguration("t_encrypt", Collections.singleton(columnRuleConfig), null);
Map<String, ShardingSphereAlgorithmConfiguration> encryptors = new HashMap<>(
Collections.singletonMap("t_encrypt_user_id_MD5", new ShardingSphereAlgorithmConfiguration("TEST", new Properties())));
@@ -99,7 +99,7 @@ public final class DropEncryptRuleStatementUpdaterTest {
}
private EncryptRuleConfiguration createCurrentRuleConfigurationWithMultipleTableRules() {
- EncryptColumnRuleConfiguration columnRuleConfig = new EncryptColumnRuleConfiguration("user_id", "user_cipher", "", "user_plain", "t_encrypt_user_id_MD5");
+ EncryptColumnRuleConfiguration columnRuleConfig = new EncryptColumnRuleConfiguration("user_id", "user_cipher", "", "user_plain", "t_encrypt_user_id_MD5", null);
EncryptTableRuleConfiguration tableRuleConfig = new EncryptTableRuleConfiguration("t_encrypt", Collections.singleton(columnRuleConfig), null);
Map<String, ShardingSphereAlgorithmConfiguration> encryptors = Collections.singletonMap("t_encrypt_user_id_MD5", new ShardingSphereAlgorithmConfiguration("TEST", new Properties()));
return new EncryptRuleConfiguration(new LinkedList<>(Arrays.asList(tableRuleConfig,
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-spring/shardingsphere-encrypt-spring-namespace/src/main/java/org/apache/shardingsphere/encrypt/spring/namespace/parser/EncryptRuleBeanDefinitionParser.java b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-spring/shardingsphere-encrypt-spring-namespace/src/main/java/org/apache/shardingsphere/encrypt/spring/namespace/parser/EncryptRuleBeanDefinitionParser.java
index c1261bb10bf..578c0ba771a 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-spring/shardingsphere-encrypt-spring-namespace/src/main/java/org/apache/shardingsphere/encrypt/spring/namespace/parser/EncryptRuleBeanDefinitionParser.java
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-spring/shardingsphere-encrypt-spring-namespace/src/main/java/org/apache/shardingsphere/encrypt/spring/namespace/parser/EncryptRuleBeanDefinitionParser.java
@@ -83,6 +83,7 @@ public final class EncryptRuleBeanDefinitionParser extends AbstractBeanDefinitio
factory.addConstructorArgValue(element.getAttribute(EncryptRuleBeanDefinitionTag.ASSISTED_QUERY_COLUMN_ATTRIBUTE));
factory.addConstructorArgValue(element.getAttribute(EncryptRuleBeanDefinitionTag.PLAIN_COLUMN_ATTRIBUTE));
factory.addConstructorArgValue(element.getAttribute(EncryptRuleBeanDefinitionTag.ENCRYPT_ALGORITHM_REF_ATTRIBUTE));
+ factory.addConstructorArgValue(element.getAttribute(EncryptRuleBeanDefinitionTag.QUERY_WITH_CIPHER_COLUMN));
return factory.getBeanDefinition();
}
}
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-spring/shardingsphere-encrypt-spring-namespace/src/main/resources/META-INF/namespace/encrypt.xsd b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-spring/shardingsphere-encrypt-spring-namespace/src/main/resources/META-INF/namespace/encrypt.xsd
index 36418c71f71..261aa3fdda3 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-spring/shardingsphere-encrypt-spring-namespace/src/main/resources/META-INF/namespace/encrypt.xsd
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-spring/shardingsphere-encrypt-spring-namespace/src/main/resources/META-INF/namespace/encrypt.xsd
@@ -49,6 +49,7 @@
<xsd:attribute name="assisted-query-column" type="xsd:string" />
<xsd:attribute name="plain-column" type="xsd:string" />
<xsd:attribute name="encrypt-algorithm-ref" type="xsd:string" use="required" />
+ <xsd:attribute name="query-with-cipher-column" type="xsd:boolean" />
</xsd:complexType>
</xsd:element>
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-spring/shardingsphere-encrypt-spring-namespace/src/test/java/org/apache/shardingsphere/encrypt/spring/namespace/EncryptSpringNamespaceTest.java b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-spring/shardingsphere-encrypt-spring-namespace/src/test/java/org/apache/shardingsphere/encrypt/spring/namespace/EncryptSpringNamespaceTest.java
index 431cab4e402..6ef3cfc2b9b 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-spring/shardingsphere-encrypt-spring-namespace/src/test/java/org/apache/shardingsphere/encrypt/spring/namespace/EncryptSpringNamespaceTest.java
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-spring/shardingsphere-encrypt-spring-namespace/src/test/java/org/apache/shardingsphere/encrypt/spring/namespace/EncryptSpringNamespaceTest.java
@@ -35,6 +35,7 @@ import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
@ContextConfiguration(locations = "classpath:META-INF/spring/encrypt-application-context.xml")
public final class EncryptSpringNamespaceTest extends AbstractJUnit4SpringContextTests {
@@ -86,6 +87,7 @@ public final class EncryptSpringNamespaceTest extends AbstractJUnit4SpringContex
assertThat(columnRuleConfig.getLogicColumn(), is("pwd"));
assertThat(columnRuleConfig.getCipherColumn(), is("pwd_cipher"));
assertThat(columnRuleConfig.getEncryptorName(), is("aesEncryptor"));
+ assertTrue(columnRuleConfig.getQueryWithCipherColumn());
}
private void assertEncryptColumn2(final EncryptColumnRuleConfiguration columnRuleConfig) {
@@ -94,5 +96,6 @@ public final class EncryptSpringNamespaceTest extends AbstractJUnit4SpringContex
assertThat(columnRuleConfig.getAssistedQueryColumn(), is("credit_card_assisted_query"));
assertThat(columnRuleConfig.getPlainColumn(), is("credit_card_plain"));
assertThat(columnRuleConfig.getEncryptorName(), is("md5Encryptor"));
+ assertFalse(columnRuleConfig.getQueryWithCipherColumn());
}
}
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-spring/shardingsphere-encrypt-spring-namespace/src/test/resources/META-INF/spring/encrypt-application-context.xml b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-spring/shardingsphere-encrypt-spring-namespace/src/test/resources/META-INF/spring/encrypt-application-context.xml
index 11e47e022d5..772ae6cd945 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-spring/shardingsphere-encrypt-spring-namespace/src/test/resources/META-INF/spring/encrypt-application-context.xml
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-spring/shardingsphere-encrypt-spring-namespace/src/test/resources/META-INF/spring/encrypt-application-context.xml
@@ -38,8 +38,8 @@
<encrypt:rule id="encryptRule">
<encrypt:table name="t_order" query-with-cipher-column="false">
- <encrypt:column logic-column="pwd" cipher-column="pwd_cipher" encrypt-algorithm-ref="aesEncryptor" />
- <encrypt:column logic-column="credit_card" cipher-column="credit_card_cipher" assisted-query-column="credit_card_assisted_query" plain-column="credit_card_plain" encrypt-algorithm-ref="md5Encryptor" />
+ <encrypt:column logic-column="pwd" cipher-column="pwd_cipher" encrypt-algorithm-ref="aesEncryptor" query-with-cipher-column="true" />
+ <encrypt:column logic-column="credit_card" cipher-column="credit_card_cipher" assisted-query-column="credit_card_assisted_query" plain-column="credit_card_plain" encrypt-algorithm-ref="md5Encryptor" query-with-cipher-column="false" />
</encrypt:table>
</encrypt:rule>
</beans>