[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
Wed Mar 6 06:58:18 EST 2013
Author: iay
Date: Wed Mar 6 06:58:18 2013
New Revision: 338
URL: http://svn.shibboleth.net/view/utilities?rev=338&view=rev
Log:
[XSTJ-27] - compatibility with Apache Santuario 1.5.x
[XSTJ-15] - XmlSecTool fails with String index out of range -1
Added:
xmlsectool/trunk/src/test/resources/manual/XSTJ-27/ (with props)
xmlsectool/trunk/src/test/resources/manual/XSTJ-27/in1.xml (with props)
xmlsectool/trunk/src/test/resources/manual/XSTJ-27/in3.xml (with props)
xmlsectool/trunk/src/test/resources/manual/XSTJ-27/in4.xml (with props)
xmlsectool/trunk/src/test/resources/manual/XSTJ-27/out1.xml (with props)
xmlsectool/trunk/src/test/resources/manual/XSTJ-27/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=338&r1=337&r2=338&view=diff
==============================================================================
--- xmlsectool/trunk/doc/RELEASE-NOTES.txt (original)
+++ xmlsectool/trunk/doc/RELEASE-NOTES.txt Wed Mar 6 06:58:18 2013
@@ -1,8 +1,10 @@
Changes in Release 1.2.0
=============================================
+[XSTJ-27] - compatibility with Apache Santuario 1.5.x
[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
+[XSTJ-15] - XmlSecTool fails with String index out of range -1
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=338&r1=337&r2=338&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 Wed Mar 6 06:58:18 2013
@@ -84,6 +84,7 @@
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
@@ -479,6 +480,8 @@
Attr referenceAttribute =
(Attr) rootElement.getAttributes().getNamedItem(cli.getReferenceIdAttributeName());
if (referenceAttribute != null) {
+ // Mark the reference attribute as a valid ID attribute
+ rootElement.setIdAttributeNode(referenceAttribute, true);
reference = DatatypeHelper.safeTrim(referenceAttribute.getValue());
if (reference.length() > 0) {
reference = "#" + reference;
@@ -534,6 +537,65 @@
}
/**
+ * Reconcile the given reference with the document element, by making sure that
+ * the appropriate attribute is marked as an ID attribute.
+ *
+ * @param docElement document element whose appropriate attribute should be marked
+ * @param reference reference which references the document element
+ */
+ protected static void markIdAttribute(final Element docElement, final Reference reference)
+ {
+ final String referenceUri = reference.getURI();
+
+ /*
+ * If the reference is empty, it implicitly references the document element
+ * and no attribute is being referenced.
+ */
+ if (DatatypeHelper.isEmpty(referenceUri)) {
+ log.debug("reference was empty; no ID marking required");
+ return;
+ }
+
+ /*
+ * If something has already identified an ID element, don't interfere
+ */
+ if (XMLHelper.getIdAttribute(docElement) != null ) {
+ log.debug("document element already has an ID attribute");
+ return;
+ }
+
+ /*
+ * The reference must be a fragment reference, from which we extract the
+ * ID value.
+ */
+ if (!referenceUri.startsWith("#")) {
+ log.error("Signature Reference URI was not a document fragment reference: " + referenceUri);
+ System.exit(RC_SIG);
+ }
+ final String id = referenceUri.substring(1);
+
+ /*
+ * Now look for the attribute which holds the ID value, and mark it as the ID attribute.
+ */
+ NamedNodeMap attributes = docElement.getAttributes();
+ for (int i = 0; i < attributes.getLength(); i++) {
+ Attr attribute = (Attr) attributes.item(i);
+ if (id.equals(attribute.getValue())) {
+ log.debug("marking ID attribute {}", attribute.getName());
+ docElement.setIdAttributeNode(attribute, true);
+ return;
+ }
+ }
+
+ /*
[... 124 lines stripped ...]
More information about the commits
mailing list