@Override
public void executeImpl()
throws MojoExecutionException, MojoFailureException
{
NativeEncrypter encrypter = encrypterManager.findUsableEncrypter();
if (encrypter == null)
throw new MojoExecutionException("No native encrypters available for current platform.");
try
{
String password;
try
{
//For the secure non-echoing prompter, prompt twice and verify
password = securePrompter.promptForPassword("Password");
String passwordVerification = securePrompter.promptForPassword("Re-enter password");
if (password != null && !password.equals(passwordVerification))
throw new MojoFailureException("Entered passwords do not match.");
}
catch (PrompterException e)
{
//Don't need to prompt twice when password is echoed
getLog().warn("Secure password prompter not available, entered password will be echoed to console!");
password = fallbackPrompter.promptForPassword("Password");
}
//Prompt for password
if (password == null || password.isEmpty())
throw new MojoFailureException("No password entered");
String encryptedBase64String = encrypter.encrypt(password);
//Add our magic around the raw data
String fullString = "{[type=native]" + encryptedBase64String + "}";
//And display the result to the user