|
From: <pe...@us...> - 2004-01-15 00:01:49
|
Update of /cvsroot/neuclear/neuclear-xmlsig/src/java/org/neuclear/xml/xmlsec In directory sc8-pr-cvs1:/tmp/cvs-serv8943/src/java/org/neuclear/xml/xmlsec Modified Files: Reference.java XMLSignature.java Log Message: Problem fixed with Enveloping signatures. Index: Reference.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-xmlsig/src/java/org/neuclear/xml/xmlsec/Reference.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Reference.java 14 Jan 2004 17:07:59 -0000 1.8 --- Reference.java 15 Jan 2004 00:01:46 -0000 1.9 *************** *** 1,4 **** --- 1,7 ---- /* $Id$ * $Log$ + * Revision 1.9 2004/01/15 00:01:46 pelle + * Problem fixed with Enveloping signatures. + * * Revision 1.8 2004/01/14 17:07:59 pelle * KeyInfo containing X509Certificates now work correctly. *************** *** 131,138 **** import org.dom4j.Element; - import org.dom4j.Node; - import org.dom4j.DocumentHelper; import org.neuclear.commons.Utility; - import org.neuclear.commons.crypto.Base64; import org.neuclear.commons.crypto.CryptoTools; import org.neuclear.xml.XMLException; --- 134,138 ---- *************** *** 141,148 **** import org.neuclear.xml.c14.CanonicalizerWithoutSignature; ! import java.io.*; ! import java.util.List; ! import java.net.URL; import java.net.MalformedURLException; public final class Reference extends AbstractXMLSigElement { --- 141,149 ---- import org.neuclear.xml.c14.CanonicalizerWithoutSignature; ! import java.io.BufferedInputStream; ! import java.io.ByteArrayOutputStream; ! import java.io.IOException; import java.net.MalformedURLException; + import java.net.URL; public final class Reference extends AbstractXMLSigElement { *************** *** 161,175 **** final Canonicalizer canon; Element transformsElement = addElement("Transforms"); ! final Element object; if (sigtype == XMLSIGTYPE_ENVELOPED){ canon=new CanonicalizerWithoutSignature(); transformsElement.addElement(XMLSecTools.createQName("Transform")).addAttribute("Algorithm","http://www.w3.org/2000/09/xmldsig#enveloped-signature"); ! object=root; } else if (sigtype == XMLSIGTYPE_ENVELOPING){ canon= new Canonicalizer(); ! object=getElement().getParent().getParent().addElement("Object"); ! object.addAttribute("Id","data"); ! object.add(root.createCopy()); } else { throw new XMLSecurityException("Unsupported Signature Method"); --- 162,174 ---- final Canonicalizer canon; Element transformsElement = addElement("Transforms"); ! // final Element object; if (sigtype == XMLSIGTYPE_ENVELOPED){ canon=new CanonicalizerWithoutSignature(); transformsElement.addElement(XMLSecTools.createQName("Transform")).addAttribute("Algorithm","http://www.w3.org/2000/09/xmldsig#enveloped-signature"); ! // object=root; } else if (sigtype == XMLSIGTYPE_ENVELOPING){ canon= new Canonicalizer(); ! //object=root.getParent(); } else { throw new XMLSecurityException("Unsupported Signature Method"); *************** *** 182,186 **** createAttribute("URI","#"+id); ! addDigest(canon,object); } --- 181,185 ---- createAttribute("URI","#"+id); ! addDigest(canon,root); } Index: XMLSignature.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-xmlsig/src/java/org/neuclear/xml/xmlsec/XMLSignature.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** XMLSignature.java 14 Jan 2004 06:42:38 -0000 1.10 --- XMLSignature.java 15 Jan 2004 00:01:46 -0000 1.11 *************** *** 1,4 **** --- 1,7 ---- /* $Id$ * $Log$ + * Revision 1.11 2004/01/15 00:01:46 pelle + * Problem fixed with Enveloping signatures. + * * Revision 1.10 2004/01/14 06:42:38 pelle * Got rid of the verifyXXX() methods *************** *** 178,184 **** import org.neuclear.commons.crypto.CryptoTools; import org.neuclear.commons.crypto.passphraseagents.UserCancellationException; - import org.neuclear.commons.crypto.signers.Signer; - import org.neuclear.commons.crypto.signers.PublicKeySource; import org.neuclear.commons.crypto.signers.NonExistingSignerException; import org.neuclear.xml.XMLException; --- 181,187 ---- import org.neuclear.commons.crypto.CryptoTools; import org.neuclear.commons.crypto.passphraseagents.UserCancellationException; import org.neuclear.commons.crypto.signers.NonExistingSignerException; + import org.neuclear.commons.crypto.signers.PublicKeySource; + import org.neuclear.commons.crypto.signers.Signer; import org.neuclear.xml.XMLException; *************** *** 228,231 **** --- 231,235 ---- } else if (type == Reference.XMLSIGTYPE_ENVELOPING) { final Element objElem = XMLSecTools.createElementInSignatureSpace("Object"); + objElem.addAttribute("Id","data"); getElement().add(objElem); DocumentHelper.createDocument(getElement());//As Signature Element is parent we will now add a doc *************** *** 233,237 **** root = objElem; } else { ! // Detached Handle this in the Ference Constructor } final int alg = (key instanceof RSAPrivateKey) ? SignatureInfo.SIG_ALG_RSA : SignatureInfo.SIG_ALG_DSA; --- 237,241 ---- root = objElem; } else { ! throw new XMLSecurityException("Unknown Signature Method"); } final int alg = (key instanceof RSAPrivateKey) ? SignatureInfo.SIG_ALG_RSA : SignatureInfo.SIG_ALG_DSA; |