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 Path |
getDefaultJSONFilePath()
Get default.json file path.
|
static String |
getDeploymentFilePath()
Get deployment toml file path
|
static Map<String,Object> |
getJSONConfiguration(Path jsonFilePath)
Read from default.json file and return a map of data.
|
static Map<String,String> |
getKeystoreFromConfiguration(String configFilePath,
String keystoreName)
Read toml file and return a map of keystore data.
|
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 |
getValueFromConfigs(String config,
String key,
Map<String,Object> defaultMap,
Element element,
String xPath)
Retrieve the value for the given configuration from the following order of files.
|
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,
Map<String,Object> defaultMap)
Resolve 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 getValueFromConfigs(String config, String key, Map<String,Object> defaultMap, Element element, String xPath)
config - Configuration value.key - Key of the configuration value in default.json.defaultMap - Map that contains values from default.json.element - Element.xPath - Xpath.public 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, Map<String,Object> defaultMap)
keyStorePath - path of the keystorehomeFolder - path of the IS_HOMEdefaultMap - map that contains values from default.jsonpublic static String getDeploymentFilePath()
public static Path getDefaultJSONFilePath()
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 Map<String,String> getKeystoreFromConfiguration(String configFilePath, String keystoreName)
configFilePath - File path to deployment toml.keystoreName - Name of the keystore.public static Map<String,Object> getJSONConfiguration(Path jsonFilePath)
public static String getUnEncryptedValue(String value)
value - key to readpublic static DocumentBuilder getSecuredDocumentBuilder(boolean setIgnoreComments) throws ParserConfigurationException
setIgnoreComments - whether to set setIgnoringComments in DocumentBuilderFactory.ParserConfigurationExceptionCopyright © 2023 WSO2. All rights reserved.