Search in sources :

Example 1 with EntitiesDescriptor

use of org.opensaml.saml.saml2.metadata.EntitiesDescriptor in project spring-security by spring-projects.

the class OpenSamlMetadataAssertingPartyDetailsConverter method convert.

Collection<RelyingPartyRegistration.AssertingPartyDetails.Builder> convert(InputStream inputStream) {
    List<RelyingPartyRegistration.AssertingPartyDetails.Builder> builders = new ArrayList<>();
    XMLObject xmlObject = xmlObject(inputStream);
    if (xmlObject instanceof EntitiesDescriptor) {
        EntitiesDescriptor descriptors = (EntitiesDescriptor) xmlObject;
        for (EntityDescriptor descriptor : descriptors.getEntityDescriptors()) {
            builders.add(convert(descriptor));
        }
        return builders;
    }
    if (xmlObject instanceof EntityDescriptor) {
        EntityDescriptor descriptor = (EntityDescriptor) xmlObject;
        return Arrays.asList(convert(descriptor));
    }
    throw new Saml2Exception("Unsupported element of type " + xmlObject.getClass());
}
Also used : EntityDescriptor(org.opensaml.saml.saml2.metadata.EntityDescriptor) ArrayList(java.util.ArrayList) XMLObject(org.opensaml.core.xml.XMLObject) EntitiesDescriptor(org.opensaml.saml.saml2.metadata.EntitiesDescriptor) Saml2Exception(org.springframework.security.saml2.Saml2Exception)

Example 2 with EntitiesDescriptor

use of org.opensaml.saml.saml2.metadata.EntitiesDescriptor in project ddf by codice.

the class MetadataConfigurationParser method readEntityDescriptors.

private List<EntityDescriptor> readEntityDescriptors(Reader reader) {
    Document entityDoc;
    try {
        entityDoc = StaxUtils.read(reader);
    } catch (Exception ex) {
        throw new IllegalArgumentException("Unable to read SAMLRequest as XML.");
    }
    XMLObject entityXmlObj;
    try {
        entityXmlObj = OpenSAMLUtil.fromDom(entityDoc.getDocumentElement());
    } catch (WSSecurityException ex) {
        throw new IllegalArgumentException("Unable to convert EntityDescriptor document to XMLObject.");
    }
    if (entityXmlObj instanceof EntitiesDescriptor) {
        return ((EntitiesDescriptor) entityXmlObj).getEntityDescriptors();
    } else {
        return Collections.singletonList((EntityDescriptor) entityXmlObj);
    }
}
Also used : XMLObject(org.opensaml.core.xml.XMLObject) WSSecurityException(org.apache.wss4j.common.ext.WSSecurityException) Document(org.w3c.dom.Document) EntitiesDescriptor(org.opensaml.saml.saml2.metadata.EntitiesDescriptor) NoSuchFileException(java.nio.file.NoSuchFileException) WSSecurityException(org.apache.wss4j.common.ext.WSSecurityException) PrivilegedActionException(java.security.PrivilegedActionException) IOException(java.io.IOException)

Example 3 with EntitiesDescriptor

use of org.opensaml.saml.saml2.metadata.EntitiesDescriptor in project cloudstack by apache.

the class SAML2AuthManagerImpl method discoverAndAddIdp.

private void discoverAndAddIdp(XMLObject metadata, Map<String, SAMLProviderMetadata> idpMap) {
    if (metadata instanceof EntityDescriptor) {
        EntityDescriptor entityDescriptor = (EntityDescriptor) metadata;
        addIdpToMap(entityDescriptor, idpMap);
    } else if (metadata instanceof EntitiesDescriptor) {
        EntitiesDescriptor entitiesDescriptor = (EntitiesDescriptor) metadata;
        if (entitiesDescriptor.getEntityDescriptors() != null) {
            for (EntityDescriptor entityDescriptor : entitiesDescriptor.getEntityDescriptors()) {
                addIdpToMap(entityDescriptor, idpMap);
            }
        }
        if (entitiesDescriptor.getEntitiesDescriptors() != null) {
            for (EntitiesDescriptor entitiesDescriptorInner : entitiesDescriptor.getEntitiesDescriptors()) {
                discoverAndAddIdp(entitiesDescriptorInner, idpMap);
            }
        }
    }
}
Also used : EntityDescriptor(org.opensaml.saml2.metadata.EntityDescriptor) EntitiesDescriptor(org.opensaml.saml2.metadata.EntitiesDescriptor)

Aggregations

XMLObject (org.opensaml.core.xml.XMLObject)2 EntitiesDescriptor (org.opensaml.saml.saml2.metadata.EntitiesDescriptor)2 IOException (java.io.IOException)1 NoSuchFileException (java.nio.file.NoSuchFileException)1 PrivilegedActionException (java.security.PrivilegedActionException)1 ArrayList (java.util.ArrayList)1 WSSecurityException (org.apache.wss4j.common.ext.WSSecurityException)1 EntityDescriptor (org.opensaml.saml.saml2.metadata.EntityDescriptor)1 EntitiesDescriptor (org.opensaml.saml2.metadata.EntitiesDescriptor)1 EntityDescriptor (org.opensaml.saml2.metadata.EntityDescriptor)1 Saml2Exception (org.springframework.security.saml2.Saml2Exception)1 Document (org.w3c.dom.Document)1