daily pastebin goal
15%
SHARE
TWEET

Untitled

a guest Jun 8th, 2017 100 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/env groovy
  2. // for logging: #!/usr/bin/env JAVA_OPTS=-Dgroovy.grape.report.downloads=true groovy
  3.  
  4. @Grab(group='commons-codec', module='commons-codec', version='1.10')
  5. @Grab(group='org.sonatype.plexus', module='plexus-cipher', version='1.7')
  6.  
  7. import java.nio.file.Paths
  8. import org.apache.commons.codec.binary.Base64
  9. import org.sonatype.plexus.components.cipher.DefaultPlexusCipher
  10.  
  11. String SYSTEM_PROPERTY_SEC_LOCATION = "settings.security";
  12. DefaultPlexusCipher cipher = new DefaultPlexusCipher();
  13. String masterPasswd = ""
  14.  
  15. File settingsSecurityFile = Paths.get( System.getProperty("user.home"), ".m2", "settings-security.xml").toFile()
  16. def rootNode = new XmlSlurper().parse( settingsSecurityFile )
  17. rootNode.children().findAll{ it.name() == 'master' }.each{ m ->
  18.     m.toString().find(/(?<=\{).*(?=\})/) { encodedText ->      
  19.         masterPasswd = cipher.decryptDecorated( encodedText, SYSTEM_PROPERTY_SEC_LOCATION )
  20.         println "master password: ${masterPasswd}"
  21.     }
  22. }
  23.  
  24. File settingsFile = Paths.get( System.getProperty("user.home"), ".m2", "settings.xml").toFile()
  25. rootNode = new XmlSlurper().parse( settingsFile )
  26. rootNode.servers.children().findAll{ it.name() == 'server' }.each{ m ->
  27.  
  28.  
  29.     String pw = cipher.isEncryptedString(m.password.text()) ?
  30.         cipher.decryptDecorated( m.password.text(), masterPasswd ) : m.password.text()
  31.     println "server id: ${m.id} username: ${m.username} password: ${pw}"   
  32. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top