Search in sources :

Example 31 with EntityConfigElement

use of com.sun.identity.saml2.jaxb.entityconfig.EntityConfigElement in project OpenAM by OpenRock.

the class SAML2MetaCache method getEntityConfig.

/**
     * Returns extended entity configuration under the realm from cache.
     * @param realm The realm under which the entity resides.
     * @param entityId ID of the entity to be retrieved.
     * @return <code>EntityConfigElement</code> object for the entity or null
     *         if not found.
     */
static EntityConfigElement getEntityConfig(String realm, String entityId) {
    String cacheKey = buildCacheKey(realm, entityId);
    EntityConfigElement config = (EntityConfigElement) configCache.get(cacheKey);
    if (debug.messageEnabled()) {
        debug.message("SAML2MetaCache.getEntityConfig: cacheKey = " + cacheKey + ", found = " + (config != null));
    }
    return config;
}
Also used : EntityConfigElement(com.sun.identity.saml2.jaxb.entityconfig.EntityConfigElement)

Example 32 with EntityConfigElement

use of com.sun.identity.saml2.jaxb.entityconfig.EntityConfigElement in project OpenAM by OpenRock.

the class SAML2MetaManager method getAuthnAuthorityConfig.

/**
     * Returns first authentication authority configuration in an entity under
     * the realm.
     * @param realm The realm under which the entity resides.
     * @param entityId ID of the entity to be retrieved.
     * @return <code>AuthnAuthorityConfigElement</code> for the entity or
     *     null if not found.
     * @throws SAML2MetaException if unable to retrieve the first authentication
     *     authority configuration.
     */
public AuthnAuthorityConfigElement getAuthnAuthorityConfig(String realm, String entityId) throws SAML2MetaException {
    EntityConfigElement eConfig = getEntityConfig(realm, entityId);
    if (eConfig == null) {
        return null;
    }
    List list = eConfig.getIDPSSOConfigOrSPSSOConfigOrAuthnAuthorityConfig();
    for (Iterator iter = list.iterator(); iter.hasNext(); ) {
        Object obj = iter.next();
        if (obj instanceof AuthnAuthorityConfigElement) {
            return (AuthnAuthorityConfigElement) obj;
        }
    }
    return null;
}
Also used : Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) AuthnAuthorityConfigElement(com.sun.identity.saml2.jaxb.entityconfig.AuthnAuthorityConfigElement) EntityConfigElement(com.sun.identity.saml2.jaxb.entityconfig.EntityConfigElement)

Example 33 with EntityConfigElement

use of com.sun.identity.saml2.jaxb.entityconfig.EntityConfigElement in project OpenAM by OpenRock.

the class SAML2MetaManager method getAllRemoteEntities.

/**
     * Returns all remote entities under the realm.
     * @param realm The realm under which the hosted entities reside.
     * @return a <code>List</code> of entity ID <code>String</code>.
     * @throws SAML2MetaException if unable to retrieve the entity ids.
     */
public List getAllRemoteEntities(String realm) throws SAML2MetaException {
    List remoteEntityIds = new ArrayList();
    String[] objs = { realm };
    try {
        Set entityIds = configInst.getAllConfigurationNames(realm);
        if (entityIds != null && !entityIds.isEmpty()) {
            for (Iterator iter = entityIds.iterator(); iter.hasNext(); ) {
                String entityId = (String) iter.next();
                EntityConfigElement config = getEntityConfig(realm, entityId);
                if (config == null || !config.isHosted()) {
                    remoteEntityIds.add(entityId);
                }
            }
        }
    } catch (ConfigurationException e) {
        debug.error("SAML2MetaManager.getAllRemoteEntities:", e);
        String[] data = { e.getMessage(), realm };
        LogUtil.error(Level.INFO, LogUtil.CONFIG_ERROR_GET_ALL_REMOTE_ENTITIES, data, null);
        throw new SAML2MetaException(e);
    }
    LogUtil.access(Level.FINE, LogUtil.GOT_ALL_REMOTE_ENTITIES, objs, null);
    return remoteEntityIds;
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) ConfigurationException(com.sun.identity.plugin.configuration.ConfigurationException) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) EntityConfigElement(com.sun.identity.saml2.jaxb.entityconfig.EntityConfigElement)

Example 34 with EntityConfigElement

use of com.sun.identity.saml2.jaxb.entityconfig.EntityConfigElement in project OpenAM by OpenRock.

the class SAML2MetaManager method addToCircleOfTrust.

private void addToCircleOfTrust(String realm, String entityId, EntityConfigElement eConfig) {
    try {
        if (eConfig != null) {
            List elist = eConfig.getIDPSSOConfigOrSPSSOConfigOrAuthnAuthorityConfig();
            // use first one to add the entity to COT
            BaseConfigType config = (BaseConfigType) elist.iterator().next();
            Map attr = SAML2MetaUtils.getAttributes(config);
            List cotAttr = (List) attr.get(SAML2Constants.COT_LIST);
            List cotList = new ArrayList(cotAttr);
            if ((cotList != null) && !cotList.isEmpty()) {
                for (Iterator iter = cotList.iterator(); iter.hasNext(); ) {
                    String cotName = ((String) iter.next()).trim();
                    if ((cotName != null) && (!cotName.equals(""))) {
                        cotm.addCircleOfTrustMember(realm, cotName, COTConstants.SAML2, entityId, false);
                    }
                }
            }
        }
    } catch (Exception e) {
        debug.error("SAML2MetaManager.addToCircleOfTrust:" + "Error while adding entity" + entityId + "to COT.", e);
    }
}
Also used : BaseConfigType(com.sun.identity.saml2.jaxb.entityconfig.BaseConfigType) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) Map(java.util.Map) COTException(com.sun.identity.cot.COTException) ConfigurationException(com.sun.identity.plugin.configuration.ConfigurationException) JAXBException(javax.xml.bind.JAXBException)

Example 35 with EntityConfigElement

use of com.sun.identity.saml2.jaxb.entityconfig.EntityConfigElement in project OpenAM by OpenRock.

the class SAML2MetaManager method getAttributeAuthorityConfig.

/**
     * Returns first attribute authority configuration in an entity under
     * the realm.
     * @param realm The realm under which the entity resides.
     * @param entityId ID of the entity to be retrieved.
     * @return <code>AttributeAuthorityConfigElement</code> for the entity or
     *     null if not found.
     * @throws SAML2MetaException if unable to retrieve the first attribute
     *     authority configuration.
     */
public AttributeAuthorityConfigElement getAttributeAuthorityConfig(String realm, String entityId) throws SAML2MetaException {
    EntityConfigElement eConfig = getEntityConfig(realm, entityId);
    if (eConfig == null) {
        return null;
    }
    List list = eConfig.getIDPSSOConfigOrSPSSOConfigOrAuthnAuthorityConfig();
    for (Iterator iter = list.iterator(); iter.hasNext(); ) {
        Object obj = iter.next();
        if (obj instanceof AttributeAuthorityConfigElement) {
            return (AttributeAuthorityConfigElement) obj;
        }
    }
    return null;
}
Also used : Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) AttributeAuthorityConfigElement(com.sun.identity.saml2.jaxb.entityconfig.AttributeAuthorityConfigElement) EntityConfigElement(com.sun.identity.saml2.jaxb.entityconfig.EntityConfigElement)

Aggregations

EntityConfigElement (com.sun.identity.saml2.jaxb.entityconfig.EntityConfigElement)44 List (java.util.List)26 SAML2MetaManager (com.sun.identity.saml2.meta.SAML2MetaManager)23 SAML2MetaException (com.sun.identity.saml2.meta.SAML2MetaException)22 ArrayList (java.util.ArrayList)21 Iterator (java.util.Iterator)19 JAXBException (javax.xml.bind.JAXBException)18 BaseConfigType (com.sun.identity.saml2.jaxb.entityconfig.BaseConfigType)12 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)11 EntityDescriptorElement (com.sun.identity.saml2.jaxb.metadata.EntityDescriptorElement)10 COTException (com.sun.identity.cot.COTException)8 ConfigurationException (com.sun.identity.plugin.configuration.ConfigurationException)8 Set (java.util.Set)8 Map (java.util.Map)7 SPSSOConfigElement (com.sun.identity.saml2.jaxb.entityconfig.SPSSOConfigElement)6 HashSet (java.util.HashSet)6 IDPSSOConfigElement (com.sun.identity.saml2.jaxb.entityconfig.IDPSSOConfigElement)5 AttributeType (com.sun.identity.saml2.jaxb.entityconfig.AttributeType)4 ObjectFactory (com.sun.identity.saml2.jaxb.entityconfig.ObjectFactory)4 CLIException (com.sun.identity.cli.CLIException)3