Ejemplo n.º 1
0
  public void writeOrganization(OrganizationType org) throws ProcessingException {
    if (org == null) throw new ProcessingException(logger.nullArgumentError("Organization"));
    StaxUtil.writeStartElement(
        writer, METADATA_PREFIX, JBossSAMLConstants.ORGANIZATION.get(), METADATA_NSURI.get());

    ExtensionsType extensions = org.getExtensions();
    if (extensions != null) {
      StaxUtil.writeDOMElement(writer, extensions.getElement());
    }

    // Write the name
    List<LocalizedNameType> nameList = org.getOrganizationName();
    for (LocalizedNameType localName : nameList) {
      StaxUtil.writeStartElement(
          writer,
          METADATA_PREFIX,
          JBossSAMLConstants.ORGANIZATION_NAME.get(),
          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(),
          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(), 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);
  }
Ejemplo n.º 2
0
  private void writeLocalizedType(LocalizedNameType localName) throws ProcessingException {
    String lang = localName.getLang();
    String val = localName.getValue();
    StaxUtil.writeAttribute(
        writer,
        new QName(JBossSAMLURIConstants.XML.get(), JBossSAMLConstants.LANG.get(), "xml"),
        lang);

    StaxUtil.writeCharacters(writer, val);

    StaxUtil.writeEndElement(writer);
  }