if (extendedMetadata == null) {
try {
extendedMetadata = metadataManager.getExtendedMetadata(descriptor.getEntityID());
} catch (MetadataProviderException e) {
logger.error("Unable to locate extended metadata", e);
throw new MarshallingException("Unable to locate extended metadata", e);
}
}
try {
if (extendedMetadata.isLocal() && extendedMetadata.isSignMetadata()) {
Credential credential = keyManager.getCredential(extendedMetadata.getSigningKey());
String signingAlgorithm = extendedMetadata.getSigningAlgorithm();
String keyGenerator = extendedMetadata.getKeyInfoGeneratorName();
element = SAMLUtil.marshallAndSignMessage(descriptor, credential, signingAlgorithm, keyGenerator);
} else {
element = SAMLUtil.marshallMessage(descriptor);
}
} catch (MessageEncodingException e) {
logger.error("Unable to marshall message", e);
throw new MarshallingException("Unable to marshall message", e);
}
return XMLHelper.nodeToString(element);
}