[Webfunds-commits] java/webfunds/openpgp/cert SimpleOpenPGPCertificate.java

Jeroen C. van Gelderen gelderen@cypherpunks.ai
Wed, 16 Aug 2000 21:45:11 -0400 (AST)


gelderen    00/08/16 21:45:11

  Modified:    webfunds/openpgp/cert SimpleOpenPGPCertificate.java
  Log:
  - Redo the verify(...) method so that we check userIds on the verifyee
    instead of the verifier key passed in.
  - Make exceptions a bit more verbose.

Revision  Changes    Path
1.4       +9 -13     java/webfunds/openpgp/cert/SimpleOpenPGPCertificate.java

Index: SimpleOpenPGPCertificate.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/openpgp/cert/SimpleOpenPGPCertificate.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- SimpleOpenPGPCertificate.java	2000/08/16 21:19:19	1.3
+++ SimpleOpenPGPCertificate.java	2000/08/17 01:45:11	1.4
@@ -1,4 +1,4 @@
-/* $Id: SimpleOpenPGPCertificate.java,v 1.3 2000/08/16 21:19:19 gelderen Exp $
+/* $Id: SimpleOpenPGPCertificate.java,v 1.4 2000/08/17 01:45:11 gelderen Exp $
  *
  * Copyright (c) Systemics Ltd 2000 on behalf of
  * the WebFunds Development Team.  All Rights Reserved.
@@ -123,23 +123,18 @@
         throws CertificateException, NoSuchAlgorithmException,
                InvalidKeyException, NoSuchProviderException, SignatureException
     {
-    
-        if (! (key instanceof PGPPublicKey)) {
+        if (! (key instanceof PGPPublicKey))
             throw new InvalidKeyException("Key not of type: PGPPublicKey.");
-        }
         
         boolean allSigned = true;  // all UserIds are signed with the key
         boolean anySigned = false; // at least one is signed with the key
 
-        Vector userids = ((PGPPublicKey)key).getUserIDs();
-        System.out.println("SOPC: userids.size(): " + userids.size());
+        Vector userids = this.key.getUserIDs();
         
         for (int i=0; i<userids.size(); i++) {
             PGPUserID userid = (PGPUserID)userids.elementAt(i);
-            System.out.print("  userid: " + userid);
             try {
                 boolean isSigned = userid.isSignedBy((PGPPublicKey)key);
-                System.out.println(", isSigned: " + isSigned);
                 allSigned &= isSigned;
                 anySigned |= isSigned;
             } catch (PGPFatalDataFormatException fdfe) {
@@ -147,11 +142,12 @@
             }
         }
         
-        if ( !(anySigned && allSigned) ) {
-            throw new SignatureException("Not all userIDs are signed with "+
-                                         "the given key.");
-        }
-        
+        if( !allSigned )
+            throw new SignatureException(
+                "Not all userIds are signed with the given key.");
+
+        if ( !anySigned ) 
+            throw new SignatureException("No userIds present.");
     }