use of com.sun.identity.plugin.configuration.ConfigurationException in project OpenAM by OpenRock.
the class WSFederationMetaManager method deleteFederation.
/**
* Deletes the standard metadata entity descriptor under the realm.
*
* @param realm The realm under which the entity resides.
* @param federationId The ID of the entity for whom the standard entity
* descriptor will be deleted.
* @throws WSFederationMetaException if unable to delete the entity
* descriptor.
*/
public void deleteFederation(String realm, String federationId) throws WSFederationMetaException {
if (federationId == null) {
return;
}
if (realm == null) {
realm = "/";
}
String[] objs = { federationId, realm };
try {
// Remove the entity from cot
IDPSSOConfigElement idpconfig = getIDPSSOConfig(realm, federationId);
if (idpconfig != null) {
removeFromCircleOfTrust(idpconfig, realm, federationId);
}
SPSSOConfigElement spconfig = getSPSSOConfig(realm, federationId);
if (spconfig != null) {
removeFromCircleOfTrust(spconfig, realm, federationId);
}
// end of remove entity from cot
configInst.deleteConfiguration(realm, federationId, null);
LogUtil.access(Level.INFO, LogUtil.ENTITY_DESCRIPTOR_DELETED, objs, null);
WSFederationMetaCache.putFederation(realm, federationId, null);
} catch (ConfigurationException e) {
debug.error("WSFederationMetaManager.deleteFederation:", e);
String[] data = { e.getMessage(), federationId, realm };
LogUtil.error(Level.INFO, LogUtil.CONFIG_ERROR_DELETE_ENTITY_DESCRIPTOR, data, null);
throw new WSFederationMetaException(e);
}
}
use of com.sun.identity.plugin.configuration.ConfigurationException in project OpenAM by OpenRock.
the class WSFederationMetaManager method setFederation.
/**
* Sets the standard metadata entity descriptor under the realm.
*
* @param realm The realm under which the entity resides.
* @param federation Federation object.
* @throws WSFederationMetaException if unable to set the entity descriptor.
*/
public void setFederation(String realm, FederationElement federation) throws WSFederationMetaException {
String federationId = federation.getFederationID();
if (federationId == null) {
federationId = WSFederationConstants.DEFAULT_FEDERATION_ID;
}
if (realm == null) {
realm = "/";
}
String[] objs = { federationId, realm };
try {
Map attrs = WSFederationMetaUtils.convertJAXBToAttrMap(ATTR_METADATA, federation);
Map oldAttrs = configInst.getConfiguration(realm, federationId);
oldAttrs.put(ATTR_METADATA, attrs.get(ATTR_METADATA));
configInst.setConfiguration(realm, federationId, oldAttrs);
LogUtil.access(Level.INFO, LogUtil.SET_ENTITY_DESCRIPTOR, objs, null);
} catch (ConfigurationException e) {
debug.error("WSFederationMetaManager.setFederation:", e);
String[] data = { e.getMessage(), federationId, realm };
LogUtil.error(Level.INFO, LogUtil.CONFIG_ERROR_SET_ENTITY_DESCRIPTOR, data, null);
throw new WSFederationMetaException(e);
} catch (JAXBException jaxbe) {
debug.error("WSFederationMetaManager.setFederation:", jaxbe);
LogUtil.error(Level.INFO, LogUtil.SET_INVALID_ENTITY_DESCRIPTOR, objs, null);
throw new WSFederationMetaException("invalid_descriptor", objs);
}
}
use of com.sun.identity.plugin.configuration.ConfigurationException in project OpenAM by OpenRock.
the class ConfigurationInstanceImpl method init.
/**
* 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.
*/
public void init(String componentName, Object session) throws ConfigurationException {
String serviceName = (String) serviceNameMap.get(componentName);
if (serviceName == null) {
throw new ConfigurationException(RESOURCE_BUNDLE, "componentNameUnsupported", null);
}
if ((session != null) && (session instanceof SSOToken)) {
ssoToken = (SSOToken) session;
}
try {
SSOToken adminToken = getSSOToken();
ssm = new ServiceSchemaManager(serviceName, adminToken);
ServiceSchema oss = ssm.getOrganizationSchema();
if (oss != null) {
hasOrgSchema = true;
Set subSchemaNames = oss.getSubSchemaNames();
if ((subSchemaNames != null) && (subSchemaNames.size() == 1)) {
subConfigId = (String) subSchemaNames.iterator().next();
}
}
scm = new ServiceConfigManager(serviceName, adminToken);
} catch (SMSException smsex) {
debug.error("ConfigurationInstanceImpl.init:", smsex);
throw new ConfigurationException(smsex);
} catch (SSOException ssoex) {
debug.error("ConfigurationInstanceImpl.init:", ssoex);
throw new ConfigurationException(ssoex);
}
this.componentName = componentName;
}
use of com.sun.identity.plugin.configuration.ConfigurationException in project OpenAM by OpenRock.
the class ConfigurationInstanceImpl method getConfiguration.
/**
* 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.
* @return Map of key/value pairs, key is the attribute name, value is
* a Set of attribute values or null if service configuration doesn't
* doesn't exist. If the configName parameter is null or empty, and OrganizationalConfig state is present,
* this state will be merged with the GlobalConfig attributes, with the OrganizationConfig attributes
* over-writing the GlobalConfig attributes, in case GlobalConfig and OrganizationConfig attributes share the
* same key.
* @exception ConfigurationException if an error occurred while getting
* service configuration.
*/
public Map getConfiguration(String realm, String configName) throws ConfigurationException {
if (debug.messageEnabled()) {
debug.message("ConfigurationInstanceImpl.getConfiguration: " + "componentName = " + componentName + ", realm = " + realm + ", configName = " + configName);
}
try {
if (hasOrgSchema) {
ServiceConfig organizationConfig = null;
organizationConfig = scm.getOrganizationConfig(realm, null);
if (organizationConfig == null) {
return null;
}
if ((configName == null) || (configName.length() == 0)) {
Map organizationAttributes = organizationConfig.getAttributes();
ServiceConfig globalConfig = scm.getGlobalConfig(configName);
if (globalConfig != null) {
Map mergedAttributes = globalConfig.getAttributes();
mergedAttributes.putAll(organizationAttributes);
return mergedAttributes;
}
return organizationAttributes;
} else {
if (subConfigId == null) {
if (debug.messageEnabled()) {
debug.message("ConfigurationInstanceImpl." + "getConfiguration: sub configuraton not " + "supported.");
}
String[] data = { componentName };
throw new ConfigurationException(RESOURCE_BUNDLE, "noSubConfig", data);
}
organizationConfig = organizationConfig.getSubConfig(configName);
if (organizationConfig == null) {
return null;
}
return organizationConfig.getAttributes();
}
} else {
if ((realm != null) && (!realm.equals("/"))) {
if (debug.messageEnabled()) {
debug.message("ConfigurationInstanceImpl." + "getConfiguration: organization configuraton not " + "supported.");
}
String[] data = { componentName };
throw new ConfigurationException(RESOURCE_BUNDLE, "noOrgConfig", data);
}
ServiceSchema ss = ssm.getGlobalSchema();
if (ss == null) {
if (debug.messageEnabled()) {
debug.message("ConfigurationInstanceImpl." + "getConfiguration: configuraton not " + "supported.");
}
String[] data = { componentName };
throw new ConfigurationException(RESOURCE_BUNDLE, "noConfig", data);
}
Map retMap = ss.getAttributeDefaults();
if (componentName.equals("PLATFORM")) {
SSOToken token = getSSOToken();
retMap.put(Constants.PLATFORM_LIST, ServerConfiguration.getServerInfo(token));
retMap.put(Constants.SITE_LIST, SiteConfiguration.getSiteInfo(token));
}
return retMap;
}
} catch (SMSException smsex) {
debug.error("ConfigurationInstanceImpl.getConfiguration:", smsex);
String[] data = { componentName, realm };
throw new ConfigurationException(RESOURCE_BUNDLE, "failedGetConfig", data);
} catch (SSOException ssoex) {
debug.error("ConfigurationInstanceImpl.getConfiguration:", ssoex);
String[] data = { componentName, realm };
throw new ConfigurationException(RESOURCE_BUNDLE, "failedGetConfig", data);
}
}
use of com.sun.identity.plugin.configuration.ConfigurationException in project OpenAM by OpenRock.
the class ConfigurationInstanceImpl method createConfiguration.
/**
* 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.
* @param avPairs Map of key/value pairs to be set in the service
* configuration, key is the attribute name, value is
* a Set of attribute values.
* @exception ConfigurationException if could not create service
* configuration.
*/
public void createConfiguration(String realm, String configName, Map avPairs) throws ConfigurationException {
if (debug.messageEnabled()) {
debug.message("ConfigurationInstanceImpl.createConfiguration: " + "componentName = " + componentName + ", realm = " + realm + ", configName = " + configName + ", avPairs = " + avPairs);
}
try {
if (hasOrgSchema) {
ServiceConfig sc = null;
sc = scm.getOrganizationConfig(realm, null);
if ((configName == null) || (configName.length() == 0)) {
scm.createOrganizationConfig(realm, avPairs);
} else {
if (subConfigId == null) {
if (debug.messageEnabled()) {
debug.message("ConfigurationInstanceImpl." + "createConfiguration: sub configuraton not " + "supported.");
}
String[] data = { componentName };
throw new ConfigurationException(RESOURCE_BUNDLE, "noSubConfig", data);
}
if (sc == null) {
sc = scm.createOrganizationConfig(realm, null);
} else if (sc.getSubConfigNames().contains(configName)) {
String[] data = { componentName, realm, configName };
throw new ConfigurationException(RESOURCE_BUNDLE, "configExist", data);
}
sc.addSubConfig(configName, subConfigId, SUBCONFIG_PRIORITY, avPairs);
}
} else {
if (debug.messageEnabled()) {
debug.message("ConfigurationInstanceImpl." + "createConfiguration: configuraton creation not " + "supported.");
}
String[] data = { componentName };
throw new ConfigurationException(RESOURCE_BUNDLE, "noConfigCreation", data);
}
} catch (SMSException smsex) {
debug.error("ConfigurationInstanceImpl.createConfiguration:", smsex);
String[] data = { componentName, realm };
throw new ConfigurationException(RESOURCE_BUNDLE, "failedCreateConfig", data);
} catch (SSOException ssoex) {
debug.error("ConfigurationInstanceImpl.createConfiguration:", ssoex);
String[] data = { componentName, realm };
throw new ConfigurationException(RESOURCE_BUNDLE, "failedCreateConfig", data);
}
}
Aggregations