[utilities COMMIT] in /xmlsectool/trunk: doc/RELEASE-NOTES.txt src/main/java/edu/internet2/middleware/security/XmlSec...
noreply at shibboleth.net
noreply at shibboleth.net
Tue Mar 5 07:35:16 EST 2013
Author: iay
Date: Tue Mar 5 07:35:16 2013
New Revision: 336
URL: http://svn.shibboleth.net/view/utilities?rev=336&view=rev
Log:
[XSTJ-16] - misleading error message on failed schema validation
Includes manual regression test for the fix.
Added:
xmlsectool/trunk/src/test/resources/manual/XSTJ-16/
xmlsectool/trunk/src/test/resources/manual/XSTJ-16/bad/
xmlsectool/trunk/src/test/resources/manual/XSTJ-16/bad/in1.xsd (with props)
xmlsectool/trunk/src/test/resources/manual/XSTJ-16/fail/
xmlsectool/trunk/src/test/resources/manual/XSTJ-16/fail/in1.xsd (with props)
xmlsectool/trunk/src/test/resources/manual/XSTJ-16/good/
xmlsectool/trunk/src/test/resources/manual/XSTJ-16/good/in1.xsd (with props)
xmlsectool/trunk/src/test/resources/manual/XSTJ-16/in1.xml (with props)
xmlsectool/trunk/src/test/resources/manual/XSTJ-16/readme.md
Modified:
xmlsectool/trunk/doc/RELEASE-NOTES.txt
xmlsectool/trunk/src/main/java/edu/internet2/middleware/security/XmlSecTool.java
Modified: xmlsectool/trunk/doc/RELEASE-NOTES.txt
URL: http://svn.shibboleth.net/view/utilities/xmlsectool/trunk/doc/RELEASE-NOTES.txt?rev=336&r1=335&r2=336&view=diff
==============================================================================
--- xmlsectool/trunk/doc/RELEASE-NOTES.txt (original)
+++ xmlsectool/trunk/doc/RELEASE-NOTES.txt Tue Mar 5 07:35:16 2013
@@ -2,6 +2,7 @@
=============================================
[XSTJ-22] - non-zero exit codes from shell script
[XSTJ-17] - multiple errors in --help documentation
+[XSTJ-16] - misleading error message on failed schema validation
Changes in Release 1.1.4
=============================================
Modified: xmlsectool/trunk/src/main/java/edu/internet2/middleware/security/XmlSecTool.java
URL: http://svn.shibboleth.net/view/utilities/xmlsectool/trunk/src/main/java/edu/internet2/middleware/security/XmlSecTool.java?rev=336&r1=335&r2=336&view=diff
==============================================================================
--- xmlsectool/trunk/src/main/java/edu/internet2/middleware/security/XmlSecTool.java (original)
+++ xmlsectool/trunk/src/main/java/edu/internet2/middleware/security/XmlSecTool.java Tue Mar 5 07:35:16 2013
@@ -333,14 +333,15 @@
}
/**
- * Validates the SAML document against the SAML 1.1 and 2.0 schema.
+ * Validates the document against the schema source indicated by the CLI arguments.
*
* @param cli command line arguments
* @param xml document to validate
*/
- protected static void schemaValidate(XmlSecToolCommandLineArguments cli, Document xml) {
- File schemaFileOrDirectory = new File(cli.getSchemaDirectory());
- try {
+ protected static void schemaValidate(final XmlSecToolCommandLineArguments cli, final Document xml) {
+ Validator validator;
+ try {
+ final File schemaFileOrDirectory = new File(cli.getSchemaDirectory());
Schema schema;
if (cli.isXsdSchema()) {
log.debug("Building W3 XML Schema from file/directory '{}'", schemaFileOrDirectory.getAbsolutePath());
@@ -350,15 +351,23 @@
schema = SchemaBuilder.buildSchema(SchemaLanguage.RELAX, schemaFileOrDirectory);
}
- Validator validator = schema.newValidator();
+ validator = schema.newValidator();
+ } catch (SAXException e) {
+ log.error("Invalid XML schema files, unable to validate XML", e);
+ System.exit(RC_INVALID_XS);
+ // Help Java understand that validator is guaranteed to have been assigned below
+ return;
+ }
+
+ try {
log.debug("Schema validating XML document");
validator.validate(new DOMSource(xml));
log.info("XML document is schema valid");
} catch (SAXException e) {
- log.error("Invalid XML schema files, unable to validate XML", e);
- System.exit(RC_INVALID_XS);
- } catch (Exception e) {
log.error("XML is not schema valid", e);
+ System.exit(RC_INVALID_XML);
+ } catch (IOException e) {
+ log.error("internal error: I/O exception while validating XML", e);
System.exit(RC_INVALID_XML);
}
}
More information about the commits
mailing list