shardingsphere: AESEncryptAlgorithm can Not use Properties to get the right AES_KEY Value
Bug Report
For English only, other languages will not accept.
Before report a bug, make sure you have:
- Searched open and closed GitHub issues.
- Read documentation: ShardingSphere Doc.
Please pay attention on issues you submitted, because we maybe need more details. If no response anymore and we cannot reproduce it on current information, we will close it.
Please answer these questions before submitting your issue. Thanks!
Which version of ShardingSphere did you use?
shardingsphere-encrypt-core Module
—exception code----
private byte[] createSecretKey() { Preconditions.checkArgument(props.containsKey(AES_KEY), String.format(“%s can not be null.”, AES_KEY)); return Arrays.copyOf(DigestUtils.sha1(props.getProperty(AES_KEY)), 16); }
—settings----
spring.shardingsphere.rules.encrypt.encryptors.name_encryptor.type=AES spring.shardingsphere.rules.encrypt.encryptors.name_encryptor.props.aes-key-value=123456 #spring.shardingsphere.encrypt.encryptors.pwd_encryptor.type=md5
spring.shardingsphere.rules.encrypt.tables.encrypt_user.columns.user_name.plain-column=user_name_plain spring.shardingsphere.rules.encrypt.tables.encrypt_user.columns.user_name.cipher-column=user_name spring.shardingsphere.rules.encrypt.tables.encrypt_user.columns.user_name.encryptor-name=name_encryptor #spring.shardingsphere.encrypt.tables.encrypt_user.columns.pwd.cipherColumn=pwd #spring.shardingsphere.encrypt.tables.encrypt_user.columns.pwd.encryptor=pwd_encryptor
Expected behavior
Preconditions.checkArgument(props.containsKey(AES_KEY), String.format(“%s can not be null.”, AES_KEY)); this step will pass and return the true
Actual behavior
Preconditions.checkArgument(props.containsKey(AES_KEY), String.format(“%s can not be null.”, AES_KEY)); this step props is empty and return the false
Reason analyze (If you can)
in version 4.0.0
public abstract class TypeBasedSPIServiceLoader<T extends TypeBasedSPI> { private final Class<T> classType;
public final T newService(String type, Properties props) {
Collection<T> typeBasedServices = this.loadTypeBasedServices(type);
if (typeBasedServices.isEmpty()) {
throw new RuntimeException(String.format("Invalid `%s` SPI type `%s`.", this.classType.getName(), type));
} else {
T result = (TypeBasedSPI)typeBasedServices.iterator().next();
result.setProperties(props); //renew the Properties
return result;
}
}
}
but where is setProperties step in 5.0.0 ?
Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.
insert into sql
Example codes for reproduce this issue (such as a github link).
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 19 (11 by maintainers)
@RaigorJiang, i tried it , it works well,thank you very much