Search in sources :

Example 1 with ContactTypeType

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

the class SAMLMetadataWriter method write.

public void write(ContactType contact) throws ProcessingException {
    StaxUtil.writeStartElement(writer, METADATA_PREFIX, JBossSAMLConstants.CONTACT_PERSON.get(), JBossSAMLURIConstants.METADATA_NSURI.get());
    ContactTypeType attribs = contact.getContactType();
    StaxUtil.writeAttribute(writer, JBossSAMLConstants.CONTACT_TYPE.get(), attribs.value());
    ExtensionsType extensions = contact.getExtensions();
    if (extensions != null) {
        write(extensions);
    }
    // Write the name
    String company = contact.getCompany();
    if (company != null) {
        StaxUtil.writeStartElement(writer, METADATA_PREFIX, JBossSAMLConstants.COMPANY.get(), JBossSAMLURIConstants.METADATA_NSURI.get());
        StaxUtil.writeCharacters(writer, company);
        StaxUtil.writeEndElement(writer);
    }
    String givenName = contact.getGivenName();
    if (givenName != null) {
        StaxUtil.writeStartElement(writer, METADATA_PREFIX, JBossSAMLConstants.GIVEN_NAME.get(), JBossSAMLURIConstants.METADATA_NSURI.get());
        StaxUtil.writeCharacters(writer, givenName);
        StaxUtil.writeEndElement(writer);
    }
    String surName = contact.getSurName();
    if (surName != null) {
        StaxUtil.writeStartElement(writer, METADATA_PREFIX, JBossSAMLConstants.SURNAME.get(), JBossSAMLURIConstants.METADATA_NSURI.get());
        StaxUtil.writeCharacters(writer, surName);
        StaxUtil.writeEndElement(writer);
    }
    List<String> emailAddresses = contact.getEmailAddress();
    for (String email : emailAddresses) {
        StaxUtil.writeStartElement(writer, METADATA_PREFIX, JBossSAMLConstants.EMAIL_ADDRESS.get(), JBossSAMLURIConstants.METADATA_NSURI.get());
        StaxUtil.writeCharacters(writer, email);
        StaxUtil.writeEndElement(writer);
    }
    List<String> tels = contact.getTelephoneNumber();
    for (String telephone : tels) {
        StaxUtil.writeStartElement(writer, METADATA_PREFIX, JBossSAMLConstants.TELEPHONE_NUMBER.get(), JBossSAMLURIConstants.METADATA_NSURI.get());
        StaxUtil.writeCharacters(writer, telephone);
        StaxUtil.writeEndElement(writer);
    }
    StaxUtil.writeEndElement(writer);
    StaxUtil.flush(writer);
}
Also used : ExtensionsType(org.keycloak.dom.saml.v2.metadata.ExtensionsType) ContactTypeType(org.keycloak.dom.saml.v2.metadata.ContactTypeType)

Aggregations

ContactTypeType (org.keycloak.dom.saml.v2.metadata.ContactTypeType)1 ExtensionsType (org.keycloak.dom.saml.v2.metadata.ExtensionsType)1