/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2005 Sun Microsystems Inc. All Rights Reserved
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the License). You may not use this file except in
* compliance with the License.
*
* You can obtain a copy of the License at
* See the License for the specific language governing
* permission and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* Header Notice in each file and include the License file
* at opensso/legal/CDDLv1.0.txt.
* If applicable, add the following below the CDDL Header,
* with the fields enclosed by brackets [] replaced by
* your own identifying information:
* "Portions Copyrighted [year] [name of copyright owner]"
*
* Portions Copyrighted 2010-2016 ForgeRock AS.
*/
/**
* This class provides functionality that allows single-point-of-access to all
* related system properties.
* <p>
* The system properties can be set in couple of ways: programmatically by
* calling the <code>initializeProperties</code> method, or can be statically
* loaded at startup from a file named:
* <code>AMConfig.[class,properties]</code>.
* Setting the properties through the API takes precedence and will replace the
* properties loaded via file. For statically loading the properties via a file,
* this class tries to first find a class, <code>AMConfig.class</code>, and
* then a file, <code>AMConfig.properties</code> in the CLASSPATH accessible
* to this code. The <code>AMConfig.class</code> takes precedence over the
* flat file <code>AMConfig.properties</code>.
* <p>
* If multiple servers are running, each may have their own configuration file.
* The naming convention for such scenarios is
* <code>AMConfig-<serverName></code>.
* @supported.all.api
*/
public class SystemProperties {
/**
* Runtime flag to be set, in order to override the path of the
* configuration file.
*/
/**
* Default name of the configuration file.
*/
/**
* New configuration file extension
*/
/** Regular expression pattern for a sequence of 1 or more white space characters. */
/**
* Maps from tags to the system properties that they should be replaced with. System property values containing
* these tags will be replaced with the actual values of these properties by {@link #get(String)}.
*/
private static final Map<String, String> TAG_SWAP_PROPERTIES = ImmutableMap.<String, String>builder()
.build();
private static final boolean SITEMONITOR_DISABLED;
/**
* Reference to the current properties map and tagswap values.
*/
new AtomicReference<>(new PropertiesHolder());
/*
* Initialization to load the properties file for config information before
* anything else starts.
*/
static {
try {
// Load properties from file
if (serverName != null) {
} else {
fname = configName;
}
// Get the location of the new configuration file in case
// of single war deployment
try {
.toLowerCase();
try {
} catch (IOException ioe) {
try {
} catch (IOException ioe2) {
}
}
}
}
} catch (MissingResourceException e) {
// Can't print the message to debug due to dependency
// Save it as a String and provide when requested.
}
}
private static PropertiesHolder loadProperties(PropertiesHolder props, String file) throws IOException {
}
}
/**
* Helper function to handle associated exceptions during initialization of
* properties using external properties file in a single war deployment.
*/
// Save it as a String and provide when requested.
}
/**
* This method lets you query for a system property whose value is same as
* <code>String</code> key. The method first tries to read the property
* from java.lang.System followed by a lookup in the config file.
*
* @param key
* type <code>String</code>, the key whose value one is
* looking for.
* @return the value if the key exists; otherwise returns <code>null</code>
*/
// look up values in SMS services only if in server mode.
if (isServerMode() || SITEMONITOR_DISABLED) {
}
}
if (k.equals("%SERVER_URI%")) {
} else {
}
}
} else {
}
}
}
}
}
return answer;
}
}
}
return answer;
}
/**
* This method lets you query for a system property whose value is same as
* <code>String</code> key.
*
* @param key the key whose value one is looking for.
* @param def the default value if the key does not exist.
* @return the value if the key exists; otherwise returns default value.
*/
}
/**
* Returns the property value as a boolean
*
* @param key the key whose value one is looking for.
* @return the boolean value if the key exists; otherwise returns false
*/
}
/**
* Returns the property value as a boolean
*
* @param key the property name.
* @param defaultValue value if key is not found.
* @return the boolean value if the key exists; otherwise the default value
*/
return defaultValue;
}
}
/**
* @param key The System Property key to lookup.
* @param defaultValue If the property was not set, or could not be parsed to an int.
* @return Either the defaultValue, or the numeric value assigned to the System Property.
*/
return defaultValue;
}
try {
} catch (NumberFormatException e) {
return defaultValue;
}
}
/**
* @param key The System Property key to lookup.
* @param defaultValue If the property was not set, or could not be parsed to a long.
* @return Either the defaultValue, or the numeric value assigned to the System Property.
*/
return defaultValue;
}
try {
} catch (NumberFormatException e) {
return defaultValue;
}
}
/**
* Parses a system property as a set of strings by splitting the value on the given delimiter expression.
*
* @param key The System Property key to lookup.
* @param delimiterRegex The regular expression to use to split the value into elements in the set.
* @param defaultValue The default set to return if the property does not exist.
* @return the value of the property parsed as a set of strings.
*/
return defaultValue;
}
}
/**
* Parses a system property as a set of strings by splitting the value on the given delimiter expression.
*
* @param key The System Property key to lookup.
* @param delimiterRegex The regular expression to use to split the value into elements in the set.
* @return the value of the property parsed as a set of strings or an empty set if no match is found.
*/
}
/**
* Parses a system property as a set of strings by splitting the value on white space characters.
*
* @param key The System Property key to lookup.
* @return the value of the property parsed as a set of strings or an empty set if no match is found.
*/
}
/**
* Returns all the properties defined and their values. This is a defensive copy of the properties and so updates
* to the returned object will not be reflected in the actual properties used by OpenAM.
*
* @return Properties object with a copy of all the key value pairs.
*/
return properties;
}
/**
* This method lets you get all the properties defined and their values. The
* method first tries to load the properties from java.lang.System followed
* by a lookup in the config file.
*
* @return Properties object with all the key value pairs.
*
*/
// Iterate over the System Properties & add them in result obj
return properties;
}
/**
* This method lets you query for all the platform properties defined and
* their values. Returns a Properties object with all the key value pairs.
*
* @deprecated use <code>getAll()</code>
*
* @return the platform properties
*/
return getAll();
}
/**
* Initializes properties bundle from the <code>file<code>
* passed.
*
* @param file type <code>String</code>, file name for the resource bundle
* @exception MissingResourceException
*/
// Copy the properties to props
}
initializeProperties(props, false, false);
}
initializeProperties(properties, false);
}
/**
* Initializes the properties to be used by OpenAM. Ideally this
* must be called first before any other method is called within OpenAM.
* This method provides a programmatic way to set the properties, and will
* override similar properties if loaded for a properties file.
*
* @param properties properties for OpenAM
* @param reset <code>true</code> to reset existing properties.
*/
}
/**
* Initializes the properties to be used by OpenAM. Ideally this
* must be called first before any other method is called within OpenAM.
* This method provides a programmatic way to set the properties, and will
* override similar properties if loaded for a properties file.
*
* @param properties properties for OpenAM.
* @param reset <code>true</code> to reset existing properties.
* @param withDefaults <code>true</code> to include default properties.
*/
public static void initializeProperties(Properties properties, boolean reset, boolean withDefaults) {
if (withDefaults) {
}
do {
if (defaultProp != null) {
}
if (!reset) {
}
}
/**
* Initializes a property to be used by OpenAM. Ideally this
* must be called first before any other method is called within OpenAM.
* This method provides a programmatic way to set a specific property, and
* will override similar property if loaded for a properties file.
*
* @param propertyName property name.
* @param propertyValue property value.
*/
initializeProperties(newProps, false, false);
}
/**
* Returns a counter for last modification. The counter is incremented if
* the properties are changed by calling the following method
* <code>initializeProperties</code>. This is a convenience method for
* applications to track changes to OpenAM properties.
*
* @return counter of the last modification
*/
public static long lastModified() {
}
/**
* Returns error messages during initialization, else <code>null</code>.
*
* @return error messages during initialization
*/
return initError;
}
/**
* Returns error messages during initialization using the single war
* deployment, else <code>null</code>.
*
* @return error messages during initialization of OpenAM as single war
*/
return initSecondaryError;
}
/**
* Sets the server instance name of which properties are retrieved
* to initialized this object.
*
* @param name Server instance name.
*/
instanceName = name;
}
/**
* Returns the server instance name of which properties are retrieved
* to initialized this object.
*
* @return Server instance name.
*/
return instanceName;
}
/**
* Returns <code>true</code> if instance is running in server mode.
*
* @return <code>true</code> if instance is running in server mode.
*/
public static boolean isServerMode() {
return IsServerModeHolder.isServerMode;
}
/**
* Returns the property name to service attribute schema name mapping.
*
* @return Property name to service attribute schema name mapping.
*/
return ATTRIBUTE_MAP;
}
try {
}
} catch (MissingResourceException mse) {
// No Resource Bundle Found, Continue.
// Could be in Test Mode.
}
}
/**
* Lazy initialisation holder idiom for server mode flag as this is read frequently but never changes.
*/
private static final class IsServerModeHolder {
// use getProp and not get method to avoid infinite loop
private static final boolean isServerMode = Boolean.parseBoolean(getProp(Constants.SERVER_MODE, "false"));
}
/**
* A singleton enum for the configuration listeners, which will be lazily initialized on first use. The code
* here cannot be added to the {@code SystemProperties} class initialization as it would create a cyclic
* dependency on the static initialization of {@code ConfigurationObserver}.
*/
private enum Listeners {
Listeners() {
servicePropertiesListeners = new HashMap<>();
}
}
}
}
});
}
}
configurationObserver.addServiceListener(platformServicePropertiesListener, new Predicate<String>() {
}
});
}
}
/**
* A listener for the properties that are provided by a single service. Property values are cached so that
* property listeners are only notified when the property(-ies) they are observing have changed.
*/
private static final class ServicePropertiesConfigurationListener implements ConfigurationListener {
}
}
propertyListeners.put(propertyName, Collections.synchronizedSet(new HashSet<ConfigurationListener>()));
}
private ServicePropertiesConfigurationListener() {
// nothing to see here
}
public void notifyChanges() {
for (Map.Entry<String, Set<ConfigurationListener>> propertyListeners : this.propertyListeners.entrySet()) {
}
}
}
}
}
}
/**
* Listen for runtime changes to a system property value. Only values that are stored in the SMS will
* be changed at runtime. See {@code serverdefaults.properties}, {@code amPlatform.xml} and
* {@code serverAttributeMap.properties}.
*
* @param listener The listener to call when one of the provided properties has changed.
* @param properties The list of properties that should be observed. A change in any one of these properties
* will cause the listener to be notified.
*/
if (serviceListener == null) {
}
synchronized (serviceListener) {
}
}
}
}
/**
* Holds the current properties map together with the tagswap values and last updated timestamp to allow atomic
* updates of all three as one unit without locking. This is an immutable structure that is intended to be used
* with an AtomicReference.
*/
private static final class PropertiesHolder {
private final long lastModified;
PropertiesHolder() {
}
}
}
}
}
}
}
}