Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor EncryptAlgorithmMetaData #30174

Merged
merged 1 commit into from
Feb 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ public final class TestQueryAssistedShardingEncryptAlgorithm implements EncryptA
@Override
public void init(final Properties props) {
this.properties = props;
EncryptAlgorithmMetaData algorithmMetaData = new EncryptAlgorithmMetaData();
algorithmMetaData.setSupportDecrypt(false);
EncryptAlgorithmMetaData algorithmMetaData = new EncryptAlgorithmMetaData(false, true, false);
metaData = algorithmMetaData;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,18 @@
package org.apache.shardingsphere.encrypt.spi;

import lombok.Getter;
import lombok.Setter;
import lombok.RequiredArgsConstructor;

/**
* Encrypt algorithm meta data.
*/
@RequiredArgsConstructor
@Getter
public final class EncryptAlgorithmMetaData {

@Setter
private boolean supportDecrypt = true;
private final boolean supportDecrypt;

@Setter
private boolean supportEquivalentFilter = true;
private final boolean supportEquivalentFilter;

@Setter
private boolean supportLike;
private final boolean supportLike;
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ public final class MD5AssistedEncryptAlgorithm implements EncryptAlgorithm {
@Override
public void init(final Properties props) {
this.salt = props.getProperty(SALT_KEY, "");
EncryptAlgorithmMetaData encryptAlgorithmMetaData = new EncryptAlgorithmMetaData();
encryptAlgorithmMetaData.setSupportDecrypt(false);
metaData = encryptAlgorithmMetaData;
metaData = new EncryptAlgorithmMetaData(false, true, false);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public final class AESEncryptAlgorithm implements EncryptAlgorithm {

@Override
public void init(final Properties props) {
metaData = new EncryptAlgorithmMetaData();
metaData = new EncryptAlgorithmMetaData(true, true, false);
secretKey = createSecretKey(props);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
@Getter
public final class CoreEncryptAlgorithmFixture implements EncryptAlgorithm {

private final EncryptAlgorithmMetaData metaData = new EncryptAlgorithmMetaData();
private final EncryptAlgorithmMetaData metaData = new EncryptAlgorithmMetaData(true, true, false);

@Override
public String encrypt(final Object plainValue, final EncryptContext encryptContext) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ public final class CoreQueryAssistedEncryptAlgorithmFixture implements EncryptAl

@Override
public void init(final Properties props) {
EncryptAlgorithmMetaData encryptAlgorithmMetaData = new EncryptAlgorithmMetaData();
encryptAlgorithmMetaData.setSupportDecrypt(false);
metaData = encryptAlgorithmMetaData;
metaData = new EncryptAlgorithmMetaData(false, true, false);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,7 @@ public final class CoreQueryLikeEncryptAlgorithmFixture implements EncryptAlgori

@Override
public void init(final Properties props) {
EncryptAlgorithmMetaData encryptAlgorithmMetaData = new EncryptAlgorithmMetaData();
encryptAlgorithmMetaData.setSupportLike(true);
encryptAlgorithmMetaData.setSupportDecrypt(false);
encryptAlgorithmMetaData.setSupportEquivalentFilter(false);
metaData = encryptAlgorithmMetaData;
metaData = new EncryptAlgorithmMetaData(false, false, true);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
@Getter
public final class DistSQLEncryptAlgorithmFixture implements EncryptAlgorithm {

private final EncryptAlgorithmMetaData metaData = new EncryptAlgorithmMetaData();
private final EncryptAlgorithmMetaData metaData = new EncryptAlgorithmMetaData(true, true, false);

@Override
public String encrypt(final Object plainValue, final EncryptContext encryptContext) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
@Getter
public final class JDBCEncryptAlgorithmFixture implements EncryptAlgorithm {

private final EncryptAlgorithmMetaData metaData = new EncryptAlgorithmMetaData();
private final EncryptAlgorithmMetaData metaData = new EncryptAlgorithmMetaData(true, true, false);

@Override
public String encrypt(final Object plainValue, final EncryptContext encryptContext) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ public final class JDBCQueryAssistedEncryptAlgorithmFixture implements EncryptAl

@Override
public void init(final Properties props) {
EncryptAlgorithmMetaData encryptAlgorithmMetaData = new EncryptAlgorithmMetaData();
encryptAlgorithmMetaData.setSupportDecrypt(false);
metaData = encryptAlgorithmMetaData;
metaData = new EncryptAlgorithmMetaData(false, true, false);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,7 @@ public void init(final Properties props) {
mask = createMask(props);
start = createStart(props);
charIndexes = createCharIndexes(props);
EncryptAlgorithmMetaData encryptAlgorithmMetaData = new EncryptAlgorithmMetaData();
encryptAlgorithmMetaData.setSupportLike(true);
encryptAlgorithmMetaData.setSupportDecrypt(false);
metaData = encryptAlgorithmMetaData;
metaData = new EncryptAlgorithmMetaData(false, true, true);
}

private int createDelta(final Properties props) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
@Getter
public final class RewriteNormalEncryptAlgorithmFixture implements EncryptAlgorithm {

private final EncryptAlgorithmMetaData metaData = new EncryptAlgorithmMetaData();
private final EncryptAlgorithmMetaData metaData = new EncryptAlgorithmMetaData(true, true, false);

@Override
public String encrypt(final Object plainValue, final EncryptContext encryptContext) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ public final class RewriteQueryAssistedEncryptAlgorithmFixture implements Encryp

@Override
public void init(final Properties props) {
EncryptAlgorithmMetaData encryptAlgorithmMetaData = new EncryptAlgorithmMetaData();
encryptAlgorithmMetaData.setSupportDecrypt(false);
metaData = encryptAlgorithmMetaData;
metaData = new EncryptAlgorithmMetaData(false, true, false);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,7 @@ public final class RewriteQueryLikeEncryptAlgorithmFixture implements EncryptAlg

@Override
public void init(final Properties props) {
EncryptAlgorithmMetaData encryptAlgorithmMetaData = new EncryptAlgorithmMetaData();
encryptAlgorithmMetaData.setSupportLike(true);
encryptAlgorithmMetaData.setSupportDecrypt(false);
metaData = encryptAlgorithmMetaData;
metaData = new EncryptAlgorithmMetaData(false, true, true);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ public final class TestQueryAssistedShardingEncryptAlgorithm implements EncryptA
@Override
public void init(final Properties props) {
this.properties = props;
EncryptAlgorithmMetaData encryptAlgorithmMetaData = new EncryptAlgorithmMetaData();
encryptAlgorithmMetaData.setSupportDecrypt(false);
metaData = encryptAlgorithmMetaData;
metaData = new EncryptAlgorithmMetaData(false, true, false);
}

@Override
Expand Down
Loading