Class PublicKeySecurityHandler
java.lang.Object
org.apache.pdfbox.pdmodel.encryption.SecurityHandler
org.apache.pdfbox.pdmodel.encryption.PublicKeySecurityHandler
This class implements the public key security handler described in the PDF specification.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
The filter name.private static final String
private static final String
Fields inherited from class org.apache.pdfbox.pdmodel.encryption.SecurityHandler
encryptionKey, keyLength
-
Constructor Summary
ConstructorsConstructorDescriptionConstructor.PublicKeySecurityHandler
(PublicKeyProtectionPolicy publicKeyProtectionPolicy) Constructor used for encryption. -
Method Summary
Modifier and TypeMethodDescriptionprivate void
appendCertInfo
(StringBuilder extraInfo, org.bouncycastle.cms.KeyTransRecipientId ktRid, X509Certificate certificate, org.bouncycastle.cert.X509CertificateHolder materialCert) private org.bouncycastle.asn1.cms.KeyTransRecipientInfo
computeRecipientInfo
(X509Certificate x509certificate, byte[] abyte0) private byte[][]
computeRecipientsField
(byte[] seed) private org.bouncycastle.asn1.ASN1Primitive
createDERForRecipient
(byte[] in, X509Certificate cert) void
Prepare the document for encryption.private void
prepareEncryptionDictAES
(PDEncryption encryptionDictionary, COSName aesVName, byte[][] recipients) void
prepareForDecryption
(PDEncryption encryption, COSArray documentIDArray, DecryptionMaterial decryptionMaterial) Prepares everything to decrypt the document.Methods inherited from class org.apache.pdfbox.pdmodel.encryption.SecurityHandler
computeVersionNumber, decrypt, decryptStream, encryptDataRC4, encryptDataRC4, encryptStream, encryptString, getCurrentAccessPermission, getEncryptionKey, getKeyLength, getProtectionPolicy, hasProtectionPolicy, isAES, isDecryptMetadata, setAES, setCurrentAccessPermission, setCustomSecureRandom, setDecryptMetadata, setEncryptionKey, setKeyLength, setProtectionPolicy, setStreamFilterName, setStringFilterName
-
Field Details
-
FILTER
The filter name.- See Also:
-
SUBFILTER4
- See Also:
-
SUBFILTER5
- See Also:
-
-
Constructor Details
-
PublicKeySecurityHandler
public PublicKeySecurityHandler()Constructor. -
PublicKeySecurityHandler
Constructor used for encryption.- Parameters:
publicKeyProtectionPolicy
- The protection policy.
-
-
Method Details
-
prepareForDecryption
public void prepareForDecryption(PDEncryption encryption, COSArray documentIDArray, DecryptionMaterial decryptionMaterial) throws IOException Prepares everything to decrypt the document.- Specified by:
prepareForDecryption
in classSecurityHandler
- Parameters:
encryption
- encryption dictionary, can be retrieved viaPDDocument.getEncryption()
documentIDArray
- document id which is returned viaCOSDocument.getDocumentID()
(not used by this handler)decryptionMaterial
- Information used to decrypt the document.- Throws:
IOException
- If there is an error accessing data. If verbose mode is enabled, the exception message will provide more details why the match wasn't successful.
-
appendCertInfo
private void appendCertInfo(StringBuilder extraInfo, org.bouncycastle.cms.KeyTransRecipientId ktRid, X509Certificate certificate, org.bouncycastle.cert.X509CertificateHolder materialCert) -
prepareDocumentForEncryption
Prepare the document for encryption.- Specified by:
prepareDocumentForEncryption
in classSecurityHandler
- Parameters:
doc
- The document that will be encrypted.- Throws:
IOException
- If there is an error while encrypting.
-
prepareEncryptionDictAES
private void prepareEncryptionDictAES(PDEncryption encryptionDictionary, COSName aesVName, byte[][] recipients) -
computeRecipientsField
- Throws:
GeneralSecurityException
IOException
-
createDERForRecipient
private org.bouncycastle.asn1.ASN1Primitive createDERForRecipient(byte[] in, X509Certificate cert) throws IOException, GeneralSecurityException - Throws:
IOException
GeneralSecurityException
-
computeRecipientInfo
private org.bouncycastle.asn1.cms.KeyTransRecipientInfo computeRecipientInfo(X509Certificate x509certificate, byte[] abyte0) throws IOException, CertificateEncodingException, InvalidKeyException, BadPaddingException, IllegalBlockSizeException
-