Created
May 19, 2021 15:35
-
-
Save dansomething/6fb60165fa61d7e0eaaf9c02a6970a4a to your computer and use it in GitHub Desktop.
Decrypt Maven settings from Groovy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Grapes([ | |
@Grab(group='org.sonatype.plexus', module='plexus-sec-dispatcher', version='1.4'), | |
@Grab(group='org.codehaus.plexus', module='plexus-utils', version='1.5.15'), | |
@Grab(group='org.eclipse.sisu', module='org.eclipse.sisu.plexus', version='0.3.4'), | |
]) | |
import org.sonatype.plexus.components.cipher.DefaultPlexusCipher | |
import org.sonatype.plexus.components.sec.dispatcher.DefaultSecDispatcher | |
def decryptSetting(String encrypted, String encryptedMaster) { | |
return decrypt(encrypted, decryptMaster(encryptedMaster)) | |
} | |
def decrypt(String encrypted, String key) { | |
DefaultPlexusCipher cipher = new DefaultPlexusCipher() | |
return cipher.decryptDecorated(encrypted, key) | |
} | |
def decryptMaster(String encryptedMaster) { | |
return decrypt(encryptedMaster, DefaultSecDispatcher.SYSTEM_PROPERTY_SEC_LOCATION) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment