|
From: <pe...@us...> - 2003-11-19 23:33:34
|
Update of /cvsroot/neuclear/neuclear-commons/src/test/org/neuclear/commons/crypto/signers
In directory sc8-pr-cvs1:/tmp/cvs-serv12633/src/test/org/neuclear/commons/crypto/signers
Modified Files:
SimpleSignerStoreTest.java TestCaseSignerTest.java
Log Message:
Signers now can generatekeys via the generateKey() method.
Refactored the relationship between SignedNamedObject and NamedObjectBuilder a bit.
SignedNamedObject now contains the full xml which is returned with getEncoded()
This means that it is now possible to further send on or process a SignedNamedObject, leaving
NamedObjectBuilder for its original purposes of purely generating new Contracts.
NamedObjectBuilder.sign() now returns a SignedNamedObject which is the prefered way of processing it.
Updated all major interfaces that used the old model to use the new model.
Index: SimpleSignerStoreTest.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-commons/src/test/org/neuclear/commons/crypto/signers/SimpleSignerStoreTest.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** SimpleSignerStoreTest.java 12 Nov 2003 23:47:50 -0000 1.2
--- SimpleSignerStoreTest.java 19 Nov 2003 23:32:51 -0000 1.3
***************
*** 1,4 ****
--- 1,13 ----
/* $Id$
* $Log$
+ * Revision 1.3 2003/11/19 23:32:51 pelle
+ * Signers now can generatekeys via the generateKey() method.
+ * Refactored the relationship between SignedNamedObject and NamedObjectBuilder a bit.
+ * SignedNamedObject now contains the full xml which is returned with getEncoded()
+ * This means that it is now possible to further send on or process a SignedNamedObject, leaving
+ * NamedObjectBuilder for its original purposes of purely generating new Contracts.
+ * NamedObjectBuilder.sign() now returns a SignedNamedObject which is the prefered way of processing it.
+ * Updated all major interfaces that used the old model to use the new model.
+ *
* Revision 1.2 2003/11/12 23:47:50 pelle
* Much work done in creating good test environment.
***************
*** 90,97 ****
import java.io.IOException;
! import java.security.GeneralSecurityException;
! import java.security.KeyPair;
! import java.security.KeyPairGenerator;
! import java.security.SecureRandom;
--- 99,103 ----
import java.io.IOException;
! import java.security.*;
***************
*** 103,107 ****
public SimpleSignerStoreTest(String name) throws GeneralSecurityException, NeuClearException, ConfigurationException {
super(name);
! store = getSignerStoreInstance();
generateKeys();
}
--- 109,113 ----
public SimpleSignerStoreTest(String name) throws GeneralSecurityException, NeuClearException, ConfigurationException {
super(name);
! signer = getSignerStoreInstance();
generateKeys();
}
***************
*** 133,137 ****
boolean success = false;
try {
! store.addKey("root", root.getPrivate());
success = true;
} catch (GeneralSecurityException e) {
--- 139,143 ----
boolean success = false;
try {
! signer.addKey("root", root.getPrivate());
success = true;
} catch (GeneralSecurityException e) {
***************
*** 147,152 ****
byte data[] = null;
try {
! store.addKey("bob", bob.getPrivate());
! data = store.sign("bob", "test".getBytes());
assertTrue(CryptoTools.verify(bob.getPublic(), "test".getBytes(), data));
success = true;
--- 153,158 ----
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;
***************
*** 161,166 ****
}
! private SimpleSigner store;
private static KeyPairGenerator kg;
protected static KeyPair root;
--- 167,182 ----
}
+ 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));
+ assertTrue(signer.canSignFor("tupac"));
!
! }
!
! private 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.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** TestCaseSignerTest.java 12 Nov 2003 23:47:50 -0000 1.1
--- TestCaseSignerTest.java 19 Nov 2003 23:32:51 -0000 1.2
***************
*** 7,10 ****
--- 7,11 ----
import java.security.GeneralSecurityException;
+ import java.security.PublicKey;
/*
***************
*** 28,31 ****
--- 29,41 ----
$Id$
$Log$
+ Revision 1.2 2003/11/19 23:32:51 pelle
+ Signers now can generatekeys via the generateKey() method.
+ Refactored the relationship between SignedNamedObject and NamedObjectBuilder a bit.
+ SignedNamedObject now contains the full xml which is returned with getEncoded()
+ This means that it is now possible to further send on or process a SignedNamedObject, leaving
+ NamedObjectBuilder for its original purposes of purely generating new Contracts.
+ NamedObjectBuilder.sign() now returns a SignedNamedObject which is the prefered way of processing it.
+ Updated all major interfaces that used the old model to use the new model.
+
Revision 1.1 2003/11/12 23:47:50 pelle
Much work done in creating good test environment.
***************
*** 59,62 ****
--- 69,83 ----
}
+ 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));
+ assertTrue(signer.canSignFor(ALIASEVE));
+
+
+ }
+
private void testKey(String name) throws CryptoException {
byte sig[] = signer.sign(name, TESTDATA.getBytes());
***************
*** 68,71 ****
--- 89,93 ----
private TestCaseSigner signer;
private String TESTDATA = "Here we go again";
+ private static final String ALIASEVE = "neu://eve@test";
}
|