diff --git a/docs/document/content/dev-manual/encrypt.cn.md b/docs/document/content/dev-manual/encrypt.cn.md index 1fd403d0f800f..9ffedbd2cfc16 100644 --- a/docs/document/content/dev-manual/encrypt.cn.md +++ b/docs/document/content/dev-manual/encrypt.cn.md @@ -20,6 +20,4 @@ chapter = true | *配置标识* | *详细说明* | *全限定类名* | |------------------|------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | AES | 基于 AES 的数据加密算法 | [`org.apache.shardingsphere.encrypt.algorithm.encrypt.AESEncryptAlgorithm`](https://github.com/apache/shardingsphere/blob/master/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/standard/AESEncryptAlgorithm.java) | -| 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/standard/RC4EncryptAlgorithm.java) | | MD5 | 基于 MD5 的辅助查询加密算法 | [`org.apache.shardingsphere.encrypt.algorithm.encrypt.MD5EncryptAlgorithm`](https://github.com/apache/shardingsphere/blob/master/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/assisted/MD5AssistedEncryptAlgorithm.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) | diff --git a/docs/document/content/dev-manual/encrypt.en.md b/docs/document/content/dev-manual/encrypt.en.md index a81d2acd3da77..caeada0038052 100644 --- a/docs/document/content/dev-manual/encrypt.en.md +++ b/docs/document/content/dev-manual/encrypt.en.md @@ -20,6 +20,4 @@ Data encrypt algorithm definition | *Configuration Type* | *Description* | *Fully-qualified class name* | |----------------------|---------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | AES | AES data encrypt algorithm | [`org.apache.shardingsphere.encrypt.algorithm.encrypt.AESEncryptAlgorithm`](https://github.com/apache/shardingsphere/blob/master/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/standard/AESEncryptAlgorithm.java) | -| 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/standard/RC4EncryptAlgorithm.java) | | MD5 | MD5 assisted query encrypt algorithm | [`org.apache.shardingsphere.encrypt.algorithm.encrypt.MD5EncryptAlgorithm`](https://github.com/apache/shardingsphere/blob/master/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/assisted/MD5AssistedEncryptAlgorithm.java) | -| 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 62931407f691c..68b5f19d7df89 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 @@ -22,31 +22,6 @@ weight = 5 | aes-key-value | String | AES 使用的 KEY | | digest-algorithm-name | String | AES KEY 的摘要算法 (可选,默认值:SHA-1) | -#### RC4 加密算法 - -类型:RC4 - -可配置属性: - -| *名称* | *数据类型* | *说明* | -|---------------|--------|-------------| -| rc4-key-value | String | RC4 使用的 KEY | - -### 模糊加密算法 - -#### 单字符摘要模糊加密算法 - -类型:CHAR_DIGEST_LIKE - -可配置属性: - -| *名称* | *数据类型* | *说明* | -|-------|--------|--------------------| -| delta | int | 字符Unicode码偏移量(十进制) | -| mask | int | 字符加密掩码(十进制) | -| start | int | 密文Unicode初始码(十进制) | -| dict | String | 常见字 | - ### 辅助查询加密算法 #### MD5 辅助查询加密算法 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 58cad71e6f7ff..ac09a77ccf472 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 @@ -22,31 +22,6 @@ Attributes: | aes-key-value | String | AES KEY | | digest-algorithm-name | String | AES KEY DIGEST ALGORITHM (optional, default: SHA-1) | -#### RC4 Encrypt Algorithm - -Type: RC4 - -Attributes: - -| *Name* | *DataType* | *Description* | -|---------------|------------|---------------| -| rc4-key-value | String | RC4 KEY | - -### Like Encrypt Algorithm - -#### CharDigestLike Encrypt Algorithm - -Type:CHAR_DIGEST_LIKE - -Attributes: - -| *Name* | *DataType* | *Description* | -|--------|------------|-------------------------------------------------| -| delta | int | Character Unicode offset(decimal number) | -| mask | int | Character encryption mask(decimal number) | -| start | int | Ciphertext Unicode initial code(decimal number) | -| dict | String | Common words | - ### Assisted Encrypt Algorithm #### MD5 Assisted Encrypt Algorithm diff --git a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/standard/RC4EncryptAlgorithm.java b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/standard/RC4EncryptAlgorithm.java deleted file mode 100644 index 1bc3e2169e56f..0000000000000 --- a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/standard/RC4EncryptAlgorithm.java +++ /dev/null @@ -1,110 +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. - */ - -package org.apache.shardingsphere.encrypt.algorithm.standard; - -import lombok.EqualsAndHashCode; -import org.apache.commons.codec.binary.Base64; -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.infra.exception.core.ShardingSpherePreconditions; - -import java.nio.charset.StandardCharsets; -import java.util.Properties; - -/** - * RC4 encrypt algorithm. - */ -@EqualsAndHashCode -public final class RC4EncryptAlgorithm implements StandardEncryptAlgorithm { - - private static final String RC4_KEY = "rc4-key-value"; - - private static final int KEY_MIN_LENGTH = 5; - - private static final int SBOX_LENGTH = 256; - - private byte[] key; - - @Override - public void init(final Properties props) { - key = getKey(props); - } - - private byte[] getKey(final Properties props) { - byte[] result = props.getProperty(RC4_KEY, "").getBytes(StandardCharsets.UTF_8); - ShardingSpherePreconditions.checkState(KEY_MIN_LENGTH <= result.length && SBOX_LENGTH > result.length, - () -> new EncryptAlgorithmInitializationException(getType(), "Key length has to be between " + KEY_MIN_LENGTH + " and " + (SBOX_LENGTH - 1))); - return result; - } - - @Override - public String encrypt(final Object plainValue, final EncryptContext encryptContext) { - return null == plainValue ? null : Base64.encodeBase64String(crypt(String.valueOf(plainValue).getBytes(StandardCharsets.UTF_8))); - } - - @Override - public Object decrypt(final Object cipherValue, final EncryptContext encryptContext) { - return null == cipherValue ? null : new String(crypt(Base64.decodeBase64(cipherValue.toString())), StandardCharsets.UTF_8); - } - - /* - * @see Pseudo-random generation algorithm - */ - private byte[] crypt(final byte[] message) { - int[] sBox = getSBox(); - byte[] result = new byte[message.length]; - int i = 0; - int j = 0; - for (int n = 0; n < message.length; n++) { - i = (i + 1) % SBOX_LENGTH; - j = (j + sBox[i]) % SBOX_LENGTH; - swap(i, j, sBox); - int rand = sBox[(sBox[i] + sBox[j]) % SBOX_LENGTH]; - result[n] = (byte) (rand ^ message[n]); - } - return result; - } - - /* - * @see Wikipedia. Init sBox - */ - private int[] getSBox() { - int[] result = new int[SBOX_LENGTH]; - int j = 0; - for (int i = 0; i < SBOX_LENGTH; i++) { - result[i] = i; - } - for (int i = 0; i < SBOX_LENGTH; i++) { - j = (j + result[i] + (key[i % key.length]) & 0xFF) % SBOX_LENGTH; - swap(i, j, result); - } - return result; - } - - private void swap(final int i, final int j, final int[] sBox) { - int temp = sBox[i]; - sBox[i] = sBox[j]; - sBox[j] = temp; - } - - @Override - public String getType() { - return "RC4"; - } -} 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 9f336b168092f..8cb0319280d90 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 @@ -16,6 +16,4 @@ # org.apache.shardingsphere.encrypt.algorithm.standard.AESEncryptAlgorithm -org.apache.shardingsphere.encrypt.algorithm.standard.RC4EncryptAlgorithm -org.apache.shardingsphere.encrypt.algorithm.like.CharDigestLikeEncryptAlgorithm org.apache.shardingsphere.encrypt.algorithm.assisted.MD5AssistedEncryptAlgorithm 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 deleted file mode 100644 index 63e3b8f4b09a1..0000000000000 --- a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/algorithm/like/CharDigestLikeEncryptAlgorithmTest.java +++ /dev/null @@ -1,71 +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. - */ - -package org.apache.shardingsphere.encrypt.algorithm.like; - -import org.apache.shardingsphere.encrypt.api.context.EncryptContext; -import org.apache.shardingsphere.encrypt.api.encrypt.like.LikeEncryptAlgorithm; -import org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm; -import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader; -import org.apache.shardingsphere.test.util.PropertiesBuilder; -import org.apache.shardingsphere.test.util.PropertiesBuilder.Property; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.jupiter.api.Assertions.assertNull; -import static org.mockito.Mockito.mock; - -class CharDigestLikeEncryptAlgorithmTest { - - private LikeEncryptAlgorithm englishLikeEncryptAlgorithm; - - private LikeEncryptAlgorithm chineseLikeEncryptAlgorithm; - - private LikeEncryptAlgorithm koreanLikeEncryptAlgorithm; - - @BeforeEach - void setUp() { - englishLikeEncryptAlgorithm = (LikeEncryptAlgorithm) TypedSPILoader.getService(EncryptAlgorithm.class, "CHAR_DIGEST_LIKE"); - chineseLikeEncryptAlgorithm = (LikeEncryptAlgorithm) TypedSPILoader.getService(EncryptAlgorithm.class, "CHAR_DIGEST_LIKE"); - koreanLikeEncryptAlgorithm = (LikeEncryptAlgorithm) TypedSPILoader.getService(EncryptAlgorithm.class, - "CHAR_DIGEST_LIKE", PropertiesBuilder.build(new Property("dict", "한국어시험"), new Property("start", "44032"))); - } - - @Test - void assertEncrypt() { - assertThat(englishLikeEncryptAlgorithm.encrypt("1234567890%abcdefghijklmnopqrstuvwxyz%ABCDEFGHIJKLMNOPQRSTUVWXYZ", - mock(EncryptContext.class)), is("0145458981%`adedehihilmlmpqpqtutuxyxy%@ADEDEHIHILMLMPQPQTUTUXYXY")); - assertThat(englishLikeEncryptAlgorithm.encrypt("_1234__5678__", mock(EncryptContext.class)), is("_0145__4589__")); - } - - @Test - void assertEncryptWithChineseChar() { - assertThat(chineseLikeEncryptAlgorithm.encrypt("中国", mock(EncryptContext.class)), is("婝估")); - } - - @Test - void assertEncryptWithKoreanChar() { - assertThat(koreanLikeEncryptAlgorithm.encrypt("한국", mock(EncryptContext.class)), is("각가")); - } - - @Test - void assertEncryptWithNullPlaintext() { - assertNull(englishLikeEncryptAlgorithm.encrypt(null, mock(EncryptContext.class))); - } -} diff --git a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/algorithm/standard/RC4EncryptAlgorithmTest.java b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/algorithm/standard/RC4EncryptAlgorithmTest.java deleted file mode 100644 index a87b3591f29a7..0000000000000 --- a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/algorithm/standard/RC4EncryptAlgorithmTest.java +++ /dev/null @@ -1,79 +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. - */ - -package org.apache.shardingsphere.encrypt.algorithm.standard; - -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.infra.spi.type.typed.TypedSPILoader; -import org.apache.shardingsphere.test.util.PropertiesBuilder; -import org.apache.shardingsphere.test.util.PropertiesBuilder.Property; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import java.util.stream.Collectors; -import java.util.stream.IntStream; - -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.jupiter.api.Assertions.assertNull; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.mockito.Mockito.mock; - -class RC4EncryptAlgorithmTest { - - private StandardEncryptAlgorithm encryptAlgorithm; - - @BeforeEach - void setUp() { - encryptAlgorithm = (StandardEncryptAlgorithm) TypedSPILoader.getService(EncryptAlgorithm.class, "RC4", PropertiesBuilder.build(new Property("rc4-key-value", "test-sharding"))); - } - - @Test - void assertEncode() { - assertThat(encryptAlgorithm.encrypt("test", mock(EncryptContext.class)), is("4Tn7lQ==")); - } - - @Test - void assertEncryptNullValue() { - assertNull(encryptAlgorithm.encrypt(null, mock(EncryptContext.class))); - } - - @Test - void assertKeyIsTooLong() { - assertThrows(EncryptAlgorithmInitializationException.class, - () -> encryptAlgorithm.init(PropertiesBuilder.build(new Property("rc4-key-value", IntStream.range(0, 100).mapToObj(each -> "test").collect(Collectors.joining()))))); - } - - @Test - void assertKeyIsTooShort() { - assertThrows(EncryptAlgorithmInitializationException.class, - () -> encryptAlgorithm.init(PropertiesBuilder.build(new Property("rc4-key-value", "test")))); - } - - @Test - void assertDecode() { - assertThat(encryptAlgorithm.decrypt("4Tn7lQ==", mock(EncryptContext.class)).toString(), is("test")); - } - - @Test - void assertDecryptNullValue() { - assertNull(encryptAlgorithm.decrypt(null, mock(EncryptContext.class))); - } -} diff --git a/features/encrypt/core/src/test/resources/yaml/encrypt-rule.yaml b/features/encrypt/core/src/test/resources/yaml/encrypt-rule.yaml index 27939450a09b3..e8b9f209e6ad6 100644 --- a/features/encrypt/core/src/test/resources/yaml/encrypt-rule.yaml +++ b/features/encrypt/core/src/test/resources/yaml/encrypt-rule.yaml @@ -27,9 +27,6 @@ rules: assistedQuery: name: assisted_query_username encryptorName: assisted_encryptor - likeQuery: - name: like_query_username - encryptorName: like_encryptor encryptors: aes_encryptor: type: AES @@ -39,5 +36,3 @@ rules: type: AES props: aes-key-value: 123456abc - like_encryptor: - type: CHAR_DIGEST_LIKE 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 a8e8c47f9cb86..6cb605cd6b51a 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 @@ -34,25 +34,16 @@ algorithmTypeName buildInEncryptAlgorithmType : standardEncryptAlgorithm | assistedEncryptAlgorithm - | likeEncryptAlgorithm ; standardEncryptAlgorithm - : MD5 - | AES - | RC4 - | SM3 - | SM4 + : AES ; assistedEncryptAlgorithm : MD5 ; -likeEncryptAlgorithm - : CHAR_DIGEST_LIKE - ; - propertiesDefinition : PROPERTIES LP_ properties? RP_ ; diff --git a/features/encrypt/distsql/parser/src/main/antlr4/imports/encrypt/Keyword.g4 b/features/encrypt/distsql/parser/src/main/antlr4/imports/encrypt/Keyword.g4 index be4b1ca11cbd2..8137363e58740 100644 --- a/features/encrypt/distsql/parser/src/main/antlr4/imports/encrypt/Keyword.g4 +++ b/features/encrypt/distsql/parser/src/main/antlr4/imports/encrypt/Keyword.g4 @@ -143,22 +143,6 @@ AES : A E S ; -RC4 - : R C [4] - ; - -SM3 - : S M [3] - ; - -SM4 - : S M [4] - ; - -CHAR_DIGEST_LIKE - : C H A R UL_ D I G E S T UL_ L I K E - ; - NOT : N O T ; 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 6fa6138f3b026..5ac1d9baf192e 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 @@ -48,8 +48,6 @@ rules: type: RC4 props: rc4-key-value: 123456abc - like_encryptor: - type: CHAR_DIGEST_LIKE tables: t_encrypt: columns: 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 8999c74c0bea2..092e1580c49b4 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 @@ -132,8 +132,6 @@ rules: type: RC4 props: rc4-key-value: 123456abc - like_encryptor: - type: CHAR_DIGEST_LIKE tables: t_encrypt: columns: diff --git a/proxy/backend/core/src/test/resources/expected/convert-encrypt.yaml b/proxy/backend/core/src/test/resources/expected/convert-encrypt.yaml index 8882645ae9399..5d56739fd454c 100644 --- a/proxy/backend/core/src/test/resources/expected/convert-encrypt.yaml +++ b/proxy/backend/core/src/test/resources/expected/convert-encrypt.yaml @@ -31,6 +31,6 @@ PROPERTIES('minPoolSize'='1', 'connectionTimeoutMilliseconds'='30000', 'maxLifet CREATE ENCRYPT RULE t_encrypt ( COLUMNS( -(NAME=user_id, CIPHER=user_cipher, ASSISTED_QUERY_COLUMN=user_assisted, LIKE_QUERY_COLUMN=user_like, ENCRYPT_ALGORITHM(TYPE(NAME='aes', PROPERTIES('aes-key-value'='123456abc'))), ASSISTED_QUERY_ALGORITHM(TYPE(NAME='rc4', PROPERTIES('rc4-key-value'='123456abc'))), LIKE_QUERY_ALGORITHM(TYPE(NAME='char_digest_like'))), +(NAME=user_id, CIPHER=user_cipher, ASSISTED_QUERY_COLUMN=user_assisted, LIKE_QUERY_COLUMN=user_like, ENCRYPT_ALGORITHM(TYPE(NAME='aes', PROPERTIES('aes-key-value'='123456abc'))), ASSISTED_QUERY_ALGORITHM(TYPE(NAME='rc4', PROPERTIES('rc4-key-value'='123456abc')))), (NAME=order_id, CIPHER=order_cipher, ENCRYPT_ALGORITHM(TYPE(NAME='rc4', PROPERTIES('rc4-key-value'='123456abc')))) )); diff --git a/proxy/backend/core/src/test/resources/expected/convert-mix.yaml b/proxy/backend/core/src/test/resources/expected/convert-mix.yaml index 4d8fece6d3b8d..756109103129b 100644 --- a/proxy/backend/core/src/test/resources/expected/convert-mix.yaml +++ b/proxy/backend/core/src/test/resources/expected/convert-mix.yaml @@ -63,7 +63,7 @@ TYPE(NAME='random') CREATE ENCRYPT RULE t_encrypt ( COLUMNS( -(NAME=user_id, CIPHER=user_cipher, ASSISTED_QUERY_COLUMN=user_assisted, LIKE_QUERY_COLUMN=user_like, ENCRYPT_ALGORITHM(TYPE(NAME='aes', PROPERTIES('aes-key-value'='123456abc'))), ASSISTED_QUERY_ALGORITHM(TYPE(NAME='rc4', PROPERTIES('rc4-key-value'='123456abc'))), LIKE_QUERY_ALGORITHM(TYPE(NAME='char_digest_like'))), +(NAME=user_id, CIPHER=user_cipher, ASSISTED_QUERY_COLUMN=user_assisted, LIKE_QUERY_COLUMN=user_like, ENCRYPT_ALGORITHM(TYPE(NAME='aes', PROPERTIES('aes-key-value'='123456abc'))), ASSISTED_QUERY_ALGORITHM(TYPE(NAME='rc4', PROPERTIES('rc4-key-value'='123456abc')))), (NAME=order_id, CIPHER=order_cipher, ENCRYPT_ALGORITHM(TYPE(NAME='rc4', PROPERTIES('rc4-key-value'='123456abc')))) )); diff --git a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/like/CharDigestLikeEncryptAlgorithm.java b/test/e2e/fixture/src/test/java/org/apache/shardingsphere/test/e2e/fixture/ITEncryptLikeAlgorithmFixture.java similarity index 95% rename from features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/like/CharDigestLikeEncryptAlgorithm.java rename to test/e2e/fixture/src/test/java/org/apache/shardingsphere/test/e2e/fixture/ITEncryptLikeAlgorithmFixture.java index 4b64d85569554..42acf4f43ee4e 100644 --- a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/like/CharDigestLikeEncryptAlgorithm.java +++ b/test/e2e/fixture/src/test/java/org/apache/shardingsphere/test/e2e/fixture/ITEncryptLikeAlgorithmFixture.java @@ -15,10 +15,9 @@ * limitations under the License. */ -package org.apache.shardingsphere.encrypt.algorithm.like; +package org.apache.shardingsphere.test.e2e.fixture; import com.google.common.base.Strings; -import lombok.EqualsAndHashCode; import lombok.SneakyThrows; import org.apache.shardingsphere.encrypt.api.context.EncryptContext; import org.apache.shardingsphere.encrypt.api.encrypt.like.LikeEncryptAlgorithm; @@ -33,11 +32,7 @@ import java.util.stream.Collectors; import java.util.stream.IntStream; -/** - * Char digest like encrypt algorithm. - */ -@EqualsAndHashCode -public final class CharDigestLikeEncryptAlgorithm implements LikeEncryptAlgorithm { +public final class ITEncryptLikeAlgorithmFixture implements LikeEncryptAlgorithm { private static final String DELTA_KEY = "delta"; @@ -158,6 +153,6 @@ private char getMaskedChar(final char originalChar) { @Override public String getType() { - return "CHAR_DIGEST_LIKE"; + return "IT.ENCRYPT.LIKE.FIXTURE"; } } diff --git a/test/e2e/fixture/src/test/resources/META-INF/services/org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm b/test/e2e/fixture/src/test/resources/META-INF/services/org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm new file mode 100644 index 0000000000000..f6c7dada3ea88 --- /dev/null +++ b/test/e2e/fixture/src/test/resources/META-INF/services/org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm @@ -0,0 +1,18 @@ +# +# 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.e2e.fixture.ITEncryptLikeAlgorithmFixture diff --git a/features/encrypt/core/src/main/resources/algorithm/like/common_chinese_character.dict b/test/e2e/fixture/src/test/resources/algorithm/like/common_chinese_character.dict similarity index 100% rename from features/encrypt/core/src/main/resources/algorithm/like/common_chinese_character.dict rename to test/e2e/fixture/src/test/resources/algorithm/like/common_chinese_character.dict diff --git a/test/e2e/sql/src/test/resources/cases/rql/dataset/encrypt/show_encrypt_rule.xml b/test/e2e/sql/src/test/resources/cases/rql/dataset/encrypt/show_encrypt_rule.xml index b1b7460494b57..d94f7c2cc56dd 100644 --- a/test/e2e/sql/src/test/resources/cases/rql/dataset/encrypt/show_encrypt_rule.xml +++ b/test/e2e/sql/src/test/resources/cases/rql/dataset/encrypt/show_encrypt_rule.xml @@ -29,8 +29,8 @@ - + - + diff --git a/test/e2e/sql/src/test/resources/cases/rql/dataset/encrypt/show_encrypt_rules.xml b/test/e2e/sql/src/test/resources/cases/rql/dataset/encrypt/show_encrypt_rules.xml index 488e8d0e859ef..1bbed24a732b1 100644 --- a/test/e2e/sql/src/test/resources/cases/rql/dataset/encrypt/show_encrypt_rules.xml +++ b/test/e2e/sql/src/test/resources/cases/rql/dataset/encrypt/show_encrypt_rules.xml @@ -29,12 +29,12 @@ - + - + - - + + 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 1a6b944972f75..52e62adb6160e 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 @@ -39,7 +39,7 @@ rules: props: aes-key-value: 123456abc like_encryptor: - type: CHAR_DIGEST_LIKE + type: IT.ENCRYPT.LIKE.FIXTURE props: mask: 4093 tables: 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 89a633b9d4e9b..ed3a7d99c7c90 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 @@ -39,7 +39,7 @@ rules: props: aes-key-value: 123456abc like_encryptor: - type: CHAR_DIGEST_LIKE + type: IT.ENCRYPT.LIKE.FIXTURE props: mask: 4093 tables: 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 9cc2b3d538277..a5030de3a717f 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 @@ -39,7 +39,7 @@ rules: props: aes-key-value: 123456abc like_encryptor: - type: CHAR_DIGEST_LIKE + type: IT.ENCRYPT.LIKE.FIXTURE props: mask: 4093 tables: 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 69a2ac6a6d94c..a4c0b5294e469 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 @@ -26,7 +26,7 @@ rules: props: aes-key-value: 123456abc like_encryptor: - type: CHAR_DIGEST_LIKE + type: IT.ENCRYPT.LIKE.FIXTURE props: mask: 4093 tables: