use of org.opensaml.core.xml.io.Marshaller in project cas by apereo.
the class SamlUtils method transformSamlObject.
/**
* Transform saml object to String.
*
* @param configBean the config bean
* @param samlObject the saml object
* @return the string
* @throws SamlException the saml exception
*/
public static StringWriter transformSamlObject(final OpenSamlConfigBean configBean, final XMLObject samlObject) throws SamlException {
final StringWriter writer = new StringWriter();
try {
final Marshaller marshaller = configBean.getMarshallerFactory().getMarshaller(samlObject.getElementQName());
if (marshaller != null) {
final Element element = marshaller.marshall(samlObject);
final DOMSource domSource = new DOMSource(element);
final StreamResult result = new StreamResult(writer);
final TransformerFactory tf = TransformerFactory.newInstance();
final Transformer transformer = tf.newTransformer();
transformer.transform(domSource, result);
}
} catch (final Exception e) {
throw new SamlException(e.getMessage(), e);
}
return writer;
}
use of org.opensaml.core.xml.io.Marshaller in project spring-security by spring-projects.
the class OpenSamlAuthenticationProviderTests method serialize.
private String serialize(XMLObject object) {
try {
Marshaller marshaller = XMLObjectProviderRegistrySupport.getMarshallerFactory().getMarshaller(object);
Element element = marshaller.marshall(object);
return SerializeSupport.nodeToString(element);
} catch (MarshallingException ex) {
throw new Saml2Exception(ex);
}
}
use of org.opensaml.core.xml.io.Marshaller in project spring-security by spring-projects.
the class OpenSamlSigningUtils method serialize.
static String serialize(XMLObject object) {
try {
Marshaller marshaller = XMLObjectProviderRegistrySupport.getMarshallerFactory().getMarshaller(object);
Element element = marshaller.marshall(object);
return SerializeSupport.nodeToString(element);
} catch (MarshallingException ex) {
throw new Saml2Exception(ex);
}
}
use of org.opensaml.core.xml.io.Marshaller in project spring-security by spring-projects.
the class OpenSaml4AuthenticationProviderTests method serialize.
private String serialize(XMLObject object) {
try {
Marshaller marshaller = XMLObjectProviderRegistrySupport.getMarshallerFactory().getMarshaller(object);
Element element = marshaller.marshall(object);
return SerializeSupport.nodeToString(element);
} catch (MarshallingException ex) {
throw new Saml2Exception(ex);
}
}
use of org.opensaml.core.xml.io.Marshaller in project spring-security by spring-projects.
the class OpenSamlSigningUtils method serialize.
static String serialize(XMLObject object) {
try {
Marshaller marshaller = XMLObjectProviderRegistrySupport.getMarshallerFactory().getMarshaller(object);
Element element = marshaller.marshall(object);
return SerializeSupport.nodeToString(element);
} catch (MarshallingException ex) {
throw new Saml2Exception(ex);
}
}
Aggregations