You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ti...@apache.org on 2014/10/29 18:26:15 UTC
svn commit: r1635211 -
/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/PublicKeySecurityHandler.java
Author: tilman
Date: Wed Oct 29 17:26:15 2014
New Revision: 1635211
URL: http://svn.apache.org/r1635211
Log:
PDFBOX-2460: member var to enable verbose mode
Modified:
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/PublicKeySecurityHandler.java
Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/PublicKeySecurityHandler.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/PublicKeySecurityHandler.java?rev=1635211&r1=1635210&r2=1635211&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/PublicKeySecurityHandler.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/PublicKeySecurityHandler.java Wed Oct 29 17:26:15 2014
@@ -91,6 +91,8 @@ public final class PublicKeySecurityHand
private static final String SUBFILTER = "adbe.pkcs7.s4";
private PublicKeyProtectionPolicy policy = null;
+
+ private boolean verbose = false;
/**
* Constructor.
@@ -100,6 +102,16 @@ public final class PublicKeySecurityHand
}
/**
+ * Enable or disable verbose mode. Default is disabled.
+ *
+ * @param verbose true if enabled, false if disabled.
+ */
+ public void setVerbose(boolean verbose)
+ {
+ this.verbose = verbose;
+ }
+
+ /**
* Constructor used for encryption.
*
* @param p The protection policy.
@@ -133,14 +145,20 @@ public final class PublicKeySecurityHand
/**
* Prepares everything to decrypt the document.
*
- * If {@link #decryptDocument(PDDocument, DecryptionMaterial)} is used, this method is
- * called from there. Only if decryption of single objects is needed this should be called instead.
+ * If {@link #decryptDocument(PDDocument, DecryptionMaterial)} is used, this
+ * method is called from there. Only if decryption of single objects is
+ * needed this should be called instead.
*
- * @param encryption encryption dictionary, can be retrieved via {@link PDDocument#getEncryption()}
- * @param documentIDArray document id which is returned via {@link org.apache.pdfbox.cos.COSDocument#getDocumentID()} (not used by this handler)
+ * @param encryption encryption dictionary, can be retrieved via
+ * {@link PDDocument#getEncryption()}
+ * @param documentIDArray document id which is returned via
+ * {@link org.apache.pdfbox.cos.COSDocument#getDocumentID()} (not used by
+ * this handler)
* @param decryptionMaterial Information used to decrypt the document.
*
- * @throws IOException If there is an error accessing data.
+ * @throws IOException If there is an error accessing data. If verbose mode
+ * is enabled, the exception message will provide more details why the the
+ * match wasn't successful.
*/
@Override
public void prepareForDecryption(PDEncryption encryption, COSArray documentIDArray,
@@ -202,7 +220,7 @@ public final class PublicKeySecurityHand
break;
}
j++;
- if (LOG.isDebugEnabled() && certificate != null)
+ if ((verbose || LOG.isDebugEnabled()) && certificate != null)
{
extraInfo += "\n" + j + ": ";
if (rid instanceof KeyTransRecipientId)