Search in sources :

Example 1 with ConfigurationException

use of com.sun.identity.plugin.configuration.ConfigurationException in project OpenAM by OpenRock.

the class SOAPBindingService method setValues.

/**
     * This method reads values from service schema.
     */
private static void setValues() {
    Map attrMap = null;
    try {
        attrMap = ci.getConfiguration(null, null);
    } catch (ConfigurationException ce) {
        Utils.debug.error("SOAPBindingService.setValues:", ce);
        return;
    }
    supportedSOAPActionsMap.clear();
    handlers.clear();
    Set values = (Set) attrMap.get(REQUEST_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;
        String soapActions = 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);
            } else if (token.startsWith("soapActions=")) {
                soapActions = token.substring(12);
            }
        }
        if (key != null && class_ != null) {
            try {
                handlers.put(key, Class.forName(class_).newInstance());
                if (soapActions != null) {
                    StringTokenizer stz2 = new StringTokenizer(soapActions);
                    List list = null;
                    while (stz2.hasMoreTokens()) {
                        if (list == null) {
                            list = new ArrayList();
                        }
                        list.add(stz2.nextToken());
                    }
                    if (list != null) {
                        supportedSOAPActionsMap.put(key, list);
                    }
                }
            } catch (Throwable t) {
                Utils.debug.error("Utils.setValues class = " + class_, t);
            }
        } else {
            if (Utils.debug.warningEnabled()) {
                Utils.debug.warning("Utils.setValues: Invalid syntax " + "for Request Handler List: " + value);
            }
        }
    }
    values = (Set) attrMap.get(WEB_SERVICE_AUTHENTICATOR_ATTR);
    if (values.isEmpty()) {
        wsAuthenticator = null;
    } else {
        String class_ = (String) values.iterator().next();
        try {
            wsAuthenticator = (WebServiceAuthenticator) Class.forName(class_).newInstance();
        } catch (Exception ex) {
            if (Utils.debug.warningEnabled()) {
                Utils.debug.warning("Utils.setValues: Unable to " + "instantiate WebServiceAuthenticator", ex);
            }
            wsAuthenticator = null;
        }
    }
    supportedAuthMechs = (Set) attrMap.get(SUPPORTED_AUTHENTICATION_MECHANISMS_ATTR);
    Set valuesEnforceOnlyKnownProvider = (Set) attrMap.get(ENFORCE_ONLY_KNOWN_PROVIDER_ATTR);
    if (valuesEnforceOnlyKnownProvider != null && !valuesEnforceOnlyKnownProvider.isEmpty()) {
        String enforce = (String) valuesEnforceOnlyKnownProvider.iterator().next();
        enforceOnlyKnownProvider = Boolean.valueOf(enforce).booleanValue();
    }
}
Also used : StringTokenizer(java.util.StringTokenizer) Set(java.util.Set) ConfigurationException(com.sun.identity.plugin.configuration.ConfigurationException) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map) ConfigurationException(com.sun.identity.plugin.configuration.ConfigurationException)

Example 2 with ConfigurationException

use of com.sun.identity.plugin.configuration.ConfigurationException in project OpenAM by OpenRock.

the class CircleOfTrustManager method getIDFFCOTProviderMapping.

/**
     * Returns a map of circle of trust name and the value
     * of the <code>sun-fm-trusted-providers</code> attribute
     * The key in the map is the circle of trust name and
     * value is a set of providers retreived from the attribute.
     *
     * @return a map where the key is the cirle of trust name
     *         and value is Set of providers retrieved from
     *         the  <code>sun-fm-trusted-providers</code> attribute.
     * @throws COTException if there is an error retrieving the
     *                      trusted providers.
     * TODO : cache this 
     */
public Map getIDFFCOTProviderMapping(String realm) throws COTException {
    String classMethod = "COTManager.getAllActiveCirclesOfTrust: ";
    Map cotMap = new HashMap();
    if (realm == null) {
        realm = COTConstants.ROOT_REALM;
    }
    try {
        Set valueSet = configInst.getAllConfigurationNames(realm);
        if ((valueSet != null) && !valueSet.isEmpty()) {
            for (Iterator iter = valueSet.iterator(); iter.hasNext(); ) {
                String name = (String) iter.next();
                Map attrMap = configInst.getConfiguration(realm, name);
                String cotStatus = COTUtils.getFirstEntry(attrMap, COTConstants.COT_STATUS);
                if (isActiveCOT(cotStatus)) {
                    Set trustedProviders = (Set) attrMap.get(COTConstants.COT_TRUSTED_PROVIDERS);
                    Map map = COTUtils.trustedProviderSetToProtocolMap(trustedProviders, "/");
                    Set idffSet = (Set) map.get(COTConstants.IDFF);
                    if ((idffSet != null) && !idffSet.isEmpty()) {
                        cotMap.put(name, idffSet);
                    }
                }
            }
        }
    } catch (ConfigurationException se) {
        debug.error(classMethod, se);
        String[] data = { se.getMessage(), COTConstants.IDFF, realm };
        LogUtil.error(Level.INFO, LogUtil.CONFIG_ERROR_GET_ALL_ACTIVE_COT, data);
        throw new COTException(se);
    }
    return cotMap;
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) ConfigurationException(com.sun.identity.plugin.configuration.ConfigurationException) Iterator(java.util.Iterator) HashMap(java.util.HashMap) Map(java.util.Map)

Example 3 with ConfigurationException

use of com.sun.identity.plugin.configuration.ConfigurationException in project OpenAM by OpenRock.

the class CircleOfTrustManager method createCircleOfTrust.

/**
     * Creates a circle of trust.
     *
     * @param realm the realm under which the circle of trust will be created.
     * @param cotDescriptor the circle of trust descriptor object to be created.
     * @throws COTException if unable to create the circle of trust.
     */
public void createCircleOfTrust(String realm, CircleOfTrustDescriptor cotDescriptor) throws COTException {
    String classMethod = "COTManager.createCircleOfTrust: ";
    if (cotDescriptor == null) {
        throw new COTException("nullCot", null);
    }
    String entityId = null;
    if (realm == null) {
        realm = "/";
    }
    String name = cotDescriptor.getCircleOfTrustName();
    if ((name == null) || (name.trim().length() == 0)) {
        String[] data = { realm };
        LogUtil.error(Level.INFO, LogUtil.NO_COT_NAME_CREATE_COT_DESCRIPTOR, data);
        throw new COTException("invalidCOTName", null);
    }
    if (getAllCirclesOfTrust(realm).contains(name)) {
        debug.error(classMethod + "Circle of trust already exists" + name);
        String[] data = { name, realm };
        LogUtil.error(Level.INFO, LogUtil.COT_EXISTS_CREATE_COT_DESCRIPTOR, data);
        throw new COTException("cotExists", data);
    }
    Map attrs = cotDescriptor.getAttributes();
    // Filter out the entityid which does not exist in the system
    Map tpMap = checkAndSetTrustedProviders(realm, cotDescriptor);
    // update the extended entity config
    if (tpMap != null) {
        updateEntityConfig(realm, name, COTConstants.SAML2, (Set) tpMap.get(COTConstants.SAML2));
        updateEntityConfig(realm, name, COTConstants.IDFF, (Set) tpMap.get(COTConstants.IDFF));
        updateEntityConfig(realm, name, COTConstants.WS_FED, (Set) tpMap.get(COTConstants.WS_FED));
    }
    // create the cot node
    try {
        configInst.createConfiguration(realm, name, attrs);
        if (debug.messageEnabled()) {
            debug.message(classMethod + "circle of trust is created.");
        }
        String[] data = { name, realm };
        LogUtil.access(Level.INFO, LogUtil.COT_DESCRIPTOR_CREATED, data);
    } catch (ConfigurationException e) {
        debug.error(classMethod, e);
        String[] data = { e.getMessage(), name, realm };
        LogUtil.error(Level.INFO, LogUtil.CONFIG_ERROR_CREATE_COT_DESCRIPTOR, data);
        throw new COTException(e);
    }
}
Also used : ConfigurationException(com.sun.identity.plugin.configuration.ConfigurationException) HashMap(java.util.HashMap) Map(java.util.Map)

Example 4 with ConfigurationException

use of com.sun.identity.plugin.configuration.ConfigurationException in project OpenAM by OpenRock.

the class CircleOfTrustManager method modifyCircleOfTrust.

/**
     * Modifies the attributes of a circle of trust.
     *
     * @param realm the realm the circle of trust is in.
     * @param cotDescriptor circle of trust descriptor that contains
     *        the new set of attributes
     * @throws COTException if unable to modify the circle of trust.
     */
public void modifyCircleOfTrust(String realm, CircleOfTrustDescriptor cotDescriptor) throws COTException {
    String classMethod = "COTManager.modifyCircleOfTrust :";
    if (cotDescriptor == null) {
        throw new COTException("nullCot", null);
    }
    if (realm == null) {
        realm = "/";
    }
    String name = cotDescriptor.getCircleOfTrustName();
    isValidCOTName(realm, name);
    try {
        Map attrs = cotDescriptor.getAttributes();
        configInst.setConfiguration(realm, name, attrs);
    } catch (ConfigurationException e) {
        debug.error(classMethod, e);
        String[] data = { e.getMessage(), name, realm };
        LogUtil.error(Level.INFO, LogUtil.CONFIG_ERROR_MODIFY_COT_DESCRIPTOR, data);
        throw new COTException(e);
    }
}
Also used : ConfigurationException(com.sun.identity.plugin.configuration.ConfigurationException) HashMap(java.util.HashMap) Map(java.util.Map)

Example 5 with ConfigurationException

use of com.sun.identity.plugin.configuration.ConfigurationException in project OpenAM by OpenRock.

the class SystemConfigurationUtil method getServiceAllURLs.

/**
     * Returns all service urls.
     * @return list of server names.
     * @throws SystemConfigurationException if unable to get the server list.
     */
public static Collection getServiceAllURLs(String serviceName) throws SystemConfigurationException {
    // TODO: Is this implementation still used?
    if (!platformNamingInitialized) {
        initPlatformNaming();
    }
    if (serviceName == null) {
        throw new SystemConfigurationException("missingServiceName");
    }
    Collection allurls = null;
    String name = "iplanet-am-naming-" + serviceName.toLowerCase() + "-url";
    Set<String> values = null;
    try {
        values = (Set<String>) namingConfig.getConfiguration(null, null).get(name);
    } catch (ConfigurationException cex) {
        getDebug().error("SystemConfigurationUtil.getServiceURL:", cex);
    }
    if ((values) == null || values.isEmpty()) {
        Object[] data = { serviceName };
        throw new SystemConfigurationException("noServiceURL", data);
    }
    for (String url : values) {
        if (url != null) {
            try {
                allurls.add(new URL(url));
            } catch (MalformedURLException muex) {
                Object[] data = { serviceName };
                throw new SystemConfigurationException("noServiceURL", data);
            }
        } else {
            Object[] data = { serviceName };
            throw new SystemConfigurationException("noServiceURL", data);
        }
    }
    return allurls;
}
Also used : MalformedURLException(java.net.MalformedURLException) ConfigurationException(com.sun.identity.plugin.configuration.ConfigurationException) Collection(java.util.Collection) URL(java.net.URL)

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