|
From: <pe...@us...> - 2003-12-19 18:02:57
|
Update of /cvsroot/neuclear/neuclear-commons/src/test/org/neuclear/commons/crypto/signers
In directory sc8-pr-cvs1:/tmp/cvs-serv5157/src/test/org/neuclear/commons/crypto/signers
Modified Files:
SimpleSignerStoreTest.java TestCaseSignerTest.java
Log Message:
Revamped a lot of exception handling throughout the framework, it has been simplified in most places:
- For most cases the main exception to worry about now is InvalidNamedObjectException.
- Most lowerlevel exception that cant be handled meaningful are now wrapped in the LowLevelException, a
runtime exception.
- Source and Store patterns each now have their own exceptions that generalizes the various physical
exceptions that can happen in that area.
Index: SimpleSignerStoreTest.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-commons/src/test/org/neuclear/commons/crypto/signers/SimpleSignerStoreTest.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** SimpleSignerStoreTest.java 18 Dec 2003 17:40:08 -0000 1.6
--- SimpleSignerStoreTest.java 19 Dec 2003 18:02:53 -0000 1.7
***************
*** 1,4 ****
--- 1,12 ----
/* $Id$
* $Log$
+ * Revision 1.7 2003/12/19 18:02:53 pelle
+ * Revamped a lot of exception handling throughout the framework, it has been simplified in most places:
+ * - For most cases the main exception to worry about now is InvalidNamedObjectException.
+ * - Most lowerlevel exception that cant be handled meaningful are now wrapped in the LowLevelException, a
+ * runtime exception.
+ * - Source and Store patterns each now have their own exceptions that generalizes the various physical
+ * exceptions that can happen in that area.
+ *
* Revision 1.6 2003/12/18 17:40:08 pelle
* You can now create keys that get stored with a X509 certificate in the keystore. These can be saved as well.
***************
*** 115,118 ****
--- 123,127 ----
import org.neuclear.commons.crypto.CryptoTools;
import org.neuclear.commons.crypto.passphraseagents.AlwaysTheSamePassphraseAgent;
+ import org.neuclear.commons.crypto.passphraseagents.UserCancellationException;
import java.io.IOException;
***************
*** 154,189 ****
! public final void testAddKey() throws NeuClearException, GeneralSecurityException, IOException {
! boolean success = false;
! try {
! signer.addKey("root", root.getPrivate());
! success = true;
! } catch (GeneralSecurityException e) {
! e.printStackTrace();
! } catch (IOException e) {
! e.printStackTrace();
! }
! assertTrue("Managed to add a key", success);
}
public final void testSignData() throws NeuClearException, GeneralSecurityException, IOException, CryptoException {
- boolean success = false;
byte data[] = null;
! try {
! signer.addKey("bob", bob.getPrivate());
! data = signer.sign("bob", "test".getBytes());
! assertTrue(CryptoTools.verify(bob.getPublic(), "test".getBytes(), data));
! success = true;
! } catch (GeneralSecurityException e) {
! e.printStackTrace();
! } catch (IOException e) {
! e.printStackTrace();
! }
! assertTrue("Managed to add and sign some data", success);
assertNotNull("Key wasn't null", data);
- //assertEquals("Gotten Key was the same as Stored Key", bob.getPrivate(), key);
}
! public final void testGenerateKey() throws CryptoException {
final PublicKey pub = signer.generateKey("tupac");
final byte[] data = "this is a test".getBytes();
--- 163,180 ----
! public final void testAddKey() throws NeuClearException{
! signer.addKey("root", root.getPrivate());
! assertTrue("Managed to add a key", signer.canSignFor("root"));
}
public final void testSignData() throws NeuClearException, GeneralSecurityException, IOException, CryptoException {
byte data[] = null;
! signer.addKey("bob", bob.getPrivate());
! data = signer.sign("bob", "test".getBytes());
! assertTrue(CryptoTools.verify(bob.getPublic(), "test".getBytes(), data));
assertNotNull("Key wasn't null", data);
}
! public final void testGenerateKey() throws CryptoException, UserCancellationException {
final PublicKey pub = signer.generateKey("tupac");
final byte[] data = "this is a test".getBytes();
Index: TestCaseSignerTest.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-commons/src/test/org/neuclear/commons/crypto/signers/TestCaseSignerTest.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** TestCaseSignerTest.java 18 Dec 2003 17:40:08 -0000 1.5
--- TestCaseSignerTest.java 19 Dec 2003 18:02:53 -0000 1.6
***************
*** 5,8 ****
--- 5,9 ----
import org.neuclear.commons.crypto.CryptoException;
import org.neuclear.commons.crypto.CryptoTools;
+ import org.neuclear.commons.crypto.passphraseagents.UserCancellationException;
import java.security.GeneralSecurityException;
***************
*** 29,32 ****
--- 30,41 ----
$Id$
$Log$
+ Revision 1.6 2003/12/19 18:02:53 pelle
+ Revamped a lot of exception handling throughout the framework, it has been simplified in most places:
+ - For most cases the main exception to worry about now is InvalidNamedObjectException.
+ - Most lowerlevel exception that cant be handled meaningful are now wrapped in the LowLevelException, a
+ runtime exception.
+ - Source and Store patterns each now have their own exceptions that generalizes the various physical
+ exceptions that can happen in that area.
+
Revision 1.5 2003/12/18 17:40:08 pelle
You can now create keys that get stored with a X509 certificate in the keystore. These can be saved as well.
***************
*** 80,84 ****
}
! public final void testSignAndVerify() throws CryptoException {
testKey("neu://test");
testKey("neu://test/bux");
--- 89,93 ----
}
! public final void testSignAndVerify() throws CryptoException, UserCancellationException {
testKey("neu://test");
testKey("neu://test/bux");
***************
*** 87,91 ****
}
! public final void testGenerateKey() throws CryptoException {
final PublicKey pub = signer.generateKey(ALIASEVE);
final byte[] data = "this is a test".getBytes();
--- 96,100 ----
}
! public final void testGenerateKey() throws CryptoException, UserCancellationException {
final PublicKey pub = signer.generateKey(ALIASEVE);
final byte[] data = "this is a test".getBytes();
***************
*** 95,99 ****
assertTrue(signer.canSignFor(ALIASEVE));
}
! private void testKey(final String name) throws CryptoException {
final byte[] sig = signer.sign(name, TESTDATA.getBytes());
assertNotNull(sig);
--- 104,108 ----
assertTrue(signer.canSignFor(ALIASEVE));
}
! private void testKey(final String name) throws CryptoException, UserCancellationException {
final byte[] sig = signer.sign(name, TESTDATA.getBytes());
assertNotNull(sig);
|