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 73cee36 modify QueryAssistedEncryptAlgorithm queryAssistedEncrypt
method para… (#12409)
73cee36 is described below
commit 73cee3614c582a14b77b3f6b1cda6049dee5da67
Author: CodingBingo <[email protected]>
AuthorDate: Tue Sep 14 07:49:20 2021 +0800
modify QueryAssistedEncryptAlgorithm queryAssistedEncrypt method para…
(#12409)
* modify QueryAssistedEncryptAlgorithm queryAssistedEncrypt method
parameter to enable user decide how use plainText
* modify method parameter type
---
.../example/fixture/TestQueryAssistedShardingEncryptAlgorithm.java | 2 +-
.../shardingsphere/encrypt/spi/QueryAssistedEncryptAlgorithm.java | 2 +-
.../impl/EncryptInsertOnDuplicateKeyUpdateValueParameterRewriter.java | 2 +-
.../rewrite/parameter/impl/EncryptInsertValueParameterRewriter.java | 2 +-
.../rewrite/token/generator/impl/EncryptInsertValuesTokenGenerator.java | 2 +-
.../main/java/org/apache/shardingsphere/encrypt/rule/EncryptRule.java | 2 +-
.../encrypt/fixture/TestQueryAssistedEncryptAlgorithm.java | 2 +-
.../driver/fixture/TestQueryAssistedEncryptAlgorithm.java | 2 +-
.../sharding/rewrite/fixture/QueryAssistedEncryptAlgorithmFixture.java | 2 +-
9 files changed, 9 insertions(+), 9 deletions(-)
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 aea7814..b196297 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
@@ -43,7 +43,7 @@ public final class TestQueryAssistedShardingEncryptAlgorithm
implements QueryAss
}
@Override
- public String queryAssistedEncrypt(final String plaintext) {
+ public String queryAssistedEncrypt(final Object plaintext) {
return "assistedEncryptValue";
}
diff --git
a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-api/src/main/java/org/apache/shardingsphere/encrypt/spi/QueryAssistedEncryptAlgorithm.java
b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-api/src/main/java/org/apache/shardingsphere/encrypt/spi/QueryAssistedEncryptAlgorithm.java
index 624e89e..0dbd84d 100644
---
a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-api/src/main/java/org/apache/shardingsphere/encrypt/spi/QueryAssistedEncryptAlgorithm.java
+++
b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-api/src/main/java/org/apache/shardingsphere/encrypt/spi/QueryAssistedEncryptAlgorithm.java
@@ -28,5 +28,5 @@ public interface QueryAssistedEncryptAlgorithm extends
EncryptAlgorithm {
* @param plaintext plaintext
* @return ciphertext
*/
- String queryAssistedEncrypt(String plaintext);
+ String queryAssistedEncrypt(Object plaintext);
}
diff --git
a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/parameter/impl/EncryptInsertOnDuplicateKeyUpdateValueParameterRewriter.java
b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/parameter/impl/EncryptInsertOnDuplicateKeyUpdateValueParameterRewriter.java
index 5bcd48b..238c54e 100644
---
a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/parameter/impl/EncryptInsertOnDuplicateKeyUpdateValueParameterRewriter.java
+++
b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/parameter/impl/EncryptInsertOnDuplicateKeyUpdateValueParameterRewriter.java
@@ -63,7 +63,7 @@ public final class
EncryptInsertOnDuplicateKeyUpdateValueParameterRewriter exten
if (encryptor instanceof QueryAssistedEncryptAlgorithm) {
Optional<String> assistedColumnName =
getEncryptRule().findAssistedQueryColumn(tableName, encryptLogicColumnName);
Preconditions.checkArgument(assistedColumnName.isPresent(), "Can not find
assisted query Column Name");
- addedParameters.add(((QueryAssistedEncryptAlgorithm)
encryptor).queryAssistedEncrypt(plainColumnValue.toString()));
+ addedParameters.add(((QueryAssistedEncryptAlgorithm)
encryptor).queryAssistedEncrypt(plainColumnValue));
}
if (getEncryptRule().findPlainColumn(tableName,
encryptLogicColumnName).isPresent()) {
addedParameters.add(plainColumnValue);
diff --git
a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/parameter/impl/EncryptInsertValueParameterRewriter.java
b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/parameter/impl/EncryptInsertValueParameterRewriter.java
index 00529a5..63a5a60 100644
---
a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/parameter/impl/EncryptInsertValueParameterRewriter.java
+++
b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/parameter/impl/EncryptInsertValueParameterRewriter.java
@@ -95,7 +95,7 @@ public final class EncryptInsertValueParameterRewriter
extends EncryptParameterR
if (encryptAlgorithm instanceof QueryAssistedEncryptAlgorithm) {
Optional<String> assistedColumnName =
getEncryptRule().findAssistedQueryColumn(tableName, encryptLogicColumnName);
Preconditions.checkArgument(assistedColumnName.isPresent(), "Can
not find assisted query Column Name");
- addedParameters.add(((QueryAssistedEncryptAlgorithm)
encryptAlgorithm).queryAssistedEncrypt(originalValue.toString()));
+ addedParameters.add(((QueryAssistedEncryptAlgorithm)
encryptAlgorithm).queryAssistedEncrypt(originalValue));
}
if (getEncryptRule().findPlainColumn(tableName,
encryptLogicColumnName).isPresent()) {
addedParameters.add(originalValue);
diff --git
a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/impl/EncryptInsertValuesTokenGenerator.java
b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/impl/EncryptInsertValuesTokenGenerator.java
index b80cca1..5c4d608 100644
---
a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/impl/EncryptInsertValuesTokenGenerator.java
+++
b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/impl/EncryptInsertValuesTokenGenerator.java
@@ -143,7 +143,7 @@ public final class EncryptInsertValuesTokenGenerator
extends BaseEncryptSQLToken
final String tableName, final String
columnName, final InsertValueContext insertValueContext, final Object
originalValue) {
if (getEncryptRule().findAssistedQueryColumn(tableName,
columnName).isPresent()) {
DerivedSimpleExpressionSegment derivedExpressionSegment =
isAddLiteralExpressionSegment(insertValueContext, columnIndex)
- ? new
DerivedLiteralExpressionSegment(((QueryAssistedEncryptAlgorithm)
encryptAlgorithm).queryAssistedEncrypt(null == originalValue ? null :
originalValue.toString()))
+ ? new
DerivedLiteralExpressionSegment(((QueryAssistedEncryptAlgorithm)
encryptAlgorithm).queryAssistedEncrypt(null == originalValue ? null :
originalValue))
: new
DerivedParameterMarkerExpressionSegment(getParameterIndexCount(insertValueToken));
insertValueToken.getValues().add(columnIndex + 1,
derivedExpressionSegment);
}
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 01d2d58..7f14cc6 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
@@ -201,7 +201,7 @@ public final class EncryptRule implements SchemaRule,
TableContainedRule {
Optional<EncryptAlgorithm> encryptor = findEncryptor(logicTable,
logicColumn);
Preconditions.checkArgument(encryptor.isPresent() && encryptor.get()
instanceof QueryAssistedEncryptAlgorithm,
String.format("Can not find QueryAssistedEncryptAlgorithm by
%s.%s.", logicTable, logicColumn));
- return originalValues.stream().map(input -> null == input ? null :
((QueryAssistedEncryptAlgorithm)
encryptor.get()).queryAssistedEncrypt(input.toString())).collect(Collectors.toList());
+ return originalValues.stream().map(input -> null == input ? null :
((QueryAssistedEncryptAlgorithm)
encryptor.get()).queryAssistedEncrypt(input)).collect(Collectors.toList());
}
/**
diff --git
a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/fixture/TestQueryAssistedEncryptAlgorithm.java
b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/fixture/TestQueryAssistedEncryptAlgorithm.java
index 1528af9..4046537 100644
---
a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/fixture/TestQueryAssistedEncryptAlgorithm.java
+++
b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/fixture/TestQueryAssistedEncryptAlgorithm.java
@@ -36,7 +36,7 @@ public final class TestQueryAssistedEncryptAlgorithm
implements QueryAssistedEnc
}
@Override
- public String queryAssistedEncrypt(final String plaintext) {
+ public String queryAssistedEncrypt(final Object plaintext) {
return "assistedEncryptValue";
}
diff --git
a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/fixture/TestQueryAssistedEncryptAlgorithm.java
b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/fixture/TestQueryAssistedEncryptAlgorithm.java
index 6c2bccf..c3b3af5 100644
---
a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/fixture/TestQueryAssistedEncryptAlgorithm.java
+++
b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/fixture/TestQueryAssistedEncryptAlgorithm.java
@@ -36,7 +36,7 @@ public final class TestQueryAssistedEncryptAlgorithm
implements QueryAssistedEnc
}
@Override
- public String queryAssistedEncrypt(final String plaintext) {
+ public String queryAssistedEncrypt(final Object plaintext) {
return "assistedEncryptValue";
}
diff --git
a/shardingsphere-test/shardingsphere-rewrite-test/src/test/java/org/apache/shardingsphere/sharding/rewrite/fixture/QueryAssistedEncryptAlgorithmFixture.java
b/shardingsphere-test/shardingsphere-rewrite-test/src/test/java/org/apache/shardingsphere/sharding/rewrite/fixture/QueryAssistedEncryptAlgorithmFixture.java
index 26e3ab1..c68448e 100644
---
a/shardingsphere-test/shardingsphere-rewrite-test/src/test/java/org/apache/shardingsphere/sharding/rewrite/fixture/QueryAssistedEncryptAlgorithmFixture.java
+++
b/shardingsphere-test/shardingsphere-rewrite-test/src/test/java/org/apache/shardingsphere/sharding/rewrite/fixture/QueryAssistedEncryptAlgorithmFixture.java
@@ -36,7 +36,7 @@ public final class QueryAssistedEncryptAlgorithmFixture
implements QueryAssisted
}
@Override
- public String queryAssistedEncrypt(final String plaintext) {
+ public String queryAssistedEncrypt(final Object plaintext) {
return "assisted_query_" + plaintext;
}