Search in sources :

Example 6 with AttributeType

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

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

the class SAMLv2ModelImpl method getPEPConfig.

/**
     * Returns a <code>Map</code> containing the extended metadata for the PEP.
     *
     * @param realm where entity exists.
     * @param entityName name of entity descriptor.
     * @param location if the entity is remote or hosted.
     * @return key-value pair Map of PEP config data.
     * @throws AMConsoleException if unable to retrieve the PEP
     *         extended metadata attribute
     */
public Map getPEPConfig(String realm, String entityName, String location) throws AMConsoleException {
    String[] params = { realm, entityName, "SAMLv2", "XACML PEP" };
    logEvent("ATTEMPT_GET_ENTITY_DESCRIPTOR_ATTR_VALUES", params);
    String role = EntityModel.POLICY_ENFORCEMENT_POINT_DESCRIPTOR;
    Map data = null;
    List configList = null;
    String metaAlias = null;
    try {
        SAML2MetaManager saml2Manager = getSAML2MetaManager();
        XACMLAuthzDecisionQueryConfigElement xacmlAuthzConfigElement = saml2Manager.getPolicyEnforcementPointConfig(realm, entityName);
        if (xacmlAuthzConfigElement != null) {
            data = new HashMap();
            configList = xacmlAuthzConfigElement.getAttribute();
            metaAlias = xacmlAuthzConfigElement.getMetaAlias();
            int size = configList.size();
            for (int i = 0; i < size; i++) {
                AttributeType atype = (AttributeType) configList.get(i);
                String name = atype.getName();
                java.util.List value = atype.getValue();
                data.put(atype.getName(), returnEmptySetIfValueIsNull(atype.getValue()));
            }
            data.put("metaAlias", metaAlias);
        } else {
            createExtendedObject(realm, entityName, location, role);
        }
        logEvent("SUCCEED_GET_ENTITY_DESCRIPTOR_ATTR_VALUES", params);
    } catch (JAXBException e) {
        String strError = getErrorString(e);
        String[] paramsEx = { realm, entityName, "SAMLv2", "XACML PEP", strError };
        logEvent("FEDERATION_EXCEPTION_GET_ENTITY_DESCRIPTOR_ATTR_VALUES", paramsEx);
        throw new AMConsoleException(strError);
    } catch (SAML2MetaException e) {
        String strError = getErrorString(e);
        String[] paramsEx = { realm, entityName, "SAMLv2", "XACML PEP", strError };
        logEvent("FEDERATION_EXCEPTION_GET_ENTITY_DESCRIPTOR_ATTR_VALUES", paramsEx);
        throw new AMConsoleException(strError);
    }
    return (data != null) ? data : Collections.EMPTY_MAP;
}
Also used : HashMap(java.util.HashMap) JAXBException(javax.xml.bind.JAXBException) SAML2MetaManager(com.sun.identity.saml2.meta.SAML2MetaManager) List(java.util.List) AttributeType(com.sun.identity.saml2.jaxb.entityconfig.AttributeType) List(java.util.List) ArrayList(java.util.ArrayList) XACMLAuthzDecisionQueryConfigElement(com.sun.identity.saml2.jaxb.entityconfig.XACMLAuthzDecisionQueryConfigElement) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) Map(java.util.Map) HashMap(java.util.HashMap) SAML2MetaException(com.sun.identity.saml2.meta.SAML2MetaException)

Example 8 with AttributeType

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

the class SAML2MetaUtils method getAttributes.

/**
     * Gets attribute value pairs from <code>BaseConfigType</code> and
     * put in a <code>Map</code>. The key is attribute name and the value is
     * a <code>List</code> of attribute values;
     * @param config the <code>BaseConfigType</code> object
     * @return a attrbute value <code>Map</code>
     */
public static Map<String, List<String>> getAttributes(BaseConfigType config) {
    Map<String, List<String>> attrMap = new HashMap<>();
    List<AttributeType> list = config.getAttribute();
    for (AttributeType avp : list) {
        attrMap.put(avp.getName(), avp.getValue());
    }
    return attrMap;
}
Also used : HashMap(java.util.HashMap) AttributeType(com.sun.identity.saml2.jaxb.entityconfig.AttributeType) NodeList(org.w3c.dom.NodeList) List(java.util.List)

Example 9 with AttributeType

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

the class SAML2MetaSecurityUtils method setExtendedAttributeValue.

private static void setExtendedAttributeValue(BaseConfigType config, String attrName, Set attrVal) throws SAML2MetaException {
    try {
        List attributes = config.getAttribute();
        for (Iterator iter = attributes.iterator(); iter.hasNext(); ) {
            AttributeType avp = (AttributeType) iter.next();
            if (avp.getName().trim().equalsIgnoreCase(attrName)) {
                iter.remove();
            }
        }
        if (attrVal != null) {
            ObjectFactory factory = new ObjectFactory();
            AttributeType atype = factory.createAttributeType();
            atype.setName(attrName);
            atype.getValue().addAll(attrVal);
            config.getAttribute().add(atype);
        }
    } catch (JAXBException e) {
        throw new SAML2MetaException(e);
    }
}
Also used : ObjectFactory(com.sun.identity.saml2.jaxb.entityconfig.ObjectFactory) AttributeType(com.sun.identity.saml2.jaxb.entityconfig.AttributeType) JAXBException(javax.xml.bind.JAXBException) Iterator(java.util.Iterator) NodeList(org.w3c.dom.NodeList) List(java.util.List)

Aggregations

AttributeType (com.sun.identity.saml2.jaxb.entityconfig.AttributeType)9 List (java.util.List)7 ObjectFactory (com.sun.identity.saml2.jaxb.entityconfig.ObjectFactory)5 JAXBException (javax.xml.bind.JAXBException)5 EntityConfigElement (com.sun.identity.saml2.jaxb.entityconfig.EntityConfigElement)4 EntityDescriptorElement (com.sun.identity.saml2.jaxb.metadata.EntityDescriptorElement)4 SAML2MetaException (com.sun.identity.saml2.meta.SAML2MetaException)4 SAML2MetaManager (com.sun.identity.saml2.meta.SAML2MetaManager)4 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)4 Iterator (java.util.Iterator)4 Map (java.util.Map)3 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)2 COTException (com.sun.identity.cot.COTException)2 AffiliationConfigElement (com.sun.identity.saml2.jaxb.entityconfig.AffiliationConfigElement)2 BaseConfigType (com.sun.identity.saml2.jaxb.entityconfig.BaseConfigType)2 SPSSOConfigElement (com.sun.identity.saml2.jaxb.entityconfig.SPSSOConfigElement)2 NodeList (org.w3c.dom.NodeList)2 XACMLAuthzDecisionQueryConfigElement (com.sun.identity.saml2.jaxb.entityconfig.XACMLAuthzDecisionQueryConfigElement)1 XACMLPDPConfigElement (com.sun.identity.saml2.jaxb.entityconfig.XACMLPDPConfigElement)1