Class CredentialUtil
- java.lang.Object
-
- org.technologybrewery.orphedomos.util.credential.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 Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidcreateFileAndGivePermissions(File newFile)Creates a new file at the targeted file location and gives full file permissions to the current user.static StringdecryptServerPassword(org.apache.maven.settings.Settings settings, String serverId)Simple utility method to decrypt a stored password for a server.static StringfindPlaintextPasswordForServer(org.apache.maven.settings.Settings settings, String serverId)Find the plain-text server password, without decryption steps, extracted from Maven's user settings.static StringfindUsernameForServer(org.apache.maven.settings.Settings settings, String serverId)Find the username for a given server in Maven's user settings.static voidgiveFullFilePermissions(String filePath)Gives full read, write, and execute permissions to a file.static voidrunBashScript(String bashScriptPath)Run the bash script found at the given location without parameters.static voidrunBashScript(String bashScriptPath, String[] parameters, boolean debug)Run the bash script found at the given location with the provided parameters.static voidwriteLinesToFile(String commands, String filePath)Writes a given list of lines to the file located at the provided file path.
-
-
-
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 scriptparameters- script parametersdebug- 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 linesfilePath- 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
-
-