Class CredentialUtil


  • public final class CredentialUtil
    extends Object
    Contains utility functionality for Habushu, including bash script execution and accessing username/password credentials that may be defined within the relevant settings.xml configuration.
    • Method Detail

      • findUsernameForServer

        public static String findUsernameForServer​(org.apache.maven.settings.Settings settings,
                                                   String serverId)
        Find the username for a given server in Maven's user settings.
        Returns:
        the username for the server specified in Maven's settings.xml
      • findPlaintextPasswordForServer

        public static String findPlaintextPasswordForServer​(org.apache.maven.settings.Settings settings,
                                                            String serverId)
        Find the plain-text server password, without decryption steps, extracted from Maven's user settings.
        Returns:
        the password for the specified server from Maven's settings.xml
      • decryptServerPassword

        public static String decryptServerPassword​(org.apache.maven.settings.Settings settings,
                                                   String serverId)
        Simple utility method to decrypt a stored password for a server.
        Parameters:
        serverId - the id of the server to decrypt the password for
      • runBashScript

        public static void runBashScript​(String bashScriptPath)
        Run the bash script found at the given location without parameters.
        Parameters:
        bashScriptPath - absolute path to the bash script
      • runBashScript

        public static void runBashScript​(String bashScriptPath,
                                         String[] parameters,
                                         boolean debug)
        Run the bash script found at the given location with the provided parameters.
        Parameters:
        bashScriptPath - absolute path to the bash script
        parameters - script parameters
        debug - true to log script output as DEBUG, otherwise logged as INFO
      • writeLinesToFile

        public static void writeLinesToFile​(String commands,
                                            String filePath)
        Writes a given list of lines to the file located at the provided file path.
        Parameters:
        commands - the newline-delineated list of String file lines
        filePath - the path to the file
      • createFileAndGivePermissions

        public static void createFileAndGivePermissions​(File newFile)
        Creates a new file at the targeted file location and gives full file permissions to the current user.
        Parameters:
        newFile - the file location
      • giveFullFilePermissions

        public static void giveFullFilePermissions​(String filePath)
        Gives full read, write, and execute permissions to a file.
        Parameters:
        filePath - the path to the file