From 6abf2def40ee5088ac160b43aa4ceeee5bc3df4b Mon Sep 17 00:00:00 2001 From: Spencer Gibb Date: Fri, 28 Apr 2017 18:57:43 -0600 Subject: [PATCH] Change type to String --- .../encrypt/EncryptionBootstrapConfiguration.java | 4 +++- .../cloud/bootstrap/encrypt/KeyProperties.java | 8 ++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/spring-cloud-context/src/main/java/org/springframework/cloud/bootstrap/encrypt/EncryptionBootstrapConfiguration.java b/spring-cloud-context/src/main/java/org/springframework/cloud/bootstrap/encrypt/EncryptionBootstrapConfiguration.java index 5996f263..2eded32b 100644 --- a/spring-cloud-context/src/main/java/org/springframework/cloud/bootstrap/encrypt/EncryptionBootstrapConfiguration.java +++ b/spring-cloud-context/src/main/java/org/springframework/cloud/bootstrap/encrypt/EncryptionBootstrapConfiguration.java @@ -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()); diff --git a/spring-cloud-context/src/main/java/org/springframework/cloud/bootstrap/encrypt/KeyProperties.java b/spring-cloud-context/src/main/java/org/springframework/cloud/bootstrap/encrypt/KeyProperties.java index df2e5fcc..7fdfd93a 100644 --- a/spring-cloud-context/src/main/java/org/springframework/cloud/bootstrap/encrypt/KeyProperties.java +++ b/spring-cloud-context/src/main/java/org/springframework/cloud/bootstrap/encrypt/KeyProperties.java @@ -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; }