Browse Source

Change type to String

pull/227/head
Spencer Gibb 8 years ago
parent
commit
6abf2def40
No known key found for this signature in database
GPG Key ID: 7788A47380690861
  1. 4
      spring-cloud-context/src/main/java/org/springframework/cloud/bootstrap/encrypt/EncryptionBootstrapConfiguration.java
  2. 8
      spring-cloud-context/src/main/java/org/springframework/cloud/bootstrap/encrypt/KeyProperties.java

4
spring-cloud-context/src/main/java/org/springframework/cloud/bootstrap/encrypt/EncryptionBootstrapConfiguration.java

@ -32,6 +32,7 @@ import org.springframework.core.env.Environment; @@ -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 { @@ -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());

8
spring-cloud-context/src/main/java/org/springframework/cloud/bootstrap/encrypt/KeyProperties.java

@ -17,7 +17,6 @@ package org.springframework.cloud.bootstrap.encrypt; @@ -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 { @@ -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 { @@ -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;
}

Loading…
Cancel
Save