use of com.sun.identity.plugin.configuration.ConfigurationException in project OpenAM by OpenRock.
the class AuthnSvcService method setValues.
/**
* Reads values from service schema.
*/
private static void setValues() {
Map attrMap = null;
try {
attrMap = ci.getConfiguration(null, null);
} catch (ConfigurationException ce) {
AuthnSvcUtils.debug.error("AuthnSvcService.setValues:", ce);
return;
}
handlers.clear();
Set values = (Set) attrMap.get(MECHANISM_HANDLER_LIST_ATTR);
for (Iterator iter = values.iterator(); iter.hasNext(); ) {
String value = (String) iter.next();
StringTokenizer stz = new StringTokenizer(value, "|");
String key = null;
String class_ = null;
while (stz.hasMoreTokens()) {
String token = stz.nextToken();
if (token.startsWith("key=")) {
key = token.substring(4);
} else if (token.startsWith("class=")) {
class_ = token.substring(6);
}
}
if (key != null && class_ != null) {
try {
handlers.put(key, (MechanismHandler) Class.forName(class_).newInstance());
} catch (Throwable t) {
AuthnSvcUtils.debug.error("AuthnSvcService.setValues class = " + class_, t);
}
} else {
if (AuthnSvcUtils.debug.warningEnabled()) {
AuthnSvcUtils.debug.warning("AuthnSvcService.setValues: Invalid syntax " + "for Mechanism Handler List: " + value);
}
}
}
values = (Set) attrMap.get(PLAIN_MECHANISM_AUTH_MODULE);
if ((values == null) || (values.isEmpty())) {
plainMechanismAuthModule = null;
} else {
plainMechanismAuthModule = (String) values.iterator().next();
}
values = (Set) attrMap.get(CRAMMD5_MECHANISM_AUTH_MODULE);
if ((values == null) || (values.isEmpty())) {
cramMD5MechanismAuthModule = null;
} else {
cramMD5MechanismAuthModule = (String) values.iterator().next();
}
}
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);
}
}
use of com.sun.identity.plugin.configuration.ConfigurationException in project OpenAM by OpenRock.
the class ConfigurationInstanceImpl method setConfiguration.
/**
* 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.
* @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 set service configuration
* or service configuration doesn't exist.
*/
public void setConfiguration(String realm, String configName, Map avPairs) throws ConfigurationException {
if (debug.messageEnabled()) {
debug.message("ConfigurationInstanceImpl.setConfiguration: " + "componentName = " + componentName + ", realm = " + realm + ", configName = " + configName + ", avPairs = " + avPairs);
}
try {
if (hasOrgSchema) {
ServiceConfig sc = null;
sc = scm.getOrganizationConfig(realm, null);
if (sc == null) {
String[] data = { componentName, realm };
throw new ConfigurationException(RESOURCE_BUNDLE, "configNotExist", data);
}
if ((configName == null) || (configName.length() == 0)) {
sc.setAttributes(avPairs);
} else {
if (subConfigId == null) {
if (debug.messageEnabled()) {
debug.message("ConfigurationInstanceImpl." + "setConfiguration: sub configuraton not " + "supported.");
}
String[] data = { componentName };
throw new ConfigurationException(RESOURCE_BUNDLE, "noSubConfig", data);
}
sc = sc.getSubConfig(configName);
if (sc == null) {
String[] data = { componentName, realm };
throw new ConfigurationException(RESOURCE_BUNDLE, "configNotExist", data);
}
sc.setAttributes(avPairs);
}
} else {
if ((realm != null) && (!realm.equals("/"))) {
if (debug.messageEnabled()) {
debug.message("ConfigurationInstanceImpl." + "setConfiguration: 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." + "setConfiguration: configuraton not " + "supported.");
}
String[] data = { componentName };
throw new ConfigurationException(RESOURCE_BUNDLE, "noConfig", data);
}
ss.setAttributeDefaults(avPairs);
}
} catch (SMSException smsex) {
debug.error("ConfigurationInstanceImpl.setConfiguration:", smsex);
String[] data = { componentName, realm };
throw new ConfigurationException(RESOURCE_BUNDLE, "failedSetConfig", data);
} catch (SSOException ssoex) {
debug.error("ConfigurationInstanceImpl.setConfiguration:", ssoex);
String[] data = { componentName, realm };
throw new ConfigurationException(RESOURCE_BUNDLE, "failedSetConfig", data);
}
}
Aggregations