Search in sources :

Example 1 with OrganizationType

use of org.keycloak.dom.saml.v2.metadata.OrganizationType in project keycloak by keycloak.

the class SAMLOrganizationParser method processSubElement.

@Override
protected void processSubElement(XMLEventReader xmlEventReader, OrganizationType target, SAMLMetadataQNames element, StartElement elementDetail) throws ParsingException {
    switch(element) {
        case ORGANIZATION_NAME:
            LocalizedNameType orgName = new LocalizedNameType(StaxParserUtil.getAttributeValue(elementDetail, ATTR_LANG));
            StaxParserUtil.advance(xmlEventReader);
            orgName.setValue(StaxParserUtil.getElementText(xmlEventReader));
            target.addOrganizationName(orgName);
            break;
        case ORGANIZATION_DISPLAY_NAME:
            LocalizedNameType orgDispName = new LocalizedNameType(StaxParserUtil.getAttributeValue(elementDetail, ATTR_LANG));
            StaxParserUtil.advance(xmlEventReader);
            orgDispName.setValue(StaxParserUtil.getElementText(xmlEventReader));
            target.addOrganizationDisplayName(orgDispName);
            break;
        case ORGANIZATION_URL:
        case ORGANIZATION_URL_ALT:
            LocalizedURIType orgURL = new LocalizedURIType(StaxParserUtil.getAttributeValue(elementDetail, ATTR_LANG));
            StaxParserUtil.advance(xmlEventReader);
            orgURL.setValue(URI.create(StaxParserUtil.getElementText(xmlEventReader)));
            target.addOrganizationURL(orgURL);
            break;
        case EXTENSIONS:
            target.setExtensions(SAMLExtensionsParser.getInstance().parse(xmlEventReader));
            break;
        default:
            throw LOGGER.parserUnknownTag(StaxParserUtil.getElementName(elementDetail), elementDetail.getLocation());
    }
}
Also used : LocalizedURIType(org.keycloak.dom.saml.v2.metadata.LocalizedURIType) LocalizedNameType(org.keycloak.dom.saml.v2.metadata.LocalizedNameType)

Example 2 with OrganizationType

use of org.keycloak.dom.saml.v2.metadata.OrganizationType in project keycloak by keycloak.

the class SAMLMetadataWriter method writeEntityDescriptor.

public void writeEntityDescriptor(EntityDescriptorType entityDescriptor) throws ProcessingException {
    StaxUtil.writeStartElement(writer, METADATA_PREFIX, JBossSAMLConstants.ENTITY_DESCRIPTOR.get(), JBossSAMLURIConstants.METADATA_NSURI.get());
    StaxUtil.writeDefaultNameSpace(writer, JBossSAMLURIConstants.METADATA_NSURI.get());
    StaxUtil.writeNameSpace(writer, "md", JBossSAMLURIConstants.METADATA_NSURI.get());
    StaxUtil.writeNameSpace(writer, "saml", JBossSAMLURIConstants.ASSERTION_NSURI.get());
    StaxUtil.writeNameSpace(writer, "ds", JBossSAMLURIConstants.XMLDSIG_NSURI.get());
    StaxUtil.writeAttribute(writer, JBossSAMLConstants.ENTITY_ID.get(), entityDescriptor.getEntityID());
    if (entityDescriptor.getValidUntil() != null) {
        StaxUtil.writeAttribute(writer, JBossSAMLConstants.VALID_UNTIL.get(), entityDescriptor.getValidUntil().toString());
    }
    if (entityDescriptor.getID() != null) {
        StaxUtil.writeAttribute(writer, JBossSAMLConstants.ID.get(), entityDescriptor.getID());
    }
    Element signature = entityDescriptor.getSignature();
    if (signature != null) {
        StaxUtil.writeDOMElement(writer, signature);
    }
    ExtensionsType extensions = entityDescriptor.getExtensions();
    if (extensions != null) {
        write(extensions);
    }
    List<EntityDescriptorType.EDTChoiceType> choiceTypes = entityDescriptor.getChoiceType();
    for (EntityDescriptorType.EDTChoiceType edtChoice : choiceTypes) {
        AffiliationDescriptorType affliationDesc = edtChoice.getAffiliationDescriptor();
        if (affliationDesc != null)
            // TODO: affiliation
            throw logger.notImplementedYet("affliation");
        List<EntityDescriptorType.EDTDescriptorChoiceType> edtDescChoices = edtChoice.getDescriptors();
        for (EntityDescriptorType.EDTDescriptorChoiceType edtDescChoice : edtDescChoices) {
            RoleDescriptorType roleDesc = edtDescChoice.getRoleDescriptor();
            if (roleDesc != null)
                throw logger.notImplementedYet("Role Descriptor type");
            IDPSSODescriptorType idpSSO = edtDescChoice.getIdpDescriptor();
            if (idpSSO != null)
                write(idpSSO);
            SPSSODescriptorType spSSO = edtDescChoice.getSpDescriptor();
            if (spSSO != null)
                write(spSSO);
            AttributeAuthorityDescriptorType attribAuth = edtDescChoice.getAttribDescriptor();
            if (attribAuth != null)
                writeAttributeAuthorityDescriptor(attribAuth);
            AuthnAuthorityDescriptorType authNDesc = edtDescChoice.getAuthnDescriptor();
            if (authNDesc != null)
                throw logger.notImplementedYet("AuthnAuthorityDescriptorType");
            PDPDescriptorType pdpDesc = edtDescChoice.getPdpDescriptor();
            if (pdpDesc != null)
                throw logger.notImplementedYet("PDPDescriptorType");
        }
    }
    OrganizationType organization = entityDescriptor.getOrganization();
    if (organization != null) {
        writeOrganization(organization);
    }
    List<ContactType> contactPersons = entityDescriptor.getContactPerson();
    for (ContactType contact : contactPersons) {
        write(contact);
    }
    List<AdditionalMetadataLocationType> addl = entityDescriptor.getAdditionalMetadataLocation();
    if (addl.size() > 0)
        throw logger.notImplementedYet("AdditionalMetadataLocationType");
    StaxUtil.writeEndElement(writer);
    StaxUtil.flush(writer);
}
Also used : AuthnAuthorityDescriptorType(org.keycloak.dom.saml.v2.metadata.AuthnAuthorityDescriptorType) IDPSSODescriptorType(org.keycloak.dom.saml.v2.metadata.IDPSSODescriptorType) ContactType(org.keycloak.dom.saml.v2.metadata.ContactType) Element(org.w3c.dom.Element) AffiliationDescriptorType(org.keycloak.dom.saml.v2.metadata.AffiliationDescriptorType) OrganizationType(org.keycloak.dom.saml.v2.metadata.OrganizationType) SPSSODescriptorType(org.keycloak.dom.saml.v2.metadata.SPSSODescriptorType) RoleDescriptorType(org.keycloak.dom.saml.v2.metadata.RoleDescriptorType) PDPDescriptorType(org.keycloak.dom.saml.v2.metadata.PDPDescriptorType) ExtensionsType(org.keycloak.dom.saml.v2.metadata.ExtensionsType) AttributeAuthorityDescriptorType(org.keycloak.dom.saml.v2.metadata.AttributeAuthorityDescriptorType) AdditionalMetadataLocationType(org.keycloak.dom.saml.v2.metadata.AdditionalMetadataLocationType) EntityDescriptorType(org.keycloak.dom.saml.v2.metadata.EntityDescriptorType)

Example 3 with OrganizationType

use of org.keycloak.dom.saml.v2.metadata.OrganizationType in project keycloak by keycloak.

the class SAMLMetadataWriter method writeOrganization.

public void writeOrganization(OrganizationType org) throws ProcessingException {
    if (org == null)
        throw new ProcessingException(logger.nullArgumentError("Organization"));
    StaxUtil.writeStartElement(writer, METADATA_PREFIX, JBossSAMLConstants.ORGANIZATION.get(), JBossSAMLURIConstants.METADATA_NSURI.get());
    ExtensionsType extensions = org.getExtensions();
    if (extensions != null) {
        write(extensions);
    }
    // Write the name
    List<LocalizedNameType> nameList = org.getOrganizationName();
    for (LocalizedNameType localName : nameList) {
        StaxUtil.writeStartElement(writer, METADATA_PREFIX, JBossSAMLConstants.ORGANIZATION_NAME.get(), JBossSAMLURIConstants.METADATA_NSURI.get());
        writeLocalizedType(localName);
    }
    // Write the display name
    List<LocalizedNameType> displayNameList = org.getOrganizationDisplayName();
    for (LocalizedNameType localName : displayNameList) {
        StaxUtil.writeStartElement(writer, METADATA_PREFIX, JBossSAMLConstants.ORGANIZATION_DISPLAY_NAME.get(), JBossSAMLURIConstants.METADATA_NSURI.get());
        writeLocalizedType(localName);
    }
    // Write the url
    List<LocalizedURIType> uriList = org.getOrganizationURL();
    for (LocalizedURIType uri : uriList) {
        StaxUtil.writeStartElement(writer, METADATA_PREFIX, JBossSAMLConstants.ORGANIZATION_URL.get(), JBossSAMLURIConstants.METADATA_NSURI.get());
        String lang = uri.getLang();
        String val = uri.getValue().toString();
        StaxUtil.writeAttribute(writer, new QName(JBossSAMLURIConstants.XML.get(), JBossSAMLConstants.LANG.get(), "xml"), lang);
        StaxUtil.writeCharacters(writer, val);
        StaxUtil.writeEndElement(writer);
    }
    StaxUtil.writeEndElement(writer);
    StaxUtil.flush(writer);
}
Also used : LocalizedURIType(org.keycloak.dom.saml.v2.metadata.LocalizedURIType) LocalizedNameType(org.keycloak.dom.saml.v2.metadata.LocalizedNameType) QName(javax.xml.namespace.QName) ExtensionsType(org.keycloak.dom.saml.v2.metadata.ExtensionsType) ProcessingException(org.keycloak.saml.common.exceptions.ProcessingException)

Aggregations

ExtensionsType (org.keycloak.dom.saml.v2.metadata.ExtensionsType)2 LocalizedNameType (org.keycloak.dom.saml.v2.metadata.LocalizedNameType)2 LocalizedURIType (org.keycloak.dom.saml.v2.metadata.LocalizedURIType)2 QName (javax.xml.namespace.QName)1 AdditionalMetadataLocationType (org.keycloak.dom.saml.v2.metadata.AdditionalMetadataLocationType)1 AffiliationDescriptorType (org.keycloak.dom.saml.v2.metadata.AffiliationDescriptorType)1 AttributeAuthorityDescriptorType (org.keycloak.dom.saml.v2.metadata.AttributeAuthorityDescriptorType)1 AuthnAuthorityDescriptorType (org.keycloak.dom.saml.v2.metadata.AuthnAuthorityDescriptorType)1 ContactType (org.keycloak.dom.saml.v2.metadata.ContactType)1 EntityDescriptorType (org.keycloak.dom.saml.v2.metadata.EntityDescriptorType)1 IDPSSODescriptorType (org.keycloak.dom.saml.v2.metadata.IDPSSODescriptorType)1 OrganizationType (org.keycloak.dom.saml.v2.metadata.OrganizationType)1 PDPDescriptorType (org.keycloak.dom.saml.v2.metadata.PDPDescriptorType)1 RoleDescriptorType (org.keycloak.dom.saml.v2.metadata.RoleDescriptorType)1 SPSSODescriptorType (org.keycloak.dom.saml.v2.metadata.SPSSODescriptorType)1 ProcessingException (org.keycloak.saml.common.exceptions.ProcessingException)1 Element (org.w3c.dom.Element)1