Author: dennisl
Date: Sat Apr 17 13:05:42 2010
New Revision: 935172

URL: http://svn.apache.org/viewvc?rev=935172&view=rev
Log:
If the secret keyring does not contain the specified key an OpenPgpException is 
thrown indicating what the problem is. The previous behavior was that an NPE 
was thrown but not handled.

Modified:
    
commons/sandbox/openpgp/trunk/src/main/java/org/apache/commons/openpgp/BouncyCastleOpenPgpStreamingSigner.java

Modified: 
commons/sandbox/openpgp/trunk/src/main/java/org/apache/commons/openpgp/BouncyCastleOpenPgpStreamingSigner.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/openpgp/trunk/src/main/java/org/apache/commons/openpgp/BouncyCastleOpenPgpStreamingSigner.java?rev=935172&r1=935171&r2=935172&view=diff
==============================================================================
--- 
commons/sandbox/openpgp/trunk/src/main/java/org/apache/commons/openpgp/BouncyCastleOpenPgpStreamingSigner.java
 (original)
+++ 
commons/sandbox/openpgp/trunk/src/main/java/org/apache/commons/openpgp/BouncyCastleOpenPgpStreamingSigner.java
 Sat Apr 17 13:05:42 2010
@@ -86,6 +86,10 @@ public class BouncyCastleOpenPgpStreamin
         try
         {
             PGPSecretKey pgpSec = keyRing.getSecretKey( keyId );
+            if ( pgpSec == null )
+            {
+                throw new OpenPgpException( "The key with id '" + keyId + "' 
was not found in the secret keyring." );
+            }
             PGPPrivateKey pgpPrivKey = pgpSec.extractPrivateKey( 
keyRing.getPassword(), PROVIDER );
             sGen = new PGPSignatureGenerator( 
pgpSec.getPublicKey().getAlgorithm(), PGPUtil.SHA1, PROVIDER );
             sGen.initSign( PGPSignature.BINARY_DOCUMENT, pgpPrivKey );


Reply via email to