public class Utils extends Object
Constructor and Description |
---|
Utils() |
Modifier and Type | Method and Description |
---|---|
static String |
doEncryption(Cipher cipher,
String plainTextPwd)
encrypt the plain text password
|
static String |
getConfigFilePath(String fileName)
returns the configuration file
|
static String |
getDeploymentFilePath()
Get deployment toml file path
|
static Map<String,String> |
getSecreteFromConfiguration(String configFilePath)
Read toml file and return list of secrets
|
static DocumentBuilder |
getSecuredDocumentBuilder(boolean setIgnoreComments)
This method provides a secured document builder which will secure XXE attacks.
|
static String |
getUnEncryptedValue(String value)
Read unencrypted value from [secrets] section in deployment toml file
|
static String |
getValueFromConsole(String msg,
boolean isPassword)
Retrieve value from command-line
|
static String |
getValueFromXPath(Element element,
String xPath)
retrieve the value for the given xpath from the file
|
static boolean |
isPrimaryKeyStore()
Returns whether it's a primary or an internal keystore
|
static Properties |
loadProperties(String filePath)
read values from property file
|
static String |
resolveKeyStorePath(String keyStorePath,
String homeFolder)
Resolve absolute path of the keystore
|
static void |
setSystemProperties()
Set the system properties
|
static void |
writeToPropertyFile(Properties properties,
String filePath)
writees the properties into a file
|
static void |
writeToSecureConfPropertyFile()
Write to the Secret-conf.properties
|
public static String getValueFromConsole(String msg, boolean isPassword)
public static Properties loadProperties(String filePath)
filePath
- file pathpublic static String getConfigFilePath(String fileName)
fileName
- file namepublic static void writeToPropertyFile(Properties properties, String filePath)
properties
- propertiesfilePath
- filepathpublic static String getValueFromXPath(Element element, String xPath)
element
- elementxPath
- xpathpublic static void writeToSecureConfPropertyFile()
public static void setSystemProperties()
public static boolean isPrimaryKeyStore()
public static String resolveKeyStorePath(String keyStorePath, String homeFolder)
public static String getDeploymentFilePath()
public static String doEncryption(Cipher cipher, String plainTextPwd)
cipher
- init cipherplainTextPwd
- plain text passwordpublic static Map<String,String> getSecreteFromConfiguration(String configFilePath)
configFilePath
- file path to deployment tomlpublic static String getUnEncryptedValue(String value)
value
- key to readpublic static DocumentBuilder getSecuredDocumentBuilder(boolean setIgnoreComments) throws ParserConfigurationException
setIgnoreComments
- whether to set setIgnoringComments in DocumentBuilderFactory.ParserConfigurationException
Copyright © 2021 WSO2. All rights reserved.