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

Ian Grigg iang@cypherpunks.ai
Sun, 3 Sep 2000 12:58:39 -0400 (AST)


iang        00/09/03 12:58:39

  Modified:    webfunds/client/contracts/wizard
                        SignContractWizardPanel.java
               webfunds/ricardian StripKeyException.java
  Log:
  slightly nicer error message on obvious unsigned case

Revision  Changes    Path
1.4       +14 -9     java/webfunds/client/contracts/wizard/SignContractWizardPanel.java

Index: SignContractWizardPanel.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/client/contracts/wizard/SignContractWizardPanel.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- SignContractWizardPanel.java	2000/08/28 18:10:53	1.3
+++ SignContractWizardPanel.java	2000/09/03 16:58:38	1.4
@@ -1,5 +1,5 @@
 /*
- * $Id: SignContractWizardPanel.java,v 1.3 2000/08/28 18:10:53 edwin Exp $
+ * $Id: SignContractWizardPanel.java,v 1.4 2000/09/03 16:58:38 iang Exp $
  *
  * Copyright (c) Systemics Inc 2000 on behalf of
  * the WebFunds Development Team.  All Rights Reserved.
@@ -27,7 +27,7 @@
  * sign contract wizard.
  *
  * @author Edwin Woudt <edwin@webfunds.org>
- * @version $Revision: 1.3 $
+ * @version $Revision: 1.4 $
  */
 
 public abstract class SignContractWizardPanel extends WizardPanel {
@@ -113,10 +113,10 @@
 
         // first, recover the top key
         PGPPublicKey topKey;
+        String topTag = Contract.USERID_TOP_LEVEL;
         try {
-            topKey = KeyUtil.checkArmouredPublicKey(top,
-                                           Contract.USERID_TOP_LEVEL,
-                                           null);
+            topKey = KeyUtil.checkArmouredPublicKey(top, topTag, null);
+
         } catch (StripKeyException ex) {
             error("certification key error (cannot check contract key): " + ex);
             return null;
@@ -126,12 +126,17 @@
         }
 
         PGPPublicKey key;
+        String tag = Contract.USERID_CONTRACT;
         try {
-            key = KeyUtil.checkArmouredPublicKey(s,
-                                           Contract.USERID_CONTRACT,
-                                           topKey);
+            key = KeyUtil.checkArmouredPublicKey(s, tag, topKey);
+
         } catch (StripKeyException ex) {
-            error(ex.toString());
+            int errno = ex.getErrno();
+            if (errno == StripKeyException.NOT_SIGNED)
+                error("Your " + tag + " key is not signed by your " +
+                      topTag + " key\n\n" + ex.getErrnoString());
+            else
+                error(ex.toString());
             return null;
         } catch (ArmouredKeyException ex) {
             error(ex.toString());



1.4       +11 -3     java/webfunds/ricardian/StripKeyException.java

Index: StripKeyException.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/ricardian/StripKeyException.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- StripKeyException.java	2000/08/28 14:38:32	1.3
+++ StripKeyException.java	2000/09/03 16:58:39	1.4
@@ -1,5 +1,5 @@
 /*
- * $Id: StripKeyException.java,v 1.3 2000/08/28 14:38:32 edwin Exp $
+ * $Id: StripKeyException.java,v 1.4 2000/09/03 16:58:39 iang Exp $
  *
  * Copyright (c) 2000 Systemics Inc on behalf of
  * the WebFunds Development Team.  All Rights Reserved.
@@ -55,8 +55,16 @@
     {
         String s = "";
         if (errno > 0)
-            s += getErrnoString() + ": ";
-        s += super.toString();
+            s += getErrnoString();
+
+        String sup = super.toString();
+        if (sup != null && sup.length() > 0)
+        {
+            if (s.length() > 0)
+                s += ": ";
+            s += super.toString();
+        }
+
         return s;
     }