Top Description Fields Constructors Methods
org.apache.pdfbox.pdmodel.encryption

public final Class PublicKeySecurityHandler

extends SecurityHandler<PublicKeyProtectionPolicy>
Class Inheritance
Imports
java.io.ByteArrayOutputStream, .IOException, java.math.BigInteger, java.security.AlgorithmParameterGenerator, .AlgorithmParameters, .GeneralSecurityException, .InvalidKeyException, .KeyStoreException, .NoSuchAlgorithmException, .PrivateKey, .Provider, .SecureRandom, java.security.cert.CertificateEncodingException, .X509Certificate, java.util.Collection, .Iterator, javax.crypto.BadPaddingException, .Cipher, .IllegalBlockSizeException, .KeyGenerator, .NoSuchPaddingException, .SecretKey, org.apache.pdfbox.cos.COSArray, .COSName, .COSString, org.apache.pdfbox.pdmodel.PDDocument, org.bouncycastle.asn1.ASN1Encoding, .ASN1InputStream, .ASN1ObjectIdentifier, .ASN1Primitive, .ASN1Set, .DEROctetString, .DERSet, org.bouncycastle.asn1.cms.ContentInfo, .EncryptedContentInfo, .EnvelopedData, .IssuerAndSerialNumber, .KeyTransRecipientInfo, .RecipientIdentifier, .RecipientInfo, org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers, org.bouncycastle.asn1.x509.AlgorithmIdentifier, .TBSCertificate, org.bouncycastle.cert.X509CertificateHolder, org.bouncycastle.cms.CMSEnvelopedData, .CMSException, .KeyTransRecipientId, .RecipientId, .RecipientInformation, org.bouncycastle.cms.jcajce.JceKeyTransEnvelopedRecipient, org.bouncycastle.util.Arrays

This class implements the public key security handler described in the PDF specification.
Author
Benoit Guillon
See Also
to see how to protect document with this security handler.

Field Summary

Modifier and TypeField and Description
public static final String
FILTER

The filter name.

private static final String
private static final String

Constructor Summary

AccessConstructor and Description
public
public
PublicKeySecurityHandler(PublicKeyProtectionPolicy
The protection policy.
publicKeyProtectionPolicy
)

Constructor used for encryption.

Method Summary

Modifier and TypeMethod and Description
private void
private KeyTransRecipientInfo
computeRecipientInfo(X509Certificate x509certificate, byte[] abyte0)

private byte[][]
private ASN1Primitive
public void
prepareDocumentForEncryption(PDDocument
The document that will be encrypted.
doc
)

Implements abstract org.apache.pdfbox.pdmodel.encryption.SecurityHandler.prepareDocumentForEncryption.

Prepare the document for encryption.

private void
prepareEncryptionDictAES(PDEncryption encryptionDictionary, COSName aesVName, byte[][] recipients)

public void
prepareForDecryption(PDEncryption
encryption dictionary, can be retrieved via PDDocument#getEncryption()
encryption
,
COSArray
document id which is returned via org.apache.pdfbox.cos.COSDocument#getDocumentID() (not used by this handler)
documentIDArray
,
DecryptionMaterial
Information used to decrypt the document.
decryptionMaterial
)

Implements abstract org.apache.pdfbox.pdmodel.encryption.SecurityHandler.prepareForDecryption.

Prepares everything to decrypt the document.

Inherited from org.apache.pdfbox.pdmodel.encryption.SecurityHandler:
computeVersionNumberdecryptdecryptStreamencryptDataRC4encryptDataRC4encryptStreamencryptStringgetCurrentAccessPermissiongetEncryptionKeygetKeyLengthgetProtectionPolicyhasProtectionPolicyisAESisDecryptMetadatasetAESsetCurrentAccessPermissionsetCustomSecureRandomsetDecryptMetadatasetEncryptionKeysetKeyLengthsetProtectionPolicysetStreamFilterNamesetStringFilterName

Field Detail

FILTERback to summary
public static final String FILTER

The filter name.

SUBFILTER4back to summary
private static final String SUBFILTER4
SUBFILTER5back to summary
private static final String SUBFILTER5

Constructor Detail

PublicKeySecurityHandlerback to summary
public PublicKeySecurityHandler()

Constructor.

PublicKeySecurityHandlerback to summary
public PublicKeySecurityHandler(PublicKeyProtectionPolicy publicKeyProtectionPolicy)

Constructor used for encryption.

Parameters
publicKeyProtectionPolicy:PublicKeyProtectionPolicy

The protection policy.

Method Detail

appendCertInfoback to summary
private void appendCertInfo(StringBuilder extraInfo, KeyTransRecipientId ktRid, X509Certificate certificate, X509CertificateHolder materialCert)
computeRecipientInfoback to summary
private KeyTransRecipientInfo computeRecipientInfo(X509Certificate x509certificate, byte[] abyte0) throws IOException, CertificateEncodingException, InvalidKeyException, BadPaddingException, IllegalBlockSizeException
computeRecipientsFieldback to summary
private byte[][] computeRecipientsField(byte[] seed) throws GeneralSecurityException, IOException
createDERForRecipientback to summary
private ASN1Primitive createDERForRecipient(byte[] in, X509Certificate cert) throws IOException, GeneralSecurityException
prepareDocumentForEncryptionback to summary
public void prepareDocumentForEncryption(PDDocument doc) throws IOException

Implements abstract org.apache.pdfbox.pdmodel.encryption.SecurityHandler.prepareDocumentForEncryption.

Prepare the document for encryption.

Parameters
doc:PDDocument

The document that will be encrypted.

Annotations
@Override
Exceptions
IOException:
If there is an error while encrypting.
prepareEncryptionDictAESback to summary
private void prepareEncryptionDictAES(PDEncryption encryptionDictionary, COSName aesVName, byte[][] recipients)
prepareForDecryptionback to summary
public void prepareForDecryption(PDEncryption encryption, COSArray documentIDArray, DecryptionMaterial decryptionMaterial) throws IOException

Implements abstract org.apache.pdfbox.pdmodel.encryption.SecurityHandler.prepareForDecryption.

Prepares everything to decrypt the document.

Parameters
encryption:PDEncryption

encryption dictionary, can be retrieved via PDDocument#getEncryption()

documentIDArray:COSArray

document id which is returned via org.apache.pdfbox.cos.COSDocument#getDocumentID() (not used by this handler)

decryptionMaterial:DecryptionMaterial

Information used to decrypt the document.

Annotations
@Override
Exceptions
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.