Change type to String
This commit is contained in:
@@ -32,6 +32,7 @@ import org.springframework.core.env.Environment;
|
||||
import org.springframework.core.type.AnnotatedTypeMetadata;
|
||||
import org.springframework.security.crypto.encrypt.TextEncryptor;
|
||||
import org.springframework.security.rsa.crypto.KeyStoreKeyFactory;
|
||||
import org.springframework.security.rsa.crypto.RsaAlgorithm;
|
||||
import org.springframework.security.rsa.crypto.RsaSecretEncryptor;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@@ -63,12 +64,13 @@ public class EncryptionBootstrapConfiguration {
|
||||
public TextEncryptor textEncryptor() {
|
||||
KeyStore keyStore = this.key.getKeyStore();
|
||||
if (keyStore.getLocation() != null && keyStore.getLocation().exists()) {
|
||||
RsaAlgorithm algorithm = RsaAlgorithm.valueOf(this.key.getRsa().getAlgorithm().toUpperCase());
|
||||
return new RsaSecretEncryptor(
|
||||
new KeyStoreKeyFactory(keyStore.getLocation(),
|
||||
keyStore.getPassword().toCharArray()).getKeyPair(
|
||||
keyStore.getAlias(),
|
||||
keyStore.getSecret().toCharArray()),
|
||||
this.key.getRsa().getAlgorithm(), this.key.getRsa().getSalt(),
|
||||
algorithm, this.key.getRsa().getSalt(),
|
||||
this.key.getRsa().isStrong());
|
||||
}
|
||||
return new EncryptorFactory().create(this.key.getKey());
|
||||
|
||||
@@ -17,7 +17,6 @@ package org.springframework.cloud.bootstrap.encrypt;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.security.rsa.crypto.RsaAlgorithm;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
@ConfigurationProperties("encrypt")
|
||||
@@ -141,7 +140,8 @@ public class KeyProperties {
|
||||
* The RSA algorithm to use (DEFAULT or OEAP). Once it is set do not change it (or
|
||||
* existing ciphers will not a decryptable).
|
||||
*/
|
||||
private RsaAlgorithm algorithm = RsaAlgorithm.DEFAULT;
|
||||
//TODO: move from String to RsaAlgorithm
|
||||
private String algorithm = "DEFAULT";
|
||||
|
||||
/**
|
||||
* Flag to indicate that "strong" AES encryption should be used internally. If
|
||||
@@ -157,11 +157,11 @@ public class KeyProperties {
|
||||
*/
|
||||
private String salt = "deadbeef";
|
||||
|
||||
public RsaAlgorithm getAlgorithm() {
|
||||
public String getAlgorithm() {
|
||||
return this.algorithm;
|
||||
}
|
||||
|
||||
public void setAlgorithm(RsaAlgorithm algorithm) {
|
||||
public void setAlgorithm(String algorithm) {
|
||||
this.algorithm = algorithm;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user