Search in sources :

Example 6 with ConfigurationException

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

the class CircleOfTrustManager method getCircleOfTrust.

/**
     * Returns the circle of trust under the realm.
     *
     * @param realm The realm under which the circle of trust resides.
     * @param name Name of the circle of trust.
     * @return <code>SAML2CircleOfTrustDescriptor</code> containing the
     * attributes of the given CircleOfTrust.
     * @throws COTException if unable to retrieve the circle of trust.
     */
public CircleOfTrustDescriptor getCircleOfTrust(String realm, String name) throws COTException {
    String classMethod = "COTManager.getCircleOfTrust :";
    if (realm == null) {
        realm = "/";
    }
    isValidCOTName(realm, name);
    String[] data = { name, realm };
    CircleOfTrustDescriptor cotDesc = COTCache.getCircleOfTrust(realm, name);
    if (cotDesc != null) {
        LogUtil.access(Level.FINE, LogUtil.COT_FROM_CACHE, data);
    } else {
        try {
            Map attrs = configInst.getConfiguration(realm, name);
            if (attrs == null) {
                cotDesc = new CircleOfTrustDescriptor(name, realm, COTConstants.ACTIVE);
            } else {
                cotDesc = new CircleOfTrustDescriptor(name, realm, attrs);
            }
            COTCache.putCircleOfTrust(realm, name, cotDesc);
            LogUtil.access(Level.INFO, LogUtil.COT_DESCRIPTOR_RETRIEVED, data);
        } catch (ConfigurationException e) {
            debug.error(classMethod, e);
            data[0] = e.getMessage();
            data[1] = name;
            data[2] = realm;
            LogUtil.error(Level.INFO, LogUtil.CONFIG_ERROR_GET_COT_DESCRIPTOR, data);
            throw new COTException(e);
        }
    }
    return cotDesc;
}
Also used : ConfigurationException(com.sun.identity.plugin.configuration.ConfigurationException) HashMap(java.util.HashMap) Map(java.util.Map)

Example 7 with ConfigurationException

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

the class SAML2ConfigService method setValues.

/**
     * This method reads values from service schema.
     */
private static synchronized void setValues() {
    if (ci == null) {
        attributes.put(SAML2_FAILOVER_ATTR, "false");
        attributes.put(SAML2_BUFFER_LENGTH, "2048");
        debug.warning("ConfigurationInstance is null, so default values for " + "failover (false) and buffer length (2048) will be set.");
    } else {
        Map attrMap = null;
        try {
            attrMap = ci.getConfiguration(null, null);
        } catch (ConfigurationException ce) {
            debug.error("Exception caught obtaining updated configuration. " + SAML2_FAILOVER_ATTR + " and " + SAML2_BUFFER_LENGTH + " will not be updated. Exception: " + ce, ce);
            return;
        }
        Map newAttributes = new HashMap();
        if (attrMap != null) {
            if (debug.messageEnabled()) {
                debug.message("The updated configuration: " + attrMap);
            }
            Set values = (Set) attrMap.get(SAML2_FAILOVER_ATTR);
            String value = "false";
            if ((values != null) && (values.size() == 1)) {
                value = (String) values.iterator().next();
            } else {
                debug.warning("Value for " + SAML2_FAILOVER_ATTR + " null or size!=1. Defaulting to false.");
            }
            newAttributes.put(SAML2_FAILOVER_ATTR, value);
            values = (Set) attrMap.get(SAML2_BUFFER_LENGTH);
            value = "2048";
            if ((values != null) && (values.size() == 1)) {
                value = (String) values.iterator().next();
            } else {
                debug.warning("Value for " + SAML2_BUFFER_LENGTH + " null or size!=1. Defaulting to 2048.");
            }
            newAttributes.put(SAML2_BUFFER_LENGTH, value);
        } else {
            debug.warning("Attribute map returned from ConfigurationInstance for the SAML2 config is null! " + "Default values for failover (false) and buffer length (2048) will be set.");
        }
        attributes = newAttributes;
    }
    if (debug.messageEnabled()) {
        debug.message("Attributes in SAML2ConfigService updated to: " + attributes);
    }
}
Also used : Set(java.util.Set) ConfigurationException(com.sun.identity.plugin.configuration.ConfigurationException) HashMap(java.util.HashMap) HashMap(java.util.HashMap) Map(java.util.Map)

Example 8 with ConfigurationException

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

the class IDFFMetaManager method getEntityIDByMetaAlias.

/**
     * Returns entity ID associated with the metaAlias.
     *
     * @param metaAlias The Meta Alias of the provider.
     * @return entity ID associated with the metaAlias or null if not found.
     * @throws IDFFMetaException if unable to retrieve the entity id.
     */
public String getEntityIDByMetaAlias(String metaAlias) throws IDFFMetaException {
    try {
        if (metaAlias == null || metaAlias.length() == 0) {
            return null;
        }
        // check cache first
        String entityId = IDFFMetaCache.getEntityByMetaAlias(metaAlias);
        if (entityId != null) {
            if (debug.messageEnabled()) {
                debug.message("IDFFMetaManager.getEntityByMetaAlias :" + " found entity in cache, metaAlias=" + metaAlias + ", ID=" + entityId);
            }
            return entityId;
        }
        String realm = IDFFMetaUtils.getRealmByMetaAlias(metaAlias);
        Set entityIds = idffMetaConfigInstance.getAllConfigurationNames(realm);
        if (entityIds == null || entityIds.isEmpty()) {
            return null;
        }
        for (Iterator iter = entityIds.iterator(); iter.hasNext(); ) {
            String tmpId = (String) iter.next();
            if (debug.messageEnabled()) {
                debug.message("IDFFMetaManager.getEntityByMetaAlias :" + " process entity cache for metaAlias=" + metaAlias + ", ID=" + tmpId);
            }
            SPDescriptorConfigElement spconfig = getSPDescriptorConfig(realm, tmpId);
            if (spconfig != null) {
                String tmpMetaAlias = spconfig.getMetaAlias();
                if (tmpMetaAlias != null && tmpMetaAlias.length() > 0) {
                    if (metaAlias.equals(tmpMetaAlias)) {
                        // remember this and continue to process others,
                        entityId = tmpId;
                    }
                    IDFFMetaCache.setMetaAliasEntityMapping(tmpMetaAlias, tmpId);
                    IDFFMetaCache.setMetaAliasRoleMapping(tmpMetaAlias, IFSConstants.SP);
                    if (debug.messageEnabled()) {
                        debug.message("IDFFMetaManager.getEntityByMetaAlias :" + " save to cache, metaAlias=" + tmpMetaAlias + ", ID=" + tmpId + ", role=" + IFSConstants.SP);
                    }
                }
            }
            IDPDescriptorConfigElement idpconfig = getIDPDescriptorConfig(realm, tmpId);
            if (idpconfig != null) {
                String tmpMetaAlias = idpconfig.getMetaAlias();
                if (tmpMetaAlias != null && tmpMetaAlias.length() > 0) {
                    if (metaAlias.equals(tmpMetaAlias)) {
                        // remember this and continue to process others,
                        entityId = tmpId;
                    }
                    IDFFMetaCache.setMetaAliasEntityMapping(tmpMetaAlias, tmpId);
                    IDFFMetaCache.setMetaAliasRoleMapping(tmpMetaAlias, IFSConstants.IDP);
                    if (debug.messageEnabled()) {
                        debug.message("IDFFMetaManager.getEntityByMetaAlias :" + " save to cache, metaAlias=" + tmpMetaAlias + ", ID=" + tmpId + ", role=" + IFSConstants.IDP);
                    }
                }
            }
        }
        return entityId;
    } catch (ConfigurationException e) {
        debug.error("IDFFMetaManager.getEntityByMetaAlias:", e);
        throw new IDFFMetaException(e);
    }
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) ConfigurationException(com.sun.identity.plugin.configuration.ConfigurationException) Iterator(java.util.Iterator) SPDescriptorConfigElement(com.sun.identity.federation.jaxb.entityconfig.SPDescriptorConfigElement) IDPDescriptorConfigElement(com.sun.identity.federation.jaxb.entityconfig.IDPDescriptorConfigElement)

Example 9 with ConfigurationException

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

the class IDFFMetaManager method getEntityDescriptor.

/**
     * Returns the standard metadata entity descriptor under the realm.
     * @param realm The realm under which the entity resides.
     * @param entityID identifier of the entity to be retrieved.
     * @return <code>EntityDescriptorElement</code> for the entity or null if
     *         not found.
     * @throws IDFFMetaException if unable to retrieve the entity descriptor.
     */
public EntityDescriptorElement getEntityDescriptor(String realm, String entityID) throws IDFFMetaException {
    String classMethod = "IDFFMetaManager.getEntityDescriptor:";
    if (debug.messageEnabled()) {
        debug.message(classMethod + " Retreiving EntityDescriptor");
    }
    EntityDescriptorElement entityDescriptor = null;
    if (entityID != null) {
        if ((realm == null) || (realm.length() == 0)) {
            realm = ROOT_REALM;
        }
        String[] args = { entityID, realm };
        // retrieve from cache
        if (callerSession == null) {
            entityDescriptor = IDFFMetaCache.getEntityDescriptor(realm, entityID);
        }
        if (entityDescriptor == null) {
            try {
                Map attrs = idffMetaConfigInstance.getConfiguration(realm, entityID);
                if (attrs != null) {
                    Set metaValues = (Set) attrs.get(IDFF_METADATA_ATTR);
                    if (metaValues != null && !metaValues.isEmpty()) {
                        String metaValue = (String) metaValues.iterator().next();
                        Object object = IDFFMetaUtils.convertStringToJAXB(metaValue);
                        if (object instanceof EntityDescriptorElement) {
                            entityDescriptor = (EntityDescriptorElement) object;
                            IDFFMetaCache.setEntityDescriptor(realm, entityID, entityDescriptor);
                        } else {
                            debug.error(classMethod + "Invalid standard " + " meta value for : " + entityID);
                        }
                    }
                }
            } catch (ConfigurationException ce) {
                debug.error("Cannot retrieve entity descriptor", ce);
                LogUtil.error(Level.INFO, LogUtil.GET_ENTITY_FAILED, args);
                throw new IDFFMetaException("cannotRetreiveEntityDescriptor", null);
            } catch (JAXBException jaxbe) {
                debug.error(classMethod, jaxbe);
                LogUtil.error(Level.INFO, LogUtil.INVALID_ENTITY_DESCRIPTOR, args);
                throw new IDFFMetaException("invalidEntityDescriptor", args);
            }
        }
        if (entityDescriptor != null) {
            LogUtil.access(Level.INFO, LogUtil.GET_ENTITY_SUCCEEDED, args);
        }
    } else {
        LogUtil.error(Level.INFO, LogUtil.NULL_ENTITY_ID, null);
        throw new IDFFMetaException("nullEntityID", null);
    }
    return entityDescriptor;
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) ConfigurationException(com.sun.identity.plugin.configuration.ConfigurationException) JAXBException(javax.xml.bind.JAXBException) EntityDescriptorElement(com.sun.identity.liberty.ws.meta.jaxb.EntityDescriptorElement) Map(java.util.Map)

Example 10 with ConfigurationException

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

the class IDFFMetaManager method setEntityDescriptor.

/**
     * Sets the standard metadata entity descriptor under the realm.
     * The EntiyDescriptor to be set should exist otherwise an error is
     * thrown.
     *
     * @param realm The realm under which the entity resides.
     * @param entityDescriptor The standard entity descriptor object to be set.
     * @throws IDFFMetaException if there is an error setting the entity
     *         descriptor.
     * @see #createEntityDescriptor(String, EntityDescriptorElement)
     */
public void setEntityDescriptor(String realm, EntityDescriptorElement entityDescriptor) throws IDFFMetaException {
    String classMethod = "IDFFMetaManager:setEntityDescriptor";
    if (entityDescriptor != null) {
        String entityID = entityDescriptor.getProviderID();
        if ((realm == null) || (realm.length() == 0)) {
            realm = ROOT_REALM;
        }
        String[] args = { entityID, realm };
        try {
            Map origEntityAttrs = null;
            if (entityID != null) {
                origEntityAttrs = idffMetaConfigInstance.getConfiguration(realm, entityID);
                Map newAttrs = IDFFMetaUtils.convertJAXBToAttrMap(IDFF_METADATA_ATTR, entityDescriptor);
                origEntityAttrs.put(IDFF_METADATA_ATTR, newAttrs.get(IDFF_METADATA_ATTR));
            } else {
                LogUtil.error(Level.INFO, LogUtil.NULL_ENTITY_ID, args);
                throw new IDFFMetaException("nullEntityID", null);
            }
            idffMetaConfigInstance.setConfiguration(realm, entityID, origEntityAttrs);
            LogUtil.access(Level.INFO, LogUtil.SET_ENTITY_SUCCEEDED, args);
        } catch (ConfigurationException ce) {
            debug.error("Error setting Entity Descriptor ", ce);
            LogUtil.error(Level.INFO, LogUtil.SET_ENTITY_FAILED, args);
            throw new IDFFMetaException(ce);
        } catch (JAXBException jaxbe) {
            debug.error(classMethod + "Invalid EntityID" + entityID, jaxbe);
            LogUtil.error(Level.INFO, LogUtil.INVALID_ENTITY_DESCRIPTOR, args);
            throw new IDFFMetaException("invalidEntityDescriptor", args);
        }
    }
}
Also used : ConfigurationException(com.sun.identity.plugin.configuration.ConfigurationException) JAXBException(javax.xml.bind.JAXBException) Map(java.util.Map)

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