|
From: <pe...@us...> - 2004-03-02 23:42:51
|
Update of /cvsroot/neuclear/neuclear-xmlsig/src/test/org/neuclear/xml/xmlsec In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32469/src/test/org/neuclear/xml/xmlsec Modified Files: SimpleXMLSigTest.java Log Message: Renamed SignatureInfo to SignedInfo as that is the name of the Element. Made some changes in the Canonicalizer to make all the output verify in Aleksey's xmlsec library. Unfortunately this breaks example 3 of merlin-eight's canonicalization interop tests, because dom4j afaik can't tell the difference between <test/> and <test xmlns=""/>. Changed XMLSignature it is now has less repeated code. Index: SimpleXMLSigTest.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-xmlsig/src/test/org/neuclear/xml/xmlsec/SimpleXMLSigTest.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** SimpleXMLSigTest.java 2 Mar 2004 18:39:57 -0000 1.9 --- SimpleXMLSigTest.java 2 Mar 2004 23:30:44 -0000 1.10 *************** *** 6,9 **** --- 6,12 ---- import org.dom4j.DocumentHelper; import org.neuclear.commons.crypto.CryptoException; + import org.neuclear.commons.crypto.passphraseagents.UserCancellationException; + import org.neuclear.commons.crypto.signers.Signer; + import org.neuclear.commons.crypto.signers.TestCaseSigner; import org.neuclear.commons.test.JunitTools; import org.neuclear.xml.XMLException; *************** *** 22,39 **** * $Id$ * $Log$ * Revision 1.9 2004/03/02 18:39:57 pelle * Done some more minor fixes within xmlsig, but mainly I've removed the old Source and Store patterns and sub packages. This is because * they really are no longer necessary with the new non naming naming system. ! * * Revision 1.8 2004/02/19 00:28:00 pelle * Discovered several incompatabilities with the xmlsig implementation. Have been working on getting it working. * Currently there is still a problem with enveloping signatures and it seems enveloped signatures done via signers. ! * * Revision 1.7 2004/01/14 06:42:38 pelle * Got rid of the verifyXXX() methods ! * * Revision 1.6 2004/01/13 23:37:59 pelle * Refactoring parts of the core of XMLSignature. There shouldnt be any real API changes. ! * * Revision 1.5 2003/11/21 04:44:31 pelle * EncryptedFileStore now works. It uses the PBECipher with DES3 afair. --- 25,49 ---- * $Id$ * $Log$ + * Revision 1.10 2004/03/02 23:30:44 pelle + * Renamed SignatureInfo to SignedInfo as that is the name of the Element. + * Made some changes in the Canonicalizer to make all the output verify in Aleksey's xmlsec library. + * Unfortunately this breaks example 3 of merlin-eight's canonicalization interop tests, because dom4j afaik + * can't tell the difference between <test/> and <test xmlns=""/>. + * Changed XMLSignature it is now has less repeated code. + * * Revision 1.9 2004/03/02 18:39:57 pelle * Done some more minor fixes within xmlsig, but mainly I've removed the old Source and Store patterns and sub packages. This is because * they really are no longer necessary with the new non naming naming system. ! * <p/> * Revision 1.8 2004/02/19 00:28:00 pelle * Discovered several incompatabilities with the xmlsig implementation. Have been working on getting it working. * Currently there is still a problem with enveloping signatures and it seems enveloped signatures done via signers. ! * <p/> * Revision 1.7 2004/01/14 06:42:38 pelle * Got rid of the verifyXXX() methods ! * <p/> * Revision 1.6 2004/01/13 23:37:59 pelle * Refactoring parts of the core of XMLSignature. There shouldnt be any real API changes. ! * <p/> * Revision 1.5 2003/11/21 04:44:31 pelle * EncryptedFileStore now works. It uses the PBECipher with DES3 afair. *************** *** 41,45 **** * Anything that can be final has been made final throughout everyting. We've used IDEA's Inspector tool to find all instance of variables that could be final. * This should hopefully make everything more stable (and secure). ! * * Revision 1.4 2003/11/20 23:41:58 pelle * Getting all the tests to work in id --- 51,55 ---- * Anything that can be final has been made final throughout everyting. We've used IDEA's Inspector tool to find all instance of variables that could be final. * This should hopefully make everything more stable (and secure). ! * <p/> * Revision 1.4 2003/11/20 23:41:58 pelle * Getting all the tests to work in id *************** *** 47,51 **** * First version of EntityLedger that will use OFB's EntityEngine. This will allow us to support a vast amount databases without * writing SQL. (Yipee) ! * * Revision 1.3 2003/11/18 23:35:18 pelle * Payment Web Application is getting there. --- 57,61 ---- * First version of EntityLedger that will use OFB's EntityEngine. This will allow us to support a vast amount databases without * writing SQL. (Yipee) ! * <p/> * Revision 1.3 2003/11/18 23:35:18 pelle * Payment Web Application is getting there. *************** *** 117,128 **** public SimpleXMLSigTest(final String s) throws SecurityException, NoSuchAlgorithmException, CryptoException { super(s); ! signer = JunitTools.getTestRSAKey(); ! dsaSigner = JunitTools.getTestDSAKey(); new File("target/testdata/homegrown").mkdirs(); } ! public final void testRSASignXML() throws DocumentException, XMLException, CryptoException { Document doc = DocumentHelper.parseText(TESTXML); ! final XMLSignature sig = new XMLSignature(signer, doc.getRootElement()); final File outputFile = new File("target/testdata/homegrown/signature-enveloped-rsa.xml"); XMLTools.writeFile(outputFile, doc); --- 127,139 ---- public SimpleXMLSigTest(final String s) throws SecurityException, NoSuchAlgorithmException, CryptoException { super(s); ! rsa = JunitTools.getTestRSAKey(); ! dsa = JunitTools.getTestDSAKey(); ! signer = new TestCaseSigner(); new File("target/testdata/homegrown").mkdirs(); } ! public final void testEnvelopedUsignRSAKeyPair() throws DocumentException, XMLException, CryptoException { Document doc = DocumentHelper.parseText(TESTXML); ! final XMLSignature sig = new XMLSignature(rsa, doc.getRootElement()); final File outputFile = new File("target/testdata/homegrown/signature-enveloped-rsa.xml"); XMLTools.writeFile(outputFile, doc); *************** *** 132,138 **** } ! public final void testRSAEnvelopingSignXML() throws DocumentException, XMLException, CryptoException { Document doc = DocumentHelper.parseText(TESTXML); ! final XMLSignature sig = new XMLSignature(signer, doc.getRootElement(), Reference.XMLSIGTYPE_ENVELOPING); final File outputFile = new File("target/testdata/homegrown/signature-enveloping-rsa.xml"); XMLTools.writeFile(outputFile, sig.getElement()); --- 143,149 ---- } ! public final void testEnvelopingUsignRSAKeyPair() throws DocumentException, XMLException, CryptoException { Document doc = DocumentHelper.parseText(TESTXML); ! final XMLSignature sig = new XMLSignature(rsa, doc.getRootElement(), Reference.XMLSIGTYPE_ENVELOPING); final File outputFile = new File("target/testdata/homegrown/signature-enveloping-rsa.xml"); XMLTools.writeFile(outputFile, sig.getElement()); *************** *** 142,148 **** } ! public final void testDSAEnvelopingSignXML() throws DocumentException, XMLException, CryptoException { Document doc = DocumentHelper.parseText(TESTXML); ! final XMLSignature sig = new XMLSignature(dsaSigner, doc.getRootElement(), Reference.XMLSIGTYPE_ENVELOPING); final File outputFile = new File("target/testdata/homegrown/signature-enveloping-dsa.xml"); XMLTools.writeFile(outputFile, sig.getElement()); --- 153,159 ---- } ! public final void testEnvelopingUsignDSAKeyPair() throws DocumentException, XMLException, CryptoException { Document doc = DocumentHelper.parseText(TESTXML); ! final XMLSignature sig = new XMLSignature(dsa, doc.getRootElement(), Reference.XMLSIGTYPE_ENVELOPING); final File outputFile = new File("target/testdata/homegrown/signature-enveloping-dsa.xml"); XMLTools.writeFile(outputFile, sig.getElement()); *************** *** 152,160 **** } ! public final void testDSASignXML() throws DocumentException, XMLException, CryptoException { ! assertTrue("Test if public key is really DSA", dsaSigner.getPublic() instanceof DSAPublicKey); Document doc = DocumentHelper.parseText(TESTXML); ! final XMLSignature sig = new XMLSignature(dsaSigner, doc.getRootElement()); final File outputFile = new File("target/testdata/homegrown/signature-enveloped-dsa.xml"); --- 163,171 ---- } ! public final void testEnvelopedUsignDSAKeyPair() throws DocumentException, XMLException, CryptoException { ! assertTrue("Test if public key is really DSA", dsa.getPublic() instanceof DSAPublicKey); Document doc = DocumentHelper.parseText(TESTXML); ! final XMLSignature sig = new XMLSignature(dsa, doc.getRootElement()); final File outputFile = new File("target/testdata/homegrown/signature-enveloped-dsa.xml"); *************** *** 166,192 **** ! public final void testBadSignXML() throws DocumentException, XMLException, CryptoException { final Document doc = DocumentHelper.parseText(TESTXML); ! XMLSecTools.signElement( doc.getRootElement(), signer); ! assertTrue("Test if Signature is valid", XMLSecTools.verifySignature(doc.getRootElement(), signer.getPublic())); doc.getRootElement().addElement("BadElement"); ! assertTrue("Test that Signature is invalid", !XMLSecTools.verifySignature(doc.getRootElement(), signer.getPublic())); } ! public final void testBadDSASignXML() throws DocumentException, XMLException, CryptoException { final Document doc = DocumentHelper.parseText(TESTXML); ! XMLSecTools.signElement(doc.getRootElement(), dsaSigner); ! assertTrue("Test if DSA Signature is valid", XMLSecTools.verifySignature(doc.getRootElement(), dsaSigner.getPublic())); doc.getRootElement().addElement("BadElement"); ! assertTrue("Test that DSA Signature is invalid", !XMLSecTools.verifySignature(doc.getRootElement(), signer.getPublic())); } ! final KeyPair signer; ! final KeyPair dsaSigner; final static String TESTXML = "<test><test2></test2></test>"; } --- 177,245 ---- ! public final void testBadRSASignature() throws DocumentException, XMLException, CryptoException { final Document doc = DocumentHelper.parseText(TESTXML); ! XMLSecTools.signElement(doc.getRootElement(), rsa); ! assertTrue("Test if Signature is valid", XMLSecTools.verifySignature(doc.getRootElement(), rsa.getPublic())); doc.getRootElement().addElement("BadElement"); ! assertTrue("Test that Signature is invalid", !XMLSecTools.verifySignature(doc.getRootElement(), rsa.getPublic())); } ! public final void testBadDSASignature() throws DocumentException, XMLException, CryptoException { final Document doc = DocumentHelper.parseText(TESTXML); ! XMLSecTools.signElement(doc.getRootElement(), dsa); ! assertTrue("Test if DSA Signature is valid", XMLSecTools.verifySignature(doc.getRootElement(), dsa.getPublic())); doc.getRootElement().addElement("BadElement"); ! assertTrue("Test that DSA Signature is invalid", !XMLSecTools.verifySignature(doc.getRootElement(), rsa.getPublic())); } ! public final void testEnvelopedUsingSigner() throws DocumentException, XMLException, CryptoException, UserCancellationException { ! Document doc = DocumentHelper.parseText(TESTXML); ! final XMLSignature sig = new XMLSignature("neu://test", signer, doc.getRootElement(), Reference.XMLSIGTYPE_ENVELOPED); ! final File outputFile = new File("target/testdata/homegrown/signature-enveloped-signer.xml"); ! XMLTools.writeFile(outputFile, doc); ! ! doc = XMLTools.loadDocument(outputFile); ! assertTrue("Test if Signature is valid", XMLSecTools.verifySignature(doc.getRootElement())); ! } ! ! public final void testEnvelopingUsingSigner() throws DocumentException, XMLException, CryptoException, UserCancellationException { ! Document doc = DocumentHelper.parseText(TESTXML); ! final XMLSignature sig = new XMLSignature("neu://test", signer, doc.getRootElement(), Reference.XMLSIGTYPE_ENVELOPING); ! final File outputFile = new File("target/testdata/homegrown/signature-enveloping-signer.xml"); ! XMLTools.writeFile(outputFile, sig.getElement()); ! ! doc = XMLTools.loadDocument(outputFile); ! assertTrue("Test if Signature is valid", XMLSecTools.verifySignature(doc.getRootElement())); ! } ! ! public final void testComplexEnvelopedUsingSigner() throws DocumentException, XMLException, CryptoException, UserCancellationException { ! Document doc = DocumentHelper.parseText(COMPLEX_XML); ! final XMLSignature sig = new XMLSignature("neu://test", signer, doc.getRootElement(), Reference.XMLSIGTYPE_ENVELOPED); ! final File outputFile = new File("target/testdata/homegrown/signature-complex-enveloped-signer.xml"); ! XMLTools.writeFile(outputFile, doc); ! ! doc = XMLTools.loadDocument(outputFile); ! assertTrue("Test if Signature is valid", XMLSecTools.verifySignature(doc.getRootElement())); ! } ! ! public final void testComplexEnvelopingUsingSigner() throws DocumentException, XMLException, CryptoException, UserCancellationException { ! Document doc = DocumentHelper.parseText(COMPLEX_XML); ! final XMLSignature sig = new XMLSignature("neu://test", signer, doc.getRootElement(), Reference.XMLSIGTYPE_ENVELOPING); ! final File outputFile = new File("target/testdata/homegrown/signature-complex-enveloping-signer.xml"); ! XMLTools.writeFile(outputFile, sig.getElement()); ! ! doc = XMLTools.loadDocument(outputFile); ! assertTrue("Test if Signature is valid", XMLSecTools.verifySignature(doc.getRootElement())); ! } ! ! private final KeyPair rsa; ! private final KeyPair dsa; ! private final Signer signer; final static String TESTXML = "<test><test2></test2></test>"; + final static String COMPLEX_XML = "<test xmlns=\"http://talk.org\"><test2></test2></test>"; } |