Pull request #569: RED-5563 - SMTP migration
Merge in RED/persistence-service from RED-5563 to master * commit 'ff3fb03f2936e85a50b00431a57390864e440232': RED-5563 - SMTP migration
This commit is contained in:
commit
5c5c3f9cc3
@ -40,16 +40,22 @@ public class SMTPConfigurationService {
|
||||
|
||||
@Transactional
|
||||
public void encryptPasswordIfNecessary() {
|
||||
var smtpConfiguration = getConfiguration();
|
||||
try {
|
||||
// this makes the migration idempotent, since an exception will be thrown if the password can't be decrypted
|
||||
// this prevents double encryption if the migration runs more than once
|
||||
var smtpConfigurationOptional = smtpRepository.findById(SMTPConfigurationEntity.ID);
|
||||
|
||||
encryptionDecryptionService.decrypt(smtpConfiguration.getPassword());
|
||||
log.info("SMTP Password for id {} is already encrypted", smtpConfiguration.getId());
|
||||
} catch (Exception e) {
|
||||
log.info("Encrypting SMTP Password for id {}", smtpConfiguration.getId());
|
||||
smtpConfiguration.setPassword(encryptionDecryptionService.encrypt(smtpConfiguration.getPassword()));
|
||||
if(smtpConfigurationOptional.isPresent()) {
|
||||
var smtpConfiguration = smtpConfigurationOptional.get();
|
||||
try {
|
||||
// this makes the migration idempotent, since an exception will be thrown if the password can't be decrypted
|
||||
// this prevents double encryption if the migration runs more than once
|
||||
|
||||
encryptionDecryptionService.decrypt(smtpConfiguration.getPassword());
|
||||
log.info("SMTP Password for id {} is already encrypted", smtpConfiguration.getId());
|
||||
} catch (Exception e) {
|
||||
log.info("Encrypting SMTP Password for id {}", smtpConfiguration.getId());
|
||||
smtpConfiguration.setPassword(encryptionDecryptionService.encrypt(smtpConfiguration.getPassword()));
|
||||
}
|
||||
}else{
|
||||
log.info("NO SMPT Configuration present for migration!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user