Search in sources :

Example 16 with SAML2MetaException

use of com.sun.identity.saml2.meta.SAML2MetaException in project OpenAM by OpenRock.

the class SAML2MetaManager method getEntityByMetaAlias.

/**
     * Returns entity ID associated with the metaAlias.
     * @param metaAlias The metaAlias.
     * @return entity ID associated with the metaAlias or null if not found.
     * @throws SAML2MetaException if unable to retrieve the entity ids.
     */
public String getEntityByMetaAlias(String metaAlias) throws SAML2MetaException {
    String realm = SAML2MetaUtils.getRealmByMetaAlias(metaAlias);
    try {
        Set entityIds = configInst.getAllConfigurationNames(realm);
        if (entityIds == null || entityIds.isEmpty()) {
            return null;
        }
        for (Iterator iter = entityIds.iterator(); iter.hasNext(); ) {
            String entityId = (String) iter.next();
            EntityConfigElement config = getEntityConfig(realm, entityId);
            if ((config == null) || !config.isHosted()) {
                continue;
            }
            List list = config.getIDPSSOConfigOrSPSSOConfigOrAuthnAuthorityConfig();
            for (Iterator iter2 = list.iterator(); iter2.hasNext(); ) {
                BaseConfigType bConfig = (BaseConfigType) iter2.next();
                String cMetaAlias = bConfig.getMetaAlias();
                if (cMetaAlias != null && cMetaAlias.equals(metaAlias)) {
                    return entityId;
                }
            }
        }
    } catch (ConfigurationException e) {
        debug.error("SAML2MetaManager.getEntityByMetaAlias:", e);
        throw new SAML2MetaException(e);
    }
    return null;
}
Also used : BaseConfigType(com.sun.identity.saml2.jaxb.entityconfig.BaseConfigType) HashSet(java.util.HashSet) Set(java.util.Set) ConfigurationException(com.sun.identity.plugin.configuration.ConfigurationException) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) EntityConfigElement(com.sun.identity.saml2.jaxb.entityconfig.EntityConfigElement)

Example 17 with SAML2MetaException

use of com.sun.identity.saml2.meta.SAML2MetaException in project OpenAM by OpenRock.

the class SAML2MetaManager method getAttributeQueryConfig.

/**
     * Returns first attribute query 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>AttributeQueryConfigElement</code> for the entity or
     *     null if not found.
     * @throws SAML2MetaException if unable to retrieve the first attribute
     *     query configuration.
     */
public AttributeQueryConfigElement getAttributeQueryConfig(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 AttributeQueryConfigElement) {
            return (AttributeQueryConfigElement) obj;
        }
    }
    return null;
}
Also used : Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) AttributeQueryConfigElement(com.sun.identity.saml2.jaxb.entityconfig.AttributeQueryConfigElement) EntityConfigElement(com.sun.identity.saml2.jaxb.entityconfig.EntityConfigElement)

Example 18 with SAML2MetaException

use of com.sun.identity.saml2.meta.SAML2MetaException in project OpenAM by OpenRock.

the class SAML2MetaManager method getIDPSSOConfig.

/**
     * Returns first identity provider's SSO 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>IDPSSOConfigElement</code> for the entity or null if not
     *         found.
     * @throws SAML2MetaException if unable to retrieve the first identity
     *                            provider's SSO configuration.
     */
public IDPSSOConfigElement getIDPSSOConfig(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 IDPSSOConfigElement) {
            return (IDPSSOConfigElement) obj;
        }
    }
    return null;
}
Also used : Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) IDPSSOConfigElement(com.sun.identity.saml2.jaxb.entityconfig.IDPSSOConfigElement) EntityConfigElement(com.sun.identity.saml2.jaxb.entityconfig.EntityConfigElement)

Example 19 with SAML2MetaException

use of com.sun.identity.saml2.meta.SAML2MetaException in project OpenAM by OpenRock.

the class SAML2MetaManager method isTrustedProvider.

/**
     * Determines whether two entities are in the same circle of trust
     * under the realm.
     * @param realm The realm under which the entity resides.
     * @param entityId The ID of the entity
     * @param trustedEntityId The ID of the entity 
     * @throws SAML2MetaException if unable to determine the trusted
     *         relationship.
     */
public boolean isTrustedProvider(String realm, String entityId, String trustedEntityId) throws SAML2MetaException {
    boolean result = false;
    SPSSOConfigElement spconfig = getSPSSOConfig(realm, entityId);
    if (spconfig != null) {
        result = isSameCircleOfTrust(spconfig, realm, trustedEntityId);
    }
    if (result) {
        return true;
    }
    IDPSSOConfigElement idpconfig = getIDPSSOConfig(realm, entityId);
    if (idpconfig != null) {
        return (isSameCircleOfTrust(idpconfig, realm, trustedEntityId));
    }
    return false;
}
Also used : SPSSOConfigElement(com.sun.identity.saml2.jaxb.entityconfig.SPSSOConfigElement) IDPSSOConfigElement(com.sun.identity.saml2.jaxb.entityconfig.IDPSSOConfigElement)

Example 20 with SAML2MetaException

use of com.sun.identity.saml2.meta.SAML2MetaException in project OpenAM by OpenRock.

the class SAML2MetaManager method getPolicyDecisionPointConfig.

/**
     * Returns first policy decision point 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 policy decision point configuration or null if it is not found.
     * @throws SAML2MetaException if unable to retrieve the configuration.
     */
public XACMLPDPConfigElement getPolicyDecisionPointConfig(String realm, String entityId) throws SAML2MetaException {
    XACMLPDPConfigElement elm = null;
    EntityConfigElement eConfig = getEntityConfig(realm, entityId);
    if (eConfig != null) {
        List list = eConfig.getIDPSSOConfigOrSPSSOConfigOrAuthnAuthorityConfig();
        for (Iterator i = list.iterator(); i.hasNext() && (elm == null); ) {
            Object obj = i.next();
            if (obj instanceof XACMLPDPConfigElement) {
                elm = (XACMLPDPConfigElement) obj;
            }
        }
    }
    return elm;
}
Also used : Iterator(java.util.Iterator) XACMLPDPConfigElement(com.sun.identity.saml2.jaxb.entityconfig.XACMLPDPConfigElement) ArrayList(java.util.ArrayList) List(java.util.List) EntityConfigElement(com.sun.identity.saml2.jaxb.entityconfig.EntityConfigElement)

Aggregations

SAML2MetaException (com.sun.identity.saml2.meta.SAML2MetaException)138 List (java.util.List)106 SAML2MetaManager (com.sun.identity.saml2.meta.SAML2MetaManager)90 ArrayList (java.util.ArrayList)80 Iterator (java.util.Iterator)55 Map (java.util.Map)50 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)47 SAML2Exception (com.sun.identity.saml2.common.SAML2Exception)44 EntityConfigElement (com.sun.identity.saml2.jaxb.entityconfig.EntityConfigElement)43 HashMap (java.util.HashMap)41 SPSSOConfigElement (com.sun.identity.saml2.jaxb.entityconfig.SPSSOConfigElement)30 BaseConfigType (com.sun.identity.saml2.jaxb.entityconfig.BaseConfigType)29 EntityDescriptorElement (com.sun.identity.saml2.jaxb.metadata.EntityDescriptorElement)28 JAXBException (javax.xml.bind.JAXBException)28 SPSSODescriptorElement (com.sun.identity.saml2.jaxb.metadata.SPSSODescriptorElement)26 IDPSSODescriptorElement (com.sun.identity.saml2.jaxb.metadata.IDPSSODescriptorElement)24 IDPSSOConfigElement (com.sun.identity.saml2.jaxb.entityconfig.IDPSSOConfigElement)23 Set (java.util.Set)20 IOException (java.io.IOException)15 HashSet (java.util.HashSet)15