public static DocumentBuilder buildSecureDocumentBuilder ( ) throws ParserConfigurationException { final DocumentBuilderFactory factory = DocumentBuilderFactory . newInstance ( ) ; factory . setFeature ( "http://apache.org/xml/features/disallow-doctype-decl" , true ) ; factory . setFeature ( "http://xml.org/sax/features/external-general-entities" , false ) ; factory . setFeature ( XMLConstants . FEATURE_SECURE_PROCESSING , true ) ; return factory . newDocumentBuilder ( ) ; }
Constructs a new document builder with security features enabled .