Search in sources :

Example 41 with BaseConfigType

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

the class SAML2Utils method getAllAttributeValueFromSSOConfig.

/**
     * Returns all values of specified attribute from SSOConfig.
     *
     * @param realm        realm of hosted entity.
     * @param hostEntityId name of hosted entity.
     * @param entityRole   role of hosted entity.
     * @param attrName     attribute name for the value.
     * @return value of specified attribute from SSOConfig.
     */
public static List<String> getAllAttributeValueFromSSOConfig(String realm, String hostEntityId, String entityRole, String attrName) {
    if (debug.messageEnabled()) {
        String method = "getAllAttributeValueFromSSOConfig : ";
        debug.message(method + "realm - " + realm);
        debug.message(method + "hostEntityId - " + hostEntityId);
        debug.message(method + "entityRole - " + entityRole);
        debug.message(method + "attrName - " + attrName);
    }
    try {
        BaseConfigType config = null;
        if (entityRole.equalsIgnoreCase(SAML2Constants.SP_ROLE)) {
            config = saml2MetaManager.getSPSSOConfig(realm, hostEntityId);
        } else if (entityRole.equalsIgnoreCase(SAML2Constants.IDP_ROLE)) {
            config = saml2MetaManager.getIDPSSOConfig(realm, hostEntityId);
        } else if (entityRole.equalsIgnoreCase(SAML2Constants.ATTR_AUTH_ROLE)) {
            config = saml2MetaManager.getAttributeAuthorityConfig(realm, hostEntityId);
        } else if (entityRole.equalsIgnoreCase(SAML2Constants.AUTHN_AUTH_ROLE)) {
            config = saml2MetaManager.getAuthnAuthorityConfig(realm, hostEntityId);
        } else if (entityRole.equalsIgnoreCase(SAML2Constants.ATTR_QUERY_ROLE)) {
            config = saml2MetaManager.getAttributeQueryConfig(realm, hostEntityId);
        }
        if (config == null) {
            return null;
        }
        Map attrs = SAML2MetaUtils.getAttributes(config);
        if (attrs == null) {
            return null;
        }
        return (List) attrs.get(attrName);
    } catch (SAML2MetaException e) {
        debug.message("get SSOConfig failed:", e);
    }
    return null;
}
Also used : BaseConfigType(com.sun.identity.saml2.jaxb.entityconfig.BaseConfigType) ArrayList(java.util.ArrayList) List(java.util.List) Map(java.util.Map) HashMap(java.util.HashMap) SAML2MetaException(com.sun.identity.saml2.meta.SAML2MetaException)

Example 42 with BaseConfigType

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

the class SAML2COTUtils method removeFromEntityConfig.

/**
     * Removes the circle trust name passed from the <code>cotlist</code>
     * attribute in the Entity Config. The Service Provider and Identity
     * Provider Entity Configuration are updated.
     *
     * @param name the circle of trust name to be removed.
     * @param entityId the entity identifier of the provider.
     * @throws SAML2MetaException if there is an error updating the entity
     *          config.
     * @throws JAXBException if there is an error updating the entity config.
     */
public void removeFromEntityConfig(String realm, String name, String entityId) throws SAML2MetaException, JAXBException {
    String classMethod = "SAML2COTUtils.removeFromEntityConfig: ";
    SAML2MetaManager metaManager = null;
    if (callerSession == null) {
        metaManager = new SAML2MetaManager();
    } else {
        metaManager = new SAML2MetaManager(callerSession);
    }
    // Check whether the entity id existed in the DS
    EntityDescriptorElement edes = metaManager.getEntityDescriptor(realm, entityId);
    if (edes == null) {
        debug.error(classMethod + "No such entity: " + entityId);
        String[] data = { realm, entityId };
        throw new SAML2MetaException("entityid_invalid", data);
    }
    EntityConfigElement eConfig = metaManager.getEntityConfig(realm, entityId);
    boolean isAffiliation = false;
    if (metaManager.getAffiliationDescriptor(realm, entityId) != null) {
        isAffiliation = true;
    }
    if (debug.messageEnabled()) {
        debug.message(classMethod + "is " + entityId + " in realm " + realm + " an affiliation? " + isAffiliation);
    }
    if (eConfig != null) {
        List elist = null;
        if (isAffiliation) {
            AffiliationConfigElement affiliationCfgElm = metaManager.getAffiliationConfig(realm, entityId);
            elist = new ArrayList();
            elist.add(affiliationCfgElm);
        } else {
            elist = eConfig.getIDPSSOConfigOrSPSSOConfigOrAuthnAuthorityConfig();
        }
        boolean needToSave = false;
        for (Iterator iter = elist.iterator(); iter.hasNext(); ) {
            BaseConfigType bConfig = (BaseConfigType) iter.next();
            List list = bConfig.getAttribute();
            for (Iterator iter2 = list.iterator(); iter2.hasNext(); ) {
                AttributeType avp = (AttributeType) iter2.next();
                if (avp.getName().trim().equalsIgnoreCase(SAML2Constants.COT_LIST)) {
                    List avpl = avp.getValue();
                    if (avpl != null && !avpl.isEmpty() && containsValue(avpl, name)) {
                        avpl.remove(name);
                        needToSave = true;
                        break;
                    }
                }
            }
        }
        if (needToSave) {
            metaManager.setEntityConfig(realm, eConfig);
        }
    }
}
Also used : ArrayList(java.util.ArrayList) EntityDescriptorElement(com.sun.identity.saml2.jaxb.metadata.EntityDescriptorElement) BaseConfigType(com.sun.identity.saml2.jaxb.entityconfig.BaseConfigType) AffiliationConfigElement(com.sun.identity.saml2.jaxb.entityconfig.AffiliationConfigElement) AttributeType(com.sun.identity.saml2.jaxb.entityconfig.AttributeType) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) EntityConfigElement(com.sun.identity.saml2.jaxb.entityconfig.EntityConfigElement)

Example 43 with BaseConfigType

use of com.sun.identity.saml2.jaxb.entityconfig.BaseConfigType 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)

Aggregations

BaseConfigType (com.sun.identity.saml2.jaxb.entityconfig.BaseConfigType)36 List (java.util.List)31 SAML2MetaException (com.sun.identity.saml2.meta.SAML2MetaException)25 ArrayList (java.util.ArrayList)17 SAML2MetaManager (com.sun.identity.saml2.meta.SAML2MetaManager)16 Iterator (java.util.Iterator)15 HashMap (java.util.HashMap)14 Map (java.util.Map)14 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)12 EntityConfigElement (com.sun.identity.saml2.jaxb.entityconfig.EntityConfigElement)11 SAML2Exception (com.sun.identity.saml2.common.SAML2Exception)10 SessionException (com.sun.identity.plugin.session.SessionException)7 AttributeType (com.sun.identity.saml2.jaxb.entityconfig.AttributeType)5 ConfigurationException (com.sun.identity.plugin.configuration.ConfigurationException)4 AffiliationConfigElement (com.sun.identity.saml2.jaxb.entityconfig.AffiliationConfigElement)4 IDPSSOConfigElement (com.sun.identity.saml2.jaxb.entityconfig.IDPSSOConfigElement)4 ObjectFactory (com.sun.identity.saml2.jaxb.entityconfig.ObjectFactory)4 EntityDescriptorElement (com.sun.identity.saml2.jaxb.metadata.EntityDescriptorElement)4 IDPSSODescriptorElement (com.sun.identity.saml2.jaxb.metadata.IDPSSODescriptorElement)4 SessionProvider (com.sun.identity.plugin.session.SessionProvider)3