Search in sources :

Example 46 with ConfigurationException

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

the class CircleOfTrustManager method getAllCirclesOfTrust.

/**
     * Returns a set of names of all circle of trusts.
     *
     * @param realm The realm under which the circle of trust resides.
     * @return Set of names of all circle of trusts.
     * @throws COTException if unable to read circle of trust.
     */
public Set getAllCirclesOfTrust(String realm) throws COTException {
    Set valueSet = null;
    Set cotSet = new HashSet();
    if (realm == null) {
        realm = COTConstants.ROOT_REALM;
    }
    String classMethod = "COTManager.getAllCircleOfTrust: ";
    try {
        valueSet = configInst.getAllConfigurationNames(realm);
        if ((valueSet != null) && !valueSet.isEmpty()) {
            for (Iterator iter = valueSet.iterator(); iter.hasNext(); ) {
                String name = (String) iter.next();
                cotSet.add(name);
            }
        }
    } catch (ConfigurationException e) {
        debug.error(classMethod, e);
        String[] data = { e.getMessage(), realm };
        LogUtil.error(Level.INFO, LogUtil.CONFIG_ERROR_GET_ALL_COT_DESCRIPTOR, data);
        throw new COTException(e);
    }
    return cotSet;
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) ConfigurationException(com.sun.identity.plugin.configuration.ConfigurationException) Iterator(java.util.Iterator) HashSet(java.util.HashSet)

Example 47 with ConfigurationException

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

the class CircleOfTrustManager method listCircleOfTrustMember.

/**
     * Lists trusted providers in a circle of trust under the realm.
     *
     * @param realm The realm under which the circle of trust will be
     *              modified.
     * @param cotName the name of the circle of trust
     * @param protocolType the federation protocol for the entities.
     * @return Set of trusted providers or null if no member in the
     *                circle of trust
     * @throws COTException if unable to list member in the
     *         circle of trust.
     */
public Set listCircleOfTrustMember(String realm, String cotName, String protocolType) throws COTException {
    String classMethod = "COTManager.listCircleOfTrustMember: ";
    if ((cotName == null) || (cotName.trim().length() == 0)) {
        String[] data = { realm };
        LogUtil.error(Level.INFO, LogUtil.NULL_COT_NAME_LIST_COT, data);
        throw new COTException("invalidCOTName", null);
    }
    if (realm == null) {
        realm = "/";
    }
    Set trustedProviders = new HashSet();
    try {
        CircleOfTrustDescriptor cotDesc = null;
        Map attrs = configInst.getConfiguration(realm, cotName);
        if (attrs == null) {
            return null;
        } else {
            isValidProtocolType(protocolType);
            cotDesc = new CircleOfTrustDescriptor(cotName, realm, attrs);
            trustedProviders = cotDesc.getTrustedProviders(protocolType);
        }
    } catch (ConfigurationException e) {
        debug.error(classMethod, e);
        String[] data = { e.getMessage(), cotName, realm };
        LogUtil.error(Level.INFO, LogUtil.CONFIG_ERROR_LIST_COT_MEMBER, data);
        throw new COTException(e);
    }
    return trustedProviders;
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) ConfigurationException(com.sun.identity.plugin.configuration.ConfigurationException) HashMap(java.util.HashMap) Map(java.util.Map) HashSet(java.util.HashSet)

Example 48 with ConfigurationException

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

the class CircleOfTrustManager method deleteCircleOfTrust.

/**
     * Deletes the circle of trust under the realm.
     *
     * @param realm The realm under which the circle of trust resides.
     * @param cotName Name of the circle of trust.
     * @throws COTException if unable to delete the circle of trust.
     */
public void deleteCircleOfTrust(String realm, String cotName) throws COTException {
    String classMethod = "COTManager.deleteCircleOfTrust:";
    if (realm == null) {
        realm = "/";
    }
    String[] data = { cotName, realm };
    isValidCOTName(realm, cotName);
    try {
        Set trustProviders = null;
        Map attrs = configInst.getConfiguration(realm, cotName);
        if (attrs != null) {
            CircleOfTrustDescriptor cotDesc = new CircleOfTrustDescriptor(cotName, realm, attrs);
            trustProviders = cotDesc.getTrustedProviders();
        }
        if (attrs == null || trustProviders == null || trustProviders.isEmpty()) {
            configInst.deleteConfiguration(realm, cotName, null);
            LogUtil.access(Level.INFO, LogUtil.COT_DESCRIPTOR_DELETED, data);
        } else {
            debug.error(classMethod + "Delete circle of trust" + " is not allowed since it contains members.");
            LogUtil.error(Level.INFO, LogUtil.HAS_ENTITIES_DELETE_COT_DESCRIPTOR, data);
            String[] args = { cotName, realm };
            throw new COTException("deleteCOTFailedHasMembers", args);
        }
    } catch (ConfigurationException e) {
        debug.error(classMethod, e);
        String[] args = { e.getMessage(), cotName, realm };
        LogUtil.error(Level.INFO, LogUtil.CONFIG_ERROR_DELETE_COT_DESCRIPTOR, args);
        throw new COTException(e);
    }
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) ConfigurationException(com.sun.identity.plugin.configuration.ConfigurationException) HashMap(java.util.HashMap) Map(java.util.Map)

Example 49 with ConfigurationException

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

the class SystemConfigurationUtil method getServiceURL.

/**
     * Returns the URL of the specified service on the specified host.
     * @param serviceName The name of the service.
     * @param protocol The service protocol.
     * @param hostname The service host name.
     * @param port The service listening port.
     * @param uri The service URI.
     * @return The URL of the specified service on the specified host.
     * @throws SystemConfigurationException if the URL could not be found.
     */
public static URL getServiceURL(String serviceName, String protocol, String hostname, int port, String uri) throws SystemConfigurationException {
    if (!platformNamingInitialized) {
        initPlatformNaming();
    }
    if ((protocol == null) || (protocol.length() == 0) || (hostname == null) || (hostname.length() == 0)) {
        throw new SystemConfigurationException("missingProtHost");
    }
    String name = "iplanet-am-naming-" + serviceName.toLowerCase() + "-url";
    Set values = null;
    try {
        values = (Set) 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);
    }
    String url = (String) values.iterator().next();
    if (url != null) {
        if ((url.indexOf("%") != -1) && (!validate(protocol, hostname, port, uri))) {
            Object[] data = { serviceName };
            throw new SystemConfigurationException("noServiceURL", data);
        }
        int idx;
        if ((idx = url.indexOf("%protocol")) != -1) {
            url = url.substring(0, idx) + protocol + url.substring(idx + "%protocol".length(), url.length());
        }
        if ((idx = url.indexOf("%host")) != -1) {
            url = url.substring(0, idx) + hostname + url.substring(idx + "%host".length(), url.length());
        }
        if ((idx = url.indexOf("%port")) != -1) {
            url = url.substring(0, idx) + port + url.substring(idx + "%port".length(), url.length());
        }
        if ((uri != null) && (idx = url.indexOf("%uri")) != -1) {
            url = url.substring(0, idx) + uri + url.substring(idx + "%uri".length(), url.length());
        }
        try {
            return new URL(url);
        } catch (MalformedURLException muex) {
            Object[] data = { serviceName };
            throw new SystemConfigurationException("noServiceURL", data);
        }
    } else {
        Object[] data = { serviceName };
        throw new SystemConfigurationException("noServiceURL", data);
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) Set(java.util.Set) ConfigurationException(com.sun.identity.plugin.configuration.ConfigurationException) URL(java.net.URL)

Example 50 with ConfigurationException

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

the class IDFFMetaManager method getAllEntities.

/**
     * Returns all entities under the realm.
     *
     * @param realm The realm under which the hosted entities reside.
     * @return a <code>Set</code> of entity ID <code>String</code>.
     * @throws IDFFMetaException if unable to retrieve the entity ids.
     */
public Set getAllEntities(String realm) throws IDFFMetaException {
    Set entityIDSet = new HashSet();
    try {
        Set entityIDs = idffMetaConfigInstance.getAllConfigurationNames(realm);
        if (entityIDs != null && !entityIDs.isEmpty()) {
            entityIDSet.addAll(entityIDs);
        }
        LogUtil.access(Level.INFO, LogUtil.GET_ENTITY_NAMES_SUCCEEDED, null);
    } catch (ConfigurationException e) {
        debug.error("IDFFMetaManager.getAllEntities:", e);
        LogUtil.error(Level.INFO, LogUtil.GET_ENTITY_NAMES_FAILED, null);
        throw new IDFFMetaException(e);
    }
    return entityIDSet;
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) ConfigurationException(com.sun.identity.plugin.configuration.ConfigurationException) HashSet(java.util.HashSet)

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