Search in sources :

Example 11 with SAML2MetaException

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

the class SAML2MetaManager method getSPSSOConfig.

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

Example 12 with SAML2MetaException

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

the class SAML2MetaManager method getPolicyEnforcementPointConfig.

/**
     * Returns first policy enforcement 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 XACMLAuthzDecisionQueryConfigElement getPolicyEnforcementPointConfig(String realm, String entityId) throws SAML2MetaException {
    XACMLAuthzDecisionQueryConfigElement 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 XACMLAuthzDecisionQueryConfigElement) {
                elm = (XACMLAuthzDecisionQueryConfigElement) obj;
            }
        }
    }
    return elm;
}
Also used : Iterator(java.util.Iterator) XACMLAuthzDecisionQueryConfigElement(com.sun.identity.saml2.jaxb.entityconfig.XACMLAuthzDecisionQueryConfigElement) ArrayList(java.util.ArrayList) List(java.util.List) EntityConfigElement(com.sun.identity.saml2.jaxb.entityconfig.EntityConfigElement)

Example 13 with SAML2MetaException

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

the class SAML2MetaManager method getEntityDescriptor.

/**
     * Returns the standard metadata entity descriptor under the realm.
     * @param realm The realm under which the entity resides.
     * @param entityId ID of the entity to be retrieved. 
     * @return <code>EntityDescriptorElement</code> for the entity or null if
     *         not found. 
     * @throws SAML2MetaException if unable to retrieve the entity descriptor. 
     */
public EntityDescriptorElement getEntityDescriptor(String realm, String entityId) throws SAML2MetaException {
    if (entityId == null) {
        return null;
    }
    if (realm == null) {
        realm = "/";
    }
    String[] objs = { entityId, realm };
    EntityDescriptorElement descriptor = null;
    if (callerSession == null) {
        descriptor = SAML2MetaCache.getEntityDescriptor(realm, entityId);
        if (descriptor != null) {
            if (debug.messageEnabled()) {
                debug.message("SAML2MetaManager.getEntityDescriptor: got " + "descriptor from SAML2MetaCache " + entityId);
            }
            LogUtil.access(Level.FINE, LogUtil.GOT_ENTITY_DESCRIPTOR, objs, null);
            return descriptor;
        }
    }
    try {
        Map attrs = configInst.getConfiguration(realm, entityId);
        if (attrs == null) {
            return null;
        }
        Set values = (Set) attrs.get(ATTR_METADATA);
        if ((values == null) || values.isEmpty()) {
            return null;
        }
        String value = (String) values.iterator().next();
        Object obj = SAML2MetaUtils.convertStringToJAXB(value);
        if (obj instanceof EntityDescriptorElement) {
            descriptor = (EntityDescriptorElement) obj;
            SAML2MetaCache.putEntityDescriptor(realm, entityId, descriptor);
            if (debug.messageEnabled()) {
                debug.message("SAML2MetaManager.getEntityDescriptor: got " + "descriptor from SMS " + entityId);
            }
            LogUtil.access(Level.FINE, LogUtil.GOT_ENTITY_DESCRIPTOR, objs, null);
            return descriptor;
        }
        debug.error("SAML2MetaManager.getEntityDescriptor: invalid descriptor");
        LogUtil.error(Level.INFO, LogUtil.GOT_INVALID_ENTITY_DESCRIPTOR, objs, null);
        throw new SAML2MetaException("invalid_descriptor", objs);
    } catch (ConfigurationException e) {
        debug.error("SAML2MetaManager.getEntityDescriptor", e);
        String[] data = { e.getMessage(), entityId, realm };
        LogUtil.error(Level.INFO, LogUtil.CONFIG_ERROR_GET_ENTITY_DESCRIPTOR, data, null);
        throw new SAML2MetaException(e);
    } catch (JAXBException jaxbe) {
        debug.error("SAML2MetaManager.getEntityDescriptor", jaxbe);
        LogUtil.error(Level.INFO, LogUtil.GOT_INVALID_ENTITY_DESCRIPTOR, objs, null);
        throw new SAML2MetaException("invalid_descriptor", objs);
    }
}
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.saml2.jaxb.metadata.EntityDescriptorElement) Map(java.util.Map)

Example 14 with SAML2MetaException

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

the class SAML2MetaManager method getAllHostedPolicyEnforcementPointMetaAliases.

/**
     * Returns meta aliases of all hosted policy enforcement point under the 
     * realm.
     *
     * @param realm The realm under which the policy enforcement point resides.
     * @return list of meta aliases 
     * @throws SAML2MetaException if unable to retrieve meta aliases.
     */
public List getAllHostedPolicyEnforcementPointMetaAliases(String realm) throws SAML2MetaException {
    List metaAliases = new ArrayList();
    List hostedEntityIds = getAllHostedPolicyEnforcementPointEntities(realm);
    for (Iterator i = hostedEntityIds.iterator(); i.hasNext(); ) {
        String entityId = (String) i.next();
        XACMLAuthzDecisionQueryConfigElement elm = getPolicyEnforcementPointConfig(realm, entityId);
        if (elm != null) {
            metaAliases.add(elm.getMetaAlias());
        }
    }
    return metaAliases;
}
Also used : ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) XACMLAuthzDecisionQueryConfigElement(com.sun.identity.saml2.jaxb.entityconfig.XACMLAuthzDecisionQueryConfigElement)

Example 15 with SAML2MetaException

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

the class SAML2MetaManager method getAllHostedServiceProviderMetaAliases.

/**
     * Returns metaAliases of all hosted service providers under the realm.
     * @param realm The realm under which the service provider metaAliases
     *              reside.
     * @return a <code>List</code> of metaAliases <code>String</code>.
     * @throws SAML2MetaException if unable to retrieve meta aliases.
     */
public List getAllHostedServiceProviderMetaAliases(String realm) throws SAML2MetaException {
    List metaAliases = new ArrayList();
    SPSSOConfigElement spConfig = null;
    List hostedEntityIds = getAllHostedServiceProviderEntities(realm);
    for (Iterator iter = hostedEntityIds.iterator(); iter.hasNext(); ) {
        String entityId = (String) iter.next();
        if ((spConfig = getSPSSOConfig(realm, entityId)) != null) {
            metaAliases.add(spConfig.getMetaAlias());
        }
    }
    return metaAliases;
}
Also used : ArrayList(java.util.ArrayList) SPSSOConfigElement(com.sun.identity.saml2.jaxb.entityconfig.SPSSOConfigElement) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List)

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