Class Config
- java.lang.Object
-
- org.apache.directory.fortress.core.util.Config
-
public final class Config extends Object
This class wraps Apache Commons Config utility and is used by internal components to retrieve name-value pair properties from its cfg context. The class will combine properties that it finds in its local property file along with data that is retrieved by name from the ldap server if name is specified within theGlobalIds.CONFIG_REALM
switch.The class will bootstrap itself during startup and must initialize correctly for the Fortress APIs to work correctly.
This object is thread safe but stores a static reference to Apache Commons Configuration
config
object.- Author:
- Apache Directory Project
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clearProperty(String name)
Clear the property from apache commons config.boolean
getBoolean(String key)
Gets the boolean attribute associated with the name or false if not found.boolean
getBoolean(String key, boolean defaultValue)
Gets the boolean attribute associated with the name or false if not found.char
getChar(String name)
Gets the prop attribute as char value from the apache commons cfg component.char
getChar(String name, char defaultValue)
Get the property value from the apache commons config but specify a default value if not found.String
getConstraintKey(String role, String contextId)
Constructs a key used to store dynamic role constraints inside the properties, as name:value.String
getDelimiter()
Fortress stores complex attribute types within a single attribute in ldap.Configuration
getIncrementReplacePosixIds(List<String> props, PropUpdater propUpdater)
Performs auto-increment on a list of key names that map to integer values stored on the current config node of the runtime.static Config
getInstance()
Return a static reference to this instance.int
getInt(String key)
Gets the int attribute of the Config class, or 0 if not found.int
getInt(String key, int defaultValue)
Gets the int attribute of the Config class or default value if not found.String
getProperty(String name)
Gets the prop attribute as String value from the apache commons cfg component.String
getProperty(String name, boolean nologvalue)
Gets the prop attribute as String value from the apache commons cfg component.String
getProperty(String name, String defaultValue)
Get the property value from the apache commons config but specify a default value if not found.boolean
isApacheds()
boolean
isAuditDisabled()
boolean
isOpenldap()
boolean
isRealm()
boolean
isRestEnabled()
boolean
isRoleOccupant()
void
setProperty(String name, String value)
Set the property String value to the apache commons config.
-
-
-
Method Detail
-
getInstance
public static Config getInstance()
Return a static reference to this instance. If the instance has not been instantiated, call the boostrap:- Load from fortress.properties
- Load some overrides from System properties
- Load from ou=Config ldap node
- Returns:
- this
-
getProperty
public String getProperty(String name)
Gets the prop attribute as String value from the apache commons cfg component.- Parameters:
name
- contains the name of the property.- Returns:
- contains the value associated with the property or null if not not found.
-
getProperty
public String getProperty(String name, boolean nologvalue)
Gets the prop attribute as String value from the apache commons cfg component.- Parameters:
name
- contains the name of the property.nologvalue
- if true will not output this prop's value to the debug logger.- Returns:
- contains the value associated with the property or null if not not found.
-
getProperty
public String getProperty(String name, String defaultValue)
Get the property value from the apache commons config but specify a default value if not found.- Parameters:
name
- contains the name of the property.defaultValue
- specified by client will be returned if property value is not found.- Returns:
- contains the value for the property as a String.
-
getChar
public char getChar(String name)
Gets the prop attribute as char value from the apache commons cfg component.- Parameters:
name
- contains the name of the property.- Returns:
- contains the value associated with the property or 0 if not not found.
-
getChar
public char getChar(String name, char defaultValue)
Get the property value from the apache commons config but specify a default value if not found.- Parameters:
name
- contains the name of the property.defaultValue
- specified by client will be returned if property value is not found.- Returns:
- contains the value for the property as a char.
-
getInt
public int getInt(String key)
Gets the int attribute of the Config class, or 0 if not found.- Parameters:
key
- name of the property name.- Returns:
- The int value or 0 if not found.
-
getInt
public int getInt(String key, int defaultValue)
Gets the int attribute of the Config class or default value if not found.- Parameters:
key
- name of the property name.defaultValue
- to use if property not found.- Returns:
- The int value or default value if not found.
-
getBoolean
public boolean getBoolean(String key)
Gets the boolean attribute associated with the name or false if not found.- Parameters:
key
- name of the property name.- Returns:
- The boolean value or false if not found.
-
getBoolean
public boolean getBoolean(String key, boolean defaultValue)
Gets the boolean attribute associated with the name or false if not found.- Parameters:
key
- name of the property name.defaultValue
- specified by client will be returned if property value is not found.- Returns:
- The boolean value or false if not found.
-
setProperty
public void setProperty(String name, String value)
Set the property String value to the apache commons config.- Parameters:
name
- contains the name of the property.value
- contains the String value of the property.
-
clearProperty
public void clearProperty(String name)
Clear the property from apache commons config.- Parameters:
name
- contains the name of the property.
-
isRestEnabled
public boolean isRestEnabled()
-
getDelimiter
public String getDelimiter()
Fortress stores complex attribute types within a single attribute in ldap. Usually a delimiter of '$' is used for string tokenization. format:part1$part2$part3....
Stored in fortress.properties as 'attr.delimiter=$'
-
isAuditDisabled
public boolean isAuditDisabled()
-
isOpenldap
public boolean isOpenldap()
-
isApacheds
public boolean isApacheds()
-
isRealm
public boolean isRealm()
-
isRoleOccupant
public boolean isRoleOccupant()
-
getConstraintKey
public String getConstraintKey(String role, String contextId)
Constructs a key used to store dynamic role constraints inside the properties, as name:value. The key format is: RC$contextId$role- Parameters:
role
- contains the name of the role being constrained.contextId
- contains the tenant name.- Returns:
- String containing the key name used to lookup the value of the role constraint.
-
getIncrementReplacePosixIds
public Configuration getIncrementReplacePosixIds(List<String> props, PropUpdater propUpdater) throws CfgException
Performs auto-increment on a list of key names that map to integer values stored on the current config node of the runtime. Unfortunately, it's synchronized to prevent a race condition of multiple threads trying to update the same id. Worse, it doesn't lock meaning not synched across processes and so a temporary workaround until the pending Apache LDAP API/Directory support for RFC 4525 (Modify Increment attribute).- Parameters:
props
- list of attribute names to update on config node.propUpdater
- reference to object that updates to new value.- Returns:
- Configuration entity containing the old values.
- Throws:
CfgException
-
-