ConfigurationInstanceImpl.java revision 4a2f0f0be43dfd4c1b490cbf3cc48b6ba6084b1c
/**
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2006 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: ConfigurationInstanceImpl.java,v 1.12 2009/10/29 00:03:50 exu Exp $
*
*/
/**
* <code>ConfigurationInstanceImpl</code> is the implementation that provides
* the operations on service configuration.
*/
public class ConfigurationInstanceImpl implements ConfigurationInstance {
private ServiceSchemaManager ssm;
private ServiceConfigManager scm;
private boolean hasOrgSchema = false;
private static final int SUBCONFIG_PRIORITY = 0;
static {
serviceNameMap = new HashMap();
}
private SSOToken getSSOToken() {
}
/**
* Initializer.
* @param componentName Name of the components, e.g. SAML1, SAML2, ID-FF
* @param session FM Session object.
* @exception ConfigurationException if could not initialize the instance.
*/
throws ConfigurationException {
if (serviceName == null) {
throw new ConfigurationException(RESOURCE_BUNDLE,
"componentNameUnsupported", null);
}
}
try {
hasOrgSchema = true;
}
}
} catch (SMSException smsex) {
throw new ConfigurationException(smsex);
} catch (SSOException ssoex) {
throw new ConfigurationException(ssoex);
}
this.componentName = componentName;
}
/**
* Returns Configurations.
* @param realm the name of organization at which the configuration resides.
* @param configName configuration instance name. e.g. "/sp".
* The configName could be null or empty string, which means the default
* configuration for this components.
* a Set of attribute values or null if service configuration doesn't
* doesn't exist.
* @exception ConfigurationException if an error occurred while getting
* service configuration.
*/
throws ConfigurationException {
if (debug.messageEnabled()) {
", configName = " + configName);
}
try {
if (hasOrgSchema) {
return null;
}
return sc.getAttributes();
} else {
if (subConfigId == null) {
if (debug.messageEnabled()) {
"getConfiguration: sub configuraton not " +
"supported.");
}
throw new ConfigurationException(RESOURCE_BUNDLE,
"noSubConfig", data);
}
return null;
}
return sc.getAttributes();
}
} else {
if (debug.messageEnabled()) {
"getConfiguration: organization configuraton not "+
"supported.");
}
throw new ConfigurationException(RESOURCE_BUNDLE,
"noOrgConfig", data);
}
if (debug.messageEnabled()) {
"getConfiguration: configuraton not " +
"supported.");
}
throw new ConfigurationException(RESOURCE_BUNDLE,
"noConfig", data);
}
}
return retMap;
}
} catch (SMSException smsex) {
throw new ConfigurationException(RESOURCE_BUNDLE,
"failedGetConfig", data);
} catch (SSOException ssoex) {
throw new ConfigurationException(RESOURCE_BUNDLE,
"failedGetConfig", data);
}
}
/**
* Sets Configurations.
* @param realm the name of organization at which the configuration resides.
* @param configName configuration instance name. e.g. "/sp"
* The configName could be null or empty string, which means the default
* configuration for this components.
* configuration, key is the attribute name, value is
* a Set of attribute values.
* @exception ConfigurationException if could not set service configuration
* or service configuration doesn't exist.
*/
throws ConfigurationException {
if (debug.messageEnabled()) {
}
try {
if (hasOrgSchema) {
throw new ConfigurationException(RESOURCE_BUNDLE,
"configNotExist", data);
}
} else {
if (subConfigId == null) {
if (debug.messageEnabled()) {
"setConfiguration: sub configuraton not " +
"supported.");
}
throw new ConfigurationException(RESOURCE_BUNDLE,
"noSubConfig", data);
}
throw new ConfigurationException(RESOURCE_BUNDLE,
"configNotExist", data);
}
}
} else {
if (debug.messageEnabled()) {
"setConfiguration: organization configuraton not "+
"supported.");
}
throw new ConfigurationException(RESOURCE_BUNDLE,
"noOrgConfig", data);
}
if (debug.messageEnabled()) {
"setConfiguration: configuraton not " +
"supported.");
}
throw new ConfigurationException(RESOURCE_BUNDLE,
"noConfig", data);
}
}
} catch (SMSException smsex) {
throw new ConfigurationException(RESOURCE_BUNDLE,
"failedSetConfig", data);
} catch (SSOException ssoex) {
throw new ConfigurationException(RESOURCE_BUNDLE,
"failedSetConfig", data);
}
}
/**
* Creates Configurations.
* @param realm the name of organization at which the configuration resides.
* @param configName service configuration name. e.g. "/sp"
* The configName could be null or empty string, which means the
* default configuration for this components.
* configuration, key is the attribute name, value is
* a Set of attribute values.
* @exception ConfigurationException if could not create service
* configuration.
*/
throws ConfigurationException {
if (debug.messageEnabled()) {
}
try {
if (hasOrgSchema) {
} else {
if (subConfigId == null) {
if (debug.messageEnabled()) {
"createConfiguration: sub configuraton not " +
"supported.");
}
throw new ConfigurationException(RESOURCE_BUNDLE,
"noSubConfig", data);
}
throw new ConfigurationException(RESOURCE_BUNDLE,
"configExist", data);
}
}
} else {
if (debug.messageEnabled()) {
"createConfiguration: configuraton creation not " +
"supported.");
}
throw new ConfigurationException(RESOURCE_BUNDLE,
"noConfigCreation", data);
}
} catch (SMSException smsex) {
smsex);
throw new ConfigurationException(RESOURCE_BUNDLE,
"failedCreateConfig", data);
} catch (SSOException ssoex) {
ssoex);
throw new ConfigurationException(RESOURCE_BUNDLE,
"failedCreateConfig", data);
}
}
/**
* Deletes Configuration.
* @param realm the name of organization at which the configuration resides.
* @param configName service configuration name. e.g. "/sp"
* The configName could be null or empty string, which means the default
* configuration for this components.
* @param attributes A set of attributes to be deleted from the Service
* configuration. If the value is null or empty, deletes all service
* configuration.
* @exception ConfigurationException if could not delete service
* configuration.
*/
throws ConfigurationException {
if (debug.messageEnabled()) {
}
try {
if (hasOrgSchema) {
if (removeConfig) {
} else {
}
}
} else {
if (subConfigId == null) {
if (debug.messageEnabled()) {
"deleteConfiguration: sub configuraton not " +
"supported.");
}
throw new ConfigurationException(RESOURCE_BUNDLE,
"noSubConfig", data);
}
if (removeConfig) {
} else {
}
}
}
}
} else {
if (debug.messageEnabled()) {
"deleteConfiguration: configuraton deletion not " +
"supported.");
}
throw new ConfigurationException(RESOURCE_BUNDLE,
"noConfigDeletion", data);
}
} catch (SMSException smsex) {
smsex);
throw new ConfigurationException(RESOURCE_BUNDLE,
"failedDeleteConfig", data);
} catch (SSOException ssoex) {
ssoex);
throw new ConfigurationException(RESOURCE_BUNDLE,
"failedDeleteConfig", data);
}
}
/**
* Returns all service config name for this components.
* @param realm the name of organization at which the configuration resides.
* @return Set of service configuration names. Return null if there
* is no service configuration for this component, return empty set
* if there is only default configuration instance.
* @exception ConfigurationException if could not get all service
* configuration names.
*/
throws ConfigurationException {
if (debug.messageEnabled()) {
}
try {
if (hasOrgSchema) {
return null;
}
return subConfigNames;
} else {
return Collections.EMPTY_SET;
}
} else {
return null;
}
return null;
} else {
return Collections.EMPTY_SET;
}
}
} catch (SMSException smsex) {
smsex);
throw new ConfigurationException(RESOURCE_BUNDLE,
"failedGetConfigNames", data);
} catch (SSOException ssoex) {
ssoex);
throw new ConfigurationException(RESOURCE_BUNDLE,
"failedGetConfigNames", data);
}
}
/**
* Registers for changes to the component's configuration. The object will
* be called when configuration for this component is changed.
* @return the registered id for this listener instance.
* @exception ConfigurationException if could not register the listener.
*/
throws ConfigurationException {
if (hasOrgSchema) {
} else {
}
}
/**
* Unregisters the listener from the component for the given
* listener ID. The ID was issued when the listener was registered.
* @param listenerID the returned id when the listener was registered.
* @exception ConfigurationException if could not register the listener.
*/
throws ConfigurationException {
if (hasOrgSchema) {
} else {
}
}
}