[Webfunds-commits] java/webfunds/client/contracts/wizard KeyPanel.java

Ian Grigg iang@cypherpunks.ai
Sun, 27 Aug 2000 23:23:44 -0400 (AST)


iang        00/08/27 23:23:44

  Modified:    webfunds/client/contracts/wizard KeyPanel.java
  Log:
  deleted (day :) old methods that are now string based and in KeyUtil
  or in WizardPanel.  This class is now empty, can be replaced with WizardPanel
  any time.

Revision  Changes    Path
1.8       +6 -107    java/webfunds/client/contracts/wizard/KeyPanel.java

Index: KeyPanel.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/client/contracts/wizard/KeyPanel.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- KeyPanel.java	2000/08/28 03:03:16	1.7
+++ KeyPanel.java	2000/08/28 03:23:44	1.8
@@ -1,5 +1,5 @@
 /*
- * $Id: KeyPanel.java,v 1.7 2000/08/28 03:03:16 iang Exp $
+ * $Id: KeyPanel.java,v 1.8 2000/08/28 03:23:44 iang Exp $
  *
  * Copyright (c) Systemics Inc 2000 on behalf of
  * the WebFunds Development Team.  All Rights Reserved.
@@ -8,6 +8,7 @@
 package webfunds.client.contracts.wizard;
 
 
+/*
 import cryptix.openpgp.PGPException;
 import cryptix.openpgp.PGPKeyFactory;
 import cryptix.openpgp.PGPKey;
@@ -20,124 +21,22 @@
 
 import webfunds.ricardian.KeyUtil;
 import webfunds.ricardian.StripKeyException;
+*/
 
 
 /**
  * Abstract superclass for all panels in a wizard.
  *
- * These amount to Utility classes for OpenPGP - perhaps better in openpgp?
+ * These amount to Utility classes for OpenPGP - now in WizardPanel
+ * (so ContractFile can use them) and ricardian.KeyUtil.
  *
  * @author Edwin Woudt <edwin@webfunds.org>
- * @version $Revision: 1.7 $
+ * @version $Revision: 1.8 $
  */
 
 public abstract class KeyPanel extends WizardPanel {
 
-    protected String loadAndCheckPublicKey(String filename,
-                                           String tag,
-                                           PGPPublicKey signerKey)
-    {
-        try {
-            // String keyAsString = loadKey(filename, false);
-            // PGPPublicKey pk = publicKeyFromString(keyAsString);
-
-            PGPPublicKey pk = loadPublicKey(filename);
-
-            // replace with stripped version
-            pk = KeyUtil.stripAndVerifyKey(pk, tag, signerKey);
-
-            return KeyUtil.publicKeyToString(pk);
-
-        } catch(Exception e) {
-            error("Dunno", e);
-            return null;
-        }
-    }
-
-    /**
-     *  Load up a key from a filename.
-     *  No checking other than that intrinsic in de-armouring and
-     *  insisting on one and one only key.
-     */
-    protected PGPKey loadKey(String filename) {
-        
-        String keyAsString = loadString(filename);
-        if (keyAsString == null)
-            return null;
-        
-        // check key
-        PGPArmoury akey;
-        try {
-            akey = new PGPArmoury(keyAsString);
-        } catch (IllegalArgumentException iae) {
-            error("Invalid key, not armoured?",iae);
-            return null;
-        }
-    
-        // get the unarmoured key
-        PGPKeyFactory factory = new PGPKeyFactory();
-        PGPKey key;
-        try {
-            Vector keys = factory.decodeKeys(akey.getPayload());
-            if (keys.size() > 1) {
-                error("More than one key found in input file");
-                return null;
-            } else if (keys.size() < 1) {
-                error("No key found in input file");
-                return null;
-            }
-            key = (PGPKey)keys.elementAt(0);
-        } catch (PGPException pe) {
-            error("Error parsing input file, "+pe, pe);
-            return null;
-        }
-
-        // everything ok, found a single Key
-        return key;
-
-    }
-
-    /**
-     *  Read a Public Key from a filename and return the key.
-     */
-    protected PGPPublicKey loadPublicKey(String filename) {
-        
-        PGPKey key = loadKey(filename);
-        if (key == null)
-            return null;
-
-        if (key instanceof PGPSecretKey) {
-            error(filename + " has a Secret Key!");
-            return null;
-        }
-        return (PGPPublicKey)key;
-    }
-
-
-
-    /**
-     *  Read a Public Key from a filename and return the key.
-     *  It must be signed by the signer, if provided (can be null).
-     *  It must have the tag in it somewhere.
-     */
-    protected PGPPublicKey checkPublicKey(String filename,
-                                          String tag,
-                                          PGPPublicKey signer)
-    {
-        
-        PGPPublicKey pk = loadPublicKey(filename);
-        // check that the signer has signed
-
-        try {
-            pk = KeyUtil.stripAndVerifyKey(pk, tag, signer);
-
-        } catch (StripKeyException ex) {
-            error(ex.toString());
-            return null;
-        }
 
-        return pk;
-    }