Merge remote-tracking branch 'origin/master' into 2.0.x

This commit is contained in:
Ryan Baxter
2017-08-22 14:10:29 -04:00
15 changed files with 50 additions and 26 deletions

View File

@@ -63,16 +63,20 @@ public class EncryptionBootstrapConfiguration {
@ConditionalOnMissingBean(TextEncryptor.class)
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()),
algorithm, this.key.getRsa().getSalt(),
this.key.getRsa().isStrong());
if (keyStore.getLocation() != null) {
if (keyStore.getLocation().exists()) {
return new RsaSecretEncryptor(
new KeyStoreKeyFactory(keyStore.getLocation(),
keyStore.getPassword().toCharArray()).getKeyPair(
keyStore.getAlias(),
keyStore.getSecret().toCharArray()),
RsaAlgorithm.valueOf(this.key.getRsa().getAlgorithm()), this.key.getRsa().getSalt(),
this.key.getRsa().isStrong());
}
throw new IllegalStateException("Invalid keystore location");
}
return new EncryptorFactory().create(this.key.getKey());
}