[WSS4J] wss4j/src/org/apache/ws/security/transform STRTransform.java,1.1,1.2
[email protected] Mon, 09 Feb 2004 08:10:30 -0800
| Newsgroups | gmane.text.xml.wss4j |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/wss4j/wss4j/src/org/apache/ws/security/transform
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8146/src/org/apache/ws/security/transform
Modified Files:
STRTransform.java
Log Message:
Add some more hooks for STRTransform. In particular a way to
exchange/publish some more information about the document and its
environment as it is processed during signature and verfication.
These hooks are working, but there is only a dummy STRTransform only.
Index: STRTransform.java
===================================================================
RCS file: /cvsroot/wss4j/wss4j/src/org/apache/ws/security/transform/STRTransform.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- STRTransform.java 15 Jan 2004 12:25:32 -0000 1.1
+++ STRTransform.java 9 Feb 2004 16:10:28 -0000 1.2
@@ -58,8 +58,16 @@
*/
package org.apache.ws.security.transform;
+import org.apache.ws.security.WSDocInfo;
+import org.apache.ws.security.WSDocInfoStore;
+
import java.io.IOException;
import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.util.Set;
+import java.util.Iterator;
+
import org.apache.xml.security.signature.XMLSignatureInput;
import org.apache.xml.security.exceptions.XMLSecurityException;
import org.apache.xml.security.utils.Constants;
@@ -126,46 +134,84 @@
doDebug = log.isDebugEnabled();
if (doDebug) {
- log.debug("Beginning STRTransform...");
+ log.debug("Beginning STRTransform..." + input.toString());
}
- /*
- * This is only a preliminary implementation to get it up and to
- * test the registration, call, etc. Real STR follows soon.
+ try {
+
+ Document doc = this._transformObject.getDocument();
+ int docHash = doc.hashCode();
+ if (doDebug) {
+ log.debug("doc: " + doc.toString() + ", " + docHash);
+ }
+ WSDocInfo wsDocInfo = WSDocInfoStore.lookup(docHash);
+ if (wsDocInfo == null) {
+ throw (new CanonicalizationException("no WSDocInfo found"));
+ }
+
+ /*
+ InputStream is = input.getOctetStream();
- try {
- Canonicalizer20010315WithComments c14n =
- new Canonicalizer20010315WithComments();
- byte[] result = null;
- if (input.isOctetStream()) {
- result = c14n.engineCanonicalize(input.getBytes());
- } else {
- result =
- c14n.engineCanonicalizeXPathNodeSet(input.getNodeSet());
- }
+ byte buf[] = new byte[is.available()];
+ is.read(buf, 0, buf.length);
+ ByteArrayOutputStream bos = new ByteArrayOutputStream(buf.length);
+ bos.write(buf, 0, buf.length);
+ if (doDebug) {
+ log.debug("input bos: " + bos.toString());
+ }
+ */
+
+ /*
+ * According to the OASIS WS Specification
+ *
+ * "Web Services Security: SOAP Message Security 1.0"
+ * Monday, 19 January 2004
+ *
+ * in chapter 8.3 the input node set
+ * must handed over to the c14n that is specified in the
+ * argument element of the STRTransform element.
+ *
+ * First step: Get the required c14n argument. After that, get the
+ * c14n, feed the node set an get back the byte[]. The byte[]
+ * contains the XML doc excerpt to be verified/processed.
+ *
+ * Second step: find the STR element inside the resulting XML doc,
+ * check if STR contains some reference to an security token.
+ * As per OASIS WS specification this shall be a X509SubjectKeyIdentifier
+ * (SKI) that points to a security token.
+ * (are other reference types also possible/allowed?)
+ *
+ * Third step: locate the security token referenced by the STR
+ * element. Either the Token is contained in the document as a
+ * BinarySecurityToken or stored in some key storage. The WSDocInfo
+ * contains the implementation of the key storage to use. To locate
+ * a BST inside a document check if a BST was already found and the
+ * element stored in WSDocInfo.
+ *
+ * Forth step: after security token was located, prepare it. Either
+ * copy (clone) the BinarySeciurityToken or wrap the located token
+ * in a newly created BST element as specified in WS Specification.
+ *
+ * Fifth step: replace the STR with the above create/copied BST, feed
+ * this result in the specified c14n method and return this to
+ * the caller.
+ *
+ */
+
+ /*
+ * NOTE: The followig code is debug, not a real STR Transform
+ */
+ Set nodeSet = input.getNodeSet();
+ Iterator iter = nodeSet.iterator();
+
+ while (iter.hasNext()) {
+ Object obj = iter.next();
+
if (doDebug) {
- log.debug("Exit STRTransform...");
+ log.debug("Node: " + obj.toString());
}
- return new XMLSignatureInput(result);
- } catch (ParserConfigurationException ex) {
- Object[] exArgs = { ex.getMessage()};
- CanonicalizationException cex =
- new CanonicalizationException(
- "c14n.Canonicalizer.ParserConfigurationException",
- exArgs);
- throw cex;
- } catch (SAXException ex) {
- Object[] exArgs = { ex.toString()};
- CanonicalizationException cex =
- new CanonicalizationException(
- "c14n.Canonicalizer.SAXException",
- exArgs);
-
- throw cex;
}
- */
-
- try {
+
InclusiveNamespaces inclusiveNamespaces = null;
if (this._transformObject
-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn