|
From: <pe...@us...> - 2003-11-21 04:44:35
|
Update of /cvsroot/neuclear/neuclear-xmlsig/src/test/org/neuclear/xml/xmlsec In directory sc8-pr-cvs1:/tmp/cvs-serv10728/src/test/org/neuclear/xml/xmlsec Modified Files: SignatureTests.java SimpleXMLSigTest.java Log Message: EncryptedFileStore now works. It uses the PBECipher with DES3 afair. Otherwise You will Finaliate. 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). Index: SignatureTests.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-xmlsig/src/test/org/neuclear/xml/xmlsec/SignatureTests.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** SignatureTests.java 11 Nov 2003 16:33:32 -0000 1.1.1.1 --- SignatureTests.java 21 Nov 2003 04:44:31 -0000 1.2 *************** *** 7,10 **** --- 7,16 ---- * $Id$ * $Log$ + * Revision 1.2 2003/11/21 04:44:31 pelle + * EncryptedFileStore now works. It uses the PBECipher with DES3 afair. + * Otherwise You will Finaliate. + * 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.1.1.1 2003/11/11 16:33:32 pelle * Moved over from neudist.org *************** *** 81,86 **** import java.io.*; ! public class SignatureTests extends TestCase { ! public SignatureTests(String s) { super(s); reader=new SAXReader(false); --- 87,92 ---- import java.io.*; ! public final class SignatureTests extends TestCase { ! public SignatureTests(final String s) { super(s); reader=new SAXReader(false); *************** *** 91,119 **** } ! public void testHomeGrown() throws IOException, DocumentException, NeuClearException { runDirectoryTest("src/testdata/homegrown"); } ! public void testMerlin23() throws IOException, DocumentException, NeuClearException { runDirectoryTest("src/testdata/merlin-xmldsig-twenty-three");//,"signature-enveloping-dsa\\.xml"); } ! public void testPhaos() throws IOException, DocumentException, NeuClearException { // runDirectoryTest("src/testdata/phaos-xmldsig-two"); } ! public void runDirectoryTest(String path) throws DocumentException, IOException, FileNotFoundException, NeuClearException { runDirectoryTest(path,null); } ! public void runDirectoryTest(String path,String regex) throws DocumentException, IOException, FileNotFoundException, NeuClearException { ! File dir=new File(path); if (!dir.exists()) { System.out.println("Doesnt exist"); return; } ! FilenameFilter filter; if (regex==null) filter=new FilenameFilter(){ ! public boolean accept(File dirf, String name) { return name.endsWith(".xml"); } --- 97,125 ---- } ! public final void testHomeGrown() throws IOException, DocumentException, NeuClearException { runDirectoryTest("src/testdata/homegrown"); } ! public final void testMerlin23() throws IOException, DocumentException, NeuClearException { runDirectoryTest("src/testdata/merlin-xmldsig-twenty-three");//,"signature-enveloping-dsa\\.xml"); } ! public final void testPhaos() throws IOException, DocumentException, NeuClearException { // runDirectoryTest("src/testdata/phaos-xmldsig-two"); } ! public final void runDirectoryTest(final String path) throws DocumentException, IOException, FileNotFoundException, NeuClearException { runDirectoryTest(path,null); } ! public final void runDirectoryTest(final String path,final String regex) throws DocumentException, IOException, FileNotFoundException, NeuClearException { ! final File dir=new File(path); if (!dir.exists()) { System.out.println("Doesnt exist"); return; } ! final FilenameFilter filter; if (regex==null) filter=new FilenameFilter(){ ! public boolean accept(final File dirf, final String name) { return name.endsWith(".xml"); } *************** *** 121,131 **** else filter=new RegexFileNameFilter(regex); ! File xmlfiles[]=dir.listFiles(filter); System.out.println("There are "+xmlfiles.length+" files in the directory"); for (int i = 0; i < xmlfiles.length; i++) { ! File xmlfile = xmlfiles[i]; System.out.print("Testing file: "+xmlfile.getName()+"... "); ! Document doc=reader.read(xmlfile); System.out.print("root element: "+doc.getRootElement().getQualifiedName()+" ..."); try { --- 127,137 ---- else filter=new RegexFileNameFilter(regex); ! final File[] xmlfiles=dir.listFiles(filter); System.out.println("There are "+xmlfiles.length+" files in the directory"); for (int i = 0; i < xmlfiles.length; i++) { ! final File xmlfile = xmlfiles[i]; System.out.print("Testing file: "+xmlfile.getName()+"... "); ! final Document doc=reader.read(xmlfile); System.out.print("root element: "+doc.getRootElement().getQualifiedName()+" ..."); try { *************** *** 143,147 **** } ! SAXReader reader; } --- 149,153 ---- } ! final SAXReader reader; } Index: SimpleXMLSigTest.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-xmlsig/src/test/org/neuclear/xml/xmlsec/SimpleXMLSigTest.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** SimpleXMLSigTest.java 20 Nov 2003 23:41:58 -0000 1.4 --- SimpleXMLSigTest.java 21 Nov 2003 04:44:31 -0000 1.5 *************** *** 22,25 **** --- 22,31 ---- * $Id$ * $Log$ + * Revision 1.5 2003/11/21 04:44:31 pelle + * EncryptedFileStore now works. It uses the PBECipher with DES3 afair. + * Otherwise You will Finaliate. + * 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 *************** *** 94,99 **** * Mainly clean ups through out and further documentation. */ ! public class SimpleXMLSigTest extends TestCase { ! public SimpleXMLSigTest(String s) throws SecurityException, NoSuchAlgorithmException, CryptoException { super(s); signer = JunitTools.getTestRSAKey(); --- 100,105 ---- * Mainly clean ups through out and further documentation. */ ! public final class SimpleXMLSigTest extends TestCase { ! public SimpleXMLSigTest(final String s) throws SecurityException, NoSuchAlgorithmException, CryptoException { super(s); signer = JunitTools.getTestRSAKey(); *************** *** 102,109 **** } ! public void testRSASignXML() throws DocumentException, XMLException, CryptoException { Document doc = DocumentHelper.parseText(TESTXML); ! XMLSignature sig = new XMLSignature(signer, doc.getRootElement(), "http://testsigs"); ! File outputFile = new File("target/testdata/homegrown/signature-enveloped-rsa.xml"); XMLTools.writeFile(outputFile, doc); --- 108,115 ---- } ! public final void testRSASignXML() throws DocumentException, XMLException, CryptoException { Document doc = DocumentHelper.parseText(TESTXML); ! final XMLSignature sig = new XMLSignature(signer, doc.getRootElement(), "http://testsigs"); ! final File outputFile = new File("target/testdata/homegrown/signature-enveloped-rsa.xml"); XMLTools.writeFile(outputFile, doc); *************** *** 112,119 **** } ! public void testRSAEnvelopingSignXML() throws DocumentException, XMLException, CryptoException { Document doc = DocumentHelper.parseText(TESTXML); ! XMLSignature sig = new XMLSignature(signer, doc.getRootElement(), "http://testsigs", Reference.XMLSIGTYPE_ENVELOPING); ! File outputFile = new File("target/testdata/homegrown/signature-enveloping-rsa.xml"); XMLTools.writeFile(outputFile, sig.getElement()); --- 118,125 ---- } ! public final void testRSAEnvelopingSignXML() throws DocumentException, XMLException, CryptoException { Document doc = DocumentHelper.parseText(TESTXML); ! final XMLSignature sig = new XMLSignature(signer, doc.getRootElement(), "http://testsigs", Reference.XMLSIGTYPE_ENVELOPING); ! final File outputFile = new File("target/testdata/homegrown/signature-enveloping-rsa.xml"); XMLTools.writeFile(outputFile, sig.getElement()); *************** *** 122,129 **** } ! public void testDSAEnvelopingSignXML() throws DocumentException, XMLException, CryptoException { Document doc = DocumentHelper.parseText(TESTXML); ! XMLSignature sig = new XMLSignature(dsaSigner, doc.getRootElement(), "http://testsigs", Reference.XMLSIGTYPE_ENVELOPING); ! File outputFile = new File("target/testdata/homegrown/signature-enveloping-dsa.xml"); XMLTools.writeFile(outputFile, sig.getElement()); --- 128,135 ---- } ! public final void testDSAEnvelopingSignXML() throws DocumentException, XMLException, CryptoException { Document doc = DocumentHelper.parseText(TESTXML); ! final XMLSignature sig = new XMLSignature(dsaSigner, doc.getRootElement(), "http://testsigs", Reference.XMLSIGTYPE_ENVELOPING); ! final File outputFile = new File("target/testdata/homegrown/signature-enveloping-dsa.xml"); XMLTools.writeFile(outputFile, sig.getElement()); *************** *** 132,142 **** } ! public void testDSASignXML() throws DocumentException, XMLException, CryptoException { assertTrue("Test if public key is really DSA", dsaSigner.getPublic() instanceof DSAPublicKey); Document doc = DocumentHelper.parseText(TESTXML); ! XMLSignature sig = new XMLSignature(dsaSigner, doc.getRootElement(), "http://testDSAsigs"); ! File outputFile = new File("target/testdata/homegrown/signature-enveloped-dsa.xml"); XMLTools.writeFile(outputFile, doc); --- 138,148 ---- } ! 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(), "http://testDSAsigs"); ! final File outputFile = new File("target/testdata/homegrown/signature-enveloped-dsa.xml"); XMLTools.writeFile(outputFile, doc); *************** *** 145,152 **** } ! public void testQuickRSASignXML() throws DocumentException, XMLException, CryptoException { Document doc = DocumentHelper.parseText(TESTXML); XMLSecTools.signElement("http://testsigs", doc.getRootElement(), signer); ! File outputFile = new File("target/testdata/homegrown/signature-enveloped-rsa-quick.xml"); XMLTools.writeFile(outputFile, doc); --- 151,158 ---- } ! public final void testQuickRSASignXML() throws DocumentException, XMLException, CryptoException { Document doc = DocumentHelper.parseText(TESTXML); XMLSecTools.signElement("http://testsigs", doc.getRootElement(), signer); ! final File outputFile = new File("target/testdata/homegrown/signature-enveloped-rsa-quick.xml"); XMLTools.writeFile(outputFile, doc); *************** *** 155,159 **** } ! public void testQuickDSASignXML() throws DocumentException, XMLException, CryptoException { assertTrue("Test if public key is really DSA", dsaSigner.getPublic() instanceof DSAPublicKey); --- 161,165 ---- } ! public final void testQuickDSASignXML() throws DocumentException, XMLException, CryptoException { assertTrue("Test if public key is really DSA", dsaSigner.getPublic() instanceof DSAPublicKey); *************** *** 161,165 **** XMLSecTools.signElement("http://testDSAsigs", doc.getRootElement(), dsaSigner); ! File outputFile = new File("target/testdata/homegrown/signature-enveloped-dsa-quick.xml"); XMLTools.writeFile(outputFile, doc); --- 167,171 ---- XMLSecTools.signElement("http://testDSAsigs", doc.getRootElement(), dsaSigner); ! final File outputFile = new File("target/testdata/homegrown/signature-enveloped-dsa-quick.xml"); XMLTools.writeFile(outputFile, doc); *************** *** 169,174 **** ! public void testBadSignXML() throws DocumentException, XMLException, CryptoException { ! Document doc = DocumentHelper.parseText(TESTXML); XMLSecTools.signElement("http://testsigs", doc.getRootElement(), signer); --- 175,180 ---- ! public final void testBadSignXML() throws DocumentException, XMLException, CryptoException { ! final Document doc = DocumentHelper.parseText(TESTXML); XMLSecTools.signElement("http://testsigs", doc.getRootElement(), signer); *************** *** 179,185 **** } ! public void testBadDSASignXML() throws DocumentException, XMLException, CryptoException { ! Document doc = DocumentHelper.parseText(TESTXML); XMLSecTools.signElement("http://testDSAsigs", doc.getRootElement(), dsaSigner); --- 185,191 ---- } ! public final void testBadDSASignXML() throws DocumentException, XMLException, CryptoException { ! final Document doc = DocumentHelper.parseText(TESTXML); XMLSecTools.signElement("http://testDSAsigs", doc.getRootElement(), dsaSigner); *************** *** 189,193 **** } ! KeyPair signer, dsaSigner; final static String TESTXML = "<test><test2></test2></test>"; --- 195,200 ---- } ! final KeyPair signer; ! final KeyPair dsaSigner; final static String TESTXML = "<test><test2></test2></test>"; |