[Webfunds-commits] java/webfunds/ricardian Contract.java

Edwin Woudt edwin@cypherpunks.ai
Mon, 12 Jun 2000 11:25:29 -0400 (AST)


edwin       00/06/12 11:25:29

  Modified:    webfunds/ricardian Tag: OPENPGP Contract.java
  Log:
  First attempt at using PGP signed contracts (it works!)

Revision  Changes    Path
No                   revision

= Diff supressed due to Sticky Options =


No                   revision

= Diff supressed due to Sticky Options =


1.19.2.3  +23 -2     java/webfunds/ricardian/Contract.java

Index: Contract.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/ricardian/Contract.java,v
retrieving revision 1.19.2.2
retrieving revision 1.19.2.3
diff -u -r1.19.2.2 -r1.19.2.3
--- Contract.java	2000/06/12 10:38:06	1.19.2.2
+++ Contract.java	2000/06/12 15:25:28	1.19.2.3
@@ -1,5 +1,5 @@
 /*
- * $Id: Contract.java,v 1.19.2.2 2000/06/12 10:38:06 edwin Exp $
+ * $Id: Contract.java,v 1.19.2.3 2000/06/12 15:25:28 edwin Exp $
  *
  * Copyright (c) Systemics Ltd 1995-1999 on behalf of
  * the WebFunds Development Team.  All Rights Reserved.
@@ -40,6 +40,9 @@
 import webfunds.sox.Crypto;
 import webfunds.sox.SOXKeyException;
 
+import cryptix.openpgp.PGPMessage;
+import cryptix.openpgp.PGPPublicKey;
+
 /**
  * Ricardian Contract Base Class
  * Rewritten from the sox.Contract and the Perl equivalents.
@@ -667,6 +670,18 @@
         return getCert("contract");
     }
 
+    private PGPPublicKey getContractCertPGP()
+        throws ContractException
+    {
+        PGPPublicKey key = new PGPPublicKey();
+        try {
+            key.readKey("pubkey.pgp");
+        } catch (IOException ioe) {
+            ioe.printStackTrace();
+        }
+        return key;
+    }
+
     /**
      * This is the top-level Issuer certification key,
      * which signs the contract key above.
@@ -744,8 +759,14 @@
     public boolean verifyContract()
         throws ContractException
     {
+        String s = new String(contractData);
+        PGPPublicKey issuerKey = getContractCertPGP();
         
-        return true;
+        try {
+            return PGPMessage.verifyClearSign(s, issuerKey);
+        } catch (IOException ioe) {
+            return false;
+        }
         
 /*        // Get the Certificate from the contract
         X509Cert issuerCert = getContractCert();