Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env groovy
- // for logging: #!/usr/bin/env JAVA_OPTS=-Dgroovy.grape.report.downloads=true groovy
- @Grab(group='commons-codec', module='commons-codec', version='1.10')
- @Grab(group='org.sonatype.plexus', module='plexus-cipher', version='1.7')
- import java.nio.file.Paths
- import org.apache.commons.codec.binary.Base64
- import org.sonatype.plexus.components.cipher.DefaultPlexusCipher
- String SYSTEM_PROPERTY_SEC_LOCATION = "settings.security";
- DefaultPlexusCipher cipher = new DefaultPlexusCipher();
- String masterPasswd = ""
- File settingsSecurityFile = Paths.get( System.getProperty("user.home"), ".m2", "settings-security.xml").toFile()
- def rootNode = new XmlSlurper().parse( settingsSecurityFile )
- rootNode.children().findAll{ it.name() == 'master' }.each{ m ->
- m.toString().find(/(?<=\{).*(?=\})/) { encodedText ->
- masterPasswd = cipher.decryptDecorated( encodedText, SYSTEM_PROPERTY_SEC_LOCATION )
- println "master password: ${masterPasswd}"
- }
- }
- File settingsFile = Paths.get( System.getProperty("user.home"), ".m2", "settings.xml").toFile()
- rootNode = new XmlSlurper().parse( settingsFile )
- rootNode.servers.children().findAll{ it.name() == 'server' }.each{ m ->
- String pw = cipher.isEncryptedString(m.password.text()) ?
- cipher.decryptDecorated( m.password.text(), masterPasswd ) : m.password.text()
- println "server id: ${m.id} username: ${m.username} password: ${pw}"
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement