public class SecureVaultUtils extends Object
Modifier and Type | Method and Description |
---|---|
static byte[] |
base64Decode(byte[] base64Encoded) |
static byte[] |
base64Encode(byte[] original) |
static Optional<Path> |
getPathFromSystemVariable(String systemProperty,
String environmentProperty)
Returns the system property specified path.
|
static MasterKey |
getSecret(List<MasterKey> masterKeys,
String secretName) |
static Optional<SecureVaultConfiguration> |
getSecureVaultConfig(Path secureVaultConfigPath)
Initialize secure vault configuration provider.
|
static boolean |
isOSGIEnv()
Check whether the environment is OSGI or not.
|
static Properties |
loadSecretFile(Path secretsFilePath) |
static String |
readUpdatedValue(String alias) |
static String |
resolveFileToString(Path configFilePath)
This method reads the configurations content from the filepath.
|
static String |
substituteVariables(Matcher matcher,
Function<String,String> function)
This method replaces the placeholders with value provided by the given Function.
|
static String |
substituteVariables(String value)
This method replaces place holders in the given String with proper values.
|
static byte[] |
toBytes(String value) |
static char[] |
toChars(byte[] bytes) |
static void |
updateSecretFile(Path secretsFilePath,
Properties properties) |
public static Optional<SecureVaultConfiguration> getSecureVaultConfig(Path secureVaultConfigPath) throws SecureVaultException
secureVaultConfigPath
- Secure vault yaml configuration pathSecureVaultException
- when error occurs in secure vault configuration provider initialisationpublic static MasterKey getSecret(List<MasterKey> masterKeys, String secretName) throws SecureVaultException
SecureVaultException
public static byte[] base64Decode(byte[] base64Encoded)
public static byte[] base64Encode(byte[] original)
public static char[] toChars(byte[] bytes)
public static byte[] toBytes(String value)
public static Properties loadSecretFile(Path secretsFilePath) throws SecureVaultException
SecureVaultException
public static void updateSecretFile(Path secretsFilePath, Properties properties) throws SecureVaultException
SecureVaultException
public static String substituteVariables(String value) throws SecureVaultException
value
- a string that contains placeholders which is needed to get substitute with proper valuesSecureVaultException
- in case a valid value for a specified placeholder is not provided.public static String substituteVariables(Matcher matcher, Function<String,String> function) throws SecureVaultException
matcher
- a valid matcher for the given sub-string.function
- a function that resolves a given property key. (eg: from system variables
or environment properties)SecureVaultException
- in case a valid value for a specified placeholder is not provided.public static String resolveFileToString(Path configFilePath) throws SecureVaultException
configFilePath
- a valid fileSecureVaultException
- if an exception happens while reading the file.public static Optional<Path> getPathFromSystemVariable(String systemProperty, String environmentProperty)
public static boolean isOSGIEnv()
Copyright © 2017 WSO2. All rights reserved.