Search in sources :

Example 21 with DOMImplementationLS

use of org.w3c.dom.ls.DOMImplementationLS in project ddf by codice.

the class SAMLAuthenticationToken method getCredentialsAsXMLString.

@Override
public String getCredentialsAsXMLString() {
    String creds = "";
    Element element = getSAMLTokenAsElement();
    if (element != null) {
        DOMImplementationLS lsImpl = (DOMImplementationLS) element.getOwnerDocument().getImplementation().getFeature("LS", "3.0");
        if (null != lsImpl) {
            LSSerializer serializer = lsImpl.createLSSerializer();
            serializer.getDomConfig().setParameter("xml-declaration", //by default its true, so set it to false to get String without xml-declaration
            false);
            creds = serializer.writeToString(element);
        }
        LOGGER.trace("XML representation of SAML token: {}", creds);
    }
    return creds;
}
Also used : Element(org.w3c.dom.Element) DOMImplementationLS(org.w3c.dom.ls.DOMImplementationLS) LSSerializer(org.w3c.dom.ls.LSSerializer)

Aggregations

DOMImplementationLS (org.w3c.dom.ls.DOMImplementationLS)21 LSSerializer (org.w3c.dom.ls.LSSerializer)18 DocumentBuilder (javax.xml.parsers.DocumentBuilder)8 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)8 Document (org.w3c.dom.Document)8 DOMImplementationRegistry (org.w3c.dom.bootstrap.DOMImplementationRegistry)6 IOException (java.io.IOException)5 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)5 LSOutput (org.w3c.dom.ls.LSOutput)5 Element (org.w3c.dom.Element)4 StringWriter (java.io.StringWriter)3 DOMImplementation (org.w3c.dom.DOMImplementation)3 Node (org.w3c.dom.Node)3 TransformerException (javax.xml.transform.TransformerException)2 DOMException (org.w3c.dom.DOMException)2 NodeList (org.w3c.dom.NodeList)2 BinaryContent (ddf.catalog.data.BinaryContent)1 Metacard (ddf.catalog.data.Metacard)1 Result (ddf.catalog.data.Result)1 CatalogTransformerException (ddf.catalog.transform.CatalogTransformerException)1