private static org.w3c.dom.Document toDom(final Document doc) throws Exception {
        LOGGER.trace("Creating document from: [{}]", doc);
        val xmlOutputter = new XMLOutputter();
        val elemStrWriter = new StringWriter();
        xmlOutputter.output(doc, elemStrWriter);
        val xmlBytes = elemStrWriter.toString().getBytes(Charset.defaultCharset());
        val dbf = DocumentBuilderFactory.newInstance();
        dbf.setNamespaceAware(true);
        dbf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
        dbf.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
        dbf.setFeature("http://apache.org/xml/features/validation/schema/normalized-value", false);
        dbf.setFeature("http://javax.xml.XMLConstants/feature/secure-processing", true);
        dbf.setFeature("http://xml.org/sax/features/external-general-entities", false);
        dbf.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
        return dbf.newDocumentBuilder().parse(new ByteArrayInputStream(xmlBytes));
    }
Gets the xml signature insert location.

@param elem the elem
@return the xml signature insert location
support/cas-server-support-saml-core-api/src/main/java/org/apereo/cas/support/saml/util/AbstractSamlObjectBuilder.java