Search in sources :

Example 6 with AttributeElement

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

the class SAMLv2ModelImpl method updateBaseConfig.

/**
     * Updates the BaseConfigElement.
     *
     * @param baseConfig is the BaseConfigType passed.
     * @param attributeName is the attribute name
     * @param list the list which contains the new values.
     * @throws AMConsoleException if update of baseConfig object fails.
     */
private void updateBaseConfig(BaseConfigType baseConfig, String attributeName, List list) throws AMConsoleException {
    List attrList = baseConfig.getAttribute();
    for (Iterator it = attrList.iterator(); it.hasNext(); ) {
        AttributeElement avpnew = (AttributeElement) it.next();
        String name = avpnew.getName();
        if (name.equals(attributeName)) {
            avpnew.getValue().clear();
            avpnew.getValue().addAll(list);
        }
    }
}
Also used : Iterator(java.util.Iterator) List(java.util.List) ArrayList(java.util.ArrayList) AttributeElement(com.sun.identity.saml2.jaxb.entityconfig.AttributeElement)

Example 7 with AttributeElement

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

the class SAML2IDPProxyFRImpl method selectIDPBasedOnLOA.

private String selectIDPBasedOnLOA(List<String> idpList, String realm, AuthnRequest authnRequest) {
    String classMethod = "selectIdPBasedOnLOA";
    EntityDescriptorElement idpDesc = null;
    Set authnRequestContextSet = null;
    String idps = "";
    try {
        RequestedAuthnContext requestedAuthnContext = authnRequest.getRequestedAuthnContext();
        if (requestedAuthnContext == null) {
            //In this case we just simply return all the IdPs as each one should support a default AuthnContext.
            return StringUtils.join(idpList, " ");
        }
        List listOfAuthnContexts = requestedAuthnContext.getAuthnContextClassRef();
        debugMessage(classMethod, "listofAuthnContexts: " + listOfAuthnContexts);
        try {
            authnRequestContextSet = new HashSet(listOfAuthnContexts);
        } catch (Exception ex1) {
            authnRequestContextSet = new HashSet();
        }
        if ((idpList != null) && (!idpList.isEmpty())) {
            Iterator idpI = idpList.iterator();
            while (idpI.hasNext()) {
                String idp = (String) idpI.next();
                debugMessage(classMethod, "IDP is: " + idp);
                idpDesc = SAML2Utils.getSAML2MetaManager().getEntityDescriptor(realm, idp);
                if (idpDesc != null) {
                    ExtensionsType et = idpDesc.getExtensions();
                    if (et != null) {
                        debugMessage(classMethod, "Extensions found for idp: " + idp);
                        List idpExtensions = et.getAny();
                        if (idpExtensions != null || !idpExtensions.isEmpty()) {
                            debugMessage(classMethod, "Extensions content found for idp: " + idp);
                            Iterator idpExtensionsI = idpExtensions.iterator();
                            while (idpExtensionsI.hasNext()) {
                                EntityAttributesElement eael = (EntityAttributesElement) idpExtensionsI.next();
                                if (eael != null) {
                                    debugMessage(classMethod, "Entity Attributes found for idp: " + idp);
                                    List attribL = eael.getAttributeOrAssertion();
                                    if (attribL != null || !attribL.isEmpty()) {
                                        Iterator attrI = attribL.iterator();
                                        while (attrI.hasNext()) {
                                            AttributeElement ae = (AttributeElement) attrI.next();
                                            // TODO: Verify what type of element this is (Attribute or assertion)
                                            // For validation purposes
                                            List av = ae.getAttributeValue();
                                            if (av != null || !av.isEmpty()) {
                                                debugMessage(classMethod, "Attribute Values found for idp: " + idp);
                                                Iterator avI = av.iterator();
                                                while (avI.hasNext()) {
                                                    AttributeValueElement ave = (AttributeValueElement) avI.next();
                                                    if (ave != null) {
                                                        List contentL = ave.getContent();
                                                        debugMessage(classMethod, "Attribute Value Elements found for idp: " + idp + "-->" + contentL);
                                                        if (contentL != null || !contentL.isEmpty()) {
                                                            Set idpContextSet = trimmedListToSet(contentL);
                                                            debugMessage(classMethod, "idpContextSet = " + idpContextSet);
                                                            idpContextSet.retainAll(authnRequestContextSet);
                                                            if (idpContextSet != null && !idpContextSet.isEmpty()) {
                                                                idps = idp + " " + idps;
                                                                debugMessage(classMethod, "Extension Values found for idp " + idp + ": " + idpContextSet);
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    } else {
                        debugMessage(classMethod, " No extensions found for IdP " + idp);
                    }
                } else {
                    debugMessage(classMethod, "Configuration for the idp " + idp + " was not found in this system");
                }
            }
        }
    } catch (SAML2MetaException me) {
        debugMessage(classMethod, "SOmething went wrong: " + me);
    }
    debugMessage(classMethod, " IDPList returns: " + idps);
    return idps.trim();
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) EntityAttributesElement(com.sun.identity.saml2.jaxb.metadataattr.EntityAttributesElement) EntityDescriptorElement(com.sun.identity.saml2.jaxb.metadata.EntityDescriptorElement) COTException(com.sun.identity.cot.COTException) SAML2MetaException(com.sun.identity.saml2.meta.SAML2MetaException) SAML2Exception(com.sun.identity.saml2.common.SAML2Exception) RequestedAuthnContext(com.sun.identity.saml2.protocol.RequestedAuthnContext) ExtensionsType(com.sun.identity.saml2.jaxb.metadata.ExtensionsType) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) AttributeValueElement(com.sun.identity.saml2.jaxb.assertion.AttributeValueElement) AttributeElement(com.sun.identity.saml2.jaxb.assertion.AttributeElement) SAML2MetaException(com.sun.identity.saml2.meta.SAML2MetaException) HashSet(java.util.HashSet)

Aggregations

Iterator (java.util.Iterator)6 List (java.util.List)6 ArrayList (java.util.ArrayList)5 SAML2Exception (com.sun.identity.saml2.common.SAML2Exception)3 AttributeElement (com.sun.identity.saml2.jaxb.assertion.AttributeElement)3 AttributeValueElement (com.sun.identity.saml2.jaxb.assertion.AttributeValueElement)3 AttributeElement (com.sun.identity.saml2.jaxb.entityconfig.AttributeElement)3 SAML2MetaException (com.sun.identity.saml2.meta.SAML2MetaException)3 Attribute (com.sun.identity.saml2.assertion.Attribute)2 Set (java.util.Set)2 COTException (com.sun.identity.cot.COTException)1 DataStoreProviderException (com.sun.identity.plugin.datastore.DataStoreProviderException)1 EntityConfigElement (com.sun.identity.saml2.jaxb.entityconfig.EntityConfigElement)1 IDPSSOConfigElement (com.sun.identity.saml2.jaxb.entityconfig.IDPSSOConfigElement)1 EntityDescriptorElement (com.sun.identity.saml2.jaxb.metadata.EntityDescriptorElement)1 ExtensionsType (com.sun.identity.saml2.jaxb.metadata.ExtensionsType)1 EntityAttributesElement (com.sun.identity.saml2.jaxb.metadataattr.EntityAttributesElement)1 SAML2MetaManager (com.sun.identity.saml2.meta.SAML2MetaManager)1 RequestedAuthnContext (com.sun.identity.saml2.protocol.RequestedAuthnContext)1 OrderedSet (com.sun.identity.shared.datastruct.OrderedSet)1