I\'m trying to understand Maven 3\'s[password encryption feature. I have found that this feature is poorly documented and confusing. For example, the feature documentation and a
Here is example code which shows how to decrypt the maven master password from
~/.m2/security-settings.xml
and also the server passwords from
~/.m2/settings.xml
Source of MavenPasswordDecryptor.java
import org.sonatype.plexus.components.cipher.DefaultPlexusCipher;
public class MavenPasswordDecryptor {
public static void main(String[] args) throws Exception {
if (args.length < 1 || args.length > 2 ) {
System.out.println("Usage: java -jar maven-password-decryptor.jar ");
System.out.println("Usage: java -jar maven-password-decryptor.jar ");
return;
}
DefaultPlexusCipher cipher = new DefaultPlexusCipher();
String encryptedPassword = args[0];
String passPhrase = (args.length == 2 && args[1] != null && !args[1].isEmpty()) ? args[1] : "settings.security";
String result = cipher.decryptDecorated(encryptedPassword, passPhrase);
System.out.println(result);
}
}
There is also an example project on GitHub:
https://github.com/uweguenther/maven-password-decryptor