class WebXmlParser {

  static void parseStream(SessionConfiguration conf, InputStream is) {
    if (is != null) {
      try {
        DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
        // We want to ignore schemas and dtd when parsing web.xml
        builder.setEntityResolver(new EntityResolver() {
          @Override
          public InputSource resolveEntity(String publicId, String systemId) {
            // Ignore entites!
            return new InputSource(new StringReader(""));
          }
        });
        Document document = builder.parse(is);
        XPath xpath = XPathFactory.newInstance().newXPath();
        lookForSessionTimeout(conf, document, xpath);
        lookForSessionConf(conf, document, xpath);
        checkDistributable(conf, document, xpath);
      } catch (SAXException | IOException | XPathExpressionException | ParserConfigurationException e) {
        throw new IllegalStateException("An exception occured while parsing web.xml. "
            + "Using default configuration: " + conf, e);
      }
    }
  }

  private  WebXmlParser();

}