ServiceConfig.java revision 56ed5bbb263838f338eb8afc978091c01a4f2a2b
/**
* 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]"
*
* $Id: ServiceConfig.java,v 1.18 2009/01/28 05:35:03 ww203982 Exp $
*
*/
/*
* Portions Copyrighted [2011] [ForgeRock AS]
*/
/**
* The class <code>ServiceConfig</code> provides interfaces to manage the
* configuration information of a service configuration. It provides methods to
* get and set configuration parameters for this service configuration.
*
* @supported.all.api
*/
public class ServiceConfig {
// Instance variables
private ServiceConfigImpl sc;
private ServiceSchemaImpl ss;
private ServiceConfigManager scm;
/**
* Default constructor. Makes it private so that it can not be instantiated.
*/
private ServiceConfig() {
// hence can not be instantiated
}
/**
* Protected constructor
*/
throws SMSException, SSOException {
}
/**
* Returns the name of this service configuration.
*
* @return the name of this service configuration
*/
public String getServiceName() {
}
/**
* Returns the service version
*
* @return service version
*/
public String getVersion() {
return (scm.getVersion());
}
/**
* Returns the service component name. It is "/" separated and the root
* component name is "/".
*
* @return service component name
*/
public String getComponentName() {
validate();
return (sc.getComponentName());
}
/**
* Returns the service component's schema ID. For global and organization's
* root configurations it returns an empty string.
*
* @return service component's schema ID
*/
public String getSchemaID() {
validate();
return (sc.getSchemaID());
}
/**
* Returns the priority assigned to the service configuration.
*
* @return the priority assigned to the service configuration
*/
public int getPriority() {
validate();
return (sc.getPriority());
}
/**
* Sets the priority to the service configuration.
*
* @param priority
* the priority to be assigned to the configuration
* @throws SMSException
* if there is an error occurred while performing the operation
* @throws SSOException
* if the user's single sign-on is invalid or expired
*/
saveSMSEntry(e);
}
/**
* Returns the labeled uri assigned to the service configuration.
*
* @return the labeled uri assigned to the service configuration
*/
public String getLabeledUri() {
validate();
return (sc.getLabeledUri());
}
/**
* Sets the labeled uri to the service configuration.
*
* @param luri the labeled uri to be assigned to the configuration
* @throws SMSException
* if there is an error occurred while performing the operation
* @throws SSOException
* if the user's single sign-on is invalid or expired
*/
saveSMSEntry(e);
}
/**
* Returns the names of all service's sub-configurations.
*
* @return set of names of all service's sub-configurations
* @throws SMSException
* if there is an error accessing the data store
*/
try {
} catch (SSOException s) {
+ "get subConfig Names", s);
}
return (Collections.EMPTY_SET);
}
/**
* Method to get names of service's sub-configurations that match the given
* pattern.
*
* @param pattern
* pattern to match for sub-configuration names
* @return names of the service sub-configuration
* @throws SMSException
* if an error occurred while performing the operation.
*/
try {
} catch (SSOException s) {
+ "get subConfig Names for filter: " + pattern, s);
}
return (Collections.EMPTY_SET);
}
/**
* Method to get names of service's sub-configurations that match the given
* pattern and belongs to the specified service schema name.
*
* @param pattern
* pattern to match for other entities.
* @param schemaName
* service schema name.
* @return names of the service sub-configuration
* @throws SMSException
* if an error occurred while performing the operation.
*/
throws SMSException {
try {
} catch (SSOException s) {
+ schemaName, s);
}
return (Collections.EMPTY_SET);
}
/**
* Returns a set of exported fully qualified sub-configuration names that
* can be imported used locally as service configuration
*
* @param serviceId
* service schema identifier
* @return names of fully qualified applicable service sub-configurations
* @throws SMSException
* if an error occurred while performing the operation.
*/
return (null);
}
/**
* Returns the service's sub-configuration given the service's
* sub-configuration name.
*
* @param subConfigName
* The name of the service's sub-configuration to retrieve.
* @return The <code>ServiceConfig</code> object corresponding to the
* specified name of the service's sub-configuration.
* @throws SMSException
* if there is an error occurred while performing the operation
* @throws SSOException
* if the user's single sign-on is invalid or expired
*/
throws SSOException, SMSException {
}
/**
* Adds a service sub-configuration with configuration parameters.
*
* @param subConfigName
* the name of service sub-configuration to add
* @param subConfigId
* type of service sub-configuration
* @param priority
* the priority of the configuration
* @param attrs
* configuration parameters for the sub-configuration
* @throws SMSException
* if there is an error occurred while performing the operation
* @throws SSOException
* if the user's single sign-on is invalid or expired
*/
// Check if this entry exists
if (sc.isNewEntry()) {
// Ideally these nodes should have been created, since they
// are not present we need to create them
// Check if rest of the component names are present
}
// Get service schemas
if (subConfigId != null) {
} else {
}
"sms-invalid-add-sub-config", args));
}
&& !getSubConfigNames().isEmpty()) {
"sms-invalid-add-sub-config", args));
}
// Convert priority to string
// Create the entry
}
/**
* Removes the service sub-configuration.
*
* @param subConfigName
* name of service sub-configuration to remove
* @throws SMSException
* if there is an error occurred while performing the operation
* @throws SSOException
* if the user's single sign-on is invalid or expired
*/
// Obtain the SMSEntry for the subconfig and delete it
// unescape in case users provide such a subConfigName for deletion.
// "http:&#47;&#47;abc.east.sun.com:58080"
// First remove the entry from ServiceConfigImpl Cache.
// Construct subconfig DN
// Construct ServiceConfigManagerImpl
// Construct ServiceConfigImpl of the removed subconfig.
// Call ServiceConfigImpl's deleteInstance() to remove from cache.
if (sConfigImpl != null) {
ss);
}
// Remove this entry from smsentry.
}
// Remove the entry from CachedSubEntries
}
/**
* Imports a service sub-configuration to the list of localy defined
* sub-configuration. The imported sub-configuration name must be fully
* qualified, as obtained from <code>getExportedSubConfigNames</code>.
*
* @param subConfigName
* the name of service sub-configuration to add locally
* @param exportedSubConfigName
* the fully qualified name of the exported sub-configuration
* name
* @throws SMSException
* if there is an error occurred while performing the operation
* @throws SSOException
* if the user's single sign-on is invalid or expired
*/
}
/**
* Returns the service configuration parameters. The keys in the
* <code>Map</code> contains the attribute names and their corresponding
* values in the <code>Map</code> is a <code>Set</code> that contains
* the values for the attribute. This method picks up the default values for
* any attributes not defined in the <code>ServiceConfig</code>. The
* default values for these attributes are picked up from the Service
* Schema. If there is no default value defined, then this method will still
* return the attribute-value pair, except that the Set will be a
* Collections.EMPTY_SET. This is distinct from an empty Set with no entries
* in it. AN empty set represents an attribute whose value has been set to
* an empty value by the application using the <code>setAttributes()</code>
* method.
*
* @return the <code>Map</code> where key is the attribute name and value
* is the <code>Set</code> of attribute values
*/
public Map getAttributes() {
validate();
return (sc.getAttributes());
}
/**
* Returns the service configuration parameters for read only.
* The keys in the <code>Map</code> contains the attribute names and
* their corresponding values in the <code>Map</code> is a
* <code>Set</code> that contains the values for the attribute.
*/
/**
* Returns the service configuration parameters without inheriting the
* default values from service's schema. The keys in the <code>Map</code>
* contains the attribute names and their corresponding values in the
* <code>Map</code> is a <code>Set</code> that contains the values for
* the attribute.
*/
public Map getAttributesWithoutDefaults() {
validate();
return (sc.getAttributesWithoutDefaults());
}
/**
* Returns the service configuration parameters for read only,
* modification cannot be performed on the return <code>Map</code>.
* The keys in the
* <code>Map</code> contains the attribute names and their
* corresponding values in the <code>Map</code> is a
* <code>Set</code> that contains the values for the attribute.
* This method picks up the default values for any attributes
* not defined in the <code>ServiceConfig</code>. The default values for
* these attributes are picked up from the Service Schema.
* If there is no default value defined, then this method
* will still return the attribute-value pair, except that
* the Set will be a Collections.EMPTY_SET.
* This is distinct from an empty Set with no entries in it.
* AN empty set represents an attribute whose value has
* been set to an empty value by the application using
* the <code>setAttributes()</code> method.
*
* @return the <code>Map</code> where key is the attribute name
* and value is the <code>Set</code> of attribute values
*/
public Map getAttributesForRead() {
validate();
return (sc.getAttributesForRead());
}
/**
* Returns the service configuration parameters for read only without
* inheriting the default values from service's schema. The keys
* in the <code>Map</code> contains the attribute names and their
* corresponding values in the <code>Map</code> is a
* <code>Set</code> that contains the values for the attribute.
*/
public Map getAttributesWithoutDefaultsForRead() {
validate();
return (sc.getAttributesWithoutDefaultsForRead());
}
/**
* Sets the service configuration parameters. The keys in the
* <code>Map</code> contains the attribute names and their corresponding
* values in the <code>Map</code> is a <code>Set</code> that contains
* the values for the attribute. This method will replace the existing
* attribute values with the given one. For attributes that are not
* specified in <code>attrs</code>, it will not be modified.
*
* @param attrs
* the <code>Map</code> where key is the attribute name and
* value is the <code>Set</code> of attribute values
* @throws SMSException
* if there is an error occurred while performing the operation
* @throws SSOException
* if the user's single sign-on is invalid or expired
*/
if (!newAttrs.containsKey(s)) {
}
}
/*
* For validation using ChoiceValues plugin we need to pass in
* OrganizationName, since the plugins use organization names to compute
* the choice values
*/
saveSMSEntry(e);
}
/**
* Adds a configuration parameter to the service configuration.
*
* @param attrName
* the name of the attribute to add
* @param values
* the set of values to add
* @throws SMSException
* if there is an error occurred while performing the operation
* @throws SSOException
* if the user's single sign-on is invalid or expired
*/
// Get current attributes
// Validate attribute values
}
.getOrganizationName());
// Store the entry
saveSMSEntry(e);
}
/**
* Removes a configuration parameter from the service configuration.
*
* @param attrName
* the name of the attribute to remove
* @throws SMSException
* if there is an error occurred while performing the operation
* @throws SSOException
* if the user's single sign-on is invalid or expired
*/
saveSMSEntry(e);
}
/**
* Removes a configuration parameters from the service configuration.
*
* @param attrNames
* <code>Set</code> of attribute names to remove
* @throws SMSException
* if there is an error occurred while performing the operation
* @throws SSOException
* if the user's single sign-on is invalid or expired
*/
}
saveSMSEntry(e);
}
}
/**
* Removes the specific values for the given configuration parameter.
*
* @param attrName
* the name of the attribute
* @param values
* set of attribute values to remove from the given attribute
* @throws SMSException
* if there is an error occurred while performing the operation
* @throws SSOException
* if the user's single sign-on is invalid or expired
*/
throws SMSException, SSOException {
saveSMSEntry(e);
}
/**
* Replaces old value of the configuration parameter with new value.
*
* @param attrName
* the name of the attribute
* @param oldValue
* the old value to remove from the attribute
* @param newValue
* the new value to add to the attribute
* @throws SMSException
* if there is an error occurred while performing the operation
* @throws SSOException
* if the user's single sign-on is invalid or expired
*/
// Get current attributes
// Validate values
}
.getOrganizationName());
// Store the entry
saveSMSEntry(e);
}
/**
* Replaces the old values of the configuration parameter with the new
* values.
*
* @param attrName
* the name of the attribute
* @param oldValues
* the set of old values to remove from the attribute
* @param newValues
* the set of new values to add to the attribute
* @throws SMSException
* if there is an error occurred while performing the operation
* @throws SSOException
* if the user's single sign-on is invalid or expired
*/
// Get current attributes
// Validate values
}
// Store the entry
saveSMSEntry(e);
}
/**
* Returns the LDAP DN represented by this <code>ServiceConfig</code>
* object.
*
* @return the LDAP DN represented by this <code>ServiceConfig</code>
* object.
*/
validate();
}
/**
* Returns the last modified time stamp of this configuration This method is
* expensive because it does not cache the modified time stamp but goes
* directly to the data store to obtain the value of this entry
*
* @return The last modified time stamp as a string with the format of
* <code> yyyyMMddhhmmss </code>
* @throws SMSException
* if there is an error trying to read from the data store
* @throws SSOException
* if the single sign-on token of the user is invalid.
*/
true);
}
return mTS;
}
/**
* Returns the organization names to which the service configuration is
* being exported. The organization names would be fully qualified starting
* with a forward slash "/". To specify an entire sub-tree that can use the
* service configuration, a "*" would have to be appended after the final
* forward slash. For example "/a/b/c/*" would imply all sub-organization
* under "/a/b/c" can use this service configuration. Exporting implies
* privileges to read the service configuration data, but not to modify or
* delete.
*
* @return names of organizations to which service configuration
* configuration is exported
*/
public Set getExportedOrganizationNames() {
return (null);
}
/**
* Sets the organization names that can import the service configuration.
* The organization names must be fully qualified, starting with a forward
* slash "/". To specify an entire sub-tree that can use the service
* configuration, a "*" would have to be appended after the final forward
* slash. For example "/a/b/c/*" would imply all sub-organization under
* "/a/b/c" can use this service configuration. Exporting implies privileges
* to read the service configuration data and not to modify or delete.
*
* @param names
* names of the organizations that can import the service
* configuration
*/
}
/**
* Adds the organization names to the list of organization names that can
* import this service configutation. If one does not exist it will be
* created. The organization names must be fully qualified, starting with a
* forward slash "/". To specify an entire sub-tree that can use the service
* configuration, a "*" would have to be appended after the final forward
* slash. For example "/a/b/c/*" would imply all sub-organization under
* "/a/b/c" can use this service configuration. Exporting implies privileges
* to read the service configuration data and not to modify or delete.
*
* @param names
* names of the organizations that can import the service
* configuration
*/
}
/**
* Removes the organization names from the list of organization names that
* can import the service configuration. If the organization has already
* imported the service configutation, it would have to be undone before the
* organization name can be removed from the list. The organization names
* must be fully qualified, starting with a forward slash "/". To specify an
* entire sub-tree that can use the service configuration, a "*" would have
* to be appended after the final forward slash. For example "/a/b/c/*"
* would imply all sub-organization under "/a/b/c" can use this service
* configuration.
*
* @param names
* names of the organizations that will be removed from the list
* of organization names that can import the service
* configutation
*/
}
/**
* Returns String representation of the <code>ServiceConfig</code> object.
* It returns attributes defined and sub configurations.
*
* @return String representation of the <code>ServiceConfig</code> object.
*/
// Print the attributes
// Try sub-configs
try {
while (subConfigNames.hasNext()) {
}
} catch (Exception e) {
}
}
// Protected methods
if (e.isNewEntry()) {
// Check if base nodes exists
getVersion());
// Check if parent DN is present
// Add object classses to this entry
}
}
throws SMSException, SSOException {
}
if (entry.isNewEntry()) {
// Check if parent exisits
}
if (pEntry.isNewEntry()) {
}
// Create this entry
}
}
}
if (entry.isNewEntry()) {
// Check if parent exisits
}
if (pEntry.isNewEntry()) {
}
// Create this entry
}
}
private void validate() {
try {
} catch (SMSException e) {
// Ignore the exception
}
}
private void validateServiceConfigImpl() throws SMSException {
" No loger valid. Cache has been cleared. Recreate from" +
"ServiceConfigManager"));
}
}
/**
* Returns the status of this Service Configuration Object.
* Must be used by classes that cache ServiceConfig.
*
* @return <code>true</code> if this object is still valid.
*/
public boolean isValid() {
}
/**
* Returns <code>true</code> if the entry exist
*/
public boolean exists() {
return (!sc.isNewEntry());
}
throws SMSException, SSOException {
}
throws SMSException, SSOException {
}
}