Package org.glassfish.internal.api
Class RelativePathResolver
- java.lang.Object
-
- org.glassfish.internal.api.RelativePathResolver
-
public class RelativePathResolver extends Object
The purpose of this class is to expand paths that contain embedded system properties of the form ${property-name}. The result must be an absolute path, or messages are logged. Here are some examples: ${com.sun.aas.installRoot}/config/domain.xml /foo/${config}/domain.xml /foo/${config}/${domain-name} This class is used to map paths containing system properties in domain.xml and used so that absolute paths (which are installation directory specific) are not present, making domain.xml portable in an SE/EE environment across many machines (with different installation directories).
-
-
Constructor Summary
Constructors Constructor Description RelativePathResolver()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
fatalError(String message, String path)
You would like to think that we could just log and continue (without throwing a RuntimeException; however, unfortunately anything logged by the logger in the launcher (PELaucnhFilter) does not appear in server.log, so for now, this will be considered a fatal error.static String
getAlias(String propName)
check if a given property name matches AS alias pattern ${ALIAS=aliasname}.protected String
getPropertyValue(String propName, boolean bIncludingEnvironmentVariables)
Resolves the given property by returning its value as either 1) a system property of the form ${system-property-name} 2) a password alias property of the form ${ALIAS=aliasname}.static String
getRealPasswordFromAlias(String at)
Returns the actual password from the domain-wide safe password store, if the given password is aliased.boolean
isResolvable(String path, boolean bIncludingEnvironmentVariables)
checks if string does not consist of unresolvable valuesstatic void
main(String[] args)
String
resolve(String path)
String
resolve(String path, boolean bIncludingEnvironmentVariables)
Replace any system properties of the form ${property} in the given path.static String
resolvePath(String path)
String
unresolve(String path, String[] propNames)
unresolvePath will replace the first occurrence of the value of the given system properties with ${propName} in the given pathstatic String
unresolvePath(String path, String[] propNames)
-
-
-
Method Detail
-
unresolve
public String unresolve(String path, String[] propNames)
unresolvePath will replace the first occurrence of the value of the given system properties with ${propName} in the given path
-
fatalError
protected void fatalError(String message, String path)
You would like to think that we could just log and continue (without throwing a RuntimeException; however, unfortunately anything logged by the logger in the launcher (PELaucnhFilter) does not appear in server.log, so for now, this will be considered a fatal error.
-
getAlias
public static String getAlias(String propName)
check if a given property name matches AS alias pattern ${ALIAS=aliasname}. if so, return the aliasname, otherwise return null.- Parameters:
propName
- The property name to resolve. ex. ${ALIAS=aliasname}.- Returns:
- The aliasname or null.
-
getPropertyValue
protected String getPropertyValue(String propName, boolean bIncludingEnvironmentVariables)
Resolves the given property by returning its value as either 1) a system property of the form ${system-property-name} 2) a password alias property of the form ${ALIAS=aliasname}. Here the alias name is mapped to a password.- Parameters:
propName
- The property name to resolve- Returns:
- The resolved value of the property or null.
-
resolve
public String resolve(String path, boolean bIncludingEnvironmentVariables)
Replace any system properties of the form ${property} in the given path. Note any mismatched delimiters (e.g. ${property/${property2} is considered a fatal error and for now causes a fatal RuntimeException to be thrown.
-
isResolvable
public boolean isResolvable(String path, boolean bIncludingEnvironmentVariables)
checks if string does not consist of unresolvable values
-
main
public static void main(String[] args)
-
getRealPasswordFromAlias
public static String getRealPasswordFromAlias(String at) throws KeyStoreException, CertificateException, IOException, NoSuchAlgorithmException, UnrecoverableKeyException
Returns the actual password from the domain-wide safe password store, if the given password is aliased. An aliased String is of the form ${ALIAS=aliasname} where the actual password is stored in given alias name. Following are the returned values:- Returns a null if given String is null.
- Retuns the given String if it is not in the alias form.
- Returns the real password from store if the given String is of the alias form and the alias has been created by the administrator. If the alias is not defined in the store, an IllegalArgumentException is thrown with appropriate message.
- Parameters:
at
- is the aliased token of the form "${ALIAS=string}"- Returns:
- a String representing the actual password
- Throws:
IllegalArgumentException
- if the alias is not definedKeyStoreException
- CertificateException IOException NoSuchAlgorithmException UnrecoverableKeyException if there is an error is opening or processing the password storeCertificateException
IOException
NoSuchAlgorithmException
UnrecoverableKeyException
-
-