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 2016/08/13 12:12:24 UTC
svn commit: r1756254 -
/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/PublicKeySecurityHandler.java
Author: tilman
Date: Sat Aug 13 12:12:24 2016
New Revision: 1756254
URL: http://svn.apache.org/viewvc?rev=1756254&view=rev
Log:
PDFBOX-3462: improve exception text for NoSuchAlgorithmException; code cleanup
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=1756254&r1=1756253&r2=1756254&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 Sat Aug 13 12:12:24 2016
@@ -317,8 +317,10 @@ public final class PublicKeySecurityHand
key.init(192, new SecureRandom());
SecretKey sk = key.generateKey();
- System.arraycopy(sk.getEncoded(), 0, seed, 0, 20); // create the 20 bytes seed
-
+
+ // create the 20 bytes seed
+ System.arraycopy(sk.getEncoded(), 0, seed, 0, 20);
+
byte[][] recipientsField = computeRecipientsField(seed);
dictionary.setRecipients(recipientsField);
@@ -377,9 +379,10 @@ public final class PublicKeySecurityHand
byte two = (byte)(permission >>> 8);
byte three = (byte)(permission >>> 16);
byte four = (byte)(permission >>> 24);
-
- System.arraycopy(seed, 0, pkcs7input, 0, 20); // put this seed in the pkcs7 input
-
+
+ // put this seed in the pkcs7 input
+ System.arraycopy(seed, 0, pkcs7input, 0, 20);
+
pkcs7input[20] = four;
pkcs7input[21] = three;
pkcs7input[22] = two;
@@ -389,9 +392,9 @@ public final class PublicKeySecurityHand
ByteArrayOutputStream baos = new ByteArrayOutputStream();
- DEROutputStream k = new DEROutputStream(baos);
+ DEROutputStream derOS = new DEROutputStream(baos);
- k.writeObject(obj);
+ derOS.writeObject(obj);
recipientsField[i] = baos.toByteArray();
@@ -415,8 +418,9 @@ public final class PublicKeySecurityHand
}
catch (NoSuchAlgorithmException e)
{
- // should never happen, if this happens throw IOException instead
- throw new RuntimeException("Could not find a suitable javax.crypto provider", e);
+ // happens when using the command line app .jar file
+ throw new IOException("Could not find a suitable javax.crypto provider for algorithm " +
+ algorithm + "; possible reason: using an unsigned .jar file", e);
}
catch (NoSuchPaddingException e)
{