*/
public class SignedObjectTest extends TestCase {
public void testSignedObject() {
Signature sig = null;
TestKeyPair tkp = null;
Properties prop;
try {
sig = Signature.getInstance("SHA1withDSA");
} catch (NoSuchAlgorithmException e) {
fail(e.toString());
}
try {
tkp = new TestKeyPair("DSA");
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
return;
}
prop = new Properties();
prop.put("aaa", "bbb");
SignedObject so = null;
try {
so = new SignedObject(prop, tkp.getPrivate(), sig);
} catch (IOException e) {
fail(e.toString());
} catch (SignatureException e) {
fail(e.toString());
} catch (InvalidKeyException e) {
fail(e.toString());
} catch (InvalidKeySpecException e) {
fail(e.toString());
}
assertEquals("SHA1withDSA", so.getAlgorithm());
try {
assertEquals(so.getObject(), prop);
} catch (ClassNotFoundException e) {
fail(e.toString());
} catch (IOException e) {
fail(e.toString());
}
try {
if (!so.verify(tkp.getPublic(), sig)) {
fail("verify() failed");
}
} catch (SignatureException e) {
fail(e.toString());
} catch (InvalidKeyException e) {