org.apache.tomcat.util.descriptor.DigesterFactory Java Examples
The following examples show how to use
org.apache.tomcat.util.descriptor.DigesterFactory.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TldConfig.java From Tomcat7.0.67 with Apache License 2.0 | 6 votes |
/** * Create (if necessary) and return a Digester configured to process the * tld. */ private static synchronized Digester createTldDigester(boolean validation, boolean blockExternal) { Digester digester; int cacheIndex = 0; if (validation) { cacheIndex += 1; } if (blockExternal) { cacheIndex += 2; } digester = tldDigesters[cacheIndex]; if (digester == null) { digester = DigesterFactory.newDigester(validation, true, new TldRuleSet(), blockExternal); digester.getParser(); tldDigesters[cacheIndex] = digester; } return digester; }
Example #2
Source File: ContextConfig.java From Tomcat7.0.67 with Apache License 2.0 | 6 votes |
/** * Create and return a Digester configured to process the * web application deployment descriptor (web.xml). */ public void createWebXmlDigester(boolean namespaceAware, boolean validation) { boolean blockExternal = context.getXmlBlockExternal(); webRuleSet = new WebRuleSet(false); webDigester = DigesterFactory.newDigester(validation, namespaceAware, webRuleSet, blockExternal); webDigester.getParser(); webFragmentRuleSet = new WebRuleSet(true); webFragmentDigester = DigesterFactory.newDigester(validation, namespaceAware, webFragmentRuleSet, blockExternal); webFragmentDigester.getParser(); }
Example #3
Source File: ContextConfig.java From tomcatsrc with Apache License 2.0 | 6 votes |
/** * Create and return a Digester configured to process the * web application deployment descriptor (web.xml). */ public void createWebXmlDigester(boolean namespaceAware, boolean validation) { boolean blockExternal = context.getXmlBlockExternal(); webRuleSet = new WebRuleSet(false); webDigester = DigesterFactory.newDigester(validation, namespaceAware, webRuleSet, blockExternal); webDigester.getParser(); webFragmentRuleSet = new WebRuleSet(true); webFragmentDigester = DigesterFactory.newDigester(validation, namespaceAware, webFragmentRuleSet, blockExternal); webFragmentDigester.getParser(); }
Example #4
Source File: TldConfig.java From tomcatsrc with Apache License 2.0 | 6 votes |
/** * Create (if necessary) and return a Digester configured to process the * tld. */ private static synchronized Digester createTldDigester(boolean validation, boolean blockExternal) { Digester digester; int cacheIndex = 0; if (validation) { cacheIndex += 1; } if (blockExternal) { cacheIndex += 2; } digester = tldDigesters[cacheIndex]; if (digester == null) { digester = DigesterFactory.newDigester(validation, true, new TldRuleSet(), blockExternal); digester.getParser(); tldDigesters[cacheIndex] = digester; } return digester; }
Example #5
Source File: TestSchemaValidation.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
@Test public void testWebapp_2_2() throws Exception { XmlErrorHandler handler = new XmlErrorHandler(); Digester digester = DigesterFactory.newDigester( true, true, new WebRuleSet(false), true); digester.setErrorHandler(handler); digester.push(new WebXml()); WebXml desc = (WebXml) digester.parse( new File("test/webapp-2.2/WEB-INF/web.xml")); Assert.assertEquals("2.2", desc.getVersion()); Assert.assertEquals(XmlIdentifiers.WEB_22_PUBLIC, desc.getPublicId()); Assert.assertEquals(0, handler.getErrors().size()); Assert.assertEquals(0, handler.getWarnings().size()); }
Example #6
Source File: JspDocumentParser.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
public JspDocumentParser( ParserController pc, String path, boolean isTagFile, boolean directivesOnly) { this.parserController = pc; this.ctxt = pc.getJspCompilationContext(); this.pageInfo = pc.getCompiler().getPageInfo(); this.err = pc.getCompiler().getErrorDispatcher(); this.path = path; this.isTagFile = isTagFile; this.directivesOnly = directivesOnly; this.isTop = true; String blockExternalString = ctxt.getServletContext().getInitParameter( Constants.XML_BLOCK_EXTERNAL_INIT_PARAM); boolean blockExternal; if (blockExternalString == null) { blockExternal = true; } else { blockExternal = Boolean.parseBoolean(blockExternalString); } this.entityResolver = new LocalResolver( DigesterFactory.SERVLET_API_PUBLIC_IDS, DigesterFactory.SERVLET_API_SYSTEM_IDS, blockExternal); }
Example #7
Source File: TestSchemaValidation.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
@Test public void testWebapp_2_3() throws Exception { XmlErrorHandler handler = new XmlErrorHandler(); Digester digester = DigesterFactory.newDigester( true, true, new WebRuleSet(false), true); digester.setErrorHandler(handler); digester.push(new WebXml()); WebXml desc = (WebXml) digester.parse( new File("test/webapp-2.3/WEB-INF/web.xml")); Assert.assertEquals("2.3", desc.getVersion()); Assert.assertEquals(XmlIdentifiers.WEB_23_PUBLIC, desc.getPublicId()); Assert.assertEquals(0, handler.getErrors().size()); Assert.assertEquals(0, handler.getWarnings().size()); }
Example #8
Source File: TestSchemaValidation.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
@Test public void testWebapp_2_4() throws Exception { XmlErrorHandler handler = new XmlErrorHandler(); Digester digester = DigesterFactory.newDigester( true, true, new WebRuleSet(false), true); digester.setErrorHandler(handler); digester.push(new WebXml()); WebXml desc = (WebXml) digester.parse( new File("test/webapp-2.4/WEB-INF/web.xml")); Assert.assertEquals("2.4", desc.getVersion()); Assert.assertEquals(0, handler.getErrors().size()); Assert.assertEquals(0, handler.getWarnings().size()); }
Example #9
Source File: TestSchemaValidation.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
@Test public void testWebapp_2_5() throws Exception { XmlErrorHandler handler = new XmlErrorHandler(); Digester digester = DigesterFactory.newDigester( true, true, new WebRuleSet(false), true); digester.setErrorHandler(handler); digester.push(new WebXml()); WebXml desc = (WebXml) digester.parse( new File("test/webapp-2.5/WEB-INF/web.xml")); Assert.assertEquals("2.5", desc.getVersion()); Assert.assertEquals(0, handler.getErrors().size()); Assert.assertEquals(0, handler.getWarnings().size()); }
Example #10
Source File: TestSchemaValidation.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
@Test public void testWebapp_3_0() throws Exception { XmlErrorHandler handler = new XmlErrorHandler(); Digester digester = DigesterFactory.newDigester( true, true, new WebRuleSet(false), true); digester.setErrorHandler(handler); digester.push(new WebXml()); WebXml desc = (WebXml) digester.parse( new File("test/webapp-3.0/WEB-INF/web.xml")); Assert.assertEquals("3.0", desc.getVersion()); Assert.assertEquals(0, handler.getErrors().size()); Assert.assertEquals(0, handler.getWarnings().size()); }
Example #11
Source File: ParserUtils.java From tomcatsrc with Apache License 2.0 | 5 votes |
public ParserUtils(boolean validating, boolean blockExternal) { this.validating = validating; if (entityResolver == null) { this.entityResolverInstance = new LocalResolver( DigesterFactory.SERVLET_API_PUBLIC_IDS, DigesterFactory.SERVLET_API_SYSTEM_IDS, blockExternal); } else { this.entityResolverInstance = entityResolver; } }
Example #12
Source File: JspDocumentParser.java From tomcatsrc with Apache License 2.0 | 5 votes |
public JspDocumentParser( ParserController pc, String path, boolean isTagFile, boolean directivesOnly) { this.parserController = pc; this.ctxt = pc.getJspCompilationContext(); this.pageInfo = pc.getCompiler().getPageInfo(); this.err = pc.getCompiler().getErrorDispatcher(); this.path = path; this.isTagFile = isTagFile; this.directivesOnly = directivesOnly; this.isTop = true; String blockExternalString = ctxt.getServletContext().getInitParameter( Constants.XML_BLOCK_EXTERNAL_INIT_PARAM); boolean blockExternal; if (blockExternalString == null) { blockExternal = true; } else { blockExternal = Boolean.parseBoolean(blockExternalString); } this.entityResolver = new LocalResolver( DigesterFactory.SERVLET_API_PUBLIC_IDS, DigesterFactory.SERVLET_API_SYSTEM_IDS, blockExternal); }
Example #13
Source File: TestWebXml.java From tomcatsrc with Apache License 2.0 | 5 votes |
private void doTestValidateVersion(String version) throws IOException, SAXException { WebXml webxml = new WebXml(); // Special cases if ("2.2".equals(version)) { webxml.setPublicId(XmlIdentifiers.WEB_22_PUBLIC); } else if ("2.3".equals(version)) { webxml.setPublicId(XmlIdentifiers.WEB_23_PUBLIC); } else { webxml.setVersion(version); } // Merged web.xml that is published as MERGED_WEB_XML context attribute // in the simplest case consists of webapp's web.xml file // plus the default conf/web.xml one. Set<WebXml> defaults = new HashSet<WebXml>(); defaults.add(getDefaultWebXmlFragment()); webxml.merge(defaults); Digester digester = DigesterFactory.newDigester(true, true, new WebRuleSet(), true); XmlErrorHandler handler = new XmlErrorHandler(); digester.setErrorHandler(handler); InputSource is = new InputSource(new StringReader(webxml.toXml())); WebXml webxmlResult = new WebXml(); digester.push(webxmlResult); digester.parse(is); Assert.assertEquals(0, handler.getErrors().size()); Assert.assertEquals(0, handler.getWarnings().size()); Assert.assertEquals(version, webxml.getVersion()); Assert.assertEquals(version, webxmlResult.getVersion()); }
Example #14
Source File: TestSchemaValidation.java From tomcatsrc with Apache License 2.0 | 5 votes |
@Test public void testWebapp_2_2() throws Exception { XmlErrorHandler handler = new XmlErrorHandler(); Digester digester = DigesterFactory.newDigester( true, true, new WebRuleSet(false), true); digester.setErrorHandler(handler); digester.push(new WebXml()); WebXml desc = (WebXml) digester.parse( new File("test/webapp-2.2/WEB-INF/web.xml")); Assert.assertEquals("2.2", desc.getVersion()); Assert.assertEquals(XmlIdentifiers.WEB_22_PUBLIC, desc.getPublicId()); Assert.assertEquals(0, handler.getErrors().size()); Assert.assertEquals(0, handler.getWarnings().size()); }
Example #15
Source File: TestSchemaValidation.java From tomcatsrc with Apache License 2.0 | 5 votes |
@Test public void testWebapp_2_3() throws Exception { XmlErrorHandler handler = new XmlErrorHandler(); Digester digester = DigesterFactory.newDigester( true, true, new WebRuleSet(false), true); digester.setErrorHandler(handler); digester.push(new WebXml()); WebXml desc = (WebXml) digester.parse( new File("test/webapp-2.3/WEB-INF/web.xml")); Assert.assertEquals("2.3", desc.getVersion()); Assert.assertEquals(XmlIdentifiers.WEB_23_PUBLIC, desc.getPublicId()); Assert.assertEquals(0, handler.getErrors().size()); Assert.assertEquals(0, handler.getWarnings().size()); }
Example #16
Source File: TestSchemaValidation.java From tomcatsrc with Apache License 2.0 | 5 votes |
@Test public void testWebapp_2_4() throws Exception { XmlErrorHandler handler = new XmlErrorHandler(); Digester digester = DigesterFactory.newDigester( true, true, new WebRuleSet(false), true); digester.setErrorHandler(handler); digester.push(new WebXml()); WebXml desc = (WebXml) digester.parse( new File("test/webapp-2.4/WEB-INF/web.xml")); Assert.assertEquals("2.4", desc.getVersion()); Assert.assertEquals(0, handler.getErrors().size()); Assert.assertEquals(0, handler.getWarnings().size()); }
Example #17
Source File: TestSchemaValidation.java From tomcatsrc with Apache License 2.0 | 5 votes |
@Test public void testWebapp_2_5() throws Exception { XmlErrorHandler handler = new XmlErrorHandler(); Digester digester = DigesterFactory.newDigester( true, true, new WebRuleSet(false), true); digester.setErrorHandler(handler); digester.push(new WebXml()); WebXml desc = (WebXml) digester.parse( new File("test/webapp-2.5/WEB-INF/web.xml")); Assert.assertEquals("2.5", desc.getVersion()); Assert.assertEquals(0, handler.getErrors().size()); Assert.assertEquals(0, handler.getWarnings().size()); }
Example #18
Source File: TestSchemaValidation.java From tomcatsrc with Apache License 2.0 | 5 votes |
@Test public void testWebapp_3_0() throws Exception { XmlErrorHandler handler = new XmlErrorHandler(); Digester digester = DigesterFactory.newDigester( true, true, new WebRuleSet(false), true); digester.setErrorHandler(handler); digester.push(new WebXml()); WebXml desc = (WebXml) digester.parse( new File("test/webapp-3.0/WEB-INF/web.xml")); Assert.assertEquals("3.0", desc.getVersion()); Assert.assertEquals(0, handler.getErrors().size()); Assert.assertEquals(0, handler.getWarnings().size()); }
Example #19
Source File: TestWebXml.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
private void doTestValidateVersion(String version) throws IOException, SAXException { WebXml webxml = new WebXml(); // Special cases if ("2.2".equals(version)) { webxml.setPublicId(XmlIdentifiers.WEB_22_PUBLIC); } else if ("2.3".equals(version)) { webxml.setPublicId(XmlIdentifiers.WEB_23_PUBLIC); } else { webxml.setVersion(version); } // Merged web.xml that is published as MERGED_WEB_XML context attribute // in the simplest case consists of webapp's web.xml file // plus the default conf/web.xml one. Set<WebXml> defaults = new HashSet<WebXml>(); defaults.add(getDefaultWebXmlFragment()); webxml.merge(defaults); Digester digester = DigesterFactory.newDigester(true, true, new WebRuleSet(), true); XmlErrorHandler handler = new XmlErrorHandler(); digester.setErrorHandler(handler); InputSource is = new InputSource(new StringReader(webxml.toXml())); WebXml webxmlResult = new WebXml(); digester.push(webxmlResult); digester.parse(is); Assert.assertEquals(0, handler.getErrors().size()); Assert.assertEquals(0, handler.getWarnings().size()); Assert.assertEquals(version, webxml.getVersion()); Assert.assertEquals(version, webxmlResult.getVersion()); }
Example #20
Source File: ValidatorTask.java From Tomcat8-Source-Read with MIT License | 5 votes |
/** * Execute the specified command. This logic only performs the common * attribute validation required by all subclasses; it does not perform * any functional logic directly. * * @exception BuildException if a validation error occurs */ @Override public void execute() throws BuildException { if (path == null) { throw new BuildException("Must specify 'path'"); } File file = new File(path, "WEB-INF/web.xml"); if (!file.canRead()) { throw new BuildException("Cannot find web.xml"); } // Commons-logging likes having the context classloader set ClassLoader oldCL = Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader (ValidatorTask.class.getClassLoader()); // Called through trusted manager interface. If running under a // SecurityManager assume that untrusted applications may be deployed. Digester digester = DigesterFactory.newDigester( true, true, null, Globals.IS_SECURITY_ENABLED); try (InputStream stream = new BufferedInputStream(new FileInputStream(file.getCanonicalFile()));) { InputSource is = new InputSource(file.toURI().toURL().toExternalForm()); is.setByteStream(stream); digester.parse(is); handleOutput("web.xml validated"); } catch (Exception e) { if (isFailOnError()) { throw new BuildException("Validation failure", e); } else { handleErrorOutput("Validation failure: " + e); } } finally { Thread.currentThread().setContextClassLoader(oldCL); closeRedirector(); } }
Example #21
Source File: ParserUtils.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
public ParserUtils(boolean validating, boolean blockExternal) { this.validating = validating; if (entityResolver == null) { this.entityResolverInstance = new LocalResolver( DigesterFactory.SERVLET_API_PUBLIC_IDS, DigesterFactory.SERVLET_API_SYSTEM_IDS, blockExternal); } else { this.entityResolverInstance = entityResolver; } }
Example #22
Source File: TestSchemaValidation.java From Tomcat8-Source-Read with MIT License | 5 votes |
@Test public void testWebapp_3_1() throws Exception { XmlErrorHandler handler = new XmlErrorHandler(); Digester digester = DigesterFactory.newDigester( true, true, new WebRuleSet(false), true); digester.setErrorHandler(handler); digester.push(new WebXml()); WebXml desc = (WebXml) digester.parse( new File("test/webapp-3.1/WEB-INF/web.xml")); Assert.assertEquals("3.1", desc.getVersion()); Assert.assertEquals(0, handler.getErrors().size()); Assert.assertEquals(0, handler.getWarnings().size()); }
Example #23
Source File: TestSchemaValidation.java From Tomcat8-Source-Read with MIT License | 5 votes |
@Test public void testWebapp_3_0() throws Exception { XmlErrorHandler handler = new XmlErrorHandler(); Digester digester = DigesterFactory.newDigester( true, true, new WebRuleSet(false), true); digester.setErrorHandler(handler); digester.push(new WebXml()); WebXml desc = (WebXml) digester.parse( new File("test/webapp-3.0/WEB-INF/web.xml")); Assert.assertEquals("3.0", desc.getVersion()); Assert.assertEquals(0, handler.getErrors().size()); Assert.assertEquals(0, handler.getWarnings().size()); }
Example #24
Source File: TestSchemaValidation.java From Tomcat8-Source-Read with MIT License | 5 votes |
@Test public void testWebapp_2_5() throws Exception { XmlErrorHandler handler = new XmlErrorHandler(); Digester digester = DigesterFactory.newDigester( true, true, new WebRuleSet(false), true); digester.setErrorHandler(handler); digester.push(new WebXml()); WebXml desc = (WebXml) digester.parse( new File("test/webapp-2.5/WEB-INF/web.xml")); Assert.assertEquals("2.5", desc.getVersion()); Assert.assertEquals(0, handler.getErrors().size()); Assert.assertEquals(0, handler.getWarnings().size()); }
Example #25
Source File: TestSchemaValidation.java From Tomcat8-Source-Read with MIT License | 5 votes |
@Test public void testWebapp_2_4() throws Exception { XmlErrorHandler handler = new XmlErrorHandler(); Digester digester = DigesterFactory.newDigester( true, true, new WebRuleSet(false), true); digester.setErrorHandler(handler); digester.push(new WebXml()); WebXml desc = (WebXml) digester.parse( new File("test/webapp-2.4/WEB-INF/web.xml")); Assert.assertEquals("2.4", desc.getVersion()); Assert.assertEquals(0, handler.getErrors().size()); Assert.assertEquals(0, handler.getWarnings().size()); }
Example #26
Source File: TestSchemaValidation.java From Tomcat8-Source-Read with MIT License | 5 votes |
@Test public void testWebapp_2_3() throws Exception { XmlErrorHandler handler = new XmlErrorHandler(); Digester digester = DigesterFactory.newDigester( true, true, new WebRuleSet(false), true); digester.setErrorHandler(handler); digester.push(new WebXml()); WebXml desc = (WebXml) digester.parse( new File("test/webapp-2.3/WEB-INF/web.xml")); Assert.assertEquals("2.3", desc.getVersion()); Assert.assertEquals(XmlIdentifiers.WEB_23_PUBLIC, desc.getPublicId()); Assert.assertEquals(0, handler.getErrors().size()); Assert.assertEquals(0, handler.getWarnings().size()); }
Example #27
Source File: TestSchemaValidation.java From Tomcat8-Source-Read with MIT License | 5 votes |
@Test public void testWebapp_2_2() throws Exception { XmlErrorHandler handler = new XmlErrorHandler(); Digester digester = DigesterFactory.newDigester( true, true, new WebRuleSet(false), true); digester.setErrorHandler(handler); digester.push(new WebXml()); WebXml desc = (WebXml) digester.parse( new File("test/webapp-2.2/WEB-INF/web.xml")); Assert.assertEquals("2.2", desc.getVersion()); Assert.assertEquals(XmlIdentifiers.WEB_22_PUBLIC, desc.getPublicId()); Assert.assertEquals(0, handler.getErrors().size()); Assert.assertEquals(0, handler.getWarnings().size()); }
Example #28
Source File: TestSchemaValidation.java From Tomcat8-Source-Read with MIT License | 5 votes |
@Test public void testWebapp() throws Exception { XmlErrorHandler handler = new XmlErrorHandler(); Digester digester = DigesterFactory.newDigester( true, true, new WebRuleSet(false), true); digester.setErrorHandler(handler); digester.push(new WebXml()); WebXml desc = (WebXml) digester.parse( new File("test/webapp/WEB-INF/web.xml")); Assert.assertEquals("3.1", desc.getVersion()); Assert.assertEquals(0, handler.getErrors().size()); Assert.assertEquals(0, handler.getWarnings().size()); }
Example #29
Source File: TestWebXml.java From Tomcat8-Source-Read with MIT License | 5 votes |
private void doTestValidateVersion(String version) throws IOException, SAXException { WebXml webxml = new WebXml(); // Special cases if ("2.2".equals(version)) { webxml.setPublicId(XmlIdentifiers.WEB_22_PUBLIC); } else if ("2.3".equals(version)) { webxml.setPublicId(XmlIdentifiers.WEB_23_PUBLIC); } else { webxml.setVersion(version); } // Merged web.xml that is published as MERGED_WEB_XML context attribute // in the simplest case consists of webapp's web.xml file // plus the default conf/web.xml one. Set<WebXml> defaults = new HashSet<>(); defaults.add(getDefaultWebXmlFragment()); webxml.merge(defaults); Digester digester = DigesterFactory.newDigester(true, true, new WebRuleSet(), true); XmlErrorHandler handler = new XmlErrorHandler(); digester.setErrorHandler(handler); InputSource is = new InputSource(new StringReader(webxml.toXml())); WebXml webxmlResult = new WebXml(); digester.push(webxmlResult); digester.parse(is); Assert.assertEquals(0, handler.getErrors().size()); Assert.assertEquals(0, handler.getWarnings().size()); Assert.assertEquals(version, webxml.getVersion()); Assert.assertEquals(version, webxmlResult.getVersion()); }
Example #30
Source File: JspDocumentParser.java From Tomcat8-Source-Read with MIT License | 5 votes |
public JspDocumentParser( ParserController pc, String path, boolean isTagFile, boolean directivesOnly) { this.parserController = pc; this.ctxt = pc.getJspCompilationContext(); this.pageInfo = pc.getCompiler().getPageInfo(); this.err = pc.getCompiler().getErrorDispatcher(); this.path = path; this.isTagFile = isTagFile; this.directivesOnly = directivesOnly; this.isTop = true; String blockExternalString = ctxt.getServletContext().getInitParameter( Constants.XML_BLOCK_EXTERNAL_INIT_PARAM); boolean blockExternal; if (blockExternalString == null) { blockExternal = true; } else { blockExternal = Boolean.parseBoolean(blockExternalString); } this.entityResolver = new LocalResolver( DigesterFactory.SERVLET_API_PUBLIC_IDS, DigesterFactory.SERVLET_API_SYSTEM_IDS, blockExternal); }