Show better message for missing config keystore props (#232)

* Show better message for missing config keystore props

* Removes unused ExpectedException

Fixes #230
This commit is contained in:
Biju Kunjummen
2017-08-04 12:53:35 -07:00
committed by Spencer Gibb
parent 54d55010de
commit a6b7f70b8e
2 changed files with 35 additions and 10 deletions

View File

@@ -63,15 +63,20 @@ public class EncryptionBootstrapConfiguration {
@ConditionalOnMissingBean(TextEncryptor.class)
public TextEncryptor textEncryptor() {
KeyStore keyStore = this.key.getKeyStore();
if (keyStore.getLocation() != null && keyStore.getLocation().exists()) {
return new RsaSecretEncryptor(
new KeyStoreKeyFactory(keyStore.getLocation(),
keyStore.getPassword().toCharArray()).getKeyPair(
keyStore.getAlias(),
keyStore.getSecret().toCharArray()),
this.key.getRsa().getAlgorithm(), 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()),
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());
}