/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
* or packager/legal/LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
* file and include the License file at packager/legal/LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
* exception as provided by Oracle in the GPL Version 2 section of the License
* file that accompanied this code.
*
* Modifications:
* If applicable, add the following below the License Header, with the fields
* enclosed by brackets [] replaced by your own identifying information:
* "Portions Copyright [year] [name of copyright owner]"
*
* Contributor(s):
* If you wish your version of this file to be governed by only the CDDL or
* only the GPL Version 2, indicate your decision by adding "[Contributor]
* elects to include this software in this distribution under the [CDDL or GPL
* Version 2] license." If you don't indicate a single choice of license, a
* recipient has the option to distribute your version of this file under
* either the CDDL, the GPL Version 2 or to extend the choice of license to
* its licensees as provided above. However, if you add GPL Version 2 code
* and therefore, elected the GPL Version 2 license, then the option applies
* only if the new code is made subject to such option by the copyright
* holder.
*/
/**
* 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
* installation directories).
*/
public class RelativePathResolver {
static{
}
}
return _logger;
}
{
_instance = new RelativePathResolver();
}
return _instance;
}
{
}
{
}
public RelativePathResolver()
{
}
/**
* unresolvePath will replace the first occurrence of the value of the given
* system properties with ${propName} in the given path
**/
int startIdx;
//All paths returned will contain / as the separator. The
//assumption is that the File class can convert this to an OS
//dependent path separator (e.g. \\ on windows).
//All paths returned will contain / as the separator. This will allow
//all comparison to be done using / as the separator
if (startIdx >= 0) {
}
} else {
"enterprise_util.path_unresolver_missing_property",
}
}
}
return 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.
*/
getClass().getClassLoader());
}
{
} else {
}
}
/**
* check if a given property name matches AS alias pattern ${ALIAS=aliasname}.
* if so, return the aliasname, otherwise return null.
* @param propName The property name to resolve. ex. ${ALIAS=aliasname}.
* @return The aliasname or null.
*/
{
if (lastIdx > 1) {
}
}
return aliasName;
}
/**
* 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.
* @param propName The property name to resolve
* @return The resolved value of the property or null.
*/
{
return null;
// Try finding the property as a system property
//If not found as a system property, the see if it is a password alias.
if (idx1 >= 0) {
if (idx2 > 0) {
//System.err.println("aliasName " + aliasName);
try {
if (pwdAdapter==null) {
}
//System.err.println("alias password " + result);
ex);
}
}
}
}
return result;
}
}
/**
* 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.
*/
return path;
}
//Now parse through the given string one character at a time looking for the
//starting delimiter "${". Occurrences of "$" or "{" are valid characters;
//however once an occurrence of "${" is found, then "}" becomes a closing
//delimiter.
//keep track of whether we have found at least one occurrence of "${". The
//significance is that "}" is parsed as a terminating character.
boolean foundOne = false;
char c;
for (int i = 0; i < size; i++) {
switch(c) {
case '$': {
//found "${"
foundOne = true;
i++;
propName = new StringBuffer();
break;
} else { // previous property not terminated missing }
"enterprise_util.path_resolver_missing_closing_delim",
path);
return path; //can't happen since fatalError throws RuntimeException
}
} else {
}
break;
} case '}': {
if (foundOne) { // we have found at least one occurrence of ${
//Note: when elaborating a system property, we always convert \\ to / to ensure that
//paths created on windows are compatible with unix filesystems.
} else {
//NOTE: We cannot ensure that system properties will always
//be defined and so this is an expected case. Consider
//a property named ${http-listener-port}. This property
//may be defined at the server or config level and set only
//when that server instance starts up. The property may not
//be set in the DAS.
}
} else { //no matching starting delimiter found ${
"enterprise_util.path_resolver_missing_starting_delim",
path);
return path; //can't happen since fatalError throws RuntimeException
}
} else {
}
break;
} default : {
break;
}
}
}
"enterprise_util.path_resolver_missing_closing_delim",
path);
return path; //can't happen
}
}
/**
* checks if string does not consist of unresolvable values
*/
}
}
} else {
}
}
}
/** 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:
* <ul>
* <li> Returns a null if given String is null. </li>
* <li> Retuns the given String if it is not in the alias form. </li>
* <li> 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. </li>
* </ul>
* @param at is the aliased token of the form "${ALIAS=string}"
* @return a String representing the actual password
* @throws IllegalArgumentException if the alias is not defined
* @throws KeyStoreException CertificateException IOException NoSuchAlgorithmException
* UnrecoverableKeyException if there is an error is opening or
* processing the password store
*/
try {
return ( at );
}
} catch (final Exception e) { //underlying code is unsafe!
return (at);
}
final PasswordAdapter pa = masterPasswordHelper.getMasterPasswordAdapter(); // use default password store
if (!exists) {
throw new IllegalArgumentException(msg);
}
return ( real );
}
}