You can subscribe to this list here.
| 2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(119) |
Oct
(111) |
Nov
(238) |
Dec
(395) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2004 |
Jan
(239) |
Feb
(59) |
Mar
(354) |
Apr
(489) |
May
(23) |
Jun
(2) |
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
| 2006 |
Jan
|
Feb
|
Mar
|
Apr
(4) |
May
(5) |
Jun
(2) |
Jul
|
Aug
|
Sep
(3) |
Oct
(14) |
Nov
(17) |
Dec
(9) |
| 2007 |
Jan
(4) |
Feb
(3) |
Mar
|
Apr
(1) |
May
(1) |
Jun
(2) |
Jul
|
Aug
|
Sep
(1) |
Oct
(2) |
Nov
(1) |
Dec
|
| 2008 |
Jan
|
Feb
|
Mar
(1) |
Apr
(7) |
May
(3) |
Jun
(6) |
Jul
(4) |
Aug
(3) |
Sep
(15) |
Oct
(13) |
Nov
(35) |
Dec
(40) |
| 2009 |
Jan
(19) |
Feb
(21) |
Mar
(16) |
Apr
(18) |
May
(36) |
Jun
(20) |
Jul
(32) |
Aug
(11) |
Sep
(3) |
Oct
(2) |
Nov
(2) |
Dec
(13) |
| 2010 |
Jan
(5) |
Feb
(5) |
Mar
(7) |
Apr
(1) |
May
(1) |
Jun
(3) |
Jul
(1) |
Aug
(1) |
Sep
(1) |
Oct
(1) |
Nov
|
Dec
|
| 2011 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(2) |
Jul
(1) |
Aug
(1) |
Sep
(1) |
Oct
(4) |
Nov
|
Dec
(3) |
| 2012 |
Jan
(3) |
Feb
(3) |
Mar
(1) |
Apr
(4) |
May
(8) |
Jun
(4) |
Jul
(9) |
Aug
(2) |
Sep
(8) |
Oct
(3) |
Nov
(8) |
Dec
(4) |
| 2013 |
Jan
(2) |
Feb
(1) |
Mar
(5) |
Apr
(6) |
May
(10) |
Jun
(5) |
Jul
(6) |
Aug
(7) |
Sep
(5) |
Oct
(2) |
Nov
(4) |
Dec
(4) |
| 2014 |
Jan
(13) |
Feb
(4) |
Mar
(7) |
Apr
(9) |
May
(20) |
Jun
(13) |
Jul
(10) |
Aug
(3) |
Sep
(5) |
Oct
(2) |
Nov
(2) |
Dec
(2) |
| 2015 |
Jan
(3) |
Feb
(3) |
Mar
(5) |
Apr
(4) |
May
(3) |
Jun
(2) |
Jul
(4) |
Aug
(3) |
Sep
(1) |
Oct
|
Nov
(1) |
Dec
(3) |
| 2016 |
Jan
|
Feb
(1) |
Mar
(1) |
Apr
(1) |
May
(1) |
Jun
(2) |
Jul
(1) |
Aug
(4) |
Sep
(3) |
Oct
(3) |
Nov
(4) |
Dec
(2) |
| 2017 |
Jan
|
Feb
(2) |
Mar
|
Apr
(2) |
May
(1) |
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <pe...@us...> - 2003-11-21 04:45:25
|
Update of /cvsroot/neuclear/neuclear-id/src/test/org/neuclear/store
In directory sc8-pr-cvs1:/tmp/cvs-serv10855/src/test/org/neuclear/store
Modified Files:
AbstractStoreTest.java EncryptedFileStoreTest.java
FileStoreTest.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: AbstractStoreTest.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-id/src/test/org/neuclear/store/AbstractStoreTest.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** AbstractStoreTest.java 19 Nov 2003 23:34:00 -0000 1.13
--- AbstractStoreTest.java 21 Nov 2003 04:45:17 -0000 1.14
***************
*** 2,5 ****
--- 2,11 ----
$Id$
$Log$
+ Revision 1.14 2003/11/21 04:45:17 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.13 2003/11/19 23:34:00 pelle
Signers now can generatekeys via the generateKey() method.
***************
*** 159,163 ****
*/
public abstract class AbstractStoreTest extends AbstractSigningTest {
! public AbstractStoreTest(String name) throws GeneralSecurityException, NeuClearException {
super(name);
store = getStoreInstance();
--- 165,169 ----
*/
public abstract class AbstractStoreTest extends AbstractSigningTest {
! public AbstractStoreTest(final String name) throws GeneralSecurityException, NeuClearException {
super(name);
store = getStoreInstance();
***************
*** 170,194 ****
! protected void tearDown() {
store = null;
}
! public void testStore() throws NeuClearException, InvalidNamedObject, XMLException {
System.out.println("\nTesting " + this.getClass().getName());
System.out.println("Storing " + bobName);
! IdentityBuilder bob = new IdentityBuilder(bobName, signer.getPublicKey(bobName));
store.receive(bob.sign(signer));
System.out.println("Storing " + aliceName);
! IdentityBuilder alice = new IdentityBuilder(aliceName, signer.getPublicKey(aliceName));
store.receive(alice.sign(signer));
System.out.println("Fetching " + bobName);
! SignedNamedObject nobj2 = store.fetch(bobName);
assertNotNull(nobj2);
assertEquals(bobName, nobj2.getName());
System.out.println("Fetching " + aliceName);
! SignedNamedObject nobj4 = store.fetch(aliceName);
assertEquals(aliceName, nobj4.getName());
}
--- 176,200 ----
! protected final void tearDown() {
store = null;
}
! public final void testStore() throws NeuClearException, InvalidNamedObject, XMLException {
System.out.println("\nTesting " + this.getClass().getName());
System.out.println("Storing " + bobName);
! final IdentityBuilder bob = new IdentityBuilder(bobName, signer.getPublicKey(bobName));
store.receive(bob.sign(signer));
System.out.println("Storing " + aliceName);
! final IdentityBuilder alice = new IdentityBuilder(aliceName, signer.getPublicKey(aliceName));
store.receive(alice.sign(signer));
System.out.println("Fetching " + bobName);
! final SignedNamedObject nobj2 = store.fetch(bobName);
assertNotNull(nobj2);
assertEquals(bobName, nobj2.getName());
System.out.println("Fetching " + aliceName);
! final SignedNamedObject nobj4 = store.fetch(aliceName);
assertEquals(aliceName, nobj4.getName());
}
Index: EncryptedFileStoreTest.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-id/src/test/org/neuclear/store/EncryptedFileStoreTest.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** EncryptedFileStoreTest.java 18 Nov 2003 15:07:37 -0000 1.4
--- EncryptedFileStoreTest.java 21 Nov 2003 04:45:18 -0000 1.5
***************
*** 2,5 ****
--- 2,11 ----
* $Id$
* $Log$
+ * Revision 1.5 2003/11/21 04:45:18 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/18 15:07:37 pelle
* Changes to JCE Implementation
***************
*** 54,59 ****
import java.security.GeneralSecurityException;
! public class EncryptedFileStoreTest extends AbstractStoreTest {
! public EncryptedFileStoreTest(String name) throws GeneralSecurityException, NeuClearException {
super(name);
}
--- 60,65 ----
import java.security.GeneralSecurityException;
! public final class EncryptedFileStoreTest extends AbstractStoreTest {
! public EncryptedFileStoreTest(final String name) throws GeneralSecurityException, NeuClearException {
super(name);
}
***************
*** 61,65 ****
/**
*/
! public Store getStoreInstance() {
return new EncryptedFileStore("target/testdata/efs");
}
--- 67,71 ----
/**
*/
! public final Store getStoreInstance() {
return new EncryptedFileStore("target/testdata/efs");
}
Index: FileStoreTest.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-id/src/test/org/neuclear/store/FileStoreTest.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** FileStoreTest.java 18 Nov 2003 15:07:37 -0000 1.4
--- FileStoreTest.java 21 Nov 2003 04:45:18 -0000 1.5
***************
*** 2,5 ****
--- 2,11 ----
* $Id$
* $Log$
+ * Revision 1.5 2003/11/21 04:45:18 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/18 15:07:37 pelle
* Changes to JCE Implementation
***************
*** 57,62 ****
import java.security.GeneralSecurityException;
! public class FileStoreTest extends AbstractStoreTest {
! public FileStoreTest(String name) throws GeneralSecurityException, NeuClearException {
super(name);
}
--- 63,68 ----
import java.security.GeneralSecurityException;
! public final class FileStoreTest extends AbstractStoreTest {
! public FileStoreTest(final String name) throws GeneralSecurityException, NeuClearException {
super(name);
}
***************
*** 64,68 ****
/**
*/
! public Store getStoreInstance() {
return new FileStore("target/testdata/filestore");
}
--- 70,74 ----
/**
*/
! public final Store getStoreInstance() {
return new FileStore("target/testdata/filestore");
}
|
|
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>"; |
|
From: <pe...@us...> - 2003-11-21 04:44:35
|
Update of /cvsroot/neuclear/neuclear-xmlsig/src/test/org/neuclear/xml/transforms In directory sc8-pr-cvs1:/tmp/cvs-serv10728/src/test/org/neuclear/xml/transforms Modified Files: AbstractTransformTest.java ClearTransformTest.java DropSignatureTransformTest.java OpaqueTransformTest.java TransformFactoryTest.java XPathTransformTest.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: AbstractTransformTest.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-xmlsig/src/test/org/neuclear/xml/transforms/AbstractTransformTest.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** AbstractTransformTest.java 11 Nov 2003 16:33:31 -0000 1.1.1.1 --- AbstractTransformTest.java 21 Nov 2003 04:44:31 -0000 1.2 *************** *** 14,17 **** --- 14,23 ---- * $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:31 pelle * Moved over from neudist.org *************** *** 37,41 **** */ public abstract class AbstractTransformTest extends TestCase { ! public AbstractTransformTest(String s) { super(s); tr=createTransform(); --- 43,47 ---- */ public abstract class AbstractTransformTest extends TestCase { ! public AbstractTransformTest(final String s) { super(s); tr=createTransform(); *************** *** 53,59 **** } ! public void testTransformElement() throws DocumentException { ! Object result=tr.transformNode(getTestElement()); ! Node expected=getExpectedResult(); if(expected==null) assertNull("The Transform did not return null as expected",result); --- 59,65 ---- } ! public final void testTransformElement() throws DocumentException { ! final Object result=tr.transformNode(getTestElement()); ! final Node expected=getExpectedResult(); if(expected==null) assertNull("The Transform did not return null as expected",result); *************** *** 64,67 **** } ! protected Transform tr; } --- 70,73 ---- } ! protected final Transform tr; } Index: ClearTransformTest.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-xmlsig/src/test/org/neuclear/xml/transforms/ClearTransformTest.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** ClearTransformTest.java 11 Nov 2003 16:33:31 -0000 1.1.1.1 --- ClearTransformTest.java 21 Nov 2003 04:44:31 -0000 1.2 *************** *** 11,14 **** --- 11,20 ---- * $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:31 pelle * Moved over from neudist.org *************** *** 30,43 **** * */ ! public class ClearTransformTest extends AbstractTransformTest { ! public ClearTransformTest(String s) { super(s); } ! public Transform createTransform() { return new ClearTransform(); } ! public Element getExpectedResult() throws DocumentException { return getTestElement(); } --- 36,49 ---- * */ ! public final class ClearTransformTest extends AbstractTransformTest { ! public ClearTransformTest(final String s) { super(s); } ! public final Transform createTransform() { return new ClearTransform(); } ! public final Element getExpectedResult() throws DocumentException { return getTestElement(); } Index: DropSignatureTransformTest.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-xmlsig/src/test/org/neuclear/xml/transforms/DropSignatureTransformTest.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** DropSignatureTransformTest.java 11 Nov 2003 16:33:31 -0000 1.1.1.1 --- DropSignatureTransformTest.java 21 Nov 2003 04:44:31 -0000 1.2 *************** *** 9,12 **** --- 9,18 ---- * $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:31 pelle * Moved over from neudist.org *************** *** 33,46 **** import org.dom4j.Element; ! public class DropSignatureTransformTest extends AbstractTransformTest { ! public DropSignatureTransformTest(String s) { super(s); } ! public Transform createTransform() { return new DropSignatureTransform(); } ! public Element getTestElement() { try { return DocumentHelper.parseText(TESTELEMENT).getRootElement(); --- 39,52 ---- import org.dom4j.Element; ! public final class DropSignatureTransformTest extends AbstractTransformTest { ! public DropSignatureTransformTest(final String s) { super(s); } ! public final Transform createTransform() { return new DropSignatureTransform(); } ! public final Element getTestElement() { try { return DocumentHelper.parseText(TESTELEMENT).getRootElement(); *************** *** 51,55 **** } ! public Element getExpectedResult() { try { return DocumentHelper.parseText(TESTRESULT).getRootElement(); --- 57,61 ---- } ! public final Element getExpectedResult() { try { return DocumentHelper.parseText(TESTRESULT).getRootElement(); *************** *** 60,64 **** } ! private static String TESTELEMENT="<test><test2/><ds:Signature xmlns:ds=\"http://www.w3.org/2000/09/xmldsig#\"/></test>"; ! private static String TESTRESULT="<test><test2/></test>"; } --- 66,70 ---- } ! private static final String TESTELEMENT="<test><test2/><ds:Signature xmlns:ds=\"http://www.w3.org/2000/09/xmldsig#\"/></test>"; ! private static final String TESTRESULT="<test><test2/></test>"; } Index: OpaqueTransformTest.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-xmlsig/src/test/org/neuclear/xml/transforms/OpaqueTransformTest.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** OpaqueTransformTest.java 11 Nov 2003 16:33:31 -0000 1.1.1.1 --- OpaqueTransformTest.java 21 Nov 2003 04:44:31 -0000 1.2 *************** *** 9,12 **** --- 9,18 ---- * $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:31 pelle * Moved over from neudist.org *************** *** 23,36 **** import org.dom4j.Element; ! public class OpaqueTransformTest extends AbstractTransformTest { ! public OpaqueTransformTest(String s) { super(s); } ! public Transform createTransform() { return new OpaqueTransform(); } ! public Element getExpectedResult() { return null; } --- 29,42 ---- import org.dom4j.Element; ! public final class OpaqueTransformTest extends AbstractTransformTest { ! public OpaqueTransformTest(final String s) { super(s); } ! public final Transform createTransform() { return new OpaqueTransform(); } ! public final Element getExpectedResult() { return null; } Index: TransformFactoryTest.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-xmlsig/src/test/org/neuclear/xml/transforms/TransformFactoryTest.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** TransformFactoryTest.java 11 Nov 2003 16:33:31 -0000 1.1.1.1 --- TransformFactoryTest.java 21 Nov 2003 04:44:31 -0000 1.2 *************** *** 8,11 **** --- 8,17 ---- * $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:31 pelle * Moved over from neudist.org *************** *** 32,37 **** import org.neuclear.xml.xmlsec.XMLSecTools; ! public class TransformFactoryTest extends TestCase{ ! public TransformFactoryTest(String s) { super(s); { --- 38,43 ---- import org.neuclear.xml.xmlsec.XMLSecTools; ! public final class TransformFactoryTest extends TestCase{ ! public TransformFactoryTest(final String s) { super(s); { *************** *** 41,45 **** } } ! public void testCreateFromAlgorithmName() throws XMLTransformNotFoundException { assertNotNull(TransformerFactory.make("uri:neuclear-test-clear-transform")); assertNotNull(TransformerFactory.make("uri:neuclear-test-opaque-transform")); --- 47,51 ---- } } ! public final void testCreateFromAlgorithmName() throws XMLTransformNotFoundException { assertNotNull(TransformerFactory.make("uri:neuclear-test-clear-transform")); assertNotNull(TransformerFactory.make("uri:neuclear-test-opaque-transform")); *************** *** 52,65 **** } ! public void testCreateFromElement() throws XMLTransformNotFoundException { ! Element clear=XMLSecTools.createElementInSignatureSpace("Transform"); clear.addAttribute("Algorithm","uri:neuclear-test-clear-transform"); assertNotNull(TransformerFactory.make(clear)); ! Element opaque=XMLSecTools.createElementInSignatureSpace("Transform"); opaque.addAttribute("Algorithm","uri:neuclear-test-opaque-transform"); assertNotNull(TransformerFactory.make(opaque)); ! Element dud=XMLSecTools.createElementInSignatureSpace("Transform"); dud.addAttribute("Algorithm","uri:neuclear-test-non-existent"); try { --- 58,71 ---- } ! public final void testCreateFromElement() throws XMLTransformNotFoundException { ! final Element clear=XMLSecTools.createElementInSignatureSpace("Transform"); clear.addAttribute("Algorithm","uri:neuclear-test-clear-transform"); assertNotNull(TransformerFactory.make(clear)); ! final Element opaque=XMLSecTools.createElementInSignatureSpace("Transform"); opaque.addAttribute("Algorithm","uri:neuclear-test-opaque-transform"); assertNotNull(TransformerFactory.make(opaque)); ! final Element dud=XMLSecTools.createElementInSignatureSpace("Transform"); dud.addAttribute("Algorithm","uri:neuclear-test-non-existent"); try { Index: XPathTransformTest.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-xmlsig/src/test/org/neuclear/xml/transforms/XPathTransformTest.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** XPathTransformTest.java 11 Nov 2003 16:33:31 -0000 1.1.1.1 --- XPathTransformTest.java 21 Nov 2003 04:44:31 -0000 1.2 *************** *** 9,12 **** --- 9,18 ---- * $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:31 pelle * Moved over from neudist.org *************** *** 37,54 **** import java.util.Iterator; ! public class XPathTransformTest extends AbstractTransformTest { ! public XPathTransformTest(String s) { super(s); } ! public Transform createTransform() { return new XPathTransform("/test"); } ! public Element getExpectedResult() throws DocumentException { return DocumentHelper.parseText("<test/>").getRootElement(); } ! public void testXPathFun() throws DocumentException { doc=DocumentHelper.parseText("<test><test2><test one=\"1\">text</test></test2></test>"); System.out.println("testXPathFun"); --- 43,60 ---- import java.util.Iterator; ! public final class XPathTransformTest extends AbstractTransformTest { ! public XPathTransformTest(final String s) { super(s); } ! public final Transform createTransform() { return new XPathTransform("/test"); } ! public final Element getExpectedResult() throws DocumentException { return DocumentHelper.parseText("<test/>").getRootElement(); } ! public final void testXPathFun() throws DocumentException { doc=DocumentHelper.parseText("<test><test2><test one=\"1\">text</test></test2></test>"); System.out.println("testXPathFun"); *************** *** 64,79 **** } ! public void testNoDoc() throws DocumentException { ! Element elem=DocumentHelper.createElement("test"); assertNotNull(tr.transformNode(elem)); } ! private void listXPath(String expr) { System.out.println("Testing: "+expr); ! XPath xp=DocumentHelper.createXPath(expr); ! Iterator iter=xp.selectNodes(doc).iterator(); while (iter.hasNext()) { ! Node node = (Node) iter.next(); System.out.println("Matched: "+node.toString()); } --- 70,85 ---- } ! public final void testNoDoc() throws DocumentException { ! final Element elem=DocumentHelper.createElement("test"); assertNotNull(tr.transformNode(elem)); } ! private void listXPath(final String expr) { System.out.println("Testing: "+expr); ! final XPath xp=DocumentHelper.createXPath(expr); ! final Iterator iter=xp.selectNodes(doc).iterator(); while (iter.hasNext()) { ! final Node node = (Node) iter.next(); System.out.println("Matched: "+node.toString()); } |
|
From: <pe...@us...> - 2003-11-21 04:44:34
|
Update of /cvsroot/neuclear/neuclear-xmlsig/src/java/org/neuclear/xml
In directory sc8-pr-cvs1:/tmp/cvs-serv10728/src/java/org/neuclear/xml
Modified Files:
AbstractElementProxy.java XMLException.java XMLTools.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: AbstractElementProxy.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-xmlsig/src/java/org/neuclear/xml/AbstractElementProxy.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** AbstractElementProxy.java 19 Nov 2003 23:33:17 -0000 1.2
--- AbstractElementProxy.java 21 Nov 2003 04:44:31 -0000 1.3
***************
*** 2,5 ****
--- 2,11 ----
* $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/19 23:33:17 pelle
* Signers now can generatekeys via the generateKey() method.
***************
*** 86,106 ****
public abstract class AbstractElementProxy implements ElementProxy {
! protected AbstractElementProxy(String name, String prefix, String nsURI) {
this(name, DocumentHelper.createNamespace(prefix, nsURI));
}
! protected AbstractElementProxy(String name, Namespace ns) {
this(DocumentHelper.createQName(name, ns));
}
! protected AbstractElementProxy(QName qname) {
this.element = DocumentHelper.createElement(qname);
}
! protected AbstractElementProxy(Element elem) {
element = elem;
}
! private Element element;
public final Element getElement() {
--- 92,112 ----
public abstract class AbstractElementProxy implements ElementProxy {
! protected AbstractElementProxy(final String name, final String prefix, final String nsURI) {
this(name, DocumentHelper.createNamespace(prefix, nsURI));
}
! protected AbstractElementProxy(final String name, final Namespace ns) {
this(DocumentHelper.createQName(name, ns));
}
! protected AbstractElementProxy(final QName qname) {
this.element = DocumentHelper.createElement(qname);
}
! protected AbstractElementProxy(final Element elem) {
element = elem;
}
! private final Element element;
public final Element getElement() {
***************
*** 108,116 ****
}
! protected void addElement(AbstractElementProxy child) throws XMLException {
addElement(child.getElement());
}
! protected void addElement(Element child) throws XMLException {
element.add(child);
element.addText("\n");
--- 114,122 ----
}
! protected final void addElement(final AbstractElementProxy child) throws XMLException {
addElement(child.getElement());
}
! protected final void addElement(final Element child) throws XMLException {
element.add(child);
element.addText("\n");
***************
*** 133,137 ****
public abstract Namespace getNS();
! static Namespace XMLNS = DocumentHelper.createNamespace("xmlns", "http://www.w3.org/XML/1998/namespace");
}
--- 139,143 ----
public abstract Namespace getNS();
! static final Namespace XMLNS = DocumentHelper.createNamespace("xmlns", "http://www.w3.org/XML/1998/namespace");
}
Index: XMLException.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-xmlsig/src/java/org/neuclear/xml/XMLException.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** XMLException.java 11 Nov 2003 16:33:20 -0000 1.1.1.1
--- XMLException.java 21 Nov 2003 04:44:31 -0000 1.2
***************
*** 1,4 ****
--- 1,10 ----
/* $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:20 pelle
* Moved over from neudist.org
***************
*** 26,38 ****
public class XMLException extends Exception {
! public XMLException(String message) {
super(message);
}
! public XMLException(Throwable t) {
super(t);
}
! public XMLException(String message, Throwable t) {
super(message, t);
}
--- 32,44 ----
public class XMLException extends Exception {
! public XMLException(final String message) {
super(message);
}
! public XMLException(final Throwable t) {
super(t);
}
! public XMLException(final String message, final Throwable t) {
super(message, t);
}
Index: XMLTools.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-xmlsig/src/java/org/neuclear/xml/XMLTools.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** XMLTools.java 19 Nov 2003 23:33:17 -0000 1.2
--- XMLTools.java 21 Nov 2003 04:44:31 -0000 1.3
***************
*** 2,5 ****
--- 2,11 ----
* $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/19 23:33:17 pelle
* Signers now can generatekeys via the generateKey() method.
***************
*** 136,140 ****
! public class XMLTools {
/**
* public static void writeDom(Document doc,OutputStream out) throws IOException{
--- 142,146 ----
! public final class XMLTools {
/**
* public static void writeDom(Document doc,OutputStream out) throws IOException{
***************
*** 158,162 ****
* }
*/
! public static boolean isAttributeTrue(Element elem, String name) {
return isTrue(elem.attributeValue(name), false);
}
--- 164,168 ----
* }
*/
! public static boolean isAttributeTrue(final Element elem, final String name) {
return isTrue(elem.attributeValue(name), false);
}
***************
*** 166,172 ****
}
! public static Document loadDocument(InputStream is) throws XMLException {
try {
! SAXReader xmlReader = new SAXReader();
return xmlReader.read(is);
} catch (Exception e) {
--- 172,178 ----
}
! public static Document loadDocument(final InputStream is) throws XMLException {
try {
! final SAXReader xmlReader = new SAXReader();
return xmlReader.read(is);
} catch (Exception e) {
***************
*** 176,181 ****
}
! public static Document loadDocument(File f) throws XMLException {
! SAXReader xmlReader = new SAXReader();
try {
return xmlReader.read(f);
--- 182,187 ----
}
! public static Document loadDocument(final File f) throws XMLException {
! final SAXReader xmlReader = new SAXReader();
try {
return xmlReader.read(f);
***************
*** 188,196 ****
}
! public static void writeFile(File outputFile, Document doc) throws XMLException {
writeFile(outputFile, doc.getRootElement());
}
! public static void writeFile(File outputFile, Element doc) throws XMLException {
try {
writeFile(new FileOutputStream(outputFile), doc);
--- 194,202 ----
}
! public static void writeFile(final File outputFile, final Document doc) throws XMLException {
writeFile(outputFile, doc.getRootElement());
}
! public static void writeFile(final File outputFile, final Element doc) throws XMLException {
try {
writeFile(new FileOutputStream(outputFile), doc);
***************
*** 200,207 ****
}
! public static void writeFile(OutputStream out, Element doc) throws XMLException {
try {
! XMLWriter writer = new XMLWriter(out, getOutputFormat());
writer.write(doc);
writer.close();
--- 206,213 ----
}
! public static void writeFile(final OutputStream out, final Element doc) throws XMLException {
try {
! final XMLWriter writer = new XMLWriter(out, getOutputFormat());
writer.write(doc);
writer.close();
***************
*** 211,218 ****
}
! public static String asXML(Element doc) throws XMLException {
! StringWriter ow = new StringWriter();
try {
! XMLWriter writer = new XMLWriter(ow, getOutputFormat());
writer.write(doc);
writer.close();
--- 217,224 ----
}
! public static String asXML(final Element doc) throws XMLException {
! final StringWriter ow = new StringWriter();
try {
! final XMLWriter writer = new XMLWriter(ow, getOutputFormat());
writer.write(doc);
writer.close();
***************
*** 224,228 ****
private static OutputFormat getOutputFormat() {
! OutputFormat format = OutputFormat.createCompactFormat();
format.setExpandEmptyElements(false);
format.setIndent(false);
--- 230,234 ----
private static OutputFormat getOutputFormat() {
! final OutputFormat format = OutputFormat.createCompactFormat();
format.setExpandEmptyElements(false);
format.setIndent(false);
***************
*** 233,240 ****
}
! public org.w3c.dom.Document doc2dom(Document doc) throws XMLException {
if (!(doc instanceof DOMDocument)) {
try {
! DOMWriter domWriter = new DOMWriter();
return domWriter.write(doc);
} catch (DocumentException e) {
--- 239,246 ----
}
! public final org.w3c.dom.Document doc2dom(final Document doc) throws XMLException {
if (!(doc instanceof DOMDocument)) {
try {
! final DOMWriter domWriter = new DOMWriter();
return domWriter.write(doc);
} catch (DocumentException e) {
***************
*** 245,258 ****
}
! public Document dom2doc(org.w3c.dom.Document dom) {
if (dom instanceof DOMDocument)
return (DOMDocument) dom;
else {
! DOMReader domReader = new DOMReader();
return domReader.read(dom);
}
}
! public static boolean isTrue(String clause, boolean defaultVal) {
if (isEmpty(clause))
return defaultVal;
--- 251,264 ----
}
! public final Document dom2doc(final org.w3c.dom.Document dom) {
if (dom instanceof DOMDocument)
return (DOMDocument) dom;
else {
! final DOMReader domReader = new DOMReader();
return domReader.read(dom);
}
}
! public static boolean isTrue(String clause, final boolean defaultVal) {
if (isEmpty(clause))
return defaultVal;
***************
*** 261,269 ****
}
! public static boolean isEmpty(Object obj) {
return (obj == null || obj.toString().equals(""));
}
! public static void rethrowException(Throwable e) throws XMLException {
throw new XMLException(e);
}
--- 267,275 ----
}
! public static boolean isEmpty(final Object obj) {
return (obj == null || obj.toString().equals(""));
}
! public static void rethrowException(final Throwable e) throws XMLException {
throw new XMLException(e);
}
|
|
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;
}
|
|
From: <pe...@us...> - 2003-11-21 04:44:34
|
Update of /cvsroot/neuclear/neuclear-xmlsig/src/test/org/neuclear/xml/soap
In directory sc8-pr-cvs1:/tmp/cvs-serv10728/src/test/org/neuclear/xml/soap
Modified Files:
SOAPTest.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: SOAPTest.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-xmlsig/src/test/org/neuclear/xml/soap/SOAPTest.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** SOAPTest.java 11 Nov 2003 16:33:30 -0000 1.1.1.1
--- SOAPTest.java 21 Nov 2003 04:44:31 -0000 1.2
***************
*** 14,19 ****
import org.neuclear.commons.NeuClearException;
! public class SOAPTest extends TestCase {
! public SOAPTest(String name) {
super(name);
}
--- 14,19 ----
import org.neuclear.commons.NeuClearException;
! public final class SOAPTest extends TestCase {
! public SOAPTest(final String name) {
super(name);
}
***************
*** 21,29 ****
! public void testGetQuote() throws NeuClearException {
! Element getQuote = DocumentHelper.createElement(DocumentHelper.createQName("getQuote", DocumentHelper.createNamespace("ns1", "urn:xmethods-delayed-quotes")));
getQuote.addElement(DocumentHelper.createQName("symbol", DocumentHelper.createNamespace("ns1", "urn:xmethods-delayed-quotes"))).addText("MSFT");
// Element response=soapRequest("http://localhost/cgi-bin/xmlenv",getQuote,"urn:xmethods-delayed-quotes#getQuote");
! Element response = SOAPTools.soapRequestElement("http://66.28.98.121:9090/soap", getQuote, "urn:xmethods-delayed-quotes#getQuote");
System.out.println("testGetQuote:");
System.out.println(response.asXML());
--- 21,29 ----
! public final void testGetQuote() throws NeuClearException {
! final Element getQuote = DocumentHelper.createElement(DocumentHelper.createQName("getQuote", DocumentHelper.createNamespace("ns1", "urn:xmethods-delayed-quotes")));
getQuote.addElement(DocumentHelper.createQName("symbol", DocumentHelper.createNamespace("ns1", "urn:xmethods-delayed-quotes"))).addText("MSFT");
// Element response=soapRequest("http://localhost/cgi-bin/xmlenv",getQuote,"urn:xmethods-delayed-quotes#getQuote");
! final Element response = SOAPTools.soapRequestElement("http://66.28.98.121:9090/soap", getQuote, "urn:xmethods-delayed-quotes#getQuote");
System.out.println("testGetQuote:");
System.out.println(response.asXML());
|
|
From: <pe...@us...> - 2003-11-21 04:44:34
|
Update of /cvsroot/neuclear/neuclear-xmlsig/src/java/org/neuclear/xml/transforms In directory sc8-pr-cvs1:/tmp/cvs-serv10728/src/java/org/neuclear/xml/transforms Modified Files: ClearTransform.java DropSignatureTransform.java OpaqueTransform.java Transform.java TransformerFactory.java XMLTransformNotFoundException.java XPathTransform.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: ClearTransform.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-xmlsig/src/java/org/neuclear/xml/transforms/ClearTransform.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** ClearTransform.java 11 Nov 2003 16:33:24 -0000 1.1.1.1 --- ClearTransform.java 21 Nov 2003 04:44:30 -0000 1.2 *************** *** 7,10 **** --- 7,16 ---- * $Id$ * $Log$ + * Revision 1.2 2003/11/21 04:44:30 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:24 pelle * Moved over from neudist.org *************** *** 31,36 **** import org.neuclear.xml.xmlsec.XMLSecurityException; ! public class ClearTransform extends Transform { ! public Object transformNode(Object in) { return in; } --- 37,42 ---- import org.neuclear.xml.xmlsec.XMLSecurityException; ! public final class ClearTransform extends Transform { ! public final Object transformNode(final Object in) { return in; } *************** *** 40,44 **** } ! public ClearTransform(Element elem) throws XMLSecurityException { super(elem); } --- 46,50 ---- } ! public ClearTransform(final Element elem) throws XMLSecurityException { super(elem); } Index: DropSignatureTransform.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-xmlsig/src/java/org/neuclear/xml/transforms/DropSignatureTransform.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** DropSignatureTransform.java 11 Nov 2003 16:33:24 -0000 1.1.1.1 --- DropSignatureTransform.java 21 Nov 2003 04:44:30 -0000 1.2 *************** *** 7,10 **** --- 7,16 ---- * $Id$ * $Log$ + * Revision 1.2 2003/11/21 04:44:30 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:24 pelle * Moved over from neudist.org *************** *** 35,55 **** import java.util.ListIterator; ! public class DropSignatureTransform extends Transform{ public DropSignatureTransform() { super(ALGORITHM); } ! public DropSignatureTransform(Element elem) throws XMLSecurityException { super(elem); } ! public Object transformNode(Object in) { if (in instanceof Document){ transformNode(((Document)in).getRootElement()); } else if (in instanceof Element){ ! ListIterator iter=((Branch)in).content().listIterator(); while(iter.hasNext()) { ! Node node=(Node)iter.next(); if ((node instanceof Element)&&(((Element)node).getQName().equals(subject)) ) iter.remove(); --- 41,61 ---- import java.util.ListIterator; ! public final class DropSignatureTransform extends Transform{ public DropSignatureTransform() { super(ALGORITHM); } ! public DropSignatureTransform(final Element elem) throws XMLSecurityException { super(elem); } ! public final Object transformNode(final Object in) { if (in instanceof Document){ transformNode(((Document)in).getRootElement()); } else if (in instanceof Element){ ! final ListIterator iter=((Branch)in).content().listIterator(); while(iter.hasNext()) { ! final Node node=(Node)iter.next(); if ((node instanceof Element)&&(((Element)node).getQName().equals(subject)) ) iter.remove(); Index: OpaqueTransform.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-xmlsig/src/java/org/neuclear/xml/transforms/OpaqueTransform.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** OpaqueTransform.java 11 Nov 2003 16:33:24 -0000 1.1.1.1 --- OpaqueTransform.java 21 Nov 2003 04:44:30 -0000 1.2 *************** *** 7,10 **** --- 7,16 ---- * $Id$ * $Log$ + * Revision 1.2 2003/11/21 04:44:30 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:24 pelle * Moved over from neudist.org *************** *** 31,36 **** import org.neuclear.xml.xmlsec.XMLSecurityException; ! public class OpaqueTransform extends Transform { ! public Object transformNode(Object in) { return null; } --- 37,42 ---- import org.neuclear.xml.xmlsec.XMLSecurityException; ! public final class OpaqueTransform extends Transform { ! public final Object transformNode(final Object in) { return null; } *************** *** 40,44 **** } ! public OpaqueTransform(Element elem) throws XMLSecurityException { super(elem); } --- 46,50 ---- } ! public OpaqueTransform(final Element elem) throws XMLSecurityException { super(elem); } Index: Transform.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-xmlsig/src/java/org/neuclear/xml/transforms/Transform.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** Transform.java 11 Nov 2003 16:33:24 -0000 1.1.1.1 --- Transform.java 21 Nov 2003 04:44:30 -0000 1.2 *************** *** 14,23 **** */ public abstract class Transform extends AbstractXMLSigElement { ! public Transform(String algorithm) { super(TAG_NAME); getElement().addAttribute("Algorithm",algorithm); } ! public Transform(Element elem) throws XMLSecurityException { super(elem); } --- 14,23 ---- */ public abstract class Transform extends AbstractXMLSigElement { ! public Transform(final String algorithm) { super(TAG_NAME); getElement().addAttribute("Algorithm",algorithm); } ! public Transform(final Element elem) throws XMLSecurityException { super(elem); } *************** *** 26,33 **** public abstract Object transformNode(Object in); ! public String getTagName() { return TAG_NAME; } ! private static String TAG_NAME="Transform"; } --- 26,33 ---- public abstract Object transformNode(Object in); ! public final String getTagName() { return TAG_NAME; } ! private static final String TAG_NAME="Transform"; } Index: TransformerFactory.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-xmlsig/src/java/org/neuclear/xml/transforms/TransformerFactory.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** TransformerFactory.java 11 Nov 2003 16:33:23 -0000 1.1.1.1 --- TransformerFactory.java 21 Nov 2003 04:44:30 -0000 1.2 *************** *** 18,31 **** public final class TransformerFactory { ! public static final Transform make(Element elem) throws XMLTransformNotFoundException{ if (elem==null) throw new XMLTransformNotFoundException("The Transform element was emtpy"); ! String name=elem.attributeValue("Algorithm"); ! Class imp=(Class)instance().implementations.get(name); if (imp==null) throw new XMLTransformNotFoundException("The Transform: "+name+" wasnt found"); ! Class params[]= new Class[] { Element.class}; try { ! Constructor constructor=imp.getConstructor(params); return (Transform)constructor.newInstance(new Element[] {elem}); } catch (NoSuchMethodException e) { --- 18,31 ---- public final class TransformerFactory { ! public static final Transform make(final Element elem) throws XMLTransformNotFoundException{ if (elem==null) throw new XMLTransformNotFoundException("The Transform element was emtpy"); ! final String name=elem.attributeValue("Algorithm"); ! final Class imp=(Class)instance().implementations.get(name); if (imp==null) throw new XMLTransformNotFoundException("The Transform: "+name+" wasnt found"); ! final Class[] params= new Class[] { Element.class}; try { ! final Constructor constructor=imp.getConstructor(params); return (Transform)constructor.newInstance(new Element[] {elem}); } catch (NoSuchMethodException e) { *************** *** 43,48 **** return null; } ! public static final Transform make(String algorithm) throws XMLTransformNotFoundException { ! Class imp=(Class)instance().implementations.get(algorithm); if (imp==null) { --- 43,48 ---- return null; } ! public static final Transform make(final String algorithm) throws XMLTransformNotFoundException { ! final Class imp=(Class)instance().implementations.get(algorithm); if (imp==null) { *************** *** 64,68 **** } ! public static final void registerTransformer(String algorithm, Class implementation) { instance().implementations.put(algorithm,implementation); } --- 64,68 ---- } ! public static final void registerTransformer(final String algorithm, final Class implementation) { instance().implementations.put(algorithm,implementation); } *************** *** 83,92 **** return singleton; } ! private HashMap implementations; private static TransformerFactory singleton; // This is just to make sure that they register themselves ! private static Class touch=DropSignatureTransform.class; ! { touch=Canonicalizer.class; touch=CanonicalizerWithComments.class; --- 83,92 ---- return singleton; } ! private final HashMap implementations; private static TransformerFactory singleton; // This is just to make sure that they register themselves ! static { ! Class touch=DropSignatureTransform.class; touch=Canonicalizer.class; touch=CanonicalizerWithComments.class; Index: XMLTransformNotFoundException.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-xmlsig/src/java/org/neuclear/xml/transforms/XMLTransformNotFoundException.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** XMLTransformNotFoundException.java 11 Nov 2003 16:33:24 -0000 1.1.1.1 --- XMLTransformNotFoundException.java 21 Nov 2003 04:44:30 -0000 1.2 *************** *** 9,12 **** --- 9,18 ---- * $Id$ * $Log$ + * Revision 1.2 2003/11/21 04:44:30 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:24 pelle * Moved over from neudist.org *************** *** 22,35 **** import org.neuclear.xml.xmlsec.XMLSecurityException; ! public class XMLTransformNotFoundException extends XMLSecurityException { ! public XMLTransformNotFoundException(String message) { super(message); } ! public XMLTransformNotFoundException(String message, Throwable t) { super(message, t); } ! public XMLTransformNotFoundException(Throwable t) { super(t); } --- 28,41 ---- import org.neuclear.xml.xmlsec.XMLSecurityException; ! public final class XMLTransformNotFoundException extends XMLSecurityException { ! public XMLTransformNotFoundException(final String message) { super(message); } ! public XMLTransformNotFoundException(final String message, final Throwable t) { super(message, t); } ! public XMLTransformNotFoundException(final Throwable t) { super(t); } Index: XPathTransform.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-xmlsig/src/java/org/neuclear/xml/transforms/XPathTransform.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** XPathTransform.java 11 Nov 2003 16:33:24 -0000 1.1.1.1 --- XPathTransform.java 21 Nov 2003 04:44:30 -0000 1.2 *************** *** 21,34 **** super(ALGORITHM); } ! public XPathTransform(String xpath) { super(ALGORITHM); // this.xpath=xpath; setXPath(xpath); ! Element xpElem=getElement().addElement("XPath"); xpElem.setText(xpath); xpElem.addAttribute("xmlns:dsig","&dsig;"); } ! private void setXPath(String xpath) { // XPathFilter=DocumentHelper.createXPath(xpath); xpathFilter=DocumentHelper.createXPath(xpath); --- 21,34 ---- super(ALGORITHM); } ! public XPathTransform(final String xpath) { super(ALGORITHM); // this.xpath=xpath; setXPath(xpath); ! final Element xpElem=getElement().addElement("XPath"); xpElem.setText(xpath); xpElem.addAttribute("xmlns:dsig","&dsig;"); } ! private void setXPath(final String xpath) { // XPathFilter=DocumentHelper.createXPath(xpath); xpathFilter=DocumentHelper.createXPath(xpath); *************** *** 43,56 **** } ! public XPathTransform(Element elem) throws XMLSecurityException { super(elem); ! Element xpElement=elem.element("XPath"); if (xpElement==null) throw new XMLSecurityException("XPath Element not found in Tranform"); ! String xpath=xpElement.getTextTrim(); setXPath(xpath); } ! public Object transformNode(Object in) { // XPath needs a document. So if element doesnt have one we add it. if (in instanceof Element){ --- 43,56 ---- } ! public XPathTransform(final Element elem) throws XMLSecurityException { super(elem); ! final Element xpElement=elem.element("XPath"); if (xpElement==null) throw new XMLSecurityException("XPath Element not found in Tranform"); ! final String xpath=xpElement.getTextTrim(); setXPath(xpath); } ! public final Object transformNode(final Object in) { // XPath needs a document. So if element doesnt have one we add it. if (in instanceof Element){ *************** *** 70,74 **** if (iter!=null) { while (iter.hasNext()) { ! Node node = (Node) iter.next(); if (transformNode(node)==null) iter.remove(); --- 70,74 ---- if (iter!=null) { while (iter.hasNext()) { ! final Node node = (Node) iter.next(); if (transformNode(node)==null) iter.remove(); *************** *** 77,81 **** return in; } ! public boolean matches(Node node){ return xpathFilter.matches(node); } --- 77,81 ---- return in; } ! public final boolean matches(final Node node){ return xpathFilter.matches(node); } |
Update of /cvsroot/neuclear/neuclear-xmlsig/src/java/org/neuclear/xml/soap In directory sc8-pr-cvs1:/tmp/cvs-serv10728/src/java/org/neuclear/xml/soap Modified Files: SOAPException.java SOAPServlet.java SOAPTools.java XMLInputStreamServlet.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: SOAPException.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-xmlsig/src/java/org/neuclear/xml/soap/SOAPException.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** SOAPException.java 11 Nov 2003 16:33:23 -0000 1.1.1.1 --- SOAPException.java 21 Nov 2003 04:44:30 -0000 1.2 *************** *** 1,4 **** --- 1,10 ---- /* $Id$ * $Log$ + * Revision 1.2 2003/11/21 04:44:30 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:23 pelle * Moved over from neudist.org *************** *** 20,33 **** import org.neuclear.xml.XMLException; ! public class SOAPException extends XMLException{ ! public SOAPException(String message) { super(message); } ! public SOAPException(Throwable t) { super(t); } ! public SOAPException(String message, Throwable t) { super(message, t); } --- 26,39 ---- import org.neuclear.xml.XMLException; ! public final class SOAPException extends XMLException{ ! public SOAPException(final String message) { super(message); } ! public SOAPException(final Throwable t) { super(t); } ! public SOAPException(final String message, final Throwable t) { super(message, t); } Index: SOAPServlet.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-xmlsig/src/java/org/neuclear/xml/soap/SOAPServlet.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** SOAPServlet.java 11 Nov 2003 16:33:22 -0000 1.1.1.1 --- SOAPServlet.java 21 Nov 2003 04:44:30 -0000 1.2 *************** *** 1,4 **** --- 1,10 ---- /* $Id$ * $Log$ + * Revision 1.2 2003/11/21 04:44:30 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:22 pelle * Moved over from neudist.org *************** *** 83,95 **** protected abstract Element handleSOAPRequest(Element request, String soapAction) throws SOAPException; ! protected void handleInputStream(InputStream is, HttpServletRequest request, HttpServletResponse response) throws IOException { try { ! SAXReader reader = new SAXReader(); ! Document doc = reader.read(is); System.out.println("RECEIVED:" + doc.asXML()); System.out.println("NEUDIST: SOAP Post Request to " + this.getClass().getName()); ! Element bodyElement = doc.getRootElement().element(DocumentHelper.createQName("Body", DocumentHelper.createNamespace("SOAP-ENV", "http://schemas.xmlsoap.org/soap/envelope/"))); //TODO: Check for null ! Element requestElement = (Element) bodyElement.elements().get(0); if (requestElement == null) { System.out.println("NEUDIST: SOAP Request was invalid"); --- 89,101 ---- protected abstract Element handleSOAPRequest(Element request, String soapAction) throws SOAPException; ! protected final void handleInputStream(final InputStream is, final HttpServletRequest request, final HttpServletResponse response) throws IOException { try { ! final SAXReader reader = new SAXReader(); ! final Document doc = reader.read(is); System.out.println("RECEIVED:" + doc.asXML()); System.out.println("NEUDIST: SOAP Post Request to " + this.getClass().getName()); ! final Element bodyElement = doc.getRootElement().element(DocumentHelper.createQName("Body", DocumentHelper.createNamespace("SOAP-ENV", "http://schemas.xmlsoap.org/soap/envelope/"))); //TODO: Check for null ! final Element requestElement = (Element) bodyElement.elements().get(0); if (requestElement == null) { System.out.println("NEUDIST: SOAP Request was invalid"); *************** *** 109,116 **** DocumentHelper.createDocument(respElement); response.setContentType("text/xml"); ! OutputStream out = response.getOutputStream(); ! XMLWriter writer = new XMLWriter(out, OutputFormat.createCompactFormat()); writer.write(respElement); out.close(); --- 115,122 ---- DocumentHelper.createDocument(respElement); response.setContentType("text/xml"); ! final OutputStream out = response.getOutputStream(); ! final XMLWriter writer = new XMLWriter(out, OutputFormat.createCompactFormat()); writer.write(respElement); out.close(); Index: SOAPTools.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-xmlsig/src/java/org/neuclear/xml/soap/SOAPTools.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** SOAPTools.java 19 Nov 2003 23:33:16 -0000 1.2 --- SOAPTools.java 21 Nov 2003 04:44:30 -0000 1.3 *************** *** 1,4 **** --- 1,10 ---- /* $Id$ * $Log$ + * Revision 1.3 2003/11/21 04:44:30 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/19 23:33:16 pelle * Signers now can generatekeys via the generateKey() method. *************** *** 111,118 **** import java.net.URLConnection; ! public class SOAPTools { ! public static Element soapRequestElement(String endpoint, Element request, String soapAction) throws NeuClearException { try { return soapRequestElement(new URL(endpoint), request, soapAction); --- 117,124 ---- import java.net.URLConnection; ! public final class SOAPTools { ! public static Element soapRequestElement(final String endpoint, final Element request, final String soapAction) throws NeuClearException { try { return soapRequestElement(new URL(endpoint), request, soapAction); *************** *** 122,126 **** } ! public static InputStream soapRequest(String endpoint, String request, String soapAction) throws NeuClearException { try { return soapRequest(new URL(endpoint), request, soapAction); --- 128,132 ---- } ! public static InputStream soapRequest(final String endpoint, final String request, final String soapAction) throws NeuClearException { try { return soapRequest(new URL(endpoint), request, soapAction); *************** *** 130,134 **** } ! public static Element soapRequestElement(URL endpoint, Element request, String soapAction) throws NeuClearException { try { return soapRequestElement(endpoint.openConnection(), request, soapAction); --- 136,140 ---- } ! public static Element soapRequestElement(final URL endpoint, final Element request, final String soapAction) throws NeuClearException { try { return soapRequestElement(endpoint.openConnection(), request, soapAction); *************** *** 139,143 **** } ! public static InputStream soapRequest(URL endpoint, String request, String soapAction) throws NeuClearException { try { return soapRequest(endpoint.openConnection(), request, soapAction); --- 145,149 ---- } ! public static InputStream soapRequest(final URL endpoint, final String request, final String soapAction) throws NeuClearException { try { return soapRequest(endpoint.openConnection(), request, soapAction); *************** *** 147,155 **** } ! public static InputStream soapRequest(URLConnection conn, Element request, String soapAction) throws NeuClearException { return soapRequest(conn, request.asXML(), soapAction); } ! public static InputStream soapRequest(URLConnection conn, String request, String soapAction) throws NeuClearException { try { //Set Headers --- 153,161 ---- } ! public static InputStream soapRequest(final URLConnection conn, final Element request, final String soapAction) throws NeuClearException { return soapRequest(conn, request.asXML(), soapAction); } ! public static InputStream soapRequest(final URLConnection conn, final String request, final String soapAction) throws NeuClearException { try { //Set Headers *************** *** 161,165 **** ((HttpURLConnection) conn).setRequestProperty("SOAPAction", soapAction); } ! OutputStream out = conn.getOutputStream(); out.write(SOAP_START); out.write(request.getBytes()); --- 167,171 ---- ((HttpURLConnection) conn).setRequestProperty("SOAPAction", soapAction); } ! final OutputStream out = conn.getOutputStream(); out.write(SOAP_START); out.write(request.getBytes()); *************** *** 172,187 **** } ! public static Element soapRequestElement(URLConnection conn, Element request, String soapAction) throws NeuClearException, IOException { try { ! BufferedReader in = new BufferedReader( new InputStreamReader( soapRequest(conn, request, soapAction) )); ! SAXReader reader = new SAXReader(); ! Document document = reader.read(in); in.close(); ! Element envelope = document.getRootElement(); if (envelope.getName().equals("Envelope")) { ! Element body = (Element) envelope.elements().get(0); if (body != null) { return (Element) body.elements().get(0); --- 178,193 ---- } ! public static Element soapRequestElement(final URLConnection conn, final Element request, final String soapAction) throws NeuClearException, IOException { try { ! final BufferedReader in = new BufferedReader( new InputStreamReader( soapRequest(conn, request, soapAction) )); ! final SAXReader reader = new SAXReader(); ! final Document document = reader.read(in); in.close(); ! final Element envelope = document.getRootElement(); if (envelope.getName().equals("Envelope")) { ! final Element body = (Element) envelope.elements().get(0); if (body != null) { return (Element) body.elements().get(0); Index: XMLInputStreamServlet.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-xmlsig/src/java/org/neuclear/xml/soap/XMLInputStreamServlet.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** XMLInputStreamServlet.java 11 Nov 2003 16:33:23 -0000 1.1.1.1 --- XMLInputStreamServlet.java 21 Nov 2003 04:44:30 -0000 1.2 *************** *** 29,32 **** --- 29,38 ---- $Id$ $Log$ + Revision 1.2 2003/11/21 04:44:30 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:23 pelle Moved over from neudist.org *************** *** 49,55 **** */ public abstract class XMLInputStreamServlet extends HttpServlet { ! protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); ! PrintWriter out = response.getWriter(); out.println("<html><head><title>SOAP Servlet</title></head><body>"); out.println("<h3>"); --- 55,61 ---- */ public abstract class XMLInputStreamServlet extends HttpServlet { ! protected void doGet(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); ! final PrintWriter out = response.getWriter(); out.println("<html><head><title>SOAP Servlet</title></head><body>"); out.println("<h3>"); *************** *** 63,69 **** } ! protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { if (request.getContentType().equals("text/xml")) { ! InputStream is = request.getInputStream(); handleInputStream(is, request, response); } --- 69,75 ---- } ! protected void doPost(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException { if (request.getContentType().equals("text/xml")) { ! final InputStream is = request.getInputStream(); handleInputStream(is, request, response); } |
Update of /cvsroot/neuclear/neuclear-xmlsig/src/java/org/neuclear/xml/c14
In directory sc8-pr-cvs1:/tmp/cvs-serv10728/src/java/org/neuclear/xml/c14
Modified Files:
Canonicalizer.java CanonicalizerWithComments.java
CanonicalizerWithoutSignature.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: Canonicalizer.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-xmlsig/src/java/org/neuclear/xml/c14/Canonicalizer.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Canonicalizer.java 11 Nov 2003 21:18:07 -0000 1.2
--- Canonicalizer.java 21 Nov 2003 04:44:30 -0000 1.3
***************
*** 8,11 ****
--- 8,17 ----
* $Id$
* $Log$
+ * Revision 1.3 2003/11/21 04:44:30 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:07 pelle
* Further vital reshuffling.
***************
*** 122,126 ****
}
! protected Canonicalizer( String xpath) {
super(xpath);
--- 128,132 ----
}
! protected Canonicalizer( final String xpath) {
super(xpath);
***************
*** 147,151 ****
* @throws IOException
*/
! public byte [] canonicalize(Object node) throws IOException {
init();
write(node);
--- 153,157 ----
* @throws IOException
*/
! public final byte [] canonicalize(final Object node) throws IOException {
init();
write(node);
***************
*** 161,171 ****
* @throws IOException
*/
! public byte[] canonicalizeSubset(Node node, String xpath) throws IOException {
init();
! XPath xpathSelector = DocumentHelper.createXPath(xpath);
! Map nsmap = new HashMap();
nsmap.put("ietf", "http://www.ietf.org");
xpathSelector.setNamespaceURIs(nsmap);
! List nl = xpathSelector.selectNodes(node);
write(nl);
return getBytes();
--- 167,177 ----
* @throws IOException
*/
! public final byte[] canonicalizeSubset(final Node node, final String xpath) throws IOException {
init();
! final XPath xpathSelector = DocumentHelper.createXPath(xpath);
! final Map nsmap = new HashMap();
nsmap.put("ietf", "http://www.ietf.org");
xpathSelector.setNamespaceURIs(nsmap);
! final List nl = xpathSelector.selectNodes(node);
write(nl);
return getBytes();
***************
*** 178,182 ****
}
! private void write(Object obj) throws IOException {
if (obj instanceof Node)
writeNode((Node) obj);
--- 184,188 ----
}
! private void write(final Object obj) throws IOException {
if (obj instanceof Node)
writeNode((Node) obj);
***************
*** 184,190 ****
writeNode(((ElementProxy) obj).getElement());
} else if (obj instanceof List) {
! Iterator iter = ((List) obj).iterator();
while (iter.hasNext()) {
! Node node = (Node) iter.next();
write(node);
}
--- 190,196 ----
writeNode(((ElementProxy) obj).getElement());
} else if (obj instanceof List) {
! final Iterator iter = ((List) obj).iterator();
while (iter.hasNext()) {
! final Node node = (Node) iter.next();
write(node);
}
***************
*** 194,202 ****
}
! private void writeNode(Node node) throws IOException {
if (!matches(node))
return;
! int nodeType = node.getNodeType();
switch (nodeType) {
--- 200,208 ----
}
! private void writeNode(final Node node) throws IOException {
if (!matches(node))
return;
! final int nodeType = node.getNodeType();
switch (nodeType) {
***************
*** 238,242 ****
}
! private void outputLF(Node node) throws IOException {
if (node.getParent() == null && notfirst) {
writer.write(LF);
--- 244,248 ----
}
! private void outputLF(final Node node) throws IOException {
if (node.getParent() == null && notfirst) {
writer.write(LF);
***************
*** 244,258 ****
}
! private void writeDocType(DocumentType documentType) {
}
! private void writeDocument(Document document) throws IOException {
for (int i = 0, size = document.nodeCount(); i < size; i++) {
! Node node = document.node(i);
write(node);
}
}
! private void writeComment(Comment comment) throws IOException {
outputLF(comment);
writer.write("<!--");
--- 250,264 ----
}
! private void writeDocType(final DocumentType documentType) {
}
! private void writeDocument(final Document document) throws IOException {
for (int i = 0, size = document.nodeCount(); i < size; i++) {
! final Node node = document.node(i);
write(node);
}
}
! private void writeComment(final Comment comment) throws IOException {
outputLF(comment);
writer.write("<!--");
***************
*** 261,265 ****
}
! private void writeProcessingInstruction(ProcessingInstruction processingInstruction) throws IOException {
outputLF(processingInstruction);
writer.write("<?");
--- 267,271 ----
}
! private void writeProcessingInstruction(final ProcessingInstruction processingInstruction) throws IOException {
outputLF(processingInstruction);
writer.write("<?");
***************
*** 272,282 ****
}
! private void writeEntity(Entity entity) throws IOException {
! String text = entity.getText();
! int hashLoc = text.indexOf('#');
writer.write(entity.getText()); //TODO entities need to be expanded
}
! private void writeAttribute(Attribute attribute) throws IOException {
writer.write(" ");
writer.write(attribute.getQualifiedName());
--- 278,288 ----
}
! private void writeEntity(final Entity entity) throws IOException {
! final String text = entity.getText();
! final int hashLoc = text.indexOf('#');
writer.write(entity.getText()); //TODO entities need to be expanded
}
! private void writeAttribute(final Attribute attribute) throws IOException {
writer.write(" ");
writer.write(attribute.getQualifiedName());
***************
*** 288,301 ****
}
! private void writeElement(Element element) throws IOException {
outputLF(element);
! String qualifiedName = element.getQualifiedName();
writer.write("<");
writer.write(qualifiedName);
! int previouslyDeclaredNamespaces = namespaceStack.size();
! Namespace ns = element.getNamespace();
! TreeMap sorted = new TreeMap();
if (isNamespaceDeclaration(ns)) {
namespaceStack.push(ns);
--- 294,307 ----
}
! private void writeElement(final Element element) throws IOException {
outputLF(element);
! final String qualifiedName = element.getQualifiedName();
writer.write("<");
writer.write(qualifiedName);
! final int previouslyDeclaredNamespaces = namespaceStack.size();
! final Namespace ns = element.getNamespace();
! final TreeMap sorted = new TreeMap();
if (isNamespaceDeclaration(ns)) {
namespaceStack.push(ns);
***************
*** 305,311 ****
}
! Iterator nsiter = element.additionalNamespaces().iterator();
while (nsiter.hasNext()) {
! Namespace namespace = (Namespace) nsiter.next();
if (!namespaceStack.contains(namespace)) {
writeNamespace(namespace, sorted);
--- 311,317 ----
}
! final Iterator nsiter = element.additionalNamespaces().iterator();
while (nsiter.hasNext()) {
! final Namespace namespace = (Namespace) nsiter.next();
if (!namespaceStack.contains(namespace)) {
writeNamespace(namespace, sorted);
***************
*** 317,321 ****
writer.write(">");
for (int i = 0, size = element.nodeCount(); i < size; i++) {
! Node node = element.node(i);
write(node);
}
--- 323,327 ----
writer.write(">");
for (int i = 0, size = element.nodeCount(); i < size; i++) {
! final Node node = element.node(i);
write(node);
}
***************
*** 333,337 ****
}
! private void writeNamespace(Namespace namespace, TreeMap sorted) throws IOException {
if (namespace != null) {
sorted.put("0" + namespace.getPrefix(), namespace);
--- 339,343 ----
}
! private void writeNamespace(final Namespace namespace, final TreeMap sorted) throws IOException {
if (namespace != null) {
sorted.put("0" + namespace.getPrefix(), namespace);
***************
*** 339,343 ****
}
! private void writeAttributes(Element element, TreeMap sorted) throws IOException {
// I do not yet handle the case where the same prefix maps to
--- 345,349 ----
}
! private void writeAttributes(final Element element, final TreeMap sorted) throws IOException {
// I do not yet handle the case where the same prefix maps to
***************
*** 349,358 ****
for (int i = 0, size = element.attributeCount(); i < size; i++) {
! Attribute attribute = element.attribute(i);
sorted.put(attribute.getNamespaceURI() + ":" + attribute.getName(), attribute);
! Namespace ns = attribute.getNamespace();
if (ns != null && ns != Namespace.NO_NAMESPACE && ns != Namespace.XML_NAMESPACE) {
! String prefix = ns.getPrefix();
! String uri = namespaceStack.getURI(prefix);
if (!ns.getURI().equals(uri)) { // output a new namespace declaration
writeNamespace(ns, sorted);
--- 355,364 ----
for (int i = 0, size = element.attributeCount(); i < size; i++) {
! final Attribute attribute = element.attribute(i);
sorted.put(attribute.getNamespaceURI() + ":" + attribute.getName(), attribute);
! final Namespace ns = attribute.getNamespace();
if (ns != null && ns != Namespace.NO_NAMESPACE && ns != Namespace.XML_NAMESPACE) {
! final String prefix = ns.getPrefix();
! final String uri = namespaceStack.getURI(prefix);
if (!ns.getURI().equals(uri)) { // output a new namespace declaration
writeNamespace(ns, sorted);
***************
*** 362,369 ****
}
! Iterator iter = sorted.keySet().iterator();
while (iter.hasNext()) {
! String name = (String) iter.next();
! Node node = (Node) sorted.get(name);
if (node instanceof Attribute)
writeAttribute((Attribute) node);
--- 368,375 ----
}
! final Iterator iter = sorted.keySet().iterator();
while (iter.hasNext()) {
! final String name = (String) iter.next();
! final Node node = (Node) sorted.get(name);
if (node instanceof Attribute)
writeAttribute((Attribute) node);
***************
*** 375,380 ****
}
! private void writeNSAttribute(Namespace namespace) throws IOException {
! String prefix = namespace.getPrefix();
writer.write(" xmlns");
if (prefix != null && prefix.length() > 0) {
--- 381,386 ----
}
! private void writeNSAttribute(final Namespace namespace) throws IOException {
! final String prefix = namespace.getPrefix();
writer.write(" xmlns");
if (prefix != null && prefix.length() > 0) {
***************
*** 387,393 ****
}
! private boolean isNamespaceDeclaration(Namespace ns) {
if (ns != null && ns != Namespace.NO_NAMESPACE && ns != Namespace.XML_NAMESPACE) {
! String uri = ns.getURI();
if (uri != null) {//&& uri.length() > 0 ) {
if (!namespaceStack.contains(ns)) {
--- 393,399 ----
}
! private boolean isNamespaceDeclaration(final Namespace ns) {
if (ns != null && ns != Namespace.NO_NAMESPACE && ns != Namespace.XML_NAMESPACE) {
! final String uri = ns.getURI();
if (uri != null) {//&& uri.length() > 0 ) {
if (!namespaceStack.contains(ns)) {
***************
*** 405,411 ****
* entity reference, suitable for XML attributes.
*/
! private void writeEscapedString(String text) throws IOException {
int i;
! int size = text.length();
for (i = 0; i < size; i++) {
--- 411,417 ----
* entity reference, suitable for XML attributes.
*/
! private void writeEscapedString(final String text) throws IOException {
int i;
! final int size = text.length();
for (i = 0; i < size; i++) {
***************
*** 436,442 ****
* entity reference, suitable for XML attributes.
*/
! private void writeEscapedAttributeString(String text) throws IOException {
int i;
! int size = text.length();
for (i = 0; i < size; i++) {
switch (text.charAt(i)) {
--- 442,448 ----
* entity reference, suitable for XML attributes.
*/
! private void writeEscapedAttributeString(final String text) throws IOException {
int i;
! final int size = text.length();
for (i = 0; i < size; i++) {
switch (text.charAt(i)) {
Index: CanonicalizerWithComments.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-xmlsig/src/java/org/neuclear/xml/c14/CanonicalizerWithComments.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** CanonicalizerWithComments.java 11 Nov 2003 21:18:07 -0000 1.2
--- CanonicalizerWithComments.java 21 Nov 2003 04:44:30 -0000 1.3
***************
*** 12,15 ****
--- 12,21 ----
* $Id$
* $Log$
+ * Revision 1.3 2003/11/21 04:44:30 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:07 pelle
* Further vital reshuffling.
***************
*** 34,38 ****
*
*/
! public class CanonicalizerWithComments extends Canonicalizer{
public CanonicalizerWithComments() {
super(XPATH_W_COMMENTS);
--- 40,44 ----
*
*/
! public final class CanonicalizerWithComments extends Canonicalizer{
public CanonicalizerWithComments() {
super(XPATH_W_COMMENTS);
Index: CanonicalizerWithoutSignature.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-xmlsig/src/java/org/neuclear/xml/c14/CanonicalizerWithoutSignature.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** CanonicalizerWithoutSignature.java 11 Nov 2003 21:18:07 -0000 1.2
--- CanonicalizerWithoutSignature.java 21 Nov 2003 04:44:30 -0000 1.3
***************
*** 14,17 ****
--- 14,23 ----
* $Id$
* $Log$
+ * Revision 1.3 2003/11/21 04:44:30 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:07 pelle
* Further vital reshuffling.
***************
*** 46,50 ****
*
*/
! public class CanonicalizerWithoutSignature extends Canonicalizer{
public CanonicalizerWithoutSignature() {
--- 52,56 ----
*
*/
! public final class CanonicalizerWithoutSignature extends Canonicalizer{
public CanonicalizerWithoutSignature() {
|
|
From: <pe...@us...> - 2003-11-21 04:44:15
|
Update of /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons/configuration
In directory sc8-pr-cvs1:/tmp/cvs-serv10533/src/java/org/neuclear/commons/configuration
Modified Files:
Configuration.java ConfigurationException.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: Configuration.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons/configuration/Configuration.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** Configuration.java 28 Oct 2003 23:43:38 -0000 1.3
--- Configuration.java 21 Nov 2003 04:43:40 -0000 1.4
***************
*** 16,22 ****
* Time: 11:34:51 AM
*/
! public class Configuration {
! private static synchronized PicoContainer getContainer(String context) throws ConfigurationException {
if (pico == null)
pico = buildContainer(context);
--- 16,22 ----
* Time: 11:34:51 AM
*/
! public final class Configuration {
! private static synchronized PicoContainer getContainer(final String context) throws ConfigurationException {
if (pico == null)
pico = buildContainer(context);
***************
*** 24,35 ****
}
! public static Object getComponent(Object type, String context) throws ConfigurationException {
return getContainer(context).getComponent(type);
}
! private static PicoContainer buildContainer(String context) throws ConfigurationException {
try {
! InputSourceRegistrationNanoContainer nc = new DomRegistrationNanoContainer.Default();
! InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream(context + ".xml");
nc.registerComponents(new InputSource(in));
nc.instantiateComponents();
--- 24,35 ----
}
! public static Object getComponent(final Object type, final String context) throws ConfigurationException {
return getContainer(context).getComponent(type);
}
! private static PicoContainer buildContainer(final String context) throws ConfigurationException {
try {
! final InputSourceRegistrationNanoContainer nc = new DomRegistrationNanoContainer.Default();
! final InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream(context + ".xml");
nc.registerComponents(new InputSource(in));
nc.instantiateComponents();
Index: ConfigurationException.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons/configuration/ConfigurationException.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** ConfigurationException.java 20 Sep 2003 23:18:12 -0000 1.1.1.1
--- ConfigurationException.java 21 Nov 2003 04:43:40 -0000 1.2
***************
*** 7,12 ****
* Time: 4:50:18 PM
*/
! public class ConfigurationException extends Exception {
! public ConfigurationException(Throwable throwable) {
super(throwable);
}
--- 7,12 ----
* Time: 4:50:18 PM
*/
! public final class ConfigurationException extends Exception {
! public ConfigurationException(final Throwable throwable) {
super(throwable);
}
|
|
From: <pe...@us...> - 2003-11-21 04:43:46
|
Update of /cvsroot/neuclear/neuclear-commons/src/test/org/neuclear/commons/crypto
In directory sc8-pr-cvs1:/tmp/cvs-serv10533/src/test/org/neuclear/commons/crypto
Modified Files:
CryptoToolsTest.java SigningBenchmark.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: CryptoToolsTest.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-commons/src/test/org/neuclear/commons/crypto/CryptoToolsTest.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** CryptoToolsTest.java 11 Nov 2003 21:17:52 -0000 1.1
--- CryptoToolsTest.java 21 Nov 2003 04:43:42 -0000 1.2
***************
*** 2,5 ****
--- 2,11 ----
$Id$
$Log$
+ Revision 1.2 2003/11/21 04:43:42 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 2003/11/11 21:17:52 pelle
Further vital reshuffling.
***************
*** 92,96 ****
* @author Pelle Braendgaard
*/
! public class CryptoToolsTest extends TestCase {
public CryptoToolsTest() {
super("CryptoToolsTest");
--- 98,102 ----
* @author Pelle Braendgaard
*/
! public final class CryptoToolsTest extends TestCase {
public CryptoToolsTest() {
super("CryptoToolsTest");
***************
*** 98,102 ****
}
! public CryptoToolsTest(String name) {
super(name);
}
--- 104,108 ----
}
! public CryptoToolsTest(final String name) {
super(name);
}
***************
*** 104,111 ****
/**
*/
! protected void setUp() {
}
! protected void tearDown() {
}
--- 110,117 ----
/**
*/
! protected final void setUp() {
}
! protected final void tearDown() {
}
***************
*** 116,139 ****
}
! public void testPadding() {
! byte src[] = new byte[20];
for (int i = 0; i < src.length; i++)
src[i] = (byte) ("a".getBytes()[0] + i);
System.out.println("Source array='" + new String(src));
! byte padded[] = CryptoTools.pad(src, 14);
System.out.println("Dest array='" + new String(padded));
assertEquals(padded.length % 14, 0);
}
! public void testSymmetricKeyEncryption() throws CryptoException {
! String contentString = "<xml>Hello</xml>";
! byte password[] = "Three Brown Geese sledded down the hill".getBytes();
! byte contents[] = contentString.getBytes();
! byte encrypted[] = CryptoTools.encrypt(password, contents);
! String encryptString = new String(encrypted);
! byte decrypted[] = CryptoTools.decrypt(password, encrypted);
! byte depadded[] = new byte[contents.length];
System.arraycopy(decrypted, 0, depadded, 0, depadded.length);
! String decryptString = new String(depadded);
System.out.println("Original: " + contentString);
System.out.println("Encrypted: " + encryptString);
--- 122,145 ----
}
! public final void testPadding() {
! final byte[] src = new byte[20];
for (int i = 0; i < src.length; i++)
src[i] = (byte) ("a".getBytes()[0] + i);
System.out.println("Source array='" + new String(src));
! final byte[] padded = CryptoTools.pad(src, 14);
System.out.println("Dest array='" + new String(padded));
assertEquals(padded.length % 14, 0);
}
! public final void testSymmetricKeyEncryption() throws CryptoException {
! final String contentString = "<xml>Hello</xml>";
! final byte[] password = "Three Brown Geese sledded down the hill".getBytes();
! final byte[] contents = contentString.getBytes();
! final byte[] encrypted = CryptoTools.encrypt(password, contents);
! final String encryptString = new String(encrypted);
! final byte[] decrypted = CryptoTools.decrypt(password, encrypted);
! final byte[] depadded = new byte[contents.length];
System.arraycopy(decrypted, 0, depadded, 0, depadded.length);
! final String decryptString = new String(depadded);
System.out.println("Original: " + contentString);
System.out.println("Encrypted: " + encryptString);
Index: SigningBenchmark.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-commons/src/test/org/neuclear/commons/crypto/SigningBenchmark.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** SigningBenchmark.java 12 Nov 2003 23:47:50 -0000 1.2
--- SigningBenchmark.java 21 Nov 2003 04:43:42 -0000 1.3
***************
*** 26,29 ****
--- 26,35 ----
$Id$
$Log$
+ Revision 1.3 2003/11/21 04:43:42 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/12 23:47:50 pelle
Much work done in creating good test environment.
***************
*** 40,45 ****
* signing and verification.
*/
! public class SigningBenchmark {
! public SigningBenchmark(String algorithm, int size) throws NoSuchAlgorithmException {
kpg = KeyPairGenerator.getInstance(algorithm);
kpg.initialize(size);
--- 46,51 ----
* signing and verification.
*/
! public final class SigningBenchmark {
! public SigningBenchmark(final String algorithm, final int size) throws NoSuchAlgorithmException {
kpg = KeyPairGenerator.getInstance(algorithm);
kpg.initialize(size);
***************
*** 51,67 ****
! public void generateKeys() {
kp = kpg.generateKeyPair();
}
! public void sign() throws CryptoException {
testsig = CryptoTools.sign(kp, testdata);
}
! public void verify() throws CryptoException {
CryptoTools.verify(kp.getPublic(), testdata, testsig);
}
! public void benchmark() throws CryptoException {
Date start = new Date();
--- 57,73 ----
! public final void generateKeys() {
kp = kpg.generateKeyPair();
}
! public final void sign() throws CryptoException {
testsig = CryptoTools.sign(kp, testdata);
}
! public final void verify() throws CryptoException {
CryptoTools.verify(kp.getPublic(), testdata, testsig);
}
! public final void benchmark() throws CryptoException {
Date start = new Date();
***************
*** 85,98 ****
}
! public void printResults() {
System.out.println(algorithm + "\t" + size + "\t" + results[0] + "\t" + results[1] + "\t" + results[2]);
}
! public static void main(String args[]) {
System.out.println("Performance Analysis of key sizes and algorithms");
! String algorithms[] = new String[]{"RSA", "DSA"};
! int keysizes[] = new int[]{512, 1024};
try {
for (int a = 0; a < algorithms.length; a++)
--- 91,104 ----
}
! public final void printResults() {
System.out.println(algorithm + "\t" + size + "\t" + results[0] + "\t" + results[1] + "\t" + results[2]);
}
! public static void main(final String[] args) {
System.out.println("Performance Analysis of key sizes and algorithms");
! final String[] algorithms = new String[]{"RSA", "DSA"};
! final int[] keysizes = new int[]{512, 1024};
try {
for (int a = 0; a < algorithms.length; a++)
***************
*** 107,120 ****
}
! private static int ITERATIONS = 100;
! private KeyPairGenerator kpg;
private KeyPair kp;
! private String algorithm;
! private int size;
! private long[] results;
! private static String TESTSTRING = "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ" +
"1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ" +
"1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ" +
--- 113,126 ----
}
! private static final int ITERATIONS = 100;
! private final KeyPairGenerator kpg;
private KeyPair kp;
! private final String algorithm;
! private final int size;
! private final long[] results;
! private static final String TESTSTRING = "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ" +
"1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ" +
"1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ" +
***************
*** 133,137 ****
"1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ";
private byte[] testsig;
! private byte[] testdata;
}
--- 139,143 ----
"1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ";
private byte[] testsig;
! private final byte[] testdata;
}
|
|
From: <pe...@us...> - 2003-11-21 04:43:46
|
Update of /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons
In directory sc8-pr-cvs1:/tmp/cvs-serv10533/src/java/org/neuclear/commons
Modified Files:
NeuClearException.java RegexFileNameFilter.java Utility.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: NeuClearException.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons/NeuClearException.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** NeuClearException.java 11 Nov 2003 21:17:50 -0000 1.2
--- NeuClearException.java 21 Nov 2003 04:43:42 -0000 1.3
***************
*** 2,5 ****
--- 2,11 ----
* $Id$
* $Log$
+ * Revision 1.3 2003/11/21 04:43:42 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:17:50 pelle
* Further vital reshuffling.
***************
*** 63,67 ****
* @since 1.4
*/
! public NeuClearException(Throwable cause) {
super(cause);
}
--- 69,73 ----
* @since 1.4
*/
! public NeuClearException(final Throwable cause) {
super(cause);
}
***************
*** 75,79 ****
* later retrieval by the {@link #getMessage()} method.
*/
! public NeuClearException(String message) {
super(message);
}
--- 81,85 ----
* later retrieval by the {@link #getMessage()} method.
*/
! public NeuClearException(final String message) {
super(message);
}
***************
*** 93,97 ****
* @since 1.4
*/
! public NeuClearException(String message, Throwable cause) {
super(message, cause);
}
--- 99,103 ----
* @since 1.4
*/
! public NeuClearException(final String message, final Throwable cause) {
super(message, cause);
}
Index: RegexFileNameFilter.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons/RegexFileNameFilter.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** RegexFileNameFilter.java 11 Nov 2003 21:17:51 -0000 1.1
--- RegexFileNameFilter.java 21 Nov 2003 04:43:42 -0000 1.2
***************
*** 12,15 ****
--- 12,21 ----
* $Id$
* $Log$
+ * Revision 1.2 2003/11/21 04:43:42 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 2003/11/11 21:17:51 pelle
* Further vital reshuffling.
***************
*** 33,38 ****
* Modified tools to handle these keys
*/
! public class RegexFileNameFilter implements FilenameFilter {
! public RegexFileNameFilter(String regex) {
this.re = Pattern.compile(regex);
}
--- 39,44 ----
* Modified tools to handle these keys
*/
! public final class RegexFileNameFilter implements FilenameFilter {
! public RegexFileNameFilter(final String regex) {
this.re = Pattern.compile(regex);
}
***************
*** 46,53 ****
* included in the file list; <code>false</code> otherwise.
*/
! public boolean accept(File dir, String name) {
return (re.matcher(name).matches());
}
! private Pattern re;
}
--- 52,59 ----
* included in the file list; <code>false</code> otherwise.
*/
! public final boolean accept(final File dir, final String name) {
return (re.matcher(name).matches());
}
! private final Pattern re;
}
Index: Utility.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons/Utility.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Utility.java 11 Nov 2003 21:17:52 -0000 1.1
--- Utility.java 21 Nov 2003 04:43:42 -0000 1.2
***************
*** 2,5 ****
--- 2,11 ----
* $Id$
* $Log$
+ * Revision 1.2 2003/11/21 04:43:42 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 2003/11/11 21:17:52 pelle
* Further vital reshuffling.
***************
*** 123,136 ****
import java.io.PrintStream;
! public class Utility {
! public static boolean isEmpty(Object obj) {
return (obj == null || obj.toString().equals(""));
}
! public static String denullString(String string) {
return denullString(string, "");
}
! public static String denullString(String string, String def) {
if (string == null)
return def;
--- 129,142 ----
import java.io.PrintStream;
! public final class Utility {
! public static boolean isEmpty(final Object obj) {
return (obj == null || obj.toString().equals(""));
}
! public static String denullString(final String string) {
return denullString(string, "");
}
! public static String denullString(final String string, final String def) {
if (string == null)
return def;
***************
*** 139,143 ****
// Im sick of writing the same crap over and over again
! public static void handleException(Throwable e, PrintStream out) {
out.println("Exception in :" + e.getClass().toString());
out.println(e.getLocalizedMessage());
--- 145,149 ----
// Im sick of writing the same crap over and over again
! public static void handleException(final Throwable e, final PrintStream out) {
out.println("Exception in :" + e.getClass().toString());
out.println(e.getLocalizedMessage());
***************
*** 145,157 ****
}
! public static void rethrowException(Throwable e) throws NeuClearException {
throw new NeuClearException(e);
}
! public static void handleException(Throwable e) {
handleException(e, System.out);
}
! public static boolean isTrue(String clause, boolean defaultVal) {
if (isEmpty(clause))
return defaultVal;
--- 151,163 ----
}
! public static void rethrowException(final Throwable e) throws NeuClearException {
throw new NeuClearException(e);
}
! public static void handleException(final Throwable e) {
handleException(e, System.out);
}
! public static boolean isTrue(String clause, final boolean defaultVal) {
if (isEmpty(clause))
return defaultVal;
***************
*** 160,164 ****
}
! public static int getIntValue(String strValue, int defValue) {
if (strValue == null)
return defValue;
--- 166,170 ----
}
! public static int getIntValue(final String strValue, final int defValue) {
if (strValue == null)
return defValue;
***************
*** 172,184 ****
}
! public static int getIntValue(String strValue) {
return getIntValue(strValue, 0);
}
! public static int getEnumVal(String[] enum, String key) {
return getEnumVal(enum, key, -1);
}
! public static int getEnumVal(String[] enum, String key, int def) {
if (enum == null || key == null)
return def;
--- 178,190 ----
}
! public static int getIntValue(final String strValue) {
return getIntValue(strValue, 0);
}
! public static int getEnumVal(final String[] enum, final String key) {
return getEnumVal(enum, key, -1);
}
! public static int getEnumVal(final String[] enum, final String key, final int def) {
if (enum == null || key == null)
return def;
|
|
From: <pe...@us...> - 2003-11-21 04:43:46
|
Update of /cvsroot/neuclear/neuclear-commons/src/test/org/neuclear/commons/crypto/signers
In directory sc8-pr-cvs1:/tmp/cvs-serv10533/src/test/org/neuclear/commons/crypto/signers
Modified Files:
SimpleSignerStoreTest.java TestCaseSignerTest.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: SimpleSignerStoreTest.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-commons/src/test/org/neuclear/commons/crypto/signers/SimpleSignerStoreTest.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** SimpleSignerStoreTest.java 19 Nov 2003 23:32:51 -0000 1.3
--- SimpleSignerStoreTest.java 21 Nov 2003 04:43:42 -0000 1.4
***************
*** 1,4 ****
--- 1,10 ----
/* $Id$
* $Log$
+ * Revision 1.4 2003/11/21 04:43:42 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.3 2003/11/19 23:32:51 pelle
* Signers now can generatekeys via the generateKey() method.
***************
*** 106,111 ****
* @version $Revision$
*/
! public class SimpleSignerStoreTest extends TestCase {
! public SimpleSignerStoreTest(String name) throws GeneralSecurityException, NeuClearException, ConfigurationException {
super(name);
signer = getSignerStoreInstance();
--- 112,117 ----
* @version $Revision$
*/
! public final class SimpleSignerStoreTest extends TestCase {
! public SimpleSignerStoreTest(final String name) throws GeneralSecurityException, NeuClearException, ConfigurationException {
super(name);
signer = getSignerStoreInstance();
***************
*** 136,140 ****
! public void testAddKey() throws NeuClearException, GeneralSecurityException, IOException {
boolean success = false;
try {
--- 142,146 ----
! public final void testAddKey() throws NeuClearException, GeneralSecurityException, IOException {
boolean success = false;
try {
***************
*** 149,153 ****
}
! public void testSignData() throws NeuClearException, GeneralSecurityException, IOException, CryptoException {
boolean success = false;
byte data[] = null;
--- 155,159 ----
}
! public final void testSignData() throws NeuClearException, GeneralSecurityException, IOException, CryptoException {
boolean success = false;
byte data[] = null;
***************
*** 167,174 ****
}
! public void testGenerateKey() throws CryptoException {
! PublicKey pub = signer.generateKey("tupac");
! byte data[] = "this is a test".getBytes();
! byte sig[] = signer.sign("tupac", data);
assertNotNull(sig);
assertTrue(CryptoTools.verify(pub, data, sig));
--- 173,180 ----
}
! public final void testGenerateKey() throws CryptoException {
! final PublicKey pub = signer.generateKey("tupac");
! final byte[] data = "this is a test".getBytes();
! final byte[] sig = signer.sign("tupac", data);
assertNotNull(sig);
assertTrue(CryptoTools.verify(pub, data, sig));
***************
*** 178,182 ****
}
! private SimpleSigner signer;
private static KeyPairGenerator kg;
protected static KeyPair root;
--- 184,188 ----
}
! private final SimpleSigner signer;
private static KeyPairGenerator kg;
protected static KeyPair root;
Index: TestCaseSignerTest.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-commons/src/test/org/neuclear/commons/crypto/signers/TestCaseSignerTest.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** TestCaseSignerTest.java 19 Nov 2003 23:32:51 -0000 1.2
--- TestCaseSignerTest.java 21 Nov 2003 04:43:42 -0000 1.3
***************
*** 29,32 ****
--- 29,38 ----
$Id$
$Log$
+ Revision 1.3 2003/11/21 04:43:42 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/19 23:32:51 pelle
Signers now can generatekeys via the generateKey() method.
***************
*** 49,59 ****
* Time: 2:48:23 PM
*/
! public class TestCaseSignerTest extends TestCase {
! public TestCaseSignerTest(String string) throws GeneralSecurityException, NeuClearException {
super(string);
signer = new TestCaseSigner();
}
! public void testHasKeys() throws CryptoException {
assertTrue(signer.canSignFor("neu://test"));
assertTrue(signer.canSignFor("neu://test/bux"));
--- 55,65 ----
* Time: 2:48:23 PM
*/
! public final class TestCaseSignerTest extends TestCase {
! public TestCaseSignerTest(final String string) throws GeneralSecurityException, NeuClearException {
super(string);
signer = new TestCaseSigner();
}
! public final void testHasKeys() throws CryptoException {
assertTrue(signer.canSignFor("neu://test"));
assertTrue(signer.canSignFor("neu://test/bux"));
***************
*** 62,66 ****
}
! public void testSignAndVerify() throws CryptoException {
testKey("neu://test");
testKey("neu://test/bux");
--- 68,72 ----
}
! public final void testSignAndVerify() throws CryptoException {
testKey("neu://test");
testKey("neu://test/bux");
***************
*** 69,76 ****
}
! public void testGenerateKey() throws CryptoException {
! PublicKey pub = signer.generateKey(ALIASEVE);
! byte data[] = "this is a test".getBytes();
! byte sig[] = signer.sign(ALIASEVE, data);
assertNotNull(sig);
assertTrue(CryptoTools.verify(pub, data, sig));
--- 75,82 ----
}
! public final void testGenerateKey() throws CryptoException {
! final PublicKey pub = signer.generateKey(ALIASEVE);
! final byte[] data = "this is a test".getBytes();
! final byte[] sig = signer.sign(ALIASEVE, data);
assertNotNull(sig);
assertTrue(CryptoTools.verify(pub, data, sig));
***************
*** 80,85 ****
}
! private void testKey(String name) throws CryptoException {
! byte sig[] = signer.sign(name, TESTDATA.getBytes());
assertNotNull(sig);
assertTrue(CryptoTools.verify(signer.getPublicKey(name), TESTDATA.getBytes(), sig));
--- 86,91 ----
}
! private void testKey(final String name) throws CryptoException {
! final byte[] sig = signer.sign(name, TESTDATA.getBytes());
assertNotNull(sig);
assertTrue(CryptoTools.verify(signer.getPublicKey(name), TESTDATA.getBytes(), sig));
***************
*** 87,92 ****
! private TestCaseSigner signer;
! private String TESTDATA = "Here we go again";
private static final String ALIASEVE = "neu://eve@test";
--- 93,98 ----
! private final TestCaseSigner signer;
! private final String TESTDATA = "Here we go again";
private static final String ALIASEVE = "neu://eve@test";
|
|
From: <pe...@us...> - 2003-11-21 04:43:46
|
Update of /cvsroot/neuclear/neuclear-commons/src/test/org/neuclear/commons/sql
In directory sc8-pr-cvs1:/tmp/cvs-serv10533/src/test/org/neuclear/commons/sql
Modified Files:
SQLToolsTest.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: SQLToolsTest.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-commons/src/test/org/neuclear/commons/sql/SQLToolsTest.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** SQLToolsTest.java 20 Sep 2003 23:18:12 -0000 1.1.1.1
--- SQLToolsTest.java 21 Nov 2003 04:43:42 -0000 1.2
***************
*** 18,27 ****
* To change this template use Options | File Templates.
*/
! public class SQLToolsTest extends TestCase {
! public SQLToolsTest(String string) {
super(string);
}
! public void testGetConnection() {
/*
try {
--- 18,27 ----
* To change this template use Options | File Templates.
*/
! public final class SQLToolsTest extends TestCase {
! public SQLToolsTest(final String string) {
super(string);
}
! public final void testGetConnection() {
/*
try {
|
|
From: <pe...@us...> - 2003-11-21 04:43:46
|
Update of /cvsroot/neuclear/neuclear-commons/src/test/org/neuclear/commons/configuration
In directory sc8-pr-cvs1:/tmp/cvs-serv10533/src/test/org/neuclear/commons/configuration
Modified Files:
ConfigurationTest.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: ConfigurationTest.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-commons/src/test/org/neuclear/commons/configuration/ConfigurationTest.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** ConfigurationTest.java 28 Oct 2003 23:43:38 -0000 1.3
--- ConfigurationTest.java 21 Nov 2003 04:43:42 -0000 1.4
***************
*** 9,18 ****
* Time: 11:15:41 AM
*/
! public class ConfigurationTest extends TestCase {
! public ConfigurationTest(String string) {
super(string);
}
! public void testGetComponent() throws ConfigurationException {
assertNotNull(Configuration.getComponent(ConnectionSource.class, "neuclear-commons"));
}
--- 9,18 ----
* Time: 11:15:41 AM
*/
! public final class ConfigurationTest extends TestCase {
! public ConfigurationTest(final String string) {
super(string);
}
! public final void testGetComponent() throws ConfigurationException {
assertNotNull(Configuration.getComponent(ConnectionSource.class, "neuclear-commons"));
}
|
|
From: <pe...@us...> - 2003-11-21 04:43:45
|
Update of /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons/time
In directory sc8-pr-cvs1:/tmp/cvs-serv10533/src/java/org/neuclear/commons/time
Modified Files:
TimeTools.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: TimeTools.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons/time/TimeTools.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** TimeTools.java 11 Nov 2003 21:17:49 -0000 1.2
--- TimeTools.java 21 Nov 2003 04:43:42 -0000 1.3
***************
*** 2,5 ****
--- 2,11 ----
* $Id$
* $Log$
+ * Revision 1.3 2003/11/21 04:43:42 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:17:49 pelle
* Further vital reshuffling.
***************
*** 60,69 ****
*/
! public class TimeTools {
! public static Date addDaysToDate(Date d, int iDays) {
//create Calendar
! Calendar cal = Calendar.getInstance();
cal.setTime(d);
--- 66,75 ----
*/
! public final class TimeTools {
! public static Date addDaysToDate(final Date d, final int iDays) {
//create Calendar
! final Calendar cal = Calendar.getInstance();
cal.setTime(d);
***************
*** 75,81 ****
}
! public static Date addMonthsToDate(Date d, int iMonths) {
//create Calendar
! Calendar cal = Calendar.getInstance();
cal.setTime(d);
--- 81,87 ----
}
! public static Date addMonthsToDate(final Date d, final int iMonths) {
//create Calendar
! final Calendar cal = Calendar.getInstance();
cal.setTime(d);
***************
*** 91,95 ****
}
! public static Timestamp convertDateToTimestamp(Date date) {
if (date instanceof Timestamp)
return (Timestamp) date;
--- 97,101 ----
}
! public static Timestamp convertDateToTimestamp(final Date date) {
if (date instanceof Timestamp)
return (Timestamp) date;
***************
*** 97,101 ****
}
! public static Timestamp parseTimeStamp(String ts) throws NeuClearException {
try {
return convertDateToTimestamp(getDateFormatter().parse(ts));
--- 103,107 ----
}
! public static Timestamp parseTimeStamp(final String ts) throws NeuClearException {
try {
return convertDateToTimestamp(getDateFormatter().parse(ts));
***************
*** 106,110 ****
}
! public static String formatTimeStamp(Date time) {
return getDateFormatter().format(time);
}
--- 112,116 ----
}
! public static String formatTimeStamp(final Date time) {
return getDateFormatter().format(time);
}
|
Update of /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons/sql
In directory sc8-pr-cvs1:/tmp/cvs-serv10533/src/java/org/neuclear/commons/sql
Modified Files:
DefaultConnectionSource.java JNDIConnectionSource.java
SQLTools.java SimpleConnectionSource.java
ThreadMappedConnectionSource.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: DefaultConnectionSource.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons/sql/DefaultConnectionSource.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** DefaultConnectionSource.java 20 Sep 2003 23:18:11 -0000 1.1.1.1
--- DefaultConnectionSource.java 21 Nov 2003 04:43:42 -0000 1.2
***************
*** 14,20 ****
* Time: 3:38:50 PM
*/
! public class DefaultConnectionSource extends ThreadMappedConnectionSource {
! public Connection createConnection() throws SQLException, IOException {
return SQLTools.getConnection();
}
--- 14,20 ----
* Time: 3:38:50 PM
*/
! public final class DefaultConnectionSource extends ThreadMappedConnectionSource {
! public final Connection createConnection() throws SQLException, IOException {
return SQLTools.getConnection();
}
Index: JNDIConnectionSource.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons/sql/JNDIConnectionSource.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** JNDIConnectionSource.java 18 Nov 2003 23:34:55 -0000 1.1
--- JNDIConnectionSource.java 21 Nov 2003 04:43:42 -0000 1.2
***************
*** 28,31 ****
--- 28,37 ----
$Id$
$Log$
+ Revision 1.2 2003/11/21 04:43:42 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 2003/11/18 23:34:55 pelle
Payment Web Application is getting there.
***************
*** 38,49 ****
* Time: 6:09:37 PM
*/
! public class JNDIConnectionSource implements ConnectionSource {
! public JNDIConnectionSource(String name) throws NamingException {
! InitialContext ctx = new InitialContext();
this.ds = (DataSource) ctx.lookup(name);
}
! public Connection getConnection() throws SQLException, IOException {
return ds.getConnection();
}
--- 44,55 ----
* Time: 6:09:37 PM
*/
! public final class JNDIConnectionSource implements ConnectionSource {
! public JNDIConnectionSource(final String name) throws NamingException {
! final InitialContext ctx = new InitialContext();
this.ds = (DataSource) ctx.lookup(name);
}
! public final Connection getConnection() throws SQLException, IOException {
return ds.getConnection();
}
Index: SQLTools.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons/sql/SQLTools.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** SQLTools.java 20 Sep 2003 23:18:11 -0000 1.1.1.1
--- SQLTools.java 21 Nov 2003 04:43:42 -0000 1.2
***************
*** 23,27 ****
public final static java.sql.Connection getConnection() throws SQLException, IOException {
! Properties props=loadProperties();
try {
Class.forName(props.getProperty("jdbc.class")).newInstance();
--- 23,27 ----
public final static java.sql.Connection getConnection() throws SQLException, IOException {
! final Properties props=loadProperties();
try {
Class.forName(props.getProperty("jdbc.class")).newInstance();
***************
*** 43,48 ****
private static Properties loadProperties() throws IOException {
! Properties props=new Properties();
! File propsFile= new File(
System.getProperty("user.home")+
System.getProperty("file.separator")+
--- 43,48 ----
private static Properties loadProperties() throws IOException {
! final Properties props=new Properties();
! final File propsFile= new File(
System.getProperty("user.home")+
System.getProperty("file.separator")+
***************
*** 58,62 ****
}
! public final static Timestamp toTimestamp(java.util.Date date) {
if (date==null)
return null;
--- 58,62 ----
}
! public final static Timestamp toTimestamp(final java.util.Date date) {
if (date==null)
return null;
Index: SimpleConnectionSource.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons/sql/SimpleConnectionSource.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** SimpleConnectionSource.java 20 Sep 2003 23:18:12 -0000 1.1.1.1
--- SimpleConnectionSource.java 21 Nov 2003 04:43:42 -0000 1.2
***************
*** 14,19 ****
* Time: 3:38:50 PM
*/
! public class SimpleConnectionSource extends ThreadMappedConnectionSource {
! public SimpleConnectionSource(String driver, String url, String user, String password) throws SQLException{
try {
Class.forName(driver).newInstance();
--- 14,19 ----
* Time: 3:38:50 PM
*/
! public final class SimpleConnectionSource extends ThreadMappedConnectionSource {
! public SimpleConnectionSource(final String driver, final String url, final String user, final String password) throws SQLException{
try {
Class.forName(driver).newInstance();
***************
*** 30,34 ****
}
! public Connection createConnection() throws SQLException {
return DriverManager.getConnection(
url,
--- 30,34 ----
}
! public final Connection createConnection() throws SQLException {
return DriverManager.getConnection(
url,
***************
*** 38,44 ****
}
! private String url;
! private String user;
! private String password;
private Connection con;
--- 38,44 ----
}
! private final String url;
! private final String user;
! private final String password;
private Connection con;
Index: ThreadMappedConnectionSource.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons/sql/ThreadMappedConnectionSource.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** ThreadMappedConnectionSource.java 20 Sep 2003 23:18:11 -0000 1.1.1.1
--- ThreadMappedConnectionSource.java 21 Nov 2003 04:43:42 -0000 1.2
***************
*** 16,20 ****
*/
public abstract class ThreadMappedConnectionSource implements ConnectionSource {
! protected Map threadmap;
public ThreadMappedConnectionSource() {
--- 16,20 ----
*/
public abstract class ThreadMappedConnectionSource implements ConnectionSource {
! protected final Map threadmap;
public ThreadMappedConnectionSource() {
***************
*** 27,31 ****
* @throws java.sql.SQLException
*/
! public Connection getConnection() throws SQLException, IOException {
Connection con=(Connection)threadmap.get(Thread.currentThread());
--- 27,31 ----
* @throws java.sql.SQLException
*/
! public final Connection getConnection() throws SQLException, IOException {
Connection con=(Connection)threadmap.get(Thread.currentThread());
|
|
From: <pe...@us...> - 2003-11-21 04:43:45
|
Update of /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons/test
In directory sc8-pr-cvs1:/tmp/cvs-serv10533/src/java/org/neuclear/commons/test
Modified Files:
JunitTools.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: JunitTools.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons/test/JunitTools.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** JunitTools.java 20 Nov 2003 23:41:36 -0000 1.2
--- JunitTools.java 21 Nov 2003 04:43:42 -0000 1.3
***************
*** 20,23 ****
--- 20,29 ----
* $Id$
* $Log$
+ * Revision 1.3 2003/11/21 04:43:42 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/20 23:41:36 pelle
* Getting all the tests to work in id
***************
*** 41,46 ****
try {
! KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
! char[] password = "neuclear".toCharArray();
ks.load(new FileInputStream(new File("src/testdata/keys/testkeys.jks")), password);
rsakey = CryptoTools.getKeyPair(ks, "rsakey", password);
--- 47,52 ----
try {
! final KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
! final char[] password = "neuclear".toCharArray();
ks.load(new FileInputStream(new File("src/testdata/keys/testkeys.jks")), password);
rsakey = CryptoTools.getKeyPair(ks, "rsakey", password);
|
|
From: <pe...@us...> - 2003-11-21 04:43:45
|
Update of /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons/servlets
In directory sc8-pr-cvs1:/tmp/cvs-serv10533/src/java/org/neuclear/commons/servlets
Modified Files:
ServletTools.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: ServletTools.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons/servlets/ServletTools.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** ServletTools.java 11 Nov 2003 21:17:48 -0000 1.1
--- ServletTools.java 21 Nov 2003 04:43:41 -0000 1.2
***************
*** 1,4 ****
--- 1,10 ----
/* $Id$
* $Log$
+ * Revision 1.2 2003/11/21 04:43:41 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 2003/11/11 21:17:48 pelle
* Further vital reshuffling.
***************
*** 36,42 ****
* @version $Revision$
**/
! public class ServletTools {
! public static String getAbsoluteURL(HttpServletRequest request, String item) {
return request.getScheme() + "://" + request.getServerName() +
((request.getServerPort() == 80) ? "" : ":" + Integer.toString(request.getServerPort()))
--- 42,48 ----
* @version $Revision$
**/
! public final class ServletTools {
! public static String getAbsoluteURL(final HttpServletRequest request, final String item) {
return request.getScheme() + "://" + request.getServerName() +
((request.getServerPort() == 80) ? "" : ":" + Integer.toString(request.getServerPort()))
***************
*** 44,48 ****
}
! public static void printHeader(PrintWriter out, HttpServletRequest request, String title) {
out.println("<html><head><title>NeuDist Local Signing Service</title>");
//out.println("<LINK rel=\"STYLESHEET\" type=\"text/css\" href=\"style/neuclear.css\">");
--- 50,54 ----
}
! public static void printHeader(final PrintWriter out, final HttpServletRequest request, final String title) {
out.println("<html><head><title>NeuDist Local Signing Service</title>");
//out.println("<LINK rel=\"STYLESHEET\" type=\"text/css\" href=\"style/neuclear.css\">");
|
Update of /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons/crypto/passphraseagents
In directory sc8-pr-cvs1:/tmp/cvs-serv10533/src/java/org/neuclear/commons/crypto/passphraseagents
Modified Files:
AlwaysTheSamePassphraseAgent.java AskAtStartupAgent.java
CommandLineAgent.java GuiDialogAgent.java
StoredPassphraseAgent.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: AlwaysTheSamePassphraseAgent.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons/crypto/passphraseagents/AlwaysTheSamePassphraseAgent.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** AlwaysTheSamePassphraseAgent.java 12 Nov 2003 23:47:50 -0000 1.1
--- AlwaysTheSamePassphraseAgent.java 21 Nov 2003 04:43:40 -0000 1.2
***************
*** 21,24 ****
--- 21,30 ----
$Id$
$Log$
+ Revision 1.2 2003/11/21 04:43:40 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 2003/11/12 23:47:50 pelle
Much work done in creating good test environment.
***************
*** 44,55 ****
* Time: 5:01:14 PM
*/
! public class AlwaysTheSamePassphraseAgent implements PassPhraseAgent {
! public AlwaysTheSamePassphraseAgent(String passphrase) {
this.passphrase = passphrase;
System.out.println("AlwaysTheSamePassphraseAgent started.\nDO NOT USE FOR PRODUCTION SERVERS");
}
! public char[] getPassPhrase(String name) {
return passphrase.toCharArray();
}
--- 50,61 ----
* Time: 5:01:14 PM
*/
! public final class AlwaysTheSamePassphraseAgent implements PassPhraseAgent {
! public AlwaysTheSamePassphraseAgent(final String passphrase) {
this.passphrase = passphrase;
System.out.println("AlwaysTheSamePassphraseAgent started.\nDO NOT USE FOR PRODUCTION SERVERS");
}
! public final char[] getPassPhrase(final String name) {
return passphrase.toCharArray();
}
Index: AskAtStartupAgent.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons/crypto/passphraseagents/AskAtStartupAgent.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** AskAtStartupAgent.java 12 Nov 2003 16:33:41 -0000 1.1
--- AskAtStartupAgent.java 21 Nov 2003 04:43:41 -0000 1.2
***************
*** 21,24 ****
--- 21,30 ----
$Id$
$Log$
+ Revision 1.2 2003/11/21 04:43:41 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 2003/11/12 16:33:41 pelle
Idea missed checking this in during a refactoring.
***************
*** 34,39 ****
* Time: 5:09:36 PM
*/
! public class AskAtStartupAgent implements PassPhraseAgent {
! public AskAtStartupAgent(InteractiveAgent agent, String name) {
this.name = name;
this.passphrase = agent.getPassPhrase(name);
--- 40,45 ----
* Time: 5:09:36 PM
*/
! public final class AskAtStartupAgent implements PassPhraseAgent {
! public AskAtStartupAgent(final InteractiveAgent agent, final String name) {
this.name = name;
this.passphrase = agent.getPassPhrase(name);
***************
*** 46,50 ****
* @return
*/
! public char[] getPassPhrase(String name) {
if (name.equals(this.name))
return passphrase;
--- 52,56 ----
* @return
*/
! public final char[] getPassPhrase(final String name) {
if (name.equals(this.name))
return passphrase;
Index: CommandLineAgent.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons/crypto/passphraseagents/CommandLineAgent.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** CommandLineAgent.java 19 Nov 2003 14:37:37 -0000 1.2
--- CommandLineAgent.java 21 Nov 2003 04:43:41 -0000 1.3
***************
*** 25,28 ****
--- 25,34 ----
$Id$
$Log$
+ Revision 1.3 2003/11/21 04:43:41 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/19 14:37:37 pelle
CommandLineAgent now masks the passphrase input using the JLine library which is now a dependency.
***************
*** 52,58 ****
* Time: 11:53:29 AM
*/
! public class CommandLineAgent implements InteractiveAgent {
! public char[] getPassPhrase(String name) {
! BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Please enter passphrase for: " + name);
System.out.print(": ");
--- 58,64 ----
* Time: 11:53:29 AM
*/
! public final class CommandLineAgent implements InteractiveAgent {
! public final char[] getPassPhrase(final String name) {
! final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Please enter passphrase for: " + name);
System.out.print(": ");
***************
*** 66,71 ****
}
! public static void main(String args[]) {
! PassPhraseAgent dia = new CommandLineAgent();
System.out.println("Getting passphrase... " + new String(dia.getPassPhrase("neu://pelle@test")));
System.out.println("Getting passphrase... " + new String(dia.getPassPhrase("neu://pelle@test")));
--- 72,77 ----
}
! public static void main(final String[] args) {
! final PassPhraseAgent dia = new CommandLineAgent();
System.out.println("Getting passphrase... " + new String(dia.getPassPhrase("neu://pelle@test")));
System.out.println("Getting passphrase... " + new String(dia.getPassPhrase("neu://pelle@test")));
Index: GuiDialogAgent.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons/crypto/passphraseagents/GuiDialogAgent.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** GuiDialogAgent.java 11 Nov 2003 21:17:46 -0000 1.1
--- GuiDialogAgent.java 21 Nov 2003 04:43:41 -0000 1.2
***************
*** 25,28 ****
--- 25,34 ----
$Id$
$Log$
+ Revision 1.2 2003/11/21 04:43:41 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 2003/11/11 21:17:46 pelle
Further vital reshuffling.
***************
*** 62,69 ****
frame.setVisible(false);
frame.setSize(200, 100);
! Panel panel = new Panel();
panel.setLayout(new BorderLayout());
frame.add(panel);
! Panel text = new Panel(new FlowLayout());
panel.add(text, BorderLayout.NORTH);
--- 68,75 ----
frame.setVisible(false);
frame.setSize(200, 100);
! final Panel panel = new Panel();
panel.setLayout(new BorderLayout());
frame.add(panel);
! final Panel text = new Panel(new FlowLayout());
panel.add(text, BorderLayout.NORTH);
***************
*** 71,76 ****
try {
img = Toolkit.getDefaultToolkit().getImage(this.getClass().getClassLoader().getResource("org/neuclear/commons/crypto/passphraseagents/neuclear.png"));
! Canvas canvas = new Canvas() {
! public void paint(Graphics g) {
setSize(50, 50);
g.drawImage(img, 0, 0, this);
--- 77,82 ----
try {
img = Toolkit.getDefaultToolkit().getImage(this.getClass().getClassLoader().getResource("org/neuclear/commons/crypto/passphraseagents/neuclear.png"));
! final Canvas canvas = new Canvas() {
! public void paint(final Graphics g) {
setSize(50, 50);
g.drawImage(img, 0, 0, this);
***************
*** 94,105 ****
passphrase.setEchoChar('*');
panel.add(passphrase, BorderLayout.CENTER);
! Panel buttons = new Panel(new FlowLayout());
panel.add(buttons, BorderLayout.SOUTH);
ok = new Button("Sign");
buttons.add(ok);
! Button cancel = new Button("Cancel");
buttons.add(cancel);
cancel.addActionListener(new ActionListener() {
! public void actionPerformed(ActionEvent actionEvent) {
synchronized (passphrase) {
passphrase.setText("");
--- 100,111 ----
passphrase.setEchoChar('*');
panel.add(passphrase, BorderLayout.CENTER);
! final Panel buttons = new Panel(new FlowLayout());
panel.add(buttons, BorderLayout.SOUTH);
ok = new Button("Sign");
buttons.add(ok);
! final Button cancel = new Button("Cancel");
buttons.add(cancel);
cancel.addActionListener(new ActionListener() {
! public void actionPerformed(final ActionEvent actionEvent) {
synchronized (passphrase) {
passphrase.setText("");
***************
*** 110,115 ****
});
! ActionListener action = new ActionListener() {
! public void actionPerformed(ActionEvent actionEvent) {
synchronized (passphrase) {
passphrase.notifyAll();
--- 116,121 ----
});
! final ActionListener action = new ActionListener() {
! public void actionPerformed(final ActionEvent actionEvent) {
synchronized (passphrase) {
passphrase.notifyAll();
***************
*** 123,127 ****
}
! public char[] getPassPhrase(String name) {
synchronized (passphrase) {
passphrase.setText("");
--- 129,133 ----
}
! public char[] getPassPhrase(final String name) {
synchronized (passphrase) {
passphrase.setText("");
***************
*** 141,146 ****
}
! public static void main(String args[]) {
! PassPhraseAgent dia = new GuiDialogAgent();
System.out.println("Getting passphrase... " + new String(dia.getPassPhrase("neu://pelle@test")));
System.out.println("Getting passphrase... " + new String(dia.getPassPhrase("neu://pelle@test")));
--- 147,152 ----
}
! public static void main(final String[] args) {
! final PassPhraseAgent dia = new GuiDialogAgent();
System.out.println("Getting passphrase... " + new String(dia.getPassPhrase("neu://pelle@test")));
System.out.println("Getting passphrase... " + new String(dia.getPassPhrase("neu://pelle@test")));
***************
*** 149,156 ****
}
! private TextField passphrase;
! private Button ok;
! private Label nameLabel;
! private Frame frame;
private Image img;
--- 155,162 ----
}
! private final TextField passphrase;
! private final Button ok;
! private final Label nameLabel;
! private final Frame frame;
private Image img;
Index: StoredPassphraseAgent.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons/crypto/passphraseagents/StoredPassphraseAgent.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** StoredPassphraseAgent.java 12 Nov 2003 23:47:50 -0000 1.2
--- StoredPassphraseAgent.java 21 Nov 2003 04:43:41 -0000 1.3
***************
*** 21,24 ****
--- 21,30 ----
$Id$
$Log$
+ Revision 1.3 2003/11/21 04:43:41 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/12 23:47:50 pelle
Much work done in creating good test environment.
***************
*** 44,50 ****
* Time: 5:01:14 PM
*/
! public class StoredPassphraseAgent implements PassPhraseAgent {
! public StoredPassphraseAgent(String name, String passphrase) {
this.name = name;
this.passphrase = passphrase;
--- 50,56 ----
* Time: 5:01:14 PM
*/
! public final class StoredPassphraseAgent implements PassPhraseAgent {
! public StoredPassphraseAgent(final String name, final String passphrase) {
this.name = name;
this.passphrase = passphrase;
***************
*** 52,56 ****
}
! public char[] getPassPhrase(String name) {
if (name.equals(this.name))
return passphrase.toCharArray();
--- 58,62 ----
}
! public final char[] getPassPhrase(final String name) {
if (name.equals(this.name))
return passphrase.toCharArray();
|
Update of /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons/crypto In directory sc8-pr-cvs1:/tmp/cvs-serv10533/src/java/org/neuclear/commons/crypto Modified Files: Base64.java CryptoException.java CryptoTools.java RawCertificate.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: Base64.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons/crypto/Base64.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Base64.java 11 Nov 2003 21:17:48 -0000 1.1 --- Base64.java 21 Nov 2003 04:43:41 -0000 1.2 *************** *** 1,4 **** --- 1,10 ---- /* $Id$ * $Log$ + * Revision 1.2 2003/11/21 04:43:41 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 2003/11/11 21:17:48 pelle * Further vital reshuffling. *************** *** 60,64 **** * @see <A HREF="ftp://ftp.isi.edu/in-notes/rfc2045.txt">RFC 2045</A> */ ! public class Base64 { /** Field LINE_SEPARATOR */ --- 66,70 ---- * @see <A HREF="ftp://ftp.isi.edu/in-notes/rfc2045.txt">RFC 2045</A> */ ! public final class Base64 { /** Field LINE_SEPARATOR */ *************** *** 69,73 **** /** Field _base64length */ ! static int _base64length = Base64.BASE64DEFAULTLENGTH; private Base64() { --- 75,79 ---- /** Field _base64length */ ! static final int _base64length = Base64.BASE64DEFAULTLENGTH; private Base64() { *************** *** 95,99 **** * @return a byte array with <code>bitlen</code> bits of <code>big</code> */ ! public static byte[] getBytes(BigInteger big) { int bitlen= big.bitLength(); --- 101,105 ---- * @return a byte array with <code>bitlen</code> bits of <code>big</code> */ ! public static byte[] getBytes(final BigInteger big) { int bitlen= big.bitLength(); *************** *** 105,109 **** } ! byte[] bigBytes = big.toByteArray(); if (((big.bitLength() % 8) != 0) --- 111,115 ---- } ! final byte[] bigBytes = big.toByteArray(); if (((big.bitLength() % 8) != 0) *************** *** 122,127 **** } ! int startDst = bitlen / 8 - bigLen; //pad with leading nulls ! byte[] resizedBytes = new byte[bitlen / 8]; System.arraycopy(bigBytes, startSrc, resizedBytes, startDst, bigLen); --- 128,133 ---- } ! final int startDst = bitlen / 8 - bigLen; //pad with leading nulls ! final byte[] resizedBytes = new byte[bitlen / 8]; System.arraycopy(bigBytes, startSrc, resizedBytes, startDst, bigLen); *************** *** 137,141 **** * @return String with Base64 encoding */ ! public static String encode(BigInteger big) { // System.out.println("JDK toByteArray(): "+encode(big.toByteArray())); // System.out.println("getBytes(): "+encode(getBytes(big))); --- 143,147 ---- * @return String with Base64 encoding */ ! public static String encode(final BigInteger big) { // System.out.println("JDK toByteArray(): "+encode(big.toByteArray())); // System.out.println("getBytes(): "+encode(getBytes(big))); *************** *** 144,148 **** ! public static String encodeClean(byte[] bytes) { return LINE_SEPARATOR+ encode(bytes)+LINE_SEPARATOR; } --- 150,154 ---- ! public static String encodeClean(final byte[] bytes) { return LINE_SEPARATOR+ encode(bytes)+LINE_SEPARATOR; } *************** *** 157,161 **** * @return */ ! public static byte[] decode(byte[] base64) throws CryptoException { return org.bouncycastle.util.encoders.Base64.decode(base64); } --- 163,167 ---- * @return */ ! public static byte[] decode(final byte[] base64) throws CryptoException { return org.bouncycastle.util.encoders.Base64.decode(base64); } *************** *** 167,171 **** * @return Decoded data in a byte array */ ! public static byte[] decode(String base64) throws CryptoException { return org.bouncycastle.util.encoders.Base64.decode(base64); --- 173,177 ---- * @return Decoded data in a byte array */ ! public static byte[] decode(final String base64) throws CryptoException { return org.bouncycastle.util.encoders.Base64.decode(base64); *************** *** 180,192 **** * @return a <code>String</code> with encoded data */ ! public static String encode(byte[] raw, int wrap) { ! byte[] b64=org.bouncycastle.util.encoders.Base64.encode(raw); //calculate length of encoded string ! int encLen = b64.length; ! int lines = (encLen / wrap); ! byte[] encoded = new byte[encLen+lines]; int sx=0,dx=0; for (sx = 0; sx < (lines*wrap); sx+=wrap,dx+=(wrap+1)) { --- 186,198 ---- * @return a <code>String</code> with encoded data */ ! public static String encode(final byte[] raw, final int wrap) { ! final byte[] b64=org.bouncycastle.util.encoders.Base64.encode(raw); //calculate length of encoded string ! final int encLen = b64.length; ! final int lines = (encLen / wrap); ! final byte[] encoded = new byte[encLen+lines]; int sx=0,dx=0; for (sx = 0; sx < (lines*wrap); sx+=wrap,dx+=(wrap+1)) { *************** *** 206,210 **** * @return the <code>String<code> with encoded data */ ! public static String encode(byte[] raw) { return new String(org.bouncycastle.util.encoders.Base64.encode(raw)); // return encode(raw, Base64.getBase64WrapLength()); --- 212,216 ---- * @return the <code>String<code> with encoded data */ ! public static String encode(final byte[] raw) { return new String(org.bouncycastle.util.encoders.Base64.encode(raw)); // return encode(raw, Base64.getBase64WrapLength()); Index: CryptoException.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons/crypto/CryptoException.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CryptoException.java 11 Nov 2003 21:17:48 -0000 1.1 --- CryptoException.java 21 Nov 2003 04:43:41 -0000 1.2 *************** *** 10,13 **** --- 10,19 ---- * $Id$ * $Log$ + * Revision 1.2 2003/11/21 04:43:41 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 2003/11/11 21:17:48 pelle * Further vital reshuffling. *************** *** 38,42 **** * @since 1.4 */ ! public CryptoException(Throwable cause) { super(cause); } --- 44,48 ---- * @since 1.4 */ ! public CryptoException(final Throwable cause) { super(cause); } *************** *** 50,54 **** * later retrieval by the {@link #getMessage()} method. */ ! public CryptoException(String message) { super(message); } --- 56,60 ---- * later retrieval by the {@link #getMessage()} method. */ ! public CryptoException(final String message) { super(message); } *************** *** 68,72 **** * @since 1.4 */ ! public CryptoException(String message, Throwable cause) { super(message, cause); } --- 74,78 ---- * @since 1.4 */ ! public CryptoException(final String message, final Throwable cause) { super(message, cause); } Index: CryptoTools.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons/crypto/CryptoTools.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** CryptoTools.java 20 Nov 2003 23:41:36 -0000 1.4 --- CryptoTools.java 21 Nov 2003 04:43:41 -0000 1.5 *************** *** 2,5 **** --- 2,11 ---- * $Id$ * $Log$ + * Revision 1.5 2003/11/21 04:43:41 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:36 pelle * Getting all the tests to work in id *************** *** 219,223 **** // TODO Implement some code to automatically BC Provider if not installed ! public class CryptoTools { /** * Call this method at the beginning of an executable. To ensure that BouncyCastle gets installed properly. --- 225,229 ---- // TODO Implement some code to automatically BC Provider if not installed ! public final class CryptoTools { /** * Call this method at the beginning of an executable. To ensure that BouncyCastle gets installed properly. *************** *** 232,239 **** } ! public static KeyPair getKeyPair(KeyStore ks, String s, char[] password) throws CryptoException { try { ! Certificate cert = ks.getCertificate(s); ! PrivateKey priv = (PrivateKey) ks.getKey(s, password); if (cert == null || priv == null) throw new CryptoException("They KeyStore Doesn't Contain an entry for: " + s); --- 238,245 ---- } ! public static KeyPair getKeyPair(final KeyStore ks, final String s, final char[] password) throws CryptoException { try { ! final Certificate cert = ks.getCertificate(s); ! final PrivateKey priv = (PrivateKey) ks.getKey(s, password); if (cert == null || priv == null) throw new CryptoException("They KeyStore Doesn't Contain an entry for: " + s); *************** *** 250,262 **** ! public static String formatKeyAsHex(Key key) { return formatByteArrayAsHex(key.getEncoded()); } ! public static PublicKey getPublicKeyFromHex(String hex) throws CryptoException { try { ! byte barray[] = convertHexToByteArray(hex); ! X509EncodedKeySpec pubKeySpec = new X509EncodedKeySpec(barray); ! KeyFactory keyFactory = KeyFactory.getInstance("RSA"); return keyFactory.generatePublic(pubKeySpec); } catch (NoSuchAlgorithmException e) { --- 256,268 ---- ! public static String formatKeyAsHex(final Key key) { return formatByteArrayAsHex(key.getEncoded()); } ! public static PublicKey getPublicKeyFromHex(final String hex) throws CryptoException { try { ! final byte[] barray = convertHexToByteArray(hex); ! final X509EncodedKeySpec pubKeySpec = new X509EncodedKeySpec(barray); ! final KeyFactory keyFactory = KeyFactory.getInstance("RSA"); return keyFactory.generatePublic(pubKeySpec); } catch (NoSuchAlgorithmException e) { *************** *** 269,278 **** } ! public static String formatByteArrayAsHex(byte barray[]) { ! byte hexarray[] = new byte[2 * barray.length]; int h = 0; for (int i = 0; i < barray.length; i++) { h = 2 * i; ! byte src = barray[i]; hexarray[h] = hexTable[(src & 0xF0) >> 4]; hexarray[h + 1] = hexTable[src & 0x0F]; --- 275,284 ---- } ! public static String formatByteArrayAsHex(final byte[] barray) { ! final byte[] hexarray = new byte[2 * barray.length]; int h = 0; for (int i = 0; i < barray.length; i++) { h = 2 * i; ! final byte src = barray[i]; hexarray[h] = hexTable[(src & 0xF0) >> 4]; hexarray[h + 1] = hexTable[src & 0x0F]; *************** *** 283,291 **** } ! public static byte[] convertHexToByteArray(String hex) { ! byte hexarray[] = hex.getBytes(); ! byte bytearray[] = new byte[(hexarray.length / 2)]; for (int i = 0; i < hexarray.length; i += 2) { ! byte result; byte high = hexarray[i]; byte low = hexarray[i + 1]; --- 289,297 ---- } ! public static byte[] convertHexToByteArray(final String hex) { ! final byte[] hexarray = hex.getBytes(); ! final byte[] bytearray = new byte[(hexarray.length / 2)]; for (int i = 0; i < hexarray.length; i += 2) { ! final byte result; byte high = hexarray[i]; byte low = hexarray[i + 1]; *************** *** 298,304 **** } ! public static byte[] getHash(String value) throws CryptoException { try { ! MessageDigest dig = MessageDigest.getInstance("SHA1"); dig.digest(value.getBytes()); return dig.digest(); --- 304,310 ---- } ! public static byte[] getHash(final String value) throws CryptoException { try { ! final MessageDigest dig = MessageDigest.getInstance("SHA1"); dig.digest(value.getBytes()); return dig.digest(); *************** *** 310,322 **** //Quick Hack. Not very efficient I know. ! public static byte[] pad(byte value[], Cipher c) { ! int blockSize = c.getBlockSize(); return pad(value, blockSize); } ! public static byte[] pad(byte[] value, int blockSize) { ! int mod = value.length % blockSize; ! int diff = blockSize - mod; ! byte output[] = new byte[value.length + diff]; System.arraycopy(value, 0, output, 0, value.length); for (int i = value.length; i < output.length; i++) --- 316,328 ---- //Quick Hack. Not very efficient I know. ! public static byte[] pad(final byte[] value, final Cipher c) { ! final int blockSize = c.getBlockSize(); return pad(value, blockSize); } ! public static byte[] pad(final byte[] value, final int blockSize) { ! final int mod = value.length % blockSize; ! final int diff = blockSize - mod; ! final byte[] output = new byte[value.length + diff]; System.arraycopy(value, 0, output, 0, value.length); for (int i = value.length; i < output.length; i++) *************** *** 325,361 **** } ! public static byte[] encrypt(byte key[], String value) throws CryptoException { return encrypt(key, value.getBytes()); } ! public static byte[] encrypt(String key, byte value[]) throws CryptoException { return encrypt(key.getBytes(), value); } ! public static byte[] encrypt(String key, String value) throws CryptoException { return encrypt(key.getBytes(), value.getBytes()); } ! public static byte[] encrypt(byte key[], byte value[]) throws CryptoException { return cipherProcess(key, value, true); } ! public static byte[] decrypt(String key, String value) throws CryptoException { return decrypt(key.getBytes(), value.getBytes()); } ! public static byte[] decrypt(byte key[], byte value[]) throws CryptoException { return cipherProcess(key, value, false); } ! private static byte[] cipherProcess(byte key[], byte value[], boolean doencrypt) throws CryptoException { try { ! BlockCipher engine = new AESEngine(); ! BufferedBlockCipher cipher = new PaddedBufferedBlockCipher(new CBCBlockCipher(engine)); cipher.init(doencrypt, new KeyParameter(digest256(key))); ! byte[] cipherText = new byte[cipher.getOutputSize(value.length)]; ! int outputLen = cipher.processBytes(value, 0, value.length, cipherText, 0); cipher.doFinal(cipherText, outputLen); return cipherText; --- 331,367 ---- } ! public static byte[] encrypt(final byte[] key, final String value) throws CryptoException { return encrypt(key, value.getBytes()); } ! public static byte[] encrypt(final String key, final byte[] value) throws CryptoException { return encrypt(key.getBytes(), value); } ! public static byte[] encrypt(final String key, final String value) throws CryptoException { return encrypt(key.getBytes(), value.getBytes()); } ! public static byte[] encrypt(final byte[] key, final byte[] value) throws CryptoException { return cipherProcess(key, value, true); } ! public static byte[] decrypt(final String key, final String value) throws CryptoException { return decrypt(key.getBytes(), value.getBytes()); } ! public static byte[] decrypt(final byte[] key, final byte[] value) throws CryptoException { return cipherProcess(key, value, false); } ! private static byte[] cipherProcess(final byte[] key, final byte[] value, final boolean doencrypt) throws CryptoException { try { ! final BlockCipher engine = new AESEngine(); ! final BufferedBlockCipher cipher = new PaddedBufferedBlockCipher(new CBCBlockCipher(engine)); cipher.init(doencrypt, new KeyParameter(digest256(key))); ! final byte[] cipherText = new byte[cipher.getOutputSize(value.length)]; ! final int outputLen = cipher.processBytes(value, 0, value.length, cipherText, 0); cipher.doFinal(cipherText, outputLen); return cipherText; *************** *** 366,375 **** } ! public static Cipher getCipher(byte key[], boolean doencrypt) throws CryptoException { try { ! Cipher cipher = Cipher.getInstance("AES"); ! KeySpec keyspec = new SecretKeySpec(key, "AES"); ! SecretKeyFactory kf = SecretKeyFactory.getInstance("AES"); ! Key skey = kf.generateSecret(keyspec); cipher.init(doencrypt ? Cipher.ENCRYPT_MODE : Cipher.DECRYPT_MODE, skey); return cipher; --- 372,381 ---- } ! public static Cipher getCipher(final byte[] key, final boolean doencrypt) throws CryptoException { try { ! final Cipher cipher = Cipher.getInstance("AES"); ! final KeySpec keyspec = new SecretKeySpec(key, "AES"); ! final SecretKeyFactory kf = SecretKeyFactory.getInstance("AES"); ! final Key skey = kf.generateSecret(keyspec); cipher.init(doencrypt ? Cipher.ENCRYPT_MODE : Cipher.DECRYPT_MODE, skey); return cipher; *************** *** 386,396 **** } ! public static byte[] sign(KeyPair kp, byte value[]) throws CryptoException { return sign(kp.getPrivate(), value); } ! public static byte[] sign(PrivateKey key, byte value[]) throws CryptoException { try { ! Signature sig = getSignatureCipher(key); sig.update(value); // put plain text of lock data into signature. byte[] raw = sig.sign(); --- 392,402 ---- } ! public static byte[] sign(final KeyPair kp, final byte[] value) throws CryptoException { return sign(kp.getPrivate(), value); } ! public static byte[] sign(final PrivateKey key, final byte[] value) throws CryptoException { try { ! final Signature sig = getSignatureCipher(key); sig.update(value); // put plain text of lock data into signature. byte[] raw = sig.sign(); *************** *** 407,411 **** } ! public static Signature getSignatureCipher(PrivateKey key) throws NoSuchAlgorithmException, NoSuchProviderException, InvalidKeyException { Signature sig = null; if (key instanceof RSAPrivateKey) --- 413,417 ---- } ! public static Signature getSignatureCipher(final PrivateKey key) throws NoSuchAlgorithmException, NoSuchProviderException, InvalidKeyException { Signature sig = null; if (key instanceof RSAPrivateKey) *************** *** 420,424 **** } ! public static boolean verify(PublicKey pk, byte value[], byte sigvalue[]) throws CryptoException { try { Signature sig = null; --- 426,430 ---- } ! public static boolean verify(final PublicKey pk, final byte[] value, byte sigvalue[]) throws CryptoException { try { Signature sig = null; *************** *** 442,462 **** } ! public static byte[] digest(byte value[]) { ! Digest dig = new org.bouncycastle.crypto.digests.SHA1Digest(); return digest(dig, value); } ! public static byte[] digest256(byte value[]) { ! Digest dig = new SHA256Digest(); return digest(dig, value); } ! public static byte[] digest512(byte value[]) { ! Digest dig = new SHA512Digest(); return digest(dig, value); } ! private static byte[] digest(Digest dig, byte[] value) { ! byte output[] = new byte[dig.getDigestSize()]; dig.update(value, 0, value.length); dig.doFinal(output, 0); --- 448,468 ---- } ! public static byte[] digest(final byte[] value) { ! final Digest dig = new org.bouncycastle.crypto.digests.SHA1Digest(); return digest(dig, value); } ! public static byte[] digest256(final byte[] value) { ! final Digest dig = new SHA256Digest(); return digest(dig, value); } ! public static byte[] digest512(final byte[] value) { ! final Digest dig = new SHA512Digest(); return digest(dig, value); } ! private static byte[] digest(final Digest dig, final byte[] value) { ! final byte[] output = new byte[dig.getDigestSize()]; dig.update(value, 0, value.length); dig.doFinal(output, 0); *************** *** 464,468 **** } ! public static boolean equalByteArrays(byte one[], byte two[]) { if ((one == null && two != null) || (one != null && two == null)) return false; --- 470,474 ---- } ! public static boolean equalByteArrays(final byte[] one, final byte[] two) { if ((one == null && two != null) || (one != null && two == null)) return false; *************** *** 478,488 **** } ! public static String formatAsURLSafe(byte val[]) { ! BigInteger big = new BigInteger(val); return big.toString(36); } public static String createRandomID() { ! BigInteger big = new BigInteger(4096, getRandomInstance()); return big.toString(36); } --- 484,494 ---- } ! public static String formatAsURLSafe(final byte[] val) { ! final BigInteger big = new BigInteger(val); return big.toString(36); } public static String createRandomID() { ! final BigInteger big = new BigInteger(4096, getRandomInstance()); return big.toString(36); } *************** *** 530,545 **** */ public static Cipher makePBECipher( ! String algorithm, ! int mode, ! char[] password, ! byte[] salt, ! int iterationCount, ! String provider ) throws GeneralSecurityException { ! PBEKeySpec pbeSpec = new PBEKeySpec(password); ! SecretKeyFactory keyFact = SecretKeyFactory.getInstance(algorithm, provider); ! PBEParameterSpec defParams = new PBEParameterSpec(salt, iterationCount); ! Cipher cipher = Cipher.getInstance(algorithm, provider); cipher.init(mode, keyFact.generateSecret(pbeSpec), defParams); --- 536,551 ---- */ public static Cipher makePBECipher( ! final String algorithm, ! final int mode, ! final char[] password, ! final byte[] salt, ! final int iterationCount, ! final String provider ) throws GeneralSecurityException { ! final PBEKeySpec pbeSpec = new PBEKeySpec(password); ! final SecretKeyFactory keyFact = SecretKeyFactory.getInstance(algorithm, provider); ! final PBEParameterSpec defParams = new PBEParameterSpec(salt, iterationCount); ! final Cipher cipher = Cipher.getInstance(algorithm, provider); cipher.init(mode, keyFact.generateSecret(pbeSpec), defParams); *************** *** 561,568 **** */ public static Cipher makePBECipher( ! int mode, ! char[] password, ! byte[] salt, ! int iterationCount ) throws GeneralSecurityException { return makePBECipher(DEFAULT_PBE_ALGORITHM, mode, password, salt, iterationCount, DEFAULT_JCE_PROVIDER); --- 567,574 ---- */ public static Cipher makePBECipher( ! final int mode, ! final char[] password, ! final byte[] salt, ! final int iterationCount ) throws GeneralSecurityException { return makePBECipher(DEFAULT_PBE_ALGORITHM, mode, password, salt, iterationCount, DEFAULT_JCE_PROVIDER); *************** *** 580,585 **** */ public static Cipher makePBECipher( ! int mode, ! char[] password ) throws GeneralSecurityException { return makePBECipher(DEFAULT_PBE_ALGORITHM, mode, password, DEFAULT_SALT, DEFAULT_ITERATION_COUNT, DEFAULT_JCE_PROVIDER); --- 586,591 ---- */ public static Cipher makePBECipher( ! final int mode, ! final char[] password ) throws GeneralSecurityException { return makePBECipher(DEFAULT_PBE_ALGORITHM, mode, password, DEFAULT_SALT, DEFAULT_ITERATION_COUNT, DEFAULT_JCE_PROVIDER); *************** *** 587,594 **** ! public static PublicKey createPK(String mod, String exp) throws CryptoException { try { ! KeyFactory rsaFactory = KeyFactory.getInstance("RSA"); ! RSAPublicKeySpec rsaKeyspec = new RSAPublicKeySpec(new BigInteger(Base64.decode(mod)), new BigInteger(Base64.decode(exp))); return rsaFactory.generatePublic(rsaKeyspec); } catch (NoSuchAlgorithmException e) { --- 593,600 ---- ! public static PublicKey createPK(final String mod, final String exp) throws CryptoException { try { ! final KeyFactory rsaFactory = KeyFactory.getInstance("RSA"); ! final RSAPublicKeySpec rsaKeyspec = new RSAPublicKeySpec(new BigInteger(Base64.decode(mod)), new BigInteger(Base64.decode(exp))); return rsaFactory.generatePublic(rsaKeyspec); } catch (NoSuchAlgorithmException e) { *************** *** 605,609 **** } ! public static KeyPair createKeyPair(String algorithm) throws NoSuchAlgorithmException { return getKeyPairGenerator(algorithm).generateKeyPair(); --- 611,615 ---- } ! public static KeyPair createKeyPair(final String algorithm) throws NoSuchAlgorithmException { return getKeyPairGenerator(algorithm).generateKeyPair(); *************** *** 620,624 **** } ! public static KeyPairGenerator getKeyPairGenerator(String algorithm) throws NoSuchAlgorithmException { if (!algorithm.equals(RSA) && !algorithm.equals(DSA)) --- 626,630 ---- } ! public static KeyPairGenerator getKeyPairGenerator(final String algorithm) throws NoSuchAlgorithmException { if (!algorithm.equals(RSA) && !algorithm.equals(DSA)) *************** *** 633,637 **** } ! public static void rethrowException(Throwable e) throws CryptoException { throw new CryptoException(e); } --- 639,643 ---- } ! public static void rethrowException(final Throwable e) throws CryptoException { throw new CryptoException(e); } *************** *** 645,656 **** * @see <A HREF="http://www.w3.org/TR/xmldsig-core/#dsa-sha1">6.4.1 DSA</A> */ ! public static byte[] convertASN1toXMLDSIG(byte asn1Bytes[]) throws IOException { ! byte rLength = asn1Bytes[3]; int i; for (i = rLength; (i > 0) && (asn1Bytes[(4 + rLength) - i] == 0); i--) ; ! byte sLength = asn1Bytes[5 + rLength]; int j; --- 651,662 ---- * @see <A HREF="http://www.w3.org/TR/xmldsig-core/#dsa-sha1">6.4.1 DSA</A> */ ! public static byte[] convertASN1toXMLDSIG(final byte[] asn1Bytes) throws IOException { ! final byte rLength = asn1Bytes[3]; int i; for (i = rLength; (i > 0) && (asn1Bytes[(4 + rLength) - i] == 0); i--) ; ! final byte sLength = asn1Bytes[5 + rLength]; int j; *************** *** 662,666 **** throw new IOException("Invalid ASN.1 format of DSA signature"); } else { ! byte xmldsigBytes[] = new byte[40]; System.arraycopy(asn1Bytes, (4 + rLength) - i, xmldsigBytes, 20 - i, i); --- 668,672 ---- throw new IOException("Invalid ASN.1 format of DSA signature"); } else { ! final byte[] xmldsigBytes = new byte[40]; System.arraycopy(asn1Bytes, (4 + rLength) - i, xmldsigBytes, 20 - i, i); *************** *** 679,683 **** * @see <A HREF="http://www.w3.org/TR/xmldsig-core/#dsa-sha1">6.4.1 DSA</A> */ ! public static byte[] convertXMLDSIGtoASN1(byte xmldsigBytes[]) throws IOException { if (xmldsigBytes.length != 40) { --- 685,689 ---- * @see <A HREF="http://www.w3.org/TR/xmldsig-core/#dsa-sha1">6.4.1 DSA</A> */ ! public static byte[] convertXMLDSIGtoASN1(final byte[] xmldsigBytes) throws IOException { if (xmldsigBytes.length != 40) { *************** *** 701,705 **** } ! byte asn1Bytes[] = new byte[6 + j + l]; asn1Bytes[0] = 48; --- 707,711 ---- } ! final byte[] asn1Bytes = new byte[6 + j + l]; asn1Bytes[0] = 48; *************** *** 729,733 **** private static final byte DEFAULT_SALT[] = "LiquidNightClubPanam".getBytes(); private static final int DEFAULT_ITERATION_COUNT = 2048; ! public static byte[] hexTable = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; private static Random randSource; --- 735,739 ---- private static final byte DEFAULT_SALT[] = "LiquidNightClubPanam".getBytes(); private static final int DEFAULT_ITERATION_COUNT = 2048; ! public static final byte[] hexTable = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; private static Random randSource; Index: RawCertificate.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons/crypto/RawCertificate.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** RawCertificate.java 19 Nov 2003 23:32:51 -0000 1.1 --- RawCertificate.java 21 Nov 2003 04:43:41 -0000 1.2 *************** *** 26,29 **** --- 26,35 ---- $Id$ $Log$ + Revision 1.2 2003/11/21 04:43:41 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 2003/11/19 23:32:51 pelle Signers now can generatekeys via the generateKey() method. *************** *** 42,52 **** * Time: 1:37:31 PM */ ! public class RawCertificate extends Certificate { ! public RawCertificate(PublicKey pub) { super("RAW"); this.pub = pub; } ! public byte[] getEncoded() throws CertificateEncodingException { return pub.getEncoded(); } --- 48,58 ---- * Time: 1:37:31 PM */ ! public final class RawCertificate extends Certificate { ! public RawCertificate(final PublicKey pub) { super("RAW"); this.pub = pub; } ! public final byte[] getEncoded() throws CertificateEncodingException { return pub.getEncoded(); } *************** *** 62,66 **** * @throws SignatureException */ ! public void verify(PublicKey publicKey) throws CertificateException, NoSuchAlgorithmException, InvalidKeyException, NoSuchProviderException, SignatureException { ; } --- 68,72 ---- * @throws SignatureException */ ! public final void verify(final PublicKey publicKey) throws CertificateException, NoSuchAlgorithmException, InvalidKeyException, NoSuchProviderException, SignatureException { ; } *************** *** 77,85 **** * @throws SignatureException */ ! public void verify(PublicKey publicKey, String string) throws CertificateException, NoSuchAlgorithmException, InvalidKeyException, NoSuchProviderException, SignatureException { ; } ! public String toString() { try { return CryptoTools.formatAsURLSafe(CryptoTools.digest(getEncoded())); --- 83,91 ---- * @throws SignatureException */ ! public final void verify(final PublicKey publicKey, final String string) throws CertificateException, NoSuchAlgorithmException, InvalidKeyException, NoSuchProviderException, SignatureException { ; } ! public final String toString() { try { return CryptoTools.formatAsURLSafe(CryptoTools.digest(getEncoded())); *************** *** 89,93 **** } ! public PublicKey getPublicKey() { return pub; } --- 95,99 ---- } ! public final PublicKey getPublicKey() { return pub; } |
|
From: <pe...@us...> - 2003-11-21 04:43:45
|
Update of /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons/crypto/signers
In directory sc8-pr-cvs1:/tmp/cvs-serv10533/src/java/org/neuclear/commons/crypto/signers
Modified Files:
DefaultSigner.java InvalidPassphraseException.java
JCESigner.java KeyCache.java NonExistingSignerException.java
SimpleSigner.java TestCaseSigner.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: DefaultSigner.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons/crypto/signers/DefaultSigner.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** DefaultSigner.java 12 Nov 2003 23:47:50 -0000 1.2
--- DefaultSigner.java 21 Nov 2003 04:43:41 -0000 1.3
***************
*** 28,31 ****
--- 28,37 ----
$Id$
$Log$
+ Revision 1.3 2003/11/21 04:43:41 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/12 23:47:50 pelle
Much work done in creating good test environment.
***************
*** 56,61 ****
* Time: 3:22:17 PM
*/
! public class DefaultSigner extends JCESigner {
! public DefaultSigner(PassPhraseAgent agent) throws NeuClearException, GeneralSecurityException, FileNotFoundException {
super(CryptoTools.DEFAULT_KEYSTORE, "jks", "SUN", agent);
--- 62,67 ----
* Time: 3:22:17 PM
*/
! public final class DefaultSigner extends JCESigner {
! public DefaultSigner(final PassPhraseAgent agent) throws NeuClearException, GeneralSecurityException, FileNotFoundException {
super(CryptoTools.DEFAULT_KEYSTORE, "jks", "SUN", agent);
Index: InvalidPassphraseException.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons/crypto/signers/InvalidPassphraseException.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** InvalidPassphraseException.java 11 Nov 2003 21:17:47 -0000 1.1
--- InvalidPassphraseException.java 21 Nov 2003 04:43:41 -0000 1.2
***************
*** 2,5 ****
--- 2,11 ----
* $Id$
* $Log$
+ * Revision 1.2 2003/11/21 04:43:41 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 2003/11/11 21:17:47 pelle
* Further vital reshuffling.
***************
*** 39,48 ****
import org.neuclear.commons.crypto.CryptoException;
! public class InvalidPassphraseException extends CryptoException {
public InvalidPassphraseException() {
super("Passphrase incorrect.");
}
! public InvalidPassphraseException(String msg) {
super(msg);
}
--- 45,54 ----
import org.neuclear.commons.crypto.CryptoException;
! public final class InvalidPassphraseException extends CryptoException {
public InvalidPassphraseException() {
super("Passphrase incorrect.");
}
! public InvalidPassphraseException(final String msg) {
super(msg);
}
Index: JCESigner.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons/crypto/signers/JCESigner.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** JCESigner.java 19 Nov 2003 23:32:50 -0000 1.6
--- JCESigner.java 21 Nov 2003 04:43:41 -0000 1.7
***************
*** 2,5 ****
--- 2,11 ----
* $Id$
* $Log$
+ * Revision 1.7 2003/11/21 04:43:41 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.6 2003/11/19 23:32:50 pelle
* Signers now can generatekeys via the generateKey() method.
***************
*** 116,128 ****
public class JCESigner implements org.neuclear.commons.crypto.signers.Signer, PublicKeySource {
! public JCESigner(String filename, String type, String provider, PassPhraseAgent agent) throws NeuClearException, GeneralSecurityException, FileNotFoundException {
this(filename, new FileInputStream(new File(filename)), type, provider, agent);
}
! protected JCESigner(String name, InputStream in, String type, String provider, PassPhraseAgent agent) throws NeuClearException {
this(loadKeyStore(provider, type, in, agent, name), agent);
}
! private static KeyStore loadKeyStore(String provider, String type, InputStream in, PassPhraseAgent agent, String name) throws NeuClearException {
try {
KeyStore ki = null;
--- 122,134 ----
public class JCESigner implements org.neuclear.commons.crypto.signers.Signer, PublicKeySource {
! public JCESigner(final String filename, final String type, final String provider, final PassPhraseAgent agent) throws NeuClearException, GeneralSecurityException, FileNotFoundException {
this(filename, new FileInputStream(new File(filename)), type, provider, agent);
}
! protected JCESigner(final String name, final InputStream in, final String type, final String provider, final PassPhraseAgent agent) throws NeuClearException {
this(loadKeyStore(provider, type, in, agent, name), agent);
}
! private static KeyStore loadKeyStore(final String provider, final String type, final InputStream in, final PassPhraseAgent agent, final String name) throws NeuClearException {
try {
KeyStore ki = null;
***************
*** 147,151 ****
}
! public JCESigner(KeyStore ks, PassPhraseAgent agent) throws CryptoException {
this.agent = agent;
this.ks = ks;
--- 153,157 ----
}
! public JCESigner(final KeyStore ks, final PassPhraseAgent agent) throws CryptoException {
this.agent = agent;
this.ks = ks;
***************
*** 160,166 ****
}
! private PrivateKey getKey(String name, char passphrase[]) throws InvalidPassphraseException, NonExistingSignerException, IOException {
try {
! PrivateKey key = (PrivateKey) cache.getKey(name, passphrase);
if (key == null)
throw new NonExistingSignerException("No keys for: " + name);
--- 166,172 ----
}
! private PrivateKey getKey(final String name, final char[] passphrase) throws InvalidPassphraseException, NonExistingSignerException, IOException {
try {
! final PrivateKey key = (PrivateKey) cache.getKey(name, passphrase);
if (key == null)
throw new NonExistingSignerException("No keys for: " + name);
***************
*** 183,187 ****
* if the passphrase doesn't match
*/
! public byte[] sign(String name, byte data[]) throws CryptoException {
try {
--- 189,193 ----
* if the passphrase doesn't match
*/
! public final byte[] sign(final String name, final byte[] data) throws CryptoException {
try {
***************
*** 192,196 ****
}
! public boolean canSignFor(String name) throws CryptoException {
try {
return ks.containsAlias(name);
--- 198,202 ----
}
! public final boolean canSignFor(final String name) throws CryptoException {
try {
return ks.containsAlias(name);
***************
*** 207,214 ****
* @throws CryptoException
*/
! public int getKeyType(String name) throws CryptoException {
try {
if (ks.isKeyEntry(name)) {
! PublicKey pk = getPublicKey(name);
if (pk instanceof RSAPublicKey)
return KEY_RSA;
--- 213,220 ----
* @throws CryptoException
*/
! public final int getKeyType(final String name) throws CryptoException {
try {
if (ks.isKeyEntry(name)) {
! final PublicKey pk = getPublicKey(name);
if (pk instanceof RSAPublicKey)
return KEY_RSA;
***************
*** 232,238 ****
*
*/
! public PublicKey generateKey(String alias) throws CryptoException {
try {
! KeyPair kp = kpg.generateKeyPair();
ks.setKeyEntry(alias, kp.getPrivate(), agent.getPassPhrase(alias), new Certificate[]{new RawCertificate(kp.getPublic())});
return kp.getPublic();
--- 238,244 ----
*
*/
! public final PublicKey generateKey(final String alias) throws CryptoException {
try {
! final KeyPair kp = kpg.generateKeyPair();
ks.setKeyEntry(alias, kp.getPrivate(), agent.getPassPhrase(alias), new Certificate[]{new RawCertificate(kp.getPublic())});
return kp.getPublic();
***************
*** 242,246 ****
}
! public PublicKey getPublicKey(String name) throws CryptoException {
try {
return ks.getCertificate(name).getPublicKey();
--- 248,252 ----
}
! public final PublicKey getPublicKey(final String name) throws CryptoException {
try {
return ks.getCertificate(name).getPublicKey();
Index: KeyCache.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons/crypto/signers/KeyCache.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** KeyCache.java 18 Nov 2003 00:01:02 -0000 1.1
--- KeyCache.java 21 Nov 2003 04:43:41 -0000 1.2
***************
*** 27,30 ****
--- 27,36 ----
$Id$
$Log$
+ Revision 1.2 2003/11/21 04:43:41 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 2003/11/18 00:01:02 pelle
The sample signing web application for logging in and out is now working.
***************
*** 37,52 ****
* is a SHA1 Digest of the alias and the passphrase
*/
! public class KeyCache {
! public KeyCache(KeyStore ks) {
this.cache = new HashMap();
this.ks = ks;
}
! public Key getKey(String alias, char passphrase[]) throws KeyStoreException, NoSuchAlgorithmException, UnrecoverableKeyException, NonExistingSignerException {
! String hash = createHash(alias, passphrase);
if (cache.containsKey(hash))
return (Key) cache.get(hash);
if (ks.containsAlias(alias)) {
! Key key = ks.getKey(alias, passphrase);
cache.put(hash, key);
return key;
--- 43,58 ----
* is a SHA1 Digest of the alias and the passphrase
*/
! public final class KeyCache {
! public KeyCache(final KeyStore ks) {
this.cache = new HashMap();
this.ks = ks;
}
! public final Key getKey(final String alias, final char[] passphrase) throws KeyStoreException, NoSuchAlgorithmException, UnrecoverableKeyException, NonExistingSignerException {
! final String hash = createHash(alias, passphrase);
if (cache.containsKey(hash))
return (Key) cache.get(hash);
if (ks.containsAlias(alias)) {
! final Key key = ks.getKey(alias, passphrase);
cache.put(hash, key);
return key;
***************
*** 55,65 ****
}
! public final static String createHash(String alias, char passphrase[]) {
! Digest dig = new org.bouncycastle.crypto.digests.SHA1Digest();
! byte a[] = alias.getBytes();
dig.update(a, 0, a.length);
! byte p[] = new String(passphrase).getBytes();
dig.update(p, 0, p.length);
! byte hash[] = new byte[dig.getDigestSize()];
dig.doFinal(hash, 0);
return new String(hash);
--- 61,71 ----
}
! public final static String createHash(final String alias, final char[] passphrase) {
! final Digest dig = new org.bouncycastle.crypto.digests.SHA1Digest();
! final byte[] a = alias.getBytes();
dig.update(a, 0, a.length);
! final byte[] p = new String(passphrase).getBytes();
dig.update(p, 0, p.length);
! final byte[] hash = new byte[dig.getDigestSize()];
dig.doFinal(hash, 0);
return new String(hash);
***************
*** 68,72 ****
}
! private KeyStore ks;
! private Map cache;
}
--- 74,78 ----
}
! private final KeyStore ks;
! private final Map cache;
}
Index: NonExistingSignerException.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons/crypto/signers/NonExistingSignerException.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** NonExistingSignerException.java 11 Nov 2003 21:17:47 -0000 1.1
--- NonExistingSignerException.java 21 Nov 2003 04:43:41 -0000 1.2
***************
*** 2,5 ****
--- 2,11 ----
* $Id$
* $Log$
+ * Revision 1.2 2003/11/21 04:43:41 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 2003/11/11 21:17:47 pelle
* Further vital reshuffling.
***************
*** 39,48 ****
import org.neuclear.commons.crypto.CryptoException;
! public class NonExistingSignerException extends CryptoException {
public NonExistingSignerException() {
super("Couldnt Sign. Non existent key.");
}
! public NonExistingSignerException(String name) {
super("Couldnt sign for: " + name);
}
--- 45,54 ----
import org.neuclear.commons.crypto.CryptoException;
! public final class NonExistingSignerException extends CryptoException {
public NonExistingSignerException() {
super("Couldnt Sign. Non existent key.");
}
! public NonExistingSignerException(final String name) {
super("Couldnt sign for: " + name);
}
Index: SimpleSigner.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons/crypto/signers/SimpleSigner.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** SimpleSigner.java 19 Nov 2003 23:32:50 -0000 1.3
--- SimpleSigner.java 21 Nov 2003 04:43:41 -0000 1.4
***************
*** 2,5 ****
--- 2,11 ----
* $Id$
* $Log$
+ * Revision 1.4 2003/11/21 04:43:41 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.3 2003/11/19 23:32:50 pelle
* Signers now can generatekeys via the generateKey() method.
***************
*** 109,115 ****
* Currently it doesnt even use the passphrase. However it does do a SHA1 digest on the name first.
*/
! public class SimpleSigner implements Signer {
! public SimpleSigner(String file, PassPhraseAgent agent) throws NeuClearException, GeneralSecurityException {
this.agent = agent;
try {
--- 115,121 ----
* Currently it doesnt even use the passphrase. However it does do a SHA1 digest on the name first.
*/
! public final class SimpleSigner implements Signer {
! public SimpleSigner(final String file, final PassPhraseAgent agent) throws NeuClearException, GeneralSecurityException {
this.agent = agent;
try {
***************
*** 117,122 ****
if (signerFile.exists()) {
System.out.println("NEUDIST: Loading KeyStore");
! FileInputStream in = new FileInputStream(signerFile);
! ObjectInputStream s = new ObjectInputStream(in);
ks = (HashMap) s.readObject();
} else
--- 123,128 ----
if (signerFile.exists()) {
System.out.println("NEUDIST: Loading KeyStore");
! final FileInputStream in = new FileInputStream(signerFile);
! final ObjectInputStream s = new ObjectInputStream(in);
ks = (HashMap) s.readObject();
} else
***************
*** 138,157 ****
}
! private PrivateKey getKey(String name, char passphrase[]) throws CryptoException, NonExistingSignerException {
System.out.println("NEUDIST: UnSealing key " + name + " ...");
! byte encrypted[] = (byte[]) ks.get(getDigestedName(name));
if (encrypted == null)
throw new NonExistingSignerException("Signer " + name + "doesnt exist in this Store");
! ByteArrayInputStream bis = new ByteArrayInputStream(encrypted);
byte keyBytes[] = new byte[0];
try {
! Cipher c = CryptoTools.makePBECipher(Cipher.DECRYPT_MODE, passphrase);
! CipherInputStream cin = new CipherInputStream(bis, c);
! DataInputStream din = new DataInputStream(cin);
//byte keyBytes[]=new byte[c.getOutputSize(encrypted.length)];
if (din.readInt() != 11870) //This is just a quick check to see if the passphrase worked
throw new InvalidPassphraseException("Passphrase Didnt Match");
! int i = din.readInt();
// Sanity Check
if (i > 5000)
--- 144,163 ----
}
! private PrivateKey getKey(final String name, final char[] passphrase) throws CryptoException, NonExistingSignerException {
System.out.println("NEUDIST: UnSealing key " + name + " ...");
! final byte[] encrypted = (byte[]) ks.get(getDigestedName(name));
if (encrypted == null)
throw new NonExistingSignerException("Signer " + name + "doesnt exist in this Store");
! final ByteArrayInputStream bis = new ByteArrayInputStream(encrypted);
byte keyBytes[] = new byte[0];
try {
! final Cipher c = CryptoTools.makePBECipher(Cipher.DECRYPT_MODE, passphrase);
! final CipherInputStream cin = new CipherInputStream(bis, c);
! final DataInputStream din = new DataInputStream(cin);
//byte keyBytes[]=new byte[c.getOutputSize(encrypted.length)];
if (din.readInt() != 11870) //This is just a quick check to see if the passphrase worked
throw new InvalidPassphraseException("Passphrase Didnt Match");
! final int i = din.readInt();
// Sanity Check
if (i > 5000)
***************
*** 160,164 ****
din.readFully(keyBytes, 0, keyBytes.length);
din.close();
! KeySpec spec = new PKCS8EncodedKeySpec(keyBytes);
return kf.generatePrivate(spec);
} catch (GeneralSecurityException e) {
--- 166,170 ----
din.readFully(keyBytes, 0, keyBytes.length);
din.close();
! final KeySpec spec = new PKCS8EncodedKeySpec(keyBytes);
return kf.generatePrivate(spec);
} catch (GeneralSecurityException e) {
***************
*** 177,181 ****
*/
! public void addKey(String name, PrivateKey key) throws GeneralSecurityException, IOException {
addKey(name, agent.getPassPhrase(name), key);
}
--- 183,187 ----
*/
! public final void addKey(final String name, final PrivateKey key) throws GeneralSecurityException, IOException {
addKey(name, agent.getPassPhrase(name), key);
}
***************
*** 189,209 ****
*/
! public void addKey(String name, char passphrase[], PrivateKey key) throws GeneralSecurityException, IOException {
System.out.println("NEUDIST: Sealing key: " + name + " in format " + key.getFormat());
! ByteArrayOutputStream bOut = new ByteArrayOutputStream();
DataOutputStream dOut = new DataOutputStream(bOut);
! Cipher c = CryptoTools.makePBECipher(Cipher.ENCRYPT_MODE, passphrase);
! CipherOutputStream cOut = new CipherOutputStream(dOut, c);
dOut = new DataOutputStream(cOut);
dOut.writeInt(11870);//This is just a quick check to see if the passphrase worked
! byte keyBytes[] = key.getEncoded(); //I'm assuming this is PKCS8, If not tough dooda
dOut.writeInt(keyBytes.length);
dOut.write(keyBytes);
dOut.close();
! byte encrypted[] = bOut.toByteArray();
ks.put(getDigestedName(name), encrypted);
}
! public boolean canSignFor(String name) throws CryptoException {
return ks.containsKey(getDigestedName(name));
}
--- 195,215 ----
*/
! public final void addKey(final String name, final char[] passphrase, final PrivateKey key) throws GeneralSecurityException, IOException {
System.out.println("NEUDIST: Sealing key: " + name + " in format " + key.getFormat());
! final ByteArrayOutputStream bOut = new ByteArrayOutputStream();
DataOutputStream dOut = new DataOutputStream(bOut);
! final Cipher c = CryptoTools.makePBECipher(Cipher.ENCRYPT_MODE, passphrase);
! final CipherOutputStream cOut = new CipherOutputStream(dOut, c);
dOut = new DataOutputStream(cOut);
dOut.writeInt(11870);//This is just a quick check to see if the passphrase worked
! final byte[] keyBytes = key.getEncoded(); //I'm assuming this is PKCS8, If not tough dooda
dOut.writeInt(keyBytes.length);
dOut.write(keyBytes);
dOut.close();
! final byte[] encrypted = bOut.toByteArray();
ks.put(getDigestedName(name), encrypted);
}
! public final boolean canSignFor(final String name) throws CryptoException {
return ks.containsKey(getDigestedName(name));
}
***************
*** 216,233 ****
* @throws CryptoException
*/
! public int getKeyType(String name) throws CryptoException {
return (canSignFor(name)) ? KEY_RSA : KEY_NONE; // We always use RSA here
}
! static final protected String getDigestedName(String name) {
return new String(CryptoTools.digest(name.getBytes()));
}
! public void save() throws IOException {
if (signerFile.getParent() != null)
signerFile.getParentFile().mkdirs();
! FileOutputStream f = new FileOutputStream(signerFile);
! ObjectOutput s = new ObjectOutputStream(f);
s.writeObject(ks);
s.flush();
--- 222,239 ----
* @throws CryptoException
*/
! public final int getKeyType(final String name) throws CryptoException {
return (canSignFor(name)) ? KEY_RSA : KEY_NONE; // We always use RSA here
}
! static final protected String getDigestedName(final String name) {
return new String(CryptoTools.digest(name.getBytes()));
}
! public final void save() throws IOException {
if (signerFile.getParent() != null)
signerFile.getParentFile().mkdirs();
! final FileOutputStream f = new FileOutputStream(signerFile);
! final ObjectOutput s = new ObjectOutputStream(f);
s.writeObject(ks);
s.flush();
***************
*** 244,248 ****
*/
! public byte[] sign(String name, byte data[]) throws CryptoException {
return CryptoTools.sign(getKey(name, agent.getPassPhrase(name)), data);
--- 250,254 ----
*/
! public final byte[] sign(final String name, final byte[] data) throws CryptoException {
return CryptoTools.sign(getKey(name, agent.getPassPhrase(name)), data);
***************
*** 258,264 ****
*
*/
! public PublicKey generateKey(String alias) throws CryptoException {
try {
! KeyPair kp = kpg.generateKeyPair();
addKey(alias, agent.getPassPhrase(alias), kp.getPrivate());
return kp.getPublic();
--- 264,270 ----
*
*/
! public final PublicKey generateKey(final String alias) throws CryptoException {
try {
! final KeyPair kp = kpg.generateKeyPair();
addKey(alias, agent.getPassPhrase(alias), kp.getPrivate());
return kp.getPublic();
Index: TestCaseSigner.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons/crypto/signers/TestCaseSigner.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** TestCaseSigner.java 18 Nov 2003 23:34:55 -0000 1.5
--- TestCaseSigner.java 21 Nov 2003 04:43:41 -0000 1.6
***************
*** 29,32 ****
--- 29,38 ----
$Id$
$Log$
+ Revision 1.6 2003/11/21 04:43:41 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.5 2003/11/18 23:34:55 pelle
Payment Web Application is getting there.
***************
*** 56,60 ****
* keystore passphrase are the same.
*/
! public class TestCaseSigner extends JCESigner {
/**
--- 62,66 ----
* keystore passphrase are the same.
*/
! public final class TestCaseSigner extends JCESigner {
/**
***************
*** 70,74 ****
}
! public TestCaseSigner(PassPhraseAgent agent) throws GeneralSecurityException, NeuClearException {
this(KEYSTORE, getKeyStore(), agent);
}
--- 76,80 ----
}
! public TestCaseSigner(final PassPhraseAgent agent) throws GeneralSecurityException, NeuClearException {
this(KEYSTORE, getKeyStore(), agent);
}
***************
*** 84,92 ****
* @throws GeneralSecurityException
*/
! public TestCaseSigner(String name, InputStream in, String passphrase) throws NeuClearException, GeneralSecurityException {
this(name, in, new AlwaysTheSamePassphraseAgent(passphrase));
}
! public TestCaseSigner(String name, InputStream in, PassPhraseAgent agent) throws NeuClearException, GeneralSecurityException {
super(name,
in,
--- 90,98 ----
* @throws GeneralSecurityException
*/
! public TestCaseSigner(final String name, final InputStream in, final String passphrase) throws NeuClearException, GeneralSecurityException {
this(name, in, new AlwaysTheSamePassphraseAgent(passphrase));
}
! public TestCaseSigner(final String name, final InputStream in, final PassPhraseAgent agent) throws NeuClearException, GeneralSecurityException {
super(name,
in,
***************
*** 97,101 ****
private static InputStream getKeyStore() {
! URL url = TestCaseSigner.class.getClassLoader().getResource(KEYSTORE);
System.out.println("loading keystore from: " + url.toString());
return TestCaseSigner.class.getClassLoader().getResourceAsStream(KEYSTORE);
--- 103,107 ----
private static InputStream getKeyStore() {
! final URL url = TestCaseSigner.class.getClassLoader().getResource(KEYSTORE);
System.out.println("loading keystore from: " + url.toString());
return TestCaseSigner.class.getClassLoader().getResourceAsStream(KEYSTORE);
|
|
From: <pe...@us...> - 2003-11-21 04:43:45
|
Update of /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons/crypto/applets
In directory sc8-pr-cvs1:/tmp/cvs-serv10533/src/java/org/neuclear/commons/crypto/applets
Modified Files:
KeyGenerationTask.java KeyGeneratorApplet.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: KeyGenerationTask.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons/crypto/applets/KeyGenerationTask.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** KeyGenerationTask.java 19 Nov 2003 14:37:37 -0000 1.1
--- KeyGenerationTask.java 21 Nov 2003 04:43:40 -0000 1.2
***************
*** 11,14 ****
--- 11,20 ----
* $Id$
* $Log$
+ * Revision 1.2 2003/11/21 04:43:40 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 2003/11/19 14:37:37 pelle
* CommandLineAgent now masks the passphrase input using the JLine library which is now a dependency.
***************
*** 16,21 ****
*
*/
! public class KeyGenerationTask implements Runnable{
! public KeyGenerationTask(KeyPairGenerator kpg,KeyGeneratorApplet applet) {
this.kpg = kpg;
this.applet=applet;
--- 22,27 ----
*
*/
! public final class KeyGenerationTask implements Runnable{
! public KeyGenerationTask(final KeyPairGenerator kpg,final KeyGeneratorApplet applet) {
this.kpg = kpg;
this.applet=applet;
***************
*** 33,38 ****
* @see Thread#run()
*/
! public void run() {
! KeyPair kp=kpg.generateKeyPair();
applet.setKp(kp);
}
--- 39,44 ----
* @see Thread#run()
*/
! public final void run() {
! final KeyPair kp=kpg.generateKeyPair();
applet.setKp(kp);
}
Index: KeyGeneratorApplet.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons/crypto/applets/KeyGeneratorApplet.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** KeyGeneratorApplet.java 19 Nov 2003 14:37:37 -0000 1.1
--- KeyGeneratorApplet.java 21 Nov 2003 04:43:40 -0000 1.2
***************
*** 20,23 ****
--- 20,29 ----
* $Id$
* $Log$
+ * Revision 1.2 2003/11/21 04:43:40 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 2003/11/19 14:37:37 pelle
* CommandLineAgent now masks the passphrase input using the JLine library which is now a dependency.
***************
*** 25,29 ****
*
*/
! public class KeyGeneratorApplet extends Applet {
/**
* Called by the browser or applet viewer to inform
--- 31,35 ----
*
*/
! public final class KeyGeneratorApplet extends Applet {
/**
* Called by the browser or applet viewer to inform
***************
*** 46,50 ****
* @see Applet#stop()
*/
! public void start() {
// TODO seed Random NumberGenerator
statusLabel.setText("Click OK to Start Key Generation");
--- 52,56 ----
* @see Applet#stop()
*/
! public final void start() {
// TODO seed Random NumberGenerator
statusLabel.setText("Click OK to Start Key Generation");
***************
*** 70,74 ****
* @see Applet#stop()
*/
! public void init() {
try {
random=SecureRandom.getInstance("SHA1PRNG");
--- 76,80 ----
* @see Applet#stop()
*/
! public final void init() {
try {
random=SecureRandom.getInstance("SHA1PRNG");
***************
*** 79,92 ****
}
agent=new GuiDialogAgent();
! Panel panel = new Panel();
panel.setLayout(new BorderLayout());
add(panel);
! Panel text = new Panel(new FlowLayout());
panel.add(text, BorderLayout.NORTH);
keygenTask=new Thread(new KeyGenerationTask(kpg,this));
try {
final Image img = Toolkit.getDefaultToolkit().getImage(this.getClass().getClassLoader().getResource("org/neuclear/commons/crypto/passphraseagents/neuclear.png"));
! Canvas canvas = new Canvas() {
! public void paint(Graphics g) {
setSize(50, 50);
g.drawImage(img, 0, 0, this);
--- 85,98 ----
}
agent=new GuiDialogAgent();
! final Panel panel = new Panel();
panel.setLayout(new BorderLayout());
add(panel);
! final Panel text = new Panel(new FlowLayout());
panel.add(text, BorderLayout.NORTH);
keygenTask=new Thread(new KeyGenerationTask(kpg,this));
try {
final Image img = Toolkit.getDefaultToolkit().getImage(this.getClass().getClassLoader().getResource("org/neuclear/commons/crypto/passphraseagents/neuclear.png"));
! final Canvas canvas = new Canvas() {
! public void paint(final Graphics g) {
setSize(50, 50);
g.drawImage(img, 0, 0, this);
***************
*** 106,117 ****
text.add(statusLabel);
! Panel buttons = new Panel(new FlowLayout());
panel.add(buttons, BorderLayout.SOUTH);
ok = new Button("OK");
buttons.add(ok);
! Button cancel = new Button("Cancel");
buttons.add(cancel);
cancel.addActionListener(new ActionListener() {
! public void actionPerformed(ActionEvent actionEvent) {
if (keygenTask!=null)
keygenTask.interrupt();
--- 112,123 ----
text.add(statusLabel);
! final Panel buttons = new Panel(new FlowLayout());
panel.add(buttons, BorderLayout.SOUTH);
ok = new Button("OK");
buttons.add(ok);
! final Button cancel = new Button("Cancel");
buttons.add(cancel);
cancel.addActionListener(new ActionListener() {
! public void actionPerformed(final ActionEvent actionEvent) {
if (keygenTask!=null)
keygenTask.interrupt();
***************
*** 120,125 ****
});
! ActionListener action = new ActionListener() {
! public void actionPerformed(ActionEvent actionEvent) {
ok.setEnabled(false);
keygenTask.run();
--- 126,131 ----
});
! final ActionListener action = new ActionListener() {
! public void actionPerformed(final ActionEvent actionEvent) {
ok.setEnabled(false);
keygenTask.run();
***************
*** 149,157 ****
* @see Applet#stop()
*/
! public void destroy() {
random=null;
}
! void setKp(KeyPair kp) {
publickey=kp.getPublic().getEncoded();
privatekey = kp.getPrivate().getEncoded();
--- 155,163 ----
* @see Applet#stop()
*/
! public final void destroy() {
random=null;
}
! final void setKp(final KeyPair kp) {
publickey=kp.getPublic().getEncoded();
privatekey = kp.getPrivate().getEncoded();
|
|
From: <pe...@us...> - 2003-11-21 04:43:24
|
Update of /cvsroot/neuclear/neuclear-ledger/src/test/org/neuclear/ledger
In directory sc8-pr-cvs1:/tmp/cvs-serv10452/src/test/org/neuclear/ledger
Modified Files:
LedgerTest.java SQLLedgerTest.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: LedgerTest.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-ledger/src/test/org/neuclear/ledger/LedgerTest.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** LedgerTest.java 11 Nov 2003 21:17:32 -0000 1.4
--- LedgerTest.java 21 Nov 2003 04:43:21 -0000 1.5
***************
*** 8,11 ****
--- 8,14 ----
import java.util.Random;
+ import org.neuclear.ledger.implementations.SQLLedger;
+ import org.neuclear.commons.sql.DefaultConnectionSource;
+
/**
* (C) 2003 Antilles Software Ventures SA
***************
*** 15,18 ****
--- 18,27 ----
* $Id$
* $Log$
+ * Revision 1.5 2003/11/21 04:43:21 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/11 21:17:32 pelle
* Further vital reshuffling.
***************
*** 92,102 ****
*/
public abstract class LedgerTest extends TestCase {
! protected String account1 = "Bob";
! protected String account2 = "Alice";
! public LedgerTest(String s) throws LedgerCreationException, LowlevelLedgerException {
super(s);
! ledger = LedgerFactory.getInstance().getLedger("neu://superbux/reserve");
}
--- 101,111 ----
*/
public abstract class LedgerTest extends TestCase {
! protected final String account1 = "Bob";
! protected final String account2 = "Alice";
! public LedgerTest(final String s) throws LowlevelLedgerException, UnknownLedgerException {
super(s);
! ledger = new SQLLedger(new DefaultConnectionSource(), "neu://superbux/reserve");
}
***************
*** 104,111 ****
public abstract Ledger createLedger();
! public void testPostTransaction() throws LedgerException {
! Book bob = getNewBobBook();
! Book alice = getNewAliceBook();
! Date t1 = new Date();
bob.transfer(alice, 100, "Loan", t1);
}
--- 113,120 ----
public abstract Ledger createLedger();
! public final void testPostTransaction() throws LedgerException {
! final Book bob = getNewBobBook();
! final Book alice = getNewAliceBook();
! final Date t1 = new Date();
bob.transfer(alice, 100, "Loan", t1);
}
***************
*** 119,142 ****
}
! private Book createNewBook(String name) throws BookExistsException, LowlevelLedgerException {
! BigInteger id = new BigInteger(168, new Random());
! String bookID = name + id.toString(36);
System.out.println("bookid: " + bookID);
return ledger.createNewBook(bookID, name);
}
! public void testAccountCreate() throws LedgerException {
! Book bob = getNewBobBook();
assertNotNull(bob);
assertTrue(ledger.bookExists(bob.getBookID()));
}
! public void testBalance() throws LedgerException {
! Book alice = getNewAliceBook();
! Book bob = getNewBobBook();
! double aliceBalance = alice.getBalance();
! double bobBalance = bob.getBalance();
final double amount = 105;
! Date t1 = new Date();
alice.transfer(bob, amount, "Repayment", t1);
assertEquals(aliceBalance - amount, alice.getBalance(), 0);
--- 128,151 ----
}
! private Book createNewBook(final String name) throws BookExistsException, LowlevelLedgerException {
! final BigInteger id = new BigInteger(168, new Random());
! final String bookID = name + id.toString(36);
System.out.println("bookid: " + bookID);
return ledger.createNewBook(bookID, name);
}
! public final void testAccountCreate() throws LedgerException {
! final Book bob = getNewBobBook();
assertNotNull(bob);
assertTrue(ledger.bookExists(bob.getBookID()));
}
! public final void testBalance() throws LedgerException {
! final Book alice = getNewAliceBook();
! final Book bob = getNewBobBook();
! final double aliceBalance = alice.getBalance();
! final double bobBalance = bob.getBalance();
final double amount = 105;
! final Date t1 = new Date();
alice.transfer(bob, amount, "Repayment", t1);
assertEquals(aliceBalance - amount, alice.getBalance(), 0);
***************
*** 144,170 ****
}
! public void testTimeBalance() throws LedgerException {
! Calendar cal = Calendar.getInstance();
! Date t1 = cal.getTime();
cal.add(Calendar.DAY_OF_YEAR, 1);
! Date t2 = cal.getTime();
cal.add(Calendar.DAY_OF_YEAR, 1);
! Date t3 = cal.getTime();
cal.add(Calendar.DAY_OF_YEAR, 1);
! Date t4 = cal.getTime();
cal.add(Calendar.DAY_OF_YEAR, 1);
! Date t5 = cal.getTime();
! Book alice = getNewAliceBook();
! Book bob = getNewBobBook();
final double amount = 105;
! double payment = amount / 2;
alice.transfer(bob, payment, "Repayment", t2);
alice.transfer(bob, payment, "2nd Repayment", t4);
! double aliceBalance = alice.getBalance(t1);
! double bobBalance = bob.getBalance(t1);
assertEquals(aliceBalance - payment, alice.getBalance(t2), 0);
--- 153,179 ----
}
! public final void testTimeBalance() throws LedgerException {
! final Calendar cal = Calendar.getInstance();
! final Date t1 = cal.getTime();
cal.add(Calendar.DAY_OF_YEAR, 1);
! final Date t2 = cal.getTime();
cal.add(Calendar.DAY_OF_YEAR, 1);
! final Date t3 = cal.getTime();
cal.add(Calendar.DAY_OF_YEAR, 1);
! final Date t4 = cal.getTime();
cal.add(Calendar.DAY_OF_YEAR, 1);
! final Date t5 = cal.getTime();
! final Book alice = getNewAliceBook();
! final Book bob = getNewBobBook();
final double amount = 105;
! final double payment = amount / 2;
alice.transfer(bob, payment, "Repayment", t2);
alice.transfer(bob, payment, "2nd Repayment", t4);
! final double aliceBalance = alice.getBalance(t1);
! final double bobBalance = bob.getBalance(t1);
assertEquals(aliceBalance - payment, alice.getBalance(t2), 0);
***************
*** 181,198 ****
}
! public void testHold() throws LedgerException {
! Calendar cal = Calendar.getInstance();
! Date t1 = cal.getTime();
cal.add(Calendar.DAY_OF_YEAR, 1);
! Date t2 = cal.getTime();
cal.add(Calendar.DAY_OF_YEAR, 1);
! Date t3 = cal.getTime();
cal.add(Calendar.DAY_OF_YEAR, 1);
! Date t4 = cal.getTime();
cal.add(Calendar.DAY_OF_YEAR, 1);
! Date t5 = cal.getTime();
! Book alice = getNewAliceBook();
! Book bob = getNewBobBook();
--- 190,207 ----
}
! public final void testHold() throws LedgerException {
! final Calendar cal = Calendar.getInstance();
! final Date t1 = cal.getTime();
cal.add(Calendar.DAY_OF_YEAR, 1);
! final Date t2 = cal.getTime();
cal.add(Calendar.DAY_OF_YEAR, 1);
! final Date t3 = cal.getTime();
cal.add(Calendar.DAY_OF_YEAR, 1);
! final Date t4 = cal.getTime();
cal.add(Calendar.DAY_OF_YEAR, 1);
! final Date t5 = cal.getTime();
! final Book alice = getNewAliceBook();
! final Book bob = getNewBobBook();
***************
*** 202,207 ****
alice.hold(bob, amount, "Hold", t2, t4);
! double aliceBalance = alice.getBalance(t1);
! double bobBalance = bob.getBalance(t1);
// First lets check it hasnt affected the real balance
assertEquals(aliceBalance, alice.getBalance(t2), 0);
--- 211,216 ----
alice.hold(bob, amount, "Hold", t2, t4);
! final double aliceBalance = alice.getBalance(t1);
! final double bobBalance = bob.getBalance(t1);
// First lets check it hasnt affected the real balance
assertEquals(aliceBalance, alice.getBalance(t2), 0);
***************
*** 237,251 ****
}
! public void testReversal() throws LedgerException {
! Book bob = getNewBobBook();
! Book alice = getNewAliceBook();
! double amount = 123;
! double balance = bob.getBalance();
! PostedTransaction tran = bob.transfer(alice, amount, "Hello", new Date());
assertNotNull(tran);
assertEquals(bob.getBalance(), balance - amount, 0);
! PostedTransaction reverse = tran.reverse("Reverse it");
assertNotNull(reverse);
assertEquals(bob.getBalance(), balance, 0);
--- 246,260 ----
}
! public final void testReversal() throws LedgerException {
! final Book bob = getNewBobBook();
! final Book alice = getNewAliceBook();
! final double amount = 123;
! final double balance = bob.getBalance();
! final PostedTransaction tran = bob.transfer(alice, amount, "Hello", new Date());
assertNotNull(tran);
assertEquals(bob.getBalance(), balance - amount, 0);
! final PostedTransaction reverse = tran.reverse("Reverse it");
assertNotNull(reverse);
assertEquals(bob.getBalance(), balance, 0);
***************
*** 253,278 ****
}
! public void testCompleteHeld() throws LedgerException {
! Calendar cal = Calendar.getInstance();
! Date t1 = cal.getTime();
cal.add(Calendar.DAY_OF_YEAR, 1);
! Date t2 = cal.getTime();
cal.add(Calendar.DAY_OF_YEAR, 1);
! Date t3 = cal.getTime();
cal.add(Calendar.DAY_OF_YEAR, 1);
! Date t4 = cal.getTime();
cal.add(Calendar.DAY_OF_YEAR, 1);
! Date t5 = cal.getTime();
! Book ignacio = createNewBook("neu://verax/testusers/Ignacio");
! Book palacio = createNewBook("neu://verax/testusers/Palacio");
! double amount = 123;
! double held = 200;
! double balance = ignacio.getBalance(t1);
! PostedHeldTransaction hold = ignacio.hold(palacio, held, "Hello", t2, t4);
assertNotNull(hold);
assertEquals(ignacio.getBalance(t1), balance, 0);
--- 262,287 ----
}
! public final void testCompleteHeld() throws LedgerException {
! final Calendar cal = Calendar.getInstance();
! final Date t1 = cal.getTime();
cal.add(Calendar.DAY_OF_YEAR, 1);
! final Date t2 = cal.getTime();
cal.add(Calendar.DAY_OF_YEAR, 1);
! final Date t3 = cal.getTime();
cal.add(Calendar.DAY_OF_YEAR, 1);
! final Date t4 = cal.getTime();
cal.add(Calendar.DAY_OF_YEAR, 1);
! final Date t5 = cal.getTime();
! final Book ignacio = createNewBook("neu://verax/testusers/Ignacio");
! final Book palacio = createNewBook("neu://verax/testusers/Palacio");
! final double amount = 123;
! final double held = 200;
! final double balance = ignacio.getBalance(t1);
! final PostedHeldTransaction hold = ignacio.hold(palacio, held, "Hello", t2, t4);
assertNotNull(hold);
assertEquals(ignacio.getBalance(t1), balance, 0);
***************
*** 312,361 ****
}
! public void testFindTransaction() throws LowlevelLedgerException, BookExistsException, UnBalancedTransactionException, InvalidTransactionException, UnknownTransactionException, UnknownBookException {
! Book bob = getNewBobBook();
! Book alice = getNewAliceBook();
! double amount = 123;
! PostedTransaction tran = bob.transfer(alice, amount, "Can we find this again", new Date());
assertNotNull(tran);
! PostedTransaction found = ledger.findTransaction(tran.getXid());
assertNotNull(found);
assertEquals(found.getXid(), tran.getXid());
}
! public void testFindHeldTransaction() throws LowlevelLedgerException, BookExistsException, UnBalancedTransactionException, InvalidTransactionException, UnknownTransactionException, UnknownBookException {
! Book bob = getNewBobBook();
! Book alice = getNewAliceBook();
! double amount = 123;
! PostedHeldTransaction tran = bob.hold(alice, amount, "Can we find this again", new Date(), new Date());
assertNotNull(tran);
! PostedHeldTransaction found = ledger.findHeldTransaction(tran.getXid());
assertNotNull(found);
assertEquals(found.getXid(), tran.getXid());
}
! public void testCancelHeld() throws LedgerException {
! Calendar cal = Calendar.getInstance();
! Date t1 = cal.getTime();
cal.add(Calendar.DAY_OF_YEAR, 1);
! Date t2 = cal.getTime();
cal.add(Calendar.DAY_OF_YEAR, 1);
! Date t3 = cal.getTime();
cal.add(Calendar.DAY_OF_YEAR, 1);
! Date t4 = cal.getTime();
cal.add(Calendar.DAY_OF_YEAR, 1);
! Date t5 = cal.getTime();
! Book ignacio = createNewBook("neu://verax/testusers/Ignacio");
! Book palacio = createNewBook("neu://verax/testusers/Palacio");
! double amount = 123;
! double held = 200;
! double balance = ignacio.getBalance(t1);
! PostedHeldTransaction hold = ignacio.hold(palacio, held, "Hello", t2, t4);
assertNotNull(hold);
hold.cancel();
--- 321,370 ----
}
! public final void testFindTransaction() throws LowlevelLedgerException, BookExistsException, UnBalancedTransactionException, InvalidTransactionException, UnknownTransactionException, UnknownBookException {
! final Book bob = getNewBobBook();
! final Book alice = getNewAliceBook();
! final double amount = 123;
! final PostedTransaction tran = bob.transfer(alice, amount, "Can we find this again", new Date());
assertNotNull(tran);
! final PostedTransaction found = ledger.findTransaction(tran.getXid());
assertNotNull(found);
assertEquals(found.getXid(), tran.getXid());
}
! public final void testFindHeldTransaction() throws LowlevelLedgerException, BookExistsException, UnBalancedTransactionException, InvalidTransactionException, UnknownTransactionException, UnknownBookException {
! final Book bob = getNewBobBook();
! final Book alice = getNewAliceBook();
! final double amount = 123;
! final PostedHeldTransaction tran = bob.hold(alice, amount, "Can we find this again", new Date(), new Date());
assertNotNull(tran);
! final PostedHeldTransaction found = ledger.findHeldTransaction(tran.getXid());
assertNotNull(found);
assertEquals(found.getXid(), tran.getXid());
}
! public final void testCancelHeld() throws LedgerException {
! final Calendar cal = Calendar.getInstance();
! final Date t1 = cal.getTime();
cal.add(Calendar.DAY_OF_YEAR, 1);
! final Date t2 = cal.getTime();
cal.add(Calendar.DAY_OF_YEAR, 1);
! final Date t3 = cal.getTime();
cal.add(Calendar.DAY_OF_YEAR, 1);
! final Date t4 = cal.getTime();
cal.add(Calendar.DAY_OF_YEAR, 1);
! final Date t5 = cal.getTime();
! final Book ignacio = createNewBook("neu://verax/testusers/Ignacio");
! final Book palacio = createNewBook("neu://verax/testusers/Palacio");
! final double amount = 123;
! final double held = 200;
! final double balance = ignacio.getBalance(t1);
! final PostedHeldTransaction hold = ignacio.hold(palacio, held, "Hello", t2, t4);
assertNotNull(hold);
hold.cancel();
***************
*** 370,373 ****
}
! Ledger ledger;
}
--- 379,382 ----
}
! final Ledger ledger;
}
Index: SQLLedgerTest.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-ledger/src/test/org/neuclear/ledger/SQLLedgerTest.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** SQLLedgerTest.java 20 Sep 2003 23:16:21 -0000 1.1.1.1
--- SQLLedgerTest.java 21 Nov 2003 04:43:21 -0000 1.2
***************
*** 16,25 ****
* To change this template use Options | File Templates.
*/
! public class SQLLedgerTest extends LedgerTest{
! public SQLLedgerTest(String s) throws LedgerCreationException, LowlevelLedgerException {
super(s);
}
! public Ledger createLedger() {
return null; //To change body of implemented methods use Options | File Templates.
}
--- 16,25 ----
* To change this template use Options | File Templates.
*/
! public final class SQLLedgerTest extends LedgerTest{
! public SQLLedgerTest(final String s) throws LowlevelLedgerException, UnknownLedgerException {
super(s);
}
! public final Ledger createLedger() {
return null; //To change body of implemented methods use Options | File Templates.
}
|
|
From: <pe...@us...> - 2003-11-21 04:43:24
|
Update of /cvsroot/neuclear/neuclear-ledger/src/java/org/neuclear/ledger/implementations
In directory sc8-pr-cvs1:/tmp/cvs-serv10452/src/java/org/neuclear/ledger/implementations
Modified Files:
EntityLedger.java SQLLedger.java SimpleLedger.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: EntityLedger.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-ledger/src/java/org/neuclear/ledger/implementations/EntityLedger.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** EntityLedger.java 20 Nov 2003 23:41:12 -0000 1.1
--- EntityLedger.java 21 Nov 2003 04:43:20 -0000 1.2
***************
*** 1,5 ****
package org.neuclear.ledger.implementations;
! import org.ofbiz.core.entity.GenericDelegator;
/*
--- 1,5 ----
package org.neuclear.ledger.implementations;
! //import org.ofbiz.core.entity.GenericDelegator;
/*
***************
*** 23,26 ****
--- 23,32 ----
$Id$
$Log$
+ Revision 1.2 2003/11/21 04:43:20 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 2003/11/20 23:41:12 pelle
Getting all the tests to work in id
***************
*** 36,44 ****
* Time: 2:16:21 PM
*/
! public class EntityLedger {
! public static void main(String args[]) {
System.out.println("Testing Entity Engine");
! GenericDelegator delegator = GenericDelegator.getGenericDelegator("default");
}
--- 42,50 ----
* Time: 2:16:21 PM
*/
! public final class EntityLedger {
! public static void main(final String[] args) {
System.out.println("Testing Entity Engine");
! // GenericDelegator delegator = GenericDelegator.getGenericDelegator("default");
}
Index: SQLLedger.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-ledger/src/java/org/neuclear/ledger/implementations/SQLLedger.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** SQLLedger.java 28 Oct 2003 23:43:14 -0000 1.2
--- SQLLedger.java 21 Nov 2003 04:43:20 -0000 1.3
***************
*** 22,26 ****
* Window>Preferences>Java>Code Generation>Code and Comments
*/
! public class SQLLedger extends Ledger {
/**
--- 22,26 ----
* Window>Preferences>Java>Code Generation>Code and Comments
*/
! public final class SQLLedger extends Ledger {
/**
***************
*** 36,49 ****
}
*/
! public SQLLedger(ConnectionSource con, String id) throws LowlevelLedgerException, UnknownLedgerException {
super(id, getLedgerName(con, id));
this.con = con;
}
! private static String getLedgerName(ConnectionSource con, String id) throws UnknownLedgerException, LowlevelLedgerException {
try {
! PreparedStatement stmt = con.getConnection().prepareStatement("select title from ledger where id=?");
stmt.setString(1, id);
! ResultSet rs = stmt.executeQuery();
if (rs.next())
return rs.getString(1);
--- 36,49 ----
}
*/
! public SQLLedger(final ConnectionSource con, final String id) throws LowlevelLedgerException, UnknownLedgerException {
super(id, getLedgerName(con, id));
this.con = con;
}
! private static String getLedgerName(final ConnectionSource con, final String id) throws UnknownLedgerException, LowlevelLedgerException {
try {
! final PreparedStatement stmt = con.getConnection().prepareStatement("select title from ledger where id=?");
stmt.setString(1, id);
! final ResultSet rs = stmt.executeQuery();
if (rs.next())
return rs.getString(1);
***************
*** 62,74 ****
* @return
*/
! public boolean allowAutoBookCreation() {
return false;
}
! public boolean bookExists(String bookID) throws LowlevelLedgerException {
try {
! PreparedStatement stmt = prepQuery("select id from account where id=?");
stmt.setString(1, bookID);
! ResultSet rs = stmt.executeQuery();
return rs.next();
} catch (SQLException e) {
--- 62,74 ----
* @return
*/
! public final boolean allowAutoBookCreation() {
return false;
}
! public final boolean bookExists(final String bookID) throws LowlevelLedgerException {
try {
! final PreparedStatement stmt = prepQuery("select id from account where id=?");
stmt.setString(1, bookID);
! final ResultSet rs = stmt.executeQuery();
return rs.next();
} catch (SQLException e) {
***************
*** 77,86 ****
}
! public Book createNewBook(String bookID, String title) throws BookExistsException, LowlevelLedgerException {
if (bookExists(bookID))
throw new BookExistsException(this, bookID);
try {
getConnection().setAutoCommit(false);
! PreparedStatement stmt = prepQuery("insert into account values (?,?,3)");
stmt.setString(1, bookID);
stmt.setString(2, title);
--- 77,86 ----
}
! public final Book createNewBook(final String bookID, final String title) throws BookExistsException, LowlevelLedgerException {
if (bookExists(bookID))
throw new BookExistsException(this, bookID);
try {
getConnection().setAutoCommit(false);
! final PreparedStatement stmt = prepQuery("insert into account values (?,?,3)");
stmt.setString(1, bookID);
stmt.setString(2, title);
***************
*** 97,102 ****
* @see org.neuclear.ledger.Ledger#performTransaction(org.neuclear.ledger.UnPostedTransaction)
*/
! public PostedTransaction performTransaction(UnPostedTransaction transaction) throws UnBalancedTransactionException, LowlevelLedgerException, InvalidTransactionException {
! String newid;
if (!transaction.isBalanced()) {
throw new UnBalancedTransactionException(this, transaction);
--- 97,102 ----
* @see org.neuclear.ledger.Ledger#performTransaction(org.neuclear.ledger.UnPostedTransaction)
*/
! public final PostedTransaction performTransaction(final UnPostedTransaction transaction) throws UnBalancedTransactionException, LowlevelLedgerException, InvalidTransactionException {
! final String newid;
if (!transaction.isBalanced()) {
throw new UnBalancedTransactionException(this, transaction);
***************
*** 105,112 ****
getConnection().setAutoCommit(false);
! long xid = insertTransaction(transaction);
! Iterator items = transaction.getItems();
while (items.hasNext()) {
! TransactionItem item = (TransactionItem) items.next();
insertTransactionItem(xid, item);
}
--- 105,112 ----
getConnection().setAutoCommit(false);
! final long xid = insertTransaction(transaction);
! final Iterator items = transaction.getItems();
while (items.hasNext()) {
! final TransactionItem item = (TransactionItem) items.next();
insertTransactionItem(xid, item);
}
***************
*** 133,138 ****
* @return Unique ID
*/
! public PostedHeldTransaction performHeldTransaction(UnPostedHeldTransaction transaction) throws UnBalancedTransactionException, LowlevelLedgerException, InvalidTransactionException {
! String newid;
if (!transaction.isBalanced()) {
throw new UnBalancedTransactionException(this, transaction);
--- 133,138 ----
* @return Unique ID
*/
! public final PostedHeldTransaction performHeldTransaction(final UnPostedHeldTransaction transaction) throws UnBalancedTransactionException, LowlevelLedgerException, InvalidTransactionException {
! final String newid;
if (!transaction.isBalanced()) {
throw new UnBalancedTransactionException(this, transaction);
***************
*** 141,148 ****
getConnection().setAutoCommit(false);
! long xid = insertHeldTransaction(transaction);
! Iterator items = transaction.getItems();
while (items.hasNext()) {
! TransactionItem item = (TransactionItem) items.next();
insertHeldTransactionItem(xid, item);
}
--- 141,148 ----
getConnection().setAutoCommit(false);
! final long xid = insertHeldTransaction(transaction);
! final Iterator items = transaction.getItems();
while (items.hasNext()) {
! final TransactionItem item = (TransactionItem) items.next();
insertHeldTransactionItem(xid, item);
}
***************
*** 170,179 ****
* @throws UnknownTransactionException
*/
! public void performCancelHold(PostedHeldTransaction hold) throws LowlevelLedgerException, UnknownTransactionException {
try {
! PreparedStatement update = prepQuery("update held_transaction set cancelled=1 where id=? and ledgerid=?");
update.setString(1, hold.getXid());
update.setString(2, getId());
! int affected = update.executeUpdate();
if (affected == 0)
throw new UnknownTransactionException(this, hold.getXid());
--- 170,179 ----
* @throws UnknownTransactionException
*/
! public final void performCancelHold(final PostedHeldTransaction hold) throws LowlevelLedgerException, UnknownTransactionException {
try {
! final PreparedStatement update = prepQuery("update held_transaction set cancelled=1 where id=? and ledgerid=?");
update.setString(1, hold.getXid());
update.setString(2, getId());
! final int affected = update.executeUpdate();
if (affected == 0)
throw new UnknownTransactionException(this, hold.getXid());
***************
*** 188,206 ****
}
! public PostedTransaction performCompleteHold(PostedHeldTransaction hold, double amount, Date time, String comment) throws TransactionExpiredException, InvalidTransactionException, LowlevelLedgerException {
try {
! PreparedStatement query = prepQuery("select * from held_transaction where cancelled=0 and transactionid is null and id=? and ledgerid=?");
query.setString(1, hold.getXid());
query.setString(2, getId());
! ResultSet rs = query.executeQuery();
if (!rs.next())
throw new TransactionExpiredException(this, hold);
! PostedTransaction tran = createHeldComplete(hold, amount, time, comment);
! PreparedStatement update = prepQuery("update held_transaction set transactionid=? where id=? and ledgerid=?");
update.setString(1, tran.getXid());
update.setString(2, hold.getXid());
update.setString(3, getId());
! int affected = update.executeUpdate();
if (affected == 0)
throw new UnknownTransactionException(this, hold.getXid());
--- 188,206 ----
}
! public final PostedTransaction performCompleteHold(final PostedHeldTransaction hold, final double amount, final Date time, final String comment) throws TransactionExpiredException, InvalidTransactionException, LowlevelLedgerException {
try {
! final PreparedStatement query = prepQuery("select * from held_transaction where cancelled=0 and transactionid is null and id=? and ledgerid=?");
query.setString(1, hold.getXid());
query.setString(2, getId());
! final ResultSet rs = query.executeQuery();
if (!rs.next())
throw new TransactionExpiredException(this, hold);
! final PostedTransaction tran = createHeldComplete(hold, amount, time, comment);
! final PreparedStatement update = prepQuery("update held_transaction set transactionid=? where id=? and ledgerid=?");
update.setString(1, tran.getXid());
update.setString(2, hold.getXid());
update.setString(3, getId());
! final int affected = update.executeUpdate();
if (affected == 0)
throw new UnknownTransactionException(this, hold.getXid());
***************
*** 221,227 ****
}
! private long insertTransaction(UnPostedTransaction transaction) throws SQLException, LowlevelLedgerException {
! PreparedStatement tranInsert;
tranInsert = prepQuery("insert into transaction (value_date,comment,ledgerid) values (?,?,?)");
tranInsert.setTimestamp(1, SQLTools.toTimestamp(transaction.getTransactionTime()));
--- 221,227 ----
}
! private long insertTransaction(final UnPostedTransaction transaction) throws SQLException, LowlevelLedgerException {
! final PreparedStatement tranInsert;
tranInsert = prepQuery("insert into transaction (value_date,comment,ledgerid) values (?,?,?)");
tranInsert.setTimestamp(1, SQLTools.toTimestamp(transaction.getTransactionTime()));
***************
*** 229,234 ****
tranInsert.setString(3, getId());
tranInsert.execute();
! PreparedStatement tranID = prepQuery("select last_insert_id()");
! ResultSet rs = tranID.executeQuery();
if (rs.next())
return rs.getLong(1);
--- 229,234 ----
tranInsert.setString(3, getId());
tranInsert.execute();
! final PreparedStatement tranID = prepQuery("select last_insert_id()");
! final ResultSet rs = tranID.executeQuery();
if (rs.next())
return rs.getLong(1);
***************
*** 239,245 ****
}
! private long insertHeldTransaction(UnPostedHeldTransaction transaction) throws SQLException, LowlevelLedgerException {
! PreparedStatement tranInsert;
tranInsert = prepQuery("insert into held_transaction (value_date,comment,held_until,ledgerid) values (?,?,?,?)");
tranInsert.setTimestamp(3, SQLTools.toTimestamp(transaction.getExpiryTime()));
--- 239,245 ----
}
! private long insertHeldTransaction(final UnPostedHeldTransaction transaction) throws SQLException, LowlevelLedgerException {
! final PreparedStatement tranInsert;
tranInsert = prepQuery("insert into held_transaction (value_date,comment,held_until,ledgerid) values (?,?,?,?)");
tranInsert.setTimestamp(3, SQLTools.toTimestamp(transaction.getExpiryTime()));
***************
*** 249,254 ****
tranInsert.setString(4, getId());
tranInsert.execute();
! PreparedStatement tranID = prepQuery("select id from held_transaction where id=last_insert_id()");
! ResultSet rs = tranID.executeQuery();
if (rs.next())
return rs.getLong(1);
--- 249,254 ----
tranInsert.setString(4, getId());
tranInsert.execute();
! final PreparedStatement tranID = prepQuery("select id from held_transaction where id=last_insert_id()");
! final ResultSet rs = tranID.executeQuery();
if (rs.next())
return rs.getLong(1);
***************
*** 259,264 ****
}
! private void insertTransactionItem(long xid, TransactionItem item) throws SQLException, LowlevelLedgerException {
! PreparedStatement itemInsert = prepQuery("insert into entry (transactionid,accountid,amount,ack) values (?,?,?,1)");
itemInsert.setLong(1, xid);
itemInsert.setString(2, item.getBook().getBookID());
--- 259,264 ----
}
! private void insertTransactionItem(final long xid, final TransactionItem item) throws SQLException, LowlevelLedgerException {
! final PreparedStatement itemInsert = prepQuery("insert into entry (transactionid,accountid,amount,ack) values (?,?,?,1)");
itemInsert.setLong(1, xid);
itemInsert.setString(2, item.getBook().getBookID());
***************
*** 267,272 ****
}
! private void insertHeldTransactionItem(long xid, TransactionItem item) throws SQLException, LowlevelLedgerException {
! PreparedStatement itemInsert = prepQuery("insert into held_entry (held_transactionid,accountid,amount,ack) values (?,?,?,1)");
itemInsert.setLong(1, xid);
itemInsert.setString(2, item.getBook().getBookID());
--- 267,272 ----
}
! private void insertHeldTransactionItem(final long xid, final TransactionItem item) throws SQLException, LowlevelLedgerException {
! final PreparedStatement itemInsert = prepQuery("insert into held_entry (held_transactionid,accountid,amount,ack) values (?,?,?,1)");
itemInsert.setLong(1, xid);
itemInsert.setString(2, item.getBook().getBookID());
***************
*** 281,286 ****
* @return The Transaction object
*/
! public PostedTransaction findTransaction(String idstring) throws LowlevelLedgerException, UnknownTransactionException {
! long id = Long.parseLong(idstring);
try {
--- 281,286 ----
* @return The Transaction object
*/
! public final PostedTransaction findTransaction(final String idstring) throws LowlevelLedgerException, UnknownTransactionException {
! final long id = Long.parseLong(idstring);
try {
***************
*** 292,299 ****
throw new UnknownTransactionException(this, idstring);
}
! Date started = rs.getTimestamp(1);
! String comment = rs.getString(2);
! UnPostedTransaction transaction = new UnPostedTransaction(this, comment, started);
stmt = prepQuery("select accountid,amount from entry where transactionid=?");
stmt.setLong(1, id);
--- 292,299 ----
throw new UnknownTransactionException(this, idstring);
}
! final Date started = rs.getTimestamp(1);
! final String comment = rs.getString(2);
! final UnPostedTransaction transaction = new UnPostedTransaction(this, comment, started);
stmt = prepQuery("select accountid,amount from entry where transactionid=?");
stmt.setLong(1, id);
***************
*** 319,324 ****
* @return The Transaction object
*/
! public PostedHeldTransaction findHeldTransaction(String idstring) throws LowlevelLedgerException, UnknownTransactionException {
! long id = Long.parseLong(idstring);
try {
--- 319,324 ----
* @return The Transaction object
*/
! public final PostedHeldTransaction findHeldTransaction(final String idstring) throws LowlevelLedgerException, UnknownTransactionException {
! final long id = Long.parseLong(idstring);
try {
***************
*** 330,338 ****
throw new UnknownTransactionException(this, idstring);
}
! Date started = rs.getTimestamp(1);
! Date ended = rs.getTimestamp(2);
! String comment = rs.getString(3);
! UnPostedHeldTransaction transaction = new UnPostedHeldTransaction(this, comment, started, ended);
stmt = prepQuery("select accountid,amount from held_entry where held_transactionid=?");
stmt.setLong(1, id);
--- 330,338 ----
throw new UnknownTransactionException(this, idstring);
}
! final Date started = rs.getTimestamp(1);
! final Date ended = rs.getTimestamp(2);
! final String comment = rs.getString(3);
! final UnPostedHeldTransaction transaction = new UnPostedHeldTransaction(this, comment, started, ended);
stmt = prepQuery("select accountid,amount from held_entry where held_transactionid=?");
stmt.setLong(1, id);
***************
*** 352,356 ****
}
! private PreparedStatement prepQuery(String sql) throws SQLException, LowlevelLedgerException {
return getConnection().prepareStatement(sql);
}
--- 352,356 ----
}
! private PreparedStatement prepQuery(final String sql) throws SQLException, LowlevelLedgerException {
return getConnection().prepareStatement(sql);
}
***************
*** 359,365 ****
* @see org.neuclear.ledger.Ledger#getBalance(org.neuclear.ledger.Book, java.util.Date)
*/
! public double getBalance(Book book, Date time) throws LowlevelLedgerException {
try {
! PreparedStatement stmt = prepQuery("select sum(e.amount) from entry e,transaction t where e.transactionid=t.id and e.accountid=? and t.value_date<= ? and t.ledgerid=?");
stmt.setString(1, book.getBookID());
--- 359,365 ----
* @see org.neuclear.ledger.Ledger#getBalance(org.neuclear.ledger.Book, java.util.Date)
*/
! public final double getBalance(final Book book, final Date time) throws LowlevelLedgerException {
try {
! final PreparedStatement stmt = prepQuery("select sum(e.amount) from entry e,transaction t where e.transactionid=t.id and e.accountid=? and t.value_date<= ? and t.ledgerid=?");
stmt.setString(1, book.getBookID());
***************
*** 367,371 ****
stmt.setString(3, getId());
! ResultSet rs = stmt.executeQuery();
if (rs.next()) {
return rs.getDouble(1);
--- 367,371 ----
stmt.setString(3, getId());
! final ResultSet rs = stmt.executeQuery();
if (rs.next()) {
return rs.getDouble(1);
***************
*** 380,391 ****
* @see org.neuclear.ledger.Ledger#getBalance(org.neuclear.ledger.Book)
*/
! public double getBalance(Book book) throws LowlevelLedgerException {
return getBalance(book, new Date());
}
! public double getAvailableBalance(Book book, Date time) throws LowlevelLedgerException {
double balance = 0.0;
try {
! PreparedStatement stmt = prepQuery("select sum(u.amount) from (" +
"select sum( e.amount) as amount from entry e,transaction t " +
"where e.transactionid=t.id and e.accountid=? and t.value_date<= ? and t.ledgerid=?"
--- 380,391 ----
* @see org.neuclear.ledger.Ledger#getBalance(org.neuclear.ledger.Book)
*/
! public final double getBalance(final Book book) throws LowlevelLedgerException {
return getBalance(book, new Date());
}
! public final double getAvailableBalance(final Book book, final Date time) throws LowlevelLedgerException {
double balance = 0.0;
try {
! final PreparedStatement stmt = prepQuery("select sum(u.amount) from (" +
"select sum( e.amount) as amount from entry e,transaction t " +
"where e.transactionid=t.id and e.accountid=? and t.value_date<= ? and t.ledgerid=?"
***************
*** 397,401 ****
+ ") u "
);
! Timestamp ts = SQLTools.toTimestamp(time);
stmt.setString(1, book.getBookID());
stmt.setTimestamp(2, ts);
--- 397,401 ----
+ ") u "
);
! final Timestamp ts = SQLTools.toTimestamp(time);
stmt.setString(1, book.getBookID());
stmt.setTimestamp(2, ts);
***************
*** 406,410 ****
stmt.setString(7, getId());
! ResultSet rs = stmt.executeQuery();
// System.out.println("Avaliable Balance at: "+ts.toString());
while (rs.next()) {
--- 406,410 ----
stmt.setString(7, getId());
! final ResultSet rs = stmt.executeQuery();
// System.out.println("Avaliable Balance at: "+ts.toString());
while (rs.next()) {
***************
*** 422,426 ****
* @see org.neuclear.ledger.Ledger#getAvailableBalance(org.neuclear.ledger.Book)
*/
! public double getAvailableBalance(Book book) throws LowlevelLedgerException {
return getAvailableBalance(book, new Date());
}
--- 422,426 ----
* @see org.neuclear.ledger.Ledger#getAvailableBalance(org.neuclear.ledger.Book)
*/
! public final double getAvailableBalance(final Book book) throws LowlevelLedgerException {
return getAvailableBalance(book, new Date());
}
***************
*** 429,433 ****
* @see org.neuclear.ledger.Ledger#beginLinkedTransaction()
*/
! public void beginLinkedTransaction() {
// TODO Auto-generated method stub
--- 429,433 ----
* @see org.neuclear.ledger.Ledger#beginLinkedTransaction()
*/
! public final void beginLinkedTransaction() {
// TODO Auto-generated method stub
***************
*** 437,446 ****
* @see org.neuclear.ledger.Ledger#endLinkedTransactions()
*/
! public void endLinkedTransactions() {
// TODO Auto-generated method stub
}
! public String toString() {
return "SQL Ledger: " + getName();
}
--- 437,446 ----
* @see org.neuclear.ledger.Ledger#endLinkedTransactions()
*/
! public final void endLinkedTransactions() {
// TODO Auto-generated method stub
}
! public final String toString() {
return "SQL Ledger: " + getName();
}
***************
*** 456,466 ****
}
! private ConnectionSource con;
! public Book getBook(String bookID) throws UnknownBookException, LowlevelLedgerException {
try {
! PreparedStatement stmt = prepQuery("select screenname from account where id=?");
stmt.setString(1, bookID);
! ResultSet rs = stmt.executeQuery();
if (rs.next())
return createBookInstance(bookID, rs.getString(1));
--- 456,466 ----
}
! private final ConnectionSource con;
! public final Book getBook(final String bookID) throws UnknownBookException, LowlevelLedgerException {
try {
! final PreparedStatement stmt = prepQuery("select screenname from account where id=?");
stmt.setString(1, bookID);
! final ResultSet rs = stmt.executeQuery();
if (rs.next())
return createBookInstance(bookID, rs.getString(1));
Index: SimpleLedger.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-ledger/src/java/org/neuclear/ledger/implementations/SimpleLedger.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** SimpleLedger.java 11 Nov 2003 21:17:31 -0000 1.2
--- SimpleLedger.java 21 Nov 2003 04:43:20 -0000 1.3
***************
*** 3,6 ****
--- 3,12 ----
* $Id$
* $Log$
+ * Revision 1.3 2003/11/21 04:43:20 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:17:31 pelle
* Further vital reshuffling.
***************
*** 66,70 ****
public final class SimpleLedger extends Ledger {
! public SimpleLedger(String name) {
super(name,name);
ledger=new LinkedHashMap();
--- 72,76 ----
public final class SimpleLedger extends Ledger {
! public SimpleLedger(final String name) {
super(name,name);
ledger=new LinkedHashMap();
***************
*** 72,76 ****
}
! public boolean bookExists(String bookID) {
return books.containsKey(bookID); //Strictly speaking not true
}
--- 78,82 ----
}
! public boolean bookExists(final String bookID) {
return books.containsKey(bookID); //Strictly speaking not true
}
***************
*** 82,89 ****
* @return
*/
! public Book createNewBook(String bookID,String title) throws BookExistsException {
if (bookExists(bookID))
throw new BookExistsException(this,bookID);
! Book book=createBookInstance(bookID,title);
books.put(bookID,book);
return book;
--- 88,95 ----
* @return
*/
! public Book createNewBook(final String bookID,final String title) throws BookExistsException {
if (bookExists(bookID))
throw new BookExistsException(this,bookID);
! final Book book=createBookInstance(bookID,title);
books.put(bookID,book);
return book;
***************
*** 98,106 ****
* @return Unique ID
*/
! public PostedTransaction performTransaction(UnPostedTransaction trans) throws UnBalancedTransactionException, InvalidTransactionException {
if (!trans.isBalanced())
throw new UnBalancedTransactionException(this,trans);
! String id=getID();
! PostedTransaction posted=createTransaction(trans,id);
ledger.put(id,posted);
return posted;
--- 104,112 ----
* @return Unique ID
*/
! public PostedTransaction performTransaction(final UnPostedTransaction trans) throws UnBalancedTransactionException, InvalidTransactionException {
if (!trans.isBalanced())
throw new UnBalancedTransactionException(this,trans);
! final String id=getID();
! final PostedTransaction posted=createTransaction(trans,id);
ledger.put(id,posted);
return posted;
***************
*** 114,122 ****
* @return Unique ID
*/
! public PostedHeldTransaction performHeldTransaction(UnPostedHeldTransaction trans) throws UnBalancedTransactionException, LowlevelLedgerException, InvalidTransactionException {
if (!trans.isBalanced())
throw new UnBalancedTransactionException(this,trans);
! String id=getID();
! PostedHeldTransaction posted=createHeldTransaction(trans,id);
ledger.put(id,posted);
return posted;
--- 120,128 ----
* @return Unique ID
*/
! public PostedHeldTransaction performHeldTransaction(final UnPostedHeldTransaction trans) throws UnBalancedTransactionException, LowlevelLedgerException, InvalidTransactionException {
if (!trans.isBalanced())
throw new UnBalancedTransactionException(this,trans);
! final String id=getID();
! final PostedHeldTransaction posted=createHeldTransaction(trans,id);
ledger.put(id,posted);
return posted;
***************
*** 129,133 ****
* @ If it couldnt find the Transaction
*/
! public PostedTransaction findTransaction(String id) throws UnknownTransactionException {
if (!ledger.containsKey(id))
throw new UnknownTransactionException(this,id);
--- 135,139 ----
* @ If it couldnt find the Transaction
*/
! public PostedTransaction findTransaction(final String id) throws UnknownTransactionException {
if (!ledger.containsKey(id))
throw new UnknownTransactionException(this,id);
***************
*** 146,162 ****
* @return the balance as a double
*/
! public double getBalance(Book book, Date balancedate) {
double balance=0;
// Very silly slow and lazy implementation
! Iterator iter=ledger.keySet().iterator();
! boolean going=true;
while(iter.hasNext()&&going){
! Transaction tran=(Transaction)ledger.get((String)iter.next());
// The reason I'm doing !xx.after is because I need this to be <=
if (!tran.getTransactionTime().after(balancedate)) {
! Iterator items=tran.getItems();
! boolean isHold=(tran instanceof HeldTransaction);
while (items.hasNext()) {
! TransactionItem item = (TransactionItem) items.next();
if (item.getBook().equals(book)&&!isHold)
balance+=item.getAmount();
--- 152,168 ----
* @return the balance as a double
*/
! public double getBalance(final Book book, final Date balancedate) {
double balance=0;
// Very silly slow and lazy implementation
! final Iterator iter=ledger.keySet().iterator();
! final boolean going=true;
while(iter.hasNext()&&going){
! final Transaction tran=(Transaction)ledger.get((String)iter.next());
// The reason I'm doing !xx.after is because I need this to be <=
if (!tran.getTransactionTime().after(balancedate)) {
! final Iterator items=tran.getItems();
! final boolean isHold=(tran instanceof HeldTransaction);
while (items.hasNext()) {
! final TransactionItem item = (TransactionItem) items.next();
if (item.getBook().equals(book)&&!isHold)
balance+=item.getAmount();
***************
*** 169,173 ****
}
! public double getBalance(Book book) {
return getBalance(book,new Date());
}
--- 175,179 ----
}
! public double getBalance(final Book book) {
return getBalance(book,new Date());
}
***************
*** 186,205 ****
* @return the balance as a double
*/
! public double getAvailableBalance(Book book, Date balancedate) {
double balance=0;
// Very silly slow and lazy implementation
! Iterator iter=ledger.keySet().iterator();
! boolean going=true;
while(iter.hasNext()){
! Transaction tran=(Transaction)ledger.get((String)iter.next());
// The reason I'm doing !xx.after is because I need this to be <=
if (!tran.getTransactionTime().after(balancedate)) {
! Iterator items=tran.getItems();
! boolean isHold=(tran instanceof HeldTransaction);
! boolean isValidHold=isHold&&(!((HeldTransaction)tran).getExpiryTime().before(balancedate));
while (items.hasNext()) {
! TransactionItem item = (TransactionItem) items.next();
if (
item.getBook().equals(book)&&
--- 192,211 ----
* @return the balance as a double
*/
! public double getAvailableBalance(final Book book, final Date balancedate) {
double balance=0;
// Very silly slow and lazy implementation
! final Iterator iter=ledger.keySet().iterator();
! final boolean going=true;
while(iter.hasNext()){
! final Transaction tran=(Transaction)ledger.get((String)iter.next());
// The reason I'm doing !xx.after is because I need this to be <=
if (!tran.getTransactionTime().after(balancedate)) {
! final Iterator items=tran.getItems();
! final boolean isHold=(tran instanceof HeldTransaction);
! final boolean isValidHold=isHold&&(!((HeldTransaction)tran).getExpiryTime().before(balancedate));
while (items.hasNext()) {
! final TransactionItem item = (TransactionItem) items.next();
if (
item.getBook().equals(book)&&
***************
*** 222,226 ****
}
! public double getAvailableBalance(Book book) {
return getAvailableBalance(book,new Date());
}
--- 228,232 ----
}
! public double getAvailableBalance(final Book book) {
return getAvailableBalance(book,new Date());
}
***************
*** 251,255 ****
* @return The Transaction object
*/
! public PostedHeldTransaction findHeldTransaction(String idstring) throws LowlevelLedgerException, UnknownTransactionException {
return null; //To change body of implemented methods use Options | File Templates.
}
--- 257,261 ----
* @return The Transaction object
*/
! public PostedHeldTransaction findHeldTransaction(final String idstring) throws LowlevelLedgerException, UnknownTransactionException {
return null; //To change body of implemented methods use Options | File Templates.
}
***************
*** 261,269 ****
* @throws UnknownTransactionException
*/
! public void performCancelHold(PostedHeldTransaction hold) throws LowlevelLedgerException, UnknownTransactionException {
//To change body of implemented methods use Options | File Templates.
}
! public PostedTransaction performCompleteHold(PostedHeldTransaction hold, double amount, Date time, String comment) throws InvalidTransactionException, LowlevelLedgerException {
return null; //To change body of implemented methods use Options | File Templates.
}
--- 267,275 ----
* @throws UnknownTransactionException
*/
! public void performCancelHold(final PostedHeldTransaction hold) throws LowlevelLedgerException, UnknownTransactionException {
//To change body of implemented methods use Options | File Templates.
}
! public PostedTransaction performCompleteHold(final PostedHeldTransaction hold, final double amount, final Date time, final String comment) throws InvalidTransactionException, LowlevelLedgerException {
return null; //To change body of implemented methods use Options | File Templates.
}
***************
*** 273,280 ****
}
private long idSeq=0;
! private LinkedHashMap ledger;
! private HashMap books;
! public Book getBook(String bookID) throws UnknownBookException,LowlevelLedgerException {
if (bookExists(bookID))
return (Book)books.get(bookID);
--- 279,286 ----
}
private long idSeq=0;
! private final LinkedHashMap ledger;
! private final HashMap books;
! public Book getBook(final String bookID) throws UnknownBookException,LowlevelLedgerException {
if (bookExists(bookID))
return (Book)books.get(bookID);
|