in services/idp-core/src/main/java/org/apache/cxf/fediz/service/idp/metadata/ServiceMetadataWriter.java [53:108]
public Document getMetaData(Idp config, TrustedIdp serviceConfig) throws ProcessingException {
try {
Crypto crypto = CertsUtils.getCryptoFromFile(config.getCertificate());
W3CDOMStreamWriter writer = new W3CDOMStreamWriter();
writer.writeStartDocument("UTF-8", "1.0");
String referenceID = IDGenerator.generateID("_");
writer.writeStartElement("md", "EntityDescriptor", SAML2_METADATA_NS);
writer.writeAttribute("ID", referenceID);
String serviceURL = config.getIdpUrl().toString();
writer.writeAttribute("entityID", config.getRealm());
writer.writeNamespace("md", SAML2_METADATA_NS);
writer.writeNamespace("fed", WS_FEDERATION_NS);
writer.writeNamespace("wsa", WS_ADDRESSING_NS);
writer.writeNamespace("auth", WS_FEDERATION_NS);
writer.writeNamespace("xsi", SCHEMA_INSTANCE_NS);
if ("http://docs.oasis-open.org/wsfed/federation/200706".equals(serviceConfig.getProtocol())) {
writeFederationMetadata(writer, serviceConfig, serviceURL);
} else if ("urn:oasis:names:tc:SAML:2.0:profiles:SSO:browser".equals(serviceConfig.getProtocol())) {
writeSAMLMetadata(writer, serviceConfig, serviceURL, crypto);
}
writer.writeEndElement(); // EntityDescriptor
writer.writeEndDocument();
writer.close();
if (LOG.isDebugEnabled()) {
String out = DOM2Writer.nodeToString(writer.getDocument());
LOG.debug("***************** unsigned ****************");
LOG.debug(out);
LOG.debug("***************** unsigned ****************");
}
Document result = SignatureUtils.signMetaInfo(crypto, null, config.getCertificatePassword(),
writer.getDocument(), referenceID);
if (result != null) {
return result;
} else {
throw new RuntimeException("Failed to sign the metadata document: result=null");
}
} catch (ProcessingException e) {
throw e;
} catch (Exception e) {
LOG.error("Error creating service metadata information ", e);
throw new ProcessingException("Error creating service metadata information: " + e.getMessage());
}
}