Search in sources :

Example 36 with ConfigurationException

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);
    }
}
Also used : ConfigurationException(com.sun.identity.plugin.configuration.ConfigurationException) SPSSOConfigElement(com.sun.identity.wsfederation.jaxb.entityconfig.SPSSOConfigElement) IDPSSOConfigElement(com.sun.identity.wsfederation.jaxb.entityconfig.IDPSSOConfigElement)

Example 37 with ConfigurationException

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);
    }
}
Also used : ConfigurationException(com.sun.identity.plugin.configuration.ConfigurationException) JAXBException(javax.xml.bind.JAXBException) Map(java.util.Map)

Example 38 with ConfigurationException

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;
}
Also used : ServiceSchema(com.sun.identity.sm.ServiceSchema) SSOToken(com.iplanet.sso.SSOToken) Set(java.util.Set) ConfigurationException(com.sun.identity.plugin.configuration.ConfigurationException) SMSException(com.sun.identity.sm.SMSException) SSOException(com.iplanet.sso.SSOException) ServiceSchemaManager(com.sun.identity.sm.ServiceSchemaManager) ServiceConfigManager(com.sun.identity.sm.ServiceConfigManager)

Example 39 with ConfigurationException

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);
    }
}
Also used : ServiceSchema(com.sun.identity.sm.ServiceSchema) SSOToken(com.iplanet.sso.SSOToken) ServiceConfig(com.sun.identity.sm.ServiceConfig) ConfigurationException(com.sun.identity.plugin.configuration.ConfigurationException) SMSException(com.sun.identity.sm.SMSException) SSOException(com.iplanet.sso.SSOException) HashMap(java.util.HashMap) Map(java.util.Map)

Example 40 with ConfigurationException

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);
    }
}
Also used : ServiceConfig(com.sun.identity.sm.ServiceConfig) ConfigurationException(com.sun.identity.plugin.configuration.ConfigurationException) SMSException(com.sun.identity.sm.SMSException) SSOException(com.iplanet.sso.SSOException)

Aggregations

ConfigurationException (com.sun.identity.plugin.configuration.ConfigurationException)59 Set (java.util.Set)38 Map (java.util.Map)35 HashSet (java.util.HashSet)31 JAXBException (javax.xml.bind.JAXBException)19 Iterator (java.util.Iterator)18 HashMap (java.util.HashMap)14 ArrayList (java.util.ArrayList)13 List (java.util.List)9 EntityConfigElement (com.sun.identity.saml2.jaxb.entityconfig.EntityConfigElement)6 SSOException (com.iplanet.sso.SSOException)5 SMSException (com.sun.identity.sm.SMSException)5 FederationConfigElement (com.sun.identity.wsfederation.jaxb.entityconfig.FederationConfigElement)5 ServiceConfig (com.sun.identity.sm.ServiceConfig)4 ServiceSchema (com.sun.identity.sm.ServiceSchema)4 EntityConfigElement (com.sun.identity.federation.jaxb.entityconfig.EntityConfigElement)3 IDPSSOConfigElement (com.sun.identity.wsfederation.jaxb.entityconfig.IDPSSOConfigElement)3 SPSSOConfigElement (com.sun.identity.wsfederation.jaxb.entityconfig.SPSSOConfigElement)3 StringTokenizer (java.util.StringTokenizer)3 SSOToken (com.iplanet.sso.SSOToken)2