private Bom parse ( StreamSource streamSource ) throws ParseException { try { final Schema schema = getXmlSchema ( CycloneDxSchema . Version . VERSION_11 ) ; final XmlMapper mapper = new XmlMapper ( ) ; // Prevent XML External Entity Injection final XMLInputFactory xif = XMLInputFactory . newFactory ( ) ; xif . setProperty ( XMLInputFactory . IS_SUPPORTING_EXTERNAL_ENTITIES , false ) ; xif . setProperty ( XMLInputFactory . SUPPORT_DTD , false ) ; final XMLStreamReader xsr = new NamespaceStreamReaderDelegate ( xif . createXMLStreamReader ( streamSource ) ) ; final Bom bom = mapper . readValue ( xsr , Bom . class ) ; xsr . close ( ) ; return bom ; } catch ( IOException | XMLStreamException | SAXException e ) { throw new ParseException ( e ) ; } }
Parses a CycloneDX BOM .