|
From: <pe...@us...> - 2003-11-21 04:44:34
|
Update of /cvsroot/neuclear/neuclear-xmlsig/src/test/org/neuclear/xml/c14
In directory sc8-pr-cvs1:/tmp/cvs-serv10728/src/test/org/neuclear/xml/c14
Modified Files:
CanonicalizationTest.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: CanonicalizationTest.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-xmlsig/src/test/org/neuclear/xml/c14/CanonicalizationTest.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** CanonicalizationTest.java 11 Nov 2003 21:18:08 -0000 1.2
--- CanonicalizationTest.java 21 Nov 2003 04:44:31 -0000 1.3
***************
*** 7,10 ****
--- 7,16 ----
* $Id$
* $Log$
+ * Revision 1.3 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.2 2003/11/11 21:18:08 pelle
* Further vital reshuffling.
***************
*** 62,67 ****
import java.net.URL;
! public class CanonicalizationTest extends TestCase {
! public CanonicalizationTest(String s) {
super(s);
reader=new SAXReader(false);
--- 68,73 ----
import java.net.URL;
! public final class CanonicalizationTest extends TestCase {
! public CanonicalizationTest(final String s) {
super(s);
reader=new SAXReader(false);
***************
*** 79,88 ****
}
*/
! public void testMerlin() throws IOException, DocumentException {
runDirectoryTest("src/testdata/merlin-xmldsig-eight");
}
! public void runDirectoryTest(String path) throws DocumentException, IOException, FileNotFoundException {
! File dir=new File(path).getAbsoluteFile();
if (!dir.exists()) {
System.out.println("Doesnt exist");
--- 85,94 ----
}
*/
! public final void testMerlin() throws IOException, DocumentException {
runDirectoryTest("src/testdata/merlin-xmldsig-eight");
}
! public final void runDirectoryTest(final String path) throws DocumentException, IOException, FileNotFoundException {
! final File dir=new File(path).getAbsoluteFile();
if (!dir.exists()) {
System.out.println("Doesnt exist");
***************
*** 91,96 ****
//FilenameFilter filter=FilenameFilter;
! File xmlfiles[]=dir.listFiles(new FilenameFilter(){
! public boolean accept(File dirf, String name) {
return name.endsWith(".xml");
}
--- 97,102 ----
//FilenameFilter filter=FilenameFilter;
! final File[] xmlfiles=dir.listFiles(new FilenameFilter(){
! public boolean accept(final File dirf, final String name) {
return name.endsWith(".xml");
}
***************
*** 100,106 ****
for (int i = 0; i < xmlfiles.length; i++) {
! File xmlfile = xmlfiles[i];
System.out.println("Testing file: "+xmlfile.getName());
! File c14file=getC14Name(xmlfile);
if (c14file.exists()&&!hasXPath(xmlfile)){ //Just disabling the XPath Subset functionality until I hear from the Dom4J guys
--- 106,112 ----
for (int i = 0; i < xmlfiles.length; i++) {
! final File xmlfile = xmlfiles[i];
System.out.println("Testing file: "+xmlfile.getName());
! final File c14file=getC14Name(xmlfile);
if (c14file.exists()&&!hasXPath(xmlfile)){ //Just disabling the XPath Subset functionality until I hear from the Dom4J guys
***************
*** 108,125 ****
if (xmlfile.getName().equals("example-6.xml"))
System.out.println("Here we go");
! Document doc=reader.read(xmlfile.toURL());
byte[] ourbytes=null;
if (hasXPath(xmlfile)) {
! File xpathFile=getXPathFileName(xmlfile);
! FileReader xpreader=new FileReader(xpathFile);
! char xpathc[]=new char[(int)xpathFile.length()];
xpreader.read(xpathc,0,xpathc.length);
xpreader.close();
! String xpath=new String(xpathc);
System.out.println("XPATH="+xpath);
ourbytes=XMLSecTools.canonicalizeSubset(doc,xpath);
} else
ourbytes=XMLSecTools.canonicalize(doc);
! FileOutputStream fos=new FileOutputStream(getC14OutputName(xmlfile));
fos.write(ourbytes);
fos.close();
--- 114,131 ----
if (xmlfile.getName().equals("example-6.xml"))
System.out.println("Here we go");
! final Document doc=reader.read(xmlfile.toURL());
byte[] ourbytes=null;
if (hasXPath(xmlfile)) {
! final File xpathFile=getXPathFileName(xmlfile);
! final FileReader xpreader=new FileReader(xpathFile);
! final char[] xpathc=new char[(int)xpathFile.length()];
xpreader.read(xpathc,0,xpathc.length);
xpreader.close();
! final String xpath=new String(xpathc);
System.out.println("XPATH="+xpath);
ourbytes=XMLSecTools.canonicalizeSubset(doc,xpath);
} else
ourbytes=XMLSecTools.canonicalize(doc);
! final FileOutputStream fos=new FileOutputStream(getC14OutputName(xmlfile));
fos.write(ourbytes);
fos.close();
***************
*** 138,145 ****
}
! private void compareFileWithByteArray(File c14file, byte[] ourbytes) throws IOException {
! byte[] theirbytes=new byte[(int)c14file.length()];
! FileInputStream fis=new FileInputStream(c14file);
fis.read(theirbytes);
boolean equal=ourbytes.length==theirbytes.length;
--- 144,151 ----
}
! private void compareFileWithByteArray(final File c14file, final byte[] ourbytes) throws IOException {
! final byte[] theirbytes=new byte[(int)c14file.length()];
! final FileInputStream fis=new FileInputStream(c14file);
fis.read(theirbytes);
boolean equal=ourbytes.length==theirbytes.length;
***************
*** 165,184 ****
}
! private File getC14Name(File file){
! String newname=file.getName();
return new File(file.getParentFile(),newname.substring(0,newname.length()-3)+"c14n");
}
! private File getC14OutputName(File file){
! String newname=file.getName();
return new File(file.getParentFile(),newname.substring(0,newname.length()-3)+"out");
}
! private File getXPathFileName(File file){
! String newname=file.getName();
return new File(file.getParentFile(),newname.substring(0,newname.length()-3)+"xpath");
}
! private boolean hasXPath(File file) {
return getXPathFileName(file).exists();
}
! SAXReader reader;
}
--- 171,190 ----
}
! private File getC14Name(final File file){
! final String newname=file.getName();
return new File(file.getParentFile(),newname.substring(0,newname.length()-3)+"c14n");
}
! private File getC14OutputName(final File file){
! final String newname=file.getName();
return new File(file.getParentFile(),newname.substring(0,newname.length()-3)+"out");
}
! private File getXPathFileName(final File file){
! final String newname=file.getName();
return new File(file.getParentFile(),newname.substring(0,newname.length()-3)+"xpath");
}
! private boolean hasXPath(final File file) {
return getXPathFileName(file).exists();
}
! final SAXReader reader;
}
|