use of org.sonatype.plexus.components.cipher.DefaultPlexusCipher in project flyway by flyway.
the class AbstractFlywayMojo method loadCredentialsFromSettings.
/**
* Load username password from settings
*
* @throws FlywayException when the credentials could not be loaded.
*/
private void loadCredentialsFromSettings() throws FlywayException {
final Server server = settings.getServer(serverId);
if (user == null) {
if (server != null) {
user = server.getUsername();
try {
SecDispatcher secDispatcher = new DefaultSecDispatcher() {
{
_cipher = new DefaultPlexusCipher();
}
};
password = secDispatcher.decrypt(server.getPassword());
} catch (SecDispatcherException e) {
throw new FlywayException("Unable to decrypt password", e);
} catch (PlexusCipherException e) {
throw new FlywayException("Unable to initialize password decryption", e);
}
}
} else if (server != null) {
throw new FlywayException("You specified credentials both in the Flyway config and settings.xml. Use either one or the other");
}
}
Aggregations