[WSS4J] wss4j/src/org/apache/ws/security/message EnvelopeIdResolver.java,1.7,1.8
[email protected] Fri, 02 Jan 2004 04:14:43 -0800
| Newsgroups | gmane.text.xml.wss4j |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/wss4j/wss4j/src/org/apache/ws/security/message
In directory sc8-pr-cvs1:/tmp/cvs-serv24415/src/org/apache/ws/security/message
Modified Files:
EnvelopeIdResolver.java
Log Message:
Add code to accept any prefix for a WSU Id (it is not required that
it is always the string "wsu").
Index: EnvelopeIdResolver.java
===================================================================
RCS file: /cvsroot/wss4j/wss4j/src/org/apache/ws/security/message/EnvelopeIdResolver.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** EnvelopeIdResolver.java 22 Dec 2003 13:36:20 -0000 1.7
--- EnvelopeIdResolver.java 2 Jan 2004 12:14:41 -0000 1.8
***************
*** 71,75 ****
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
! import org.w3c.dom.NodeList;
import java.util.HashSet;
--- 71,75 ----
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
! import org.w3c.dom.traversal.NodeIterator;
import java.util.HashSet;
***************
*** 130,134 ****
}
- NodeList resultNodes = null;
Document doc = uri.getOwnerDocument();
--- 130,133 ----
***************
*** 145,148 ****
--- 144,152 ----
* attributes -- but not comments.
*/
+
+ /*
+ * First lookup the SOAP Body element (processed by default) and
+ * check if it contains an Id and if it matches
+ */
String id = uriNodeValue.substring(1);
Element selectedElem = WSSecurityUtil.findBodyElement(doc);
***************
*** 158,162 ****
--- 162,177 ----
cId = selectedElem.getAttributeNS(WSConstants.SOAP_SEC_NS, "id");
}
+ /*
+ * If Body Id match fails, look for a generic Id (without a namespace)
+ * that matches the URI. If that lookup fails, try to get a namespace
+ * qualified Id that matches the URI. The lookup uses a wildcard
+ * namespace. This lookup is not bound to s specific namespace prefix
+ * but accepts all prefixes.
+ *
+ * Then loop over the result set and try to get the namespace
+ * qualified Id (WSU_NS).
+ */
if (!id.equals(cId)) {
+ cId = null;
try {
selectedElem =
***************
*** 166,179 ****
if (selectedElem != null) {
cId = selectedElem.getAttribute("Id");
! } else {
! Element nscontext =
! XMLUtils.createDSctx(doc, "wsu", WSConstants.WSU_NS);
! selectedElem =
! (Element) XPathAPI.selectSingleNode(
doc,
! "//*[@wsu:Id='" + id + "']",
! nscontext);
! if (selectedElem != null) {
! cId = selectedElem.getAttributeNS(WSConstants.WSU_NS, "Id");
}
}
--- 181,200 ----
if (selectedElem != null) {
cId = selectedElem.getAttribute("Id");
! }
! else {
! NodeIterator iter =
! XPathAPI.selectNodeIterator(
doc,
! "//*[@*:Id='" + id + "']");
! for (selectedElem = (Element) iter.nextNode();
! selectedElem != null;
! selectedElem = (Element) iter.nextNode()) {
! if ((cId =
! selectedElem.getAttributeNS(
! WSConstants.WSU_NS,
! "Id"))
! != null) {
! break;
! }
}
}
***************
*** 185,195 ****
BaseURI);
}
! }
! if (!id.equals(cId)) {
! throw new ResourceResolverException(
! "generic.EmptyMessage",
! new Object[] { "Id not found" },
! uri,
! BaseURI);
}
--- 206,216 ----
BaseURI);
}
! if (cId == null) {
! throw new ResourceResolverException(
! "generic.EmptyMessage",
! new Object[] { "Id not found" },
! uri,
! BaseURI);
! }
}
-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills. Sign up for IBM's
Free Linux Tutorials. Learn everything from the bash shell to sys admin.
Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click