|
|
|
@ -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()); |
|
|
|
|