You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@santuario.apache.org by mu...@apache.org on 2007/09/07 16:23:35 UTC

svn commit: r573593 - /xml/security/branches/stax_jsr105/src/com/r_bg/stax/StaxXMLSignatureFactory.java

Author: mullan
Date: Fri Sep  7 07:23:35 2007
New Revision: 573593

URL: http://svn.apache.org/viewvc?rev=573593&view=rev
Log:
Implement unmarshalXMLSignature method.

Modified:
    xml/security/branches/stax_jsr105/src/com/r_bg/stax/StaxXMLSignatureFactory.java

Modified: xml/security/branches/stax_jsr105/src/com/r_bg/stax/StaxXMLSignatureFactory.java
URL: http://svn.apache.org/viewvc/xml/security/branches/stax_jsr105/src/com/r_bg/stax/StaxXMLSignatureFactory.java?rev=573593&r1=573592&r2=573593&view=diff
==============================================================================
--- xml/security/branches/stax_jsr105/src/com/r_bg/stax/StaxXMLSignatureFactory.java (original)
+++ xml/security/branches/stax_jsr105/src/com/r_bg/stax/StaxXMLSignatureFactory.java Fri Sep  7 07:23:35 2007
@@ -30,6 +30,10 @@
 import javax.xml.crypto.dsig.spec.DigestMethodParameterSpec;
 import javax.xml.crypto.dsig.spec.SignatureMethodParameterSpec;
 import javax.xml.crypto.dsig.spec.TransformParameterSpec;
+import javax.xml.stream.StreamFilter;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
 
 import org.jcp.xml.dsig.internal.dom.XMLDSigRI;
 
@@ -152,17 +156,37 @@
 		return null;
 	}
 
-	@Override
-	public XMLSignature unmarshalXMLSignature(XMLValidateContext context) throws MarshalException {
-		// TODO Auto-generated method stub
-		return ((StaxValidateContext)context).getSignature();
-	}
-
-	@Override
-	public XMLSignature unmarshalXMLSignature(XMLStructure xmlStructure) throws MarshalException {
-		// TODO Auto-generated method stub
-		return null;
-	}
+    @Override
+    public XMLSignature unmarshalXMLSignature(XMLValidateContext context) 
+        throws MarshalException {
+        if (context == null) {
+            throw new NullPointerException();
+        }
+        if (!(context instanceof StaxValidateContext)) {
+            throw new ClassCastException();
+        }
+        StaxValidateContext svc = (StaxValidateContext) context;
+        XMLStreamReader reader = svc.getXMLStreamReader();
+        XMLInputFactory xif = XMLInputFactory.newInstance();
+        StreamFilter sf = svc.getStreamFilter();
+        try {
+            XMLStreamReader fsr = xif.createFilteredReader(reader, sf);
+              while ((fsr.getEventType()) != XMLStreamReader.END_DOCUMENT) {
+                  fsr.next();
+              }
+        } catch (XMLStreamException xse) {
+            throw new MarshalException(xse);
+        }
+
+        return svc.getSignature();
+    }
+
+    @Override
+    public XMLSignature unmarshalXMLSignature(XMLStructure xmlStructure) 
+        throws MarshalException {
+        if (xmlStructure == null) throw new NullPointerException();
+        return null;
+    }
 
 	@Override
 	public boolean isFeatureSupported(String feature) {