Samples and examples in this document are only for AEM Forms on JEE environment.
About the Encryption Service
The Encryption service lets you encrypt and decrypt documents. When a document is encrypted, its contents become unreadable. An authorized user can decrypt the document to obtain access to the contents. If a PDF document is encrypted with a password, the user must specify the open password before the document can be viewed in Adobe Reader or Adobe Acrobat. Likewise, if a PDF document is encrypted with a certificate, the user must decrypt the PDF document with the public key that corresponds to the certificate (private key) that was used to encrypt the PDF document.
You can accomplish these tasks using the Encryption service:
For more information about the Encryption service, see Services Reference for AEM Forms.
When you encrypt a PDF document with a password, a user must specify the password to open the PDF document in Adobe Reader or Acrobat. Also, before another AEM Forms operation, such as digitally signing the PDF document, can be performed on the document, a password-encrypted PDF document must be unlocked.
If you upload an encrypted PDF document to the AEM Forms repository, it cannot decrypt the PDF document and extract the XDP content. It is recommended that you do not encrypt a document prior to uploading it to the AEM Forms repository. (See Writing Resources.)
For more information about the Encryption service, see Services Reference for AEM Forms.
To encrypt a PDF document with a password, perform the following steps:
Include project files
Include necessary files in your development project. If you are creating a client application using Java, include the necessary JAR files. If you are using web services, ensure that you include the proxy files.
The following JAR files must be added to your project’s class path:
Create an Encryption Client API object
To programmatically perform an Encryption service operation, you must create an Encryption service client.
Get a PDF document to encrypt
You must obtain an unencrypted PDF document to encrypt the document with a password. If you attempt to secure a PDF document that is already encrypted, you cause an exception.
Set encryption run-time options
To encrypt a PDF document with a password, you specify four values, including two password values. The first password value is used to encrypt the PDF document and must be specified when opening the PDF document. The second password value, named the master password value, is used to remove encryption from the PDF document. Password values are case sensitive, and these two password values cannot be the same values.
You must specify the PDF document resources to encrypt. You can encrypt the entire PDF document, everything except for the document’s metadata, or just the document’s attachments. If you encrypt only the document’s attachments, a user is prompted for a password when they attempt to access the file attachments.
When encrypting a PDF document, you can specify permissions that are associated with the secured document. By specifying permissions, you can control the actions that a user who opens a password-encrypted PDF document is allowed to perform. For example to successfully extract form data, you must set the following permissions:
Permissions are specified as PasswordEncryptionPermission
enumeration values.
Add the password
After you retrieve an unsecured PDF document and set encryption run-time values, you can add a password to the PDF document.
Save the encrypted PDF document as a PDF file
You can save the password-encrypted PDF document as a PDF file.
See also
Encrypt a PDF document using the Java API
Encrypting a PDF document using the web service API
Including AEM Forms Java library files
Encryption Service API Quick Starts
Encrypting PDF Documents with Certificates
Encrypt a PDF document with a password by using the Encryption API (Java):
Include project files.
Include client JAR files, such as adobe-encryption-client.jar, in your Java project’s class path.
Create an Encryption Client API.
ServiceClientFactory
object that contains connection properties.EncryptionServiceClient
object by using its constructor and passing the ServiceClientFactory
object.Get a PDF document to encrypt.
java.io.FileInputStream
object that represents the PDF document to encrypt by using its constructor and passing a string value that specifies the location of the PDF document.com.adobe.idp.Document
object by using its constructor and passing the java.io.FileInputStream
object.Set encryption run-time options.
PasswordEncryptionOptionSpec
object by invoking its constructor.PasswordEncryptionOptionSpec
object’s setEncryptOption
method and passing a PasswordEncryptionOption
enumeration value that specifies the document resources to encrypt. For example, to encrypt the entire PDF document, including its metadata and its attachments, specify PasswordEncryptionOption.ALL
.java.util.List
object that stores the encryption permissions by using the ArrayList
constructor.java.util.List
object ‘s add
method and passing an enumeration value that corresponds to the permission that you want to set. For example, to set the permission that lets a user copy data located in the PDF document, specify PasswordEncryptionPermission.PASSWORD_EDIT_COPY
. (Repeat this step for each permission to set).PasswordEncryptionOptionSpec
object’s setCompatability
method and passing an enumeration value that specifies the Acrobat compatibility level. For example, you can specify PasswordEncryptionCompatability.ACRO_7
.PasswordEncryptionOptionSpec
object’s setDocumentOpenPassword
method and passing a string value that represents the open password.PasswordEncryptionOptionSpec
object’s setPermissionPassword
method and passing a string value that represents the master password.Add the password.
Encrypt the PDF document by invoking the EncryptionServiceClient
object’s encryptPDFUsingPassword
method and passing the following values:
com.adobe.idp.Document
object that contains the PDF document to encrypt with the password.PasswordEncryptionOptionSpec
object that contains encryption run-time options.The encryptPDFUsingPassword
method returns a com.adobe.idp.Document
object that contains a password-encrypted PDF document.
Save the encrypted PDF document as a PDF file.
java.io.File
object and ensure that the file extension is .pdf.com.adobe.idp.Document
object’s copyToFile
method to copy the contents of the com.adobe.idp.Document
object to the file. Ensure that you use the com.adobe.idp.Document
object that was returned by the encryptPDFUsingPassword
method.See also
Quick Start (SOAP mode): Encrypting a PDF document using the Java API
Including AEM Forms Java library files
Encrypt a PDF document with a password by using the Encryption API (web service):
Include project files.
Create a Microsoft .NET project that uses MTOM. Ensure that you use the following WSDL definition: http://localhost:8080/soap/services/EncryptionService?WSDL&lc_version=9.0.1
.
Replace localhost
with the IP address of the server hosting AEM Forms.
Create an Encryption Client API object.
Create an EncryptionServiceClient
object by using its default constructor.
Create an EncryptionServiceClient.Endpoint.Address
object by using the System.ServiceModel.EndpointAddress
constructor. Pass a string value that specifies the WSDL to the AEM Forms service (for example, http://localhost:8080/soap/services/EncryptionService?WSDL
.) You do not need to use the lc_version
attribute. This attribute is used when you create a service reference.)
Create a System.ServiceModel.BasicHttpBinding
object by getting the value of the EncryptionServiceClient.Endpoint.Binding
field. Cast the return value to BasicHttpBinding
.
Set the System.ServiceModel.BasicHttpBinding
object’s MessageEncoding
field to WSMessageEncoding.Mtom
. This value ensures that MTOM is used.
Enable basic HTTP authentication by performing the following tasks:
EncryptionServiceClient.ClientCredentials.UserName.UserName
.EncryptionServiceClient.ClientCredentials.UserName.Password
.HttpClientCredentialType.Basic
to the field BasicHttpBindingSecurity.Transport.ClientCredentialType
.BasicHttpSecurityMode.TransportCredentialOnly
to the field BasicHttpBindingSecurity.Security.Mode
.Get a PDF document to encrypt.
BLOB
object by using its constructor. The BLOB
object is used to store a PDF document that is encrypted with a password.System.IO.FileStream
object by invoking its constructor and passing a string value that represents the file location of the PDF document to encrypt and the mode in which to open the file.System.IO.FileStream
object. You can determine the size of the byte array by getting the System.IO.FileStream
object’s Length
property.System.IO.FileStream
object’s Read
method and passing the byte array, the starting position, and the stream length to read.BLOB
object by assigning the contents of the byte array to the BLOB
object’s MTOM
data member.Set encryption run-time options.
PasswordEncryptionOptionSpec
object by using its constructor.PasswordEncryptionOption
enumeration value to the PasswordEncryptionOptionSpec
object’s encryptOption
data member. To encrypt the entire PDF, including its metadata and its attachments, assign PasswordEncryptionOption.ALL
to this data member.PasswordEncryptionCompatability
enumeration value to the PasswordEncryptionOptionSpec
object’s compatability
data member. For example, assign PasswordEncryptionCompatability.ACRO_7
to this data member.PasswordEncryptionOptionSpec
object’s documentOpenPassword
data member.PasswordEncryptionOptionSpec
object’s permissionPassword
data member.Add the password.
Encrypt the PDF document by invoking the EncryptionServiceClient
object’s encryptPDFUsingPassword
method and passing the following values:
BLOB
object that contains the PDF document to encrypt with the password.PasswordEncryptionOptionSpec
object that contains encryption run-time options.The encryptPDFUsingPassword
method returns a BLOB
object that contains a password-encrypted PDF document.
Save the encrypted PDF document as a PDF file.
System.IO.FileStream
object by invoking its constructor and passing a string value that represents the file location of the secured PDF document.BLOB
object that was returned by the encryptPDFUsingPassword
method. Populate the byte array by getting the value of the BLOB
object’s MTOM
data member.System.IO.BinaryWriter
object by invoking its constructor and passing the System.IO.FileStream
object.System.IO.BinaryWriter
object’s Write
method and passing the byte array.See also
Invoking AEM Forms using SwaRef
Certificate-based encryption lets you encrypt a document for specific recipients by means of public key technology. Various recipients can be given different permissions for the document. Many aspects of encryption are made possible by public key technology. An algorithm is used to generate two large numbers, known as keys, that have the following properties:
One of the keys acts as a user’s private key. It is important that only the user has access to this key. The other key is the user’s public key, which can be shared with others.
A public key certificate contains a user’s public key and identifying information. The X.509 format is used for storing certificates. Certificates are typically issued and digitally signed by a certificate authority (CA), which is a recognized entity that provides a measure of confidence in the validity of the certificate. Certificates have an expiration date, after which they are no longer valid. In addition, certificate revocation lists (CRLs) provide information about certificates that were revoked prior to their expiration date. CRLs are published periodically by certificate authorities. The revocation status of a certificate can also be retrieved through Online Certificate Status Protocol (OCSP) over the network.
If you upload an encrypted PDF document to the AEM Forms repository, it cannot decrypt the PDF document and extract the XDP content. It is recommended that you do not encrypt a document prior to uploading it to the AEM Forms repository. (See Writing Resources.)
Before you can encrypt a PDF document with a certificate, you must ensure that you add the certificate to AEM Forms. A certificate is added using administration console or programmatically using the Trust Manager API. (See Importing Credentials by using the Trust Manager API.)
For more information about the Encryption service, see Services Reference for AEM Forms.
To encrypt a PDF document with a certificate, perform the following steps:
Include project files
Include the necessary files in your development project. If you are creating a client application by using Java, include the necessary JAR files. If you are using web services, ensure that you include the proxy files.
The following JAR files must be added to your project’s class path:
Create an Encryption Client API object
To programmatically perform an Encryption service operation, you must create an Encryption service client. If you are using the Java Encryption Service API, create an EncrytionServiceClient
object. If you are using the web service Encryption Service API, create an EncryptionServiceService
object.
Get a PDF document to encrypt
You must obtain an unencrypted PDF document to encrypt. If you attempt to secure a PDF document that is already encrypted, an exception is thrown.
Reference the certificate
To encrypt a PDF document with a certificate, reference a certificate that is used to encrypt a PDF document. The certificate is a .cer file, a .crt file, or a .pem file. A PKCS#12 file is used to store private keys with corresponding certificates.
When encrypting a PDF document with a certificate, specify permissions that are associated with the secured document. By specifying permissions, you can control the actions that a user who opens a certificate-encrypted PDF document can perform.
Set encryption run-time options
Specify the PDF document resources to encrypt. You can encrypt the entire PDF document, everything except the document’s metadata, or only the document’s attachments.
Create a certificate-encrypted PDF document
After you retrieve an unsecured PDF document, reference the certificate, and set run-time options, you can create a certificate-encrypted PDF document. After the PDF document is encrypted, you need the corresponding public key to decrypt it.
Save the encrypted PDF document as a PDF file
You can save the encrypted PDF document as a PDF file.
See also
Encrypt a PDF document with a certificate using the Java API
Encrypt a PDF document with a certificate using the web service API
Including AEM Forms Java library files
Encryption Service API Quick Starts
Encrypting PDF Documents with a Password
Encrypt a PDF document with a certificate by using the Encryption API (Java):
Include project files.
Include client JAR files, such as adobe-encryption-client.jar, in your Java project’s class path.
Create an Encryption Client API object.
ServiceClientFactory
object that contains connection properties.EncryptionServiceClient
object by using its constructor and passing the ServiceClientFactory
object.Get a PDF document to encrypt.
java.io.FileInputStream
object that represents the PDF document to encrypt by using its constructor and passing a string value that specifies the location of the PDF document.com.adobe.idp.Document
object by using its constructor and passing the java.io.FileInputStream
object.Reference the certificate.
java.util.List
object that stores permission information by using its constructor.java.util.List
object’s add
method and passing a CertificateEncryptionPermissions
enumeration value that represents the permissions that are granted to the user who opens the secured PDF document. For example, to specify all permissions, pass CertificateEncryptionPermissions.PKI_ALL_PERM
.Recipient
object by using its constructor.java.io.FileInputStream
object that represents the certificate that is used to encrypt the PDF document by using its constructor and passing a string value that specifies the location of the certificate.com.adobe.idp.Document
object by using its constructor and passing the java.io.FileInputStream
object that represents the certificate.Recipient
object’s setX509Cert
method and pass the com.adobe.idp.Document
object that contains the certificate. (In addition, the Recipient
object can have a Truststore certificate alias or LDAP URL as a certificate source.)CertificateEncryptionIdentity
object that stores permission and certificate information by using its constructor.CertificateEncryptionIdentity
object’s setPerms
method and pass the java.util.List
object that stores permission information.CertificateEncryptionIdentity
object’s setRecipient
method and pass the Recipient
object that stores certificate information.java.util.List
object that stores certificate information by using its constructor.java.util.List
object’s add method and pass the CertificateEncryptionIdentity
object. (This java.util.List
object is passed as a parameter to the encryptPDFUsingCertificates
method.)Set encryption run-time options.
CertificateEncryptionOptionSpec
object by invoking its constructor.CertificateEncryptionOptionSpec
object’s setOption
method and passing a CertificateEncryptionOption
enumeration value that specifies the document resources to encrypt. For example, to encrypt the entire PDF document, including its metadata and its attachments, specify CertificateEncryptionOption.ALL
.CertificateEncryptionOptionSpec
object’s setCompat
method and passing a CertificateEncryptionCompatibility
enumeration value that specifies the Acrobat compatibility level. For example, you can specify CertificateEncryptionCompatibility.ACRO_7
.Create a certificate-encrypted PDF document.
Encrypt the PDF document with a certificate by invoking the EncryptionServiceClient
object’s encryptPDFUsingCertificates
method and passing the following values:
com.adobe.idp.Document
object that contains the PDF document to encrypt.java.util.List
object that stores certificate information.CertificateEncryptionOptionSpec
object that contains encryption run-time options.The encryptPDFUsingCertificates
method returns a com.adobe.idp.Document
object that contains a certificate-encrypted PDF document.
Save the encrypted PDF document as a PDF file.
java.io.File
object and ensure that the file name extension is .pdf.com.adobe.idp.Document
object’s copyToFile
method to copy the contents of the com.adobe.idp.Document
object to the file. Ensure that you use the com.adobe.idp.Document
object that was returned by the encryptPDFUsingCertificates
method.See also
Quick Start (SOAP mode): Encrypting a PDF document with a certificate using the Java API
Including AEM Forms Java library files
Encrypt a PDF document with a certificate by using the Encryption API (web service):
Include project files.
Create a Microsoft .NET project that uses MTOM. Ensure that you use the following WSDL definition: http://localhost:8080/soap/services/EncryptionService?WSDL&lc_version=9.0.1
.
Replace localhost
with the IP address of the server hosting AEM Forms.
Create an Encryption Client API object.
Create an EncryptionServiceClient
object by using its default constructor.
Create an EncryptionServiceClient.Endpoint.Address
object by using the System.ServiceModel.EndpointAddress
constructor. Pass a string value that specifies the WSDL to the AEM Forms service (for example, http://localhost:8080/soap/services/EncryptionService?WSDL
.) You do not need to use the lc_version
attribute. This attribute is used when you create a service reference.)
Create a System.ServiceModel.BasicHttpBinding
object by getting the value of the EncryptionServiceClient.Endpoint.Binding
field. Cast the return value to BasicHttpBinding
.
Set the System.ServiceModel.BasicHttpBinding
object’s MessageEncoding
field to WSMessageEncoding.Mtom
. This value ensures that MTOM is used.
Enable basic HTTP authentication by performing the following tasks:
EncryptionServiceClient.ClientCredentials.UserName.UserName
.EncryptionServiceClient.ClientCredentials.UserName.Password
.HttpClientCredentialType.Basic
to the field BasicHttpBindingSecurity.Transport.ClientCredentialType
.BasicHttpSecurityMode.TransportCredentialOnly
to the field BasicHttpBindingSecurity.Security.Mode
.Get a PDF document to encrypt.
BLOB
object by using its constructor. The BLOB
object is used to store a PDF document that is encrypted with a certificate.System.IO.FileStream
object by invoking its constructor and passing a string value that represents the file location of the PDF document to encrypt and the mode in which to open the file.System.IO.FileStream
object. You can determine the size of the byte array by getting the System.IO.FileStream
object’s Length
property.System.IO.FileStream
object’s Read
method and passing the byte array, the starting position, and the stream length to read.BLOB
object by assigning its MTOM
property with the contents of the byte array.Reference the certificate.
Recipient
object by using its constructor. This object will store certificate information.BLOB
object by using its constructor. This BLOB
object will store the certificate that encrypts the PDF document.System.IO.FileStream
object by invoking its constructor and passing a string value that represents the file location of the certificate and the mode in which to open the file.System.IO.FileStream
object. You can determine the size of the byte array by getting the System.IO.FileStream
object’s Length
property.System.IO.FileStream
object’s Read
method and passing the byte array, the starting position, and the stream length to read.BLOB
object by assigning the contents of the byte array to the BLOB
object’s MTOM
data member.BLOB
object that stores the certificate to the Recipient
object’s x509Cert
data member.CertificateEncryptionIdentity
object that stores certificate information by using its constructor.Recipient
object that stores the certificate to the CertificateEncryptionIdentity
object’s recipient data member.Object
array and assign the CertificateEncryptionIdentity
object to the first element of the Object
array. This Object
array is passed as a parameter to the encryptPDFUsingCertificates
method.Set encryption run-time options.
CertificateEncryptionOptionSpec
object by using its constructor.CertificateEncryptionOption
enumeration value to the CertificateEncryptionOptionSpec
object’s option
data member. To encrypt the entire PDF document, including its metadata and its attachments, assign CertificateEncryptionOption.ALL
to this data member.CertificateEncryptionCompatibility
enumeration value to the CertificateEncryptionOptionSpec
object’s compat
data member. For example, assign CertificateEncryptionCompatibility.ACRO_7
to this data member.Create a certificate-encrypted PDF document.
Encrypt the PDF document with a certificate by invoking the EncryptionServiceService
object’s encryptPDFUsingCertificates
method and passing the following values:
BLOB
object that contains the PDF document to encrypt.Object
array that stores certificate information.CertificateEncryptionOptionSpec
object that contains encryption run-time options.The encryptPDFUsingCertificates
method returns a BLOB
object that contains a certificate-encrypted PDF document.
Save the encrypted PDF document as a PDF file.
System.IO.FileStream
object by invoking its constructor and passing a string value that represents the file location of the secured PDF document.BLOB
object that was returned by the encryptPDFUsingCertificates
method. Populate the byte array by getting the value of the BLOB
object’s binaryData
data member.System.IO.BinaryWriter
object by invoking its constructor and passing the System.IO.FileStream
object.System.IO.BinaryWriter
object’s Write
method and passing the byte array.See also
Invoking AEM Forms using SwaRef
Certificate-based encryption can be removed from a PDF document so that users can open the PDF document in Adobe Reader or Acrobat. To remove encryption from a PDF document that is encrypted with a certificate, a public key must be referenced. After encryption is removed from a PDF document, it is no longer secure.
For more information about the Encryption service, see Services Reference for AEM Forms.
To remove certificate-based encryption from a PDF document, perform the following steps:
Include project files
Include necessary files into your development project. If you are creating a client application using Java, include the necessary JAR files. If you are using web services, ensure that you include the proxy files.
The following JAR files must be added to your project’s class path:
Create an encryption service client
To programmatically perform an Encryption service operation, you must create an Encryption service client. If you are using the Java Encryption Service API, create an EncrytionServiceClient
object. If you are using the web service Encryption Service API, create an EncryptionServiceService
object.
Get the encrypted PDF document
You must obtain an encrypted PDF document to remove certificate-based encryption. If you attempt to remove encryption from a PDF document that is not encrypted, an exception is thrown. Likewise, if you attempt to remove certificate-based encryption from a password-encrypted document, an exception is thrown.
Remove encryption
To remove certificate-based encryption from an encrypted PDF document, you require both an encrypted PDF document and the private key that corresponds to the key that was used to encrypt the PDF document. The alias value of the private key is specified when removing certificate-based encryption from an encrypted PDF document. For information about the public key, see Encrypting PDF Documents with Certificates.
A private key is stored in the AEM Forms Trust Store. When a certificate is placed there, an alias value is specified.
Save the PDF document
After certificate-based encryption is removed from an encrypted PDF document, you can save the PDF document as a PDF file. Users can open the PDF document in Adobe Reader or Acrobat.
See also
Remove certificate-based encryption using the Java API
Remove certificate-based encryption using the web service API
Including AEM Forms Java library files
Encryption Service API Quick Starts
Remove certificate-based encryption from a PDF document by using the Encryption API (Java):
Include project files.
Include client JAR files, such as adobe-encryption-client.jar, in your Java project’s class path.
Create an encryption service client.
ServiceClientFactory
object that contains connection properties.EncryptionServiceClient
object by using its constructor and passing the ServiceClientFactory
object.Get the encrypted PDF document.
java.io.FileInputStream
object that represents the encrypted PDF document by using its constructor and passing a string value that specifies the location of the encrypted PDF document.com.adobe.idp.Document
object by using its constructor and passing the java.io.FileInputStream
object.Remove encryption.
Remove certificate-based encryption from the PDF document by invoking the EncryptionServiceClient
object’s removePDFCertificateSecurity
method and passing the following values:
com.adobe.idp.Document
object that contains the encrypted PDF document.The removePDFCertificateSecurity
method returns a com.adobe.idp.Document
object that contains an unsecured PDF document.
Save the PDF document.
java.io.File
object and ensure that the file extension is .pdf.com.adobe.idp.Document
object’s copyToFile
method to copy the contents of the Document
object to the file. Ensure that you use the com.adobe.idp.Document
object that was returned by the removePDFCredentialSecurity
method.See also
Quick Start (SOAP mode): Removing certificate-based encryption using the Java API
Including AEM Forms Java library files
Remove certificate-based encryption by using the Encryption API (web service):
Include project files.
Create a Microsoft .NET project that uses MTOM. Ensure that you use the following WSDL definition: http://localhost:8080/soap/services/EncryptionService?WSDL&lc_version=9.0.1
.
Replace localhost
with the IP address of the server hosting AEM Forms.
Create an encryption service client.
Create an EncryptionServiceClient
object by using its default constructor.
Create an EncryptionServiceClient.Endpoint.Address
object by using the System.ServiceModel.EndpointAddress
constructor. Pass a string value that specifies the WSDL to the AEM Forms service (for example, http://localhost:8080/soap/services/EncryptionService?WSDL
.) You do not need to use the lc_version
attribute. This attribute is used when you create a service reference.)
Create a System.ServiceModel.BasicHttpBinding
object by getting the value of the EncryptionServiceClient.Endpoint.Binding
field. Cast the return value to BasicHttpBinding
.
Set the System.ServiceModel.BasicHttpBinding
object’s MessageEncoding
field to WSMessageEncoding.Mtom
. This value ensures that MTOM is used.
Enable basic HTTP authentication by performing the following tasks:
EncryptionServiceClient.ClientCredentials.UserName.UserName
.EncryptionServiceClient.ClientCredentials.UserName.Password
.HttpClientCredentialType.Basic
to the field BasicHttpBindingSecurity.Transport.ClientCredentialType
.BasicHttpSecurityMode.TransportCredentialOnly
to the field BasicHttpBindingSecurity.Security.Mode
.Get the encrypted PDF document.
BLOB
object by using its constructor. The BLOB
object is used to store the encrypted PDF document.System.IO.FileStream
object by invoking its constructor and passing a string value that represents the file location of the encrypted PDF document and the mode in which to open the file.System.IO.FileStream
object. You can determine the size of the byte array by getting the System.IO.FileStream
object’s Length
property.System.IO.FileStream
object’s Read
method and passing the byte array, the starting position, and the stream length to read.BLOB
object by assigning the contents of the byte array to the BLOB
object’s MTOM
data member.Remove encryption.
Invoke the EncryptionServiceClient
object’s removePDFCertificateSecurity
method and pass the following values:
BLOB
object that contains file stream data that represents an encrypted PDF document.The removePDFCredentialSecurity
method returns a BLOB
object that contains an unsecured PDF document.
Save the PDF document.
System.IO.FileStream
object by invoking its constructor and passing a string value that represents the file location of the unsecured PDF document.BLOB
object that was returned by the removePDFPasswordSecurity
method. Populate the byte array by getting the value of the BLOB
object’s MTOM
data member.System.IO.BinaryWriter
object by invoking its constructor and passing the System.IO.FileStream
object.System.IO.BinaryWriter
object’s Write
method and passing the byte array.See also
Invoking AEM Forms using SwaRef
Password-based encryption can be removed from a PDF document so that users can open the PDF document in Adobe Reader or Acrobat without having to specify a password. After password-based encryption is removed from a PDF document, the document is no longer secure.
For more information about the Encryption service, see Services Reference for AEM Forms.
To remove password-based encryption from a PDF document, perform the following steps:
Include project files
Include the necessary files into your development project. If you are creating a client application using Java, include the necessary JAR files. If you are using web services, make sure that you include the proxy files.
The following JAR files must be added to your project’s class path:
Create an encryption service client
To programmatically perform an Encryption service operation, you must create an Encryption service client. If you are using the Java Encryption Service API, create an EncrytionServiceClient
object. If you are using the web service Encryption Service API, create an EncryptionServiceService
object.
Get the encrypted PDF document
You must obtain an encrypted PDF document to remove password-based encryption. If you attempt to remove encryption from a PDF document that is not encrypted, an exception is thrown.
Remove the password
To remove password-based encryption from an encrypted PDF document, you require both an encrypted PDF document and a master password value that is used to remove encryption from the PDF document. The password that is used to open a password-encrypted PDF document cannot be used to remove encryption. A master password is specified when the PDF document is encrypted with a password. (See Encrypting PDF Documents with a Password.)
Save the PDF document
After the Encryption service removes password-based encryption from a PDF document, you can save the PDF document as a PDF file. Users can open the PDF document in Adobe Reader or Acrobat without specifying a password.
See also
Including AEM Forms Java library files
Encryption Service API Quick Starts
Encrypting PDF Documents with a Password
Remove password-based encryption from a PDF document by using the Encryption API (Java):
Include project files.
Include client JAR files, such as the adobe-encryption-client.jar, in your Java project’s class path.
Create an encryption service client.
ServiceClientFactory
object that contains connection properties.EncryptionServiceClient
object by using its constructor and passing the ServiceClientFactory
object.Get the encrypted PDF document.
java.io.FileInputStream
object that represents the encrypted PDF document by using its constructor and passing a string value that specifies the location of the PDF document.com.adobe.idp.Document
object by using its constructor and passing the java.io.FileInputStream
object.Remove the password.
Remove password-based encryption from the PDF document by invoking the EncryptionServiceClient
object’s removePDFPasswordSecurity
method and passing the following values:
com.adobe.idp.Document
object that contains the encrypted PDF document.The removePDFPasswordSecurity
method returns a com.adobe.idp.Document
object that contains an unsecured PDF document.
Save the PDF document.
java.io.File
object and ensure that the file name extension is .pdf.com.adobe.idp.Document
object’s copyToFile
method to copy the contents of the Document
object to the file. Ensure that you use the Document
object that was returned by the removePDFPasswordSecurity
method.See also
Quick Start (SOAP mode): Removing password-based encryption using the Java API
Remove password-based encryption by using the Encryption API (web service):
Include project files.
Create a Microsoft .NET project that uses MTOM. Ensure that you use the following WSDL definition: http://localhost:8080/soap/services/EncryptionService?WSDL&lc_version=9.0.1
.
Replace localhost
with the IP address of the server hosting AEM Forms.
Create an encryption service client.
Create an EncryptionServiceClient
object by using its default constructor.
Create an EncryptionServiceClient.Endpoint.Address
object by using the System.ServiceModel.EndpointAddress
constructor. Pass a string value that specifies the WSDL to the AEM Forms service (for example, http://localhost:8080/soap/services/EncryptionService?WSDL
.) You do not need to use the lc_version
attribute. This attribute is used when you create a service reference.)
Create a System.ServiceModel.BasicHttpBinding
object by getting the value of the EncryptionServiceClient.Endpoint.Binding
field. Cast the return value to BasicHttpBinding
.
Set the System.ServiceModel.BasicHttpBinding
object’s MessageEncoding
field to WSMessageEncoding.Mtom
. This value ensures that MTOM is used.
Enable basic HTTP authentication by performing the following tasks:
EncryptionServiceClient.ClientCredentials.UserName.UserName
.EncryptionServiceClient.ClientCredentials.UserName.Password
.HttpClientCredentialType.Basic
to the field BasicHttpBindingSecurity.Transport.ClientCredentialType
.BasicHttpSecurityMode.TransportCredentialOnly
to the field BasicHttpBindingSecurity.Security.Mode
.Get the encrypted PDF document.
BLOB
object by using its constructor. The BLOB
object is used to store a password-encrypted PDF document.System.IO.FileStream
object by invoking its constructor and passing a string value that represents the file location of the encrypted PDF document and the mode in which to open the file.System.IO.FileStream
object. You can determine the size of the byte array by getting the System.IO.FileStream
object’s Length
property.System.IO.FileStream
object’s Read
method and passing the byte array, the starting position, and the stream length to read.BLOB
object by assigning the contents of the byte array to the BLOB
object’s MTOM
data member.Remove the password.
Invoke the EncryptionServiceService
object’s removePDFPasswordSecurity
method and pass the following values:
BLOB
object that contains file stream data that represents an encrypted PDF document.The removePDFPasswordSecurity
method returns a BLOB
object that contains an unsecured PDF document.
Save the PDF document.
System.IO.FileStream
object by invoking its constructor and passing a string value that represents the file location of the unsecured PDF document.BLOB
object that was returned by the removePDFPasswordSecurity
method. Populate the byte array by getting the value of the BLOB
object’s MTOM
data member.System.IO.BinaryWriter
object by invoking its constructor and passing the System.IO.FileStream
object.System.IO.BinaryWriter
object’s Write
method and passing the byte array.See also
Invoking AEM Forms using SwaRef
A password-encrypted or certificate-encrypted PDF document must be unlocked before another AEM Forms operation can be performed on it. If you attempt to perform an operation on an encrypted PDF document, you will generate an exception. After you unlock an encrypted PDF document, you can perform one or more operations on it. These operations can belong to other services, such as the Acrobat Reader DC extensions Service.
For more information about the Encryption service, see Services Reference for AEM Forms.
To unlock an encrypted PDF document, perform the following steps:
Include project files
Include necessary files into your development project. If you are creating a client application using Java, include the necessary JAR files. If you are using web services, make sure that you include the proxy files.
The following JAR files must be added to your project’s class path:
Create an encryption service client
To programmatically perform an Encryption service operation, you must create an Encryption service client. If you are using the Java Encryption Service API, create an EncrytionServiceClient
object. If you are using the web service Encryption Service API, create an EncryptionServiceService
object.
Get the encrypted PDF document
You must obtain an encrypted PDF document in order to unlock it. If you attempt to unlock a PDF document that is not encrypted, an exception is thrown.
Unlock the document
To unlock a password-encrypted PDF document, you require both an encrypted PDF document and a password value that is used to open a password-encrypted PDF document. This value is specified when encrypting the PDF document with a password. (See Encrypting PDF Documents with a Password.)
To unlock a certificate-encrypted PDF document, you require both an encrypted PDF document and the alias value of the public key that corresponds to the private key that was used to encrypt the PDF document.
Perform an AEM Forms operation
After an encrypted PDF document is unlocked, you can perform another service operation on it, such as applying usage rights to it. This operation belongs to the Acrobat Reader DC Extensions service.
See also
Unlock an encrypted PDF document using the Java API
Unlock an encrypted PDF document using the web service API
Including AEM Forms Java library files
Encryption Service API Quick Starts
Unlock an encrypted PDF document by using the Encryption API (Java):
Include project files.
Include client JAR files, such as adobe-encryption-client.jar, in your Java project’s class path.
Create an encryption service client.
ServiceClientFactory
object that contains connection properties.EncryptionServiceClient
object by using its constructor and passing the ServiceClientFactory
object.Get the encrypted PDF document.
java.io.FileInputStream
object that represents the encrypted PDF document by using its constructor and passing a string value that specifies the location of the encrypted PDF document.com.adobe.idp.Document
object by using its constructor and passing the java.io.FileInputStream
object.Unlock the document.
Unlock an encrypted PDF document by invoking the EncryptionServiceClient
object’s unlockPDFUsingPassword
or unlockPDFUsingCredential
method.
To unlock a PDF document that is encrypted with a password, invoke the unlockPDFUsingPassword
method and pass the following values:
com.adobe.idp.Document
object that contains the password-encrypted PDF document.To unlock a PDF document that is encrypted with a certificate, invoke the unlockPDFUsingCredential
method and pass the following values:
com.adobe.idp.Document
object that contains the certificate-encrypted PDF document.The unlockPDFUsingPassword
and unlockPDFUsingCredential
methods both return a com.adobe.idp.Document
object that you pass to another AEM Forms Java method to perform an operation.
Perform a AEM Forms operation.
Perform a AEM Forms operation on the unlocked PDF document to meet your business requirements. For example, assuming that you want to apply usage rights to an unlocked PDF document, pass the com.adobe.idp.Document
object that was returned by either the unlockPDFUsingPassword
or unlockPDFUsingCredential
methods to the ReaderExtensionsServiceClient
object’s applyUsageRights
method.
See also
Quick Start (SOAP mode): Unlocking an encrypted PDF document using the Java API (SOAP mode)
Applying Usage Rights to PDF Documents
Including AEM Forms Java library files
Unlock an encrypted PDF document by using the Encryption API (web service):
Include project files.
Create a Microsoft .NET project that uses MTOM. Ensure that you use the following WSDL definition: http://localhost:8080/soap/services/EncryptionService?WSDL&lc_version=9.0.1
.
Replace localhost
with the IP address of the server hosting AEM Forms.
Create an encryption service client.
Create an EncryptionServiceClient
object by using its default constructor.
Create an EncryptionServiceClient.Endpoint.Address
object by using the System.ServiceModel.EndpointAddress
constructor. Pass a string value that specifies the WSDL to the AEM Forms service (for example, http://localhost:8080/soap/services/EncryptionService?WSDL
.) You do not need to use the lc_version
attribute. This attribute is used when you create a service reference.)
Create a System.ServiceModel.BasicHttpBinding
object by getting the value of the EncryptionServiceClient.Endpoint.Binding
field. Cast the return value to BasicHttpBinding
.
Set the System.ServiceModel.BasicHttpBinding
object’s MessageEncoding
field to WSMessageEncoding.Mtom
. This value ensures that MTOM is used.
Enable basic HTTP authentication by performing the following tasks:
EncryptionServiceClient.ClientCredentials.UserName.UserName
.EncryptionServiceClient.ClientCredentials.UserName.Password
.HttpClientCredentialType.Basic
to the field BasicHttpBindingSecurity.Transport.ClientCredentialType
.BasicHttpSecurityMode.TransportCredentialOnly
to the field BasicHttpBindingSecurity.Security.Mode
.Get an encrypted PDF document.
BLOB
object by using its constructor.System.IO.FileStream
object by invoking its constructor and passing a string value that represents the file location of the encrypted PDF document and the mode in which to open the file.System.IO.FileStream
object. You can determine the size of the byte array by getting the System.IO.FileStream
object’s Length
property.System.IO.FileStream
object’s Read
method and passing the byte array, the starting position, and the stream length to read.BLOB
object by assigning the contents of the byte array to the BLOB
object’s MTOM
data member.Unlock the document.
Unlock an encrypted PDF document by invoking the EncryptionServiceClient
object’s unlockPDFUsingPassword
or unlockPDFUsingCredential
method.
To unlock a PDF document that is encrypted with a password, invoke the unlockPDFUsingPassword
method and pass the following values:
BLOB
object that contains the password-encrypted PDF document.To unlock a PDF document that is encrypted with a certificate, invoke the unlockPDFUsingCredential
method and pass the following values:
BLOB
object that contains the certificate-encrypted PDF document.The unlockPDFUsingPassword
and unlockPDFUsingCredential
methods both return a com.adobe.idp.Document
object that you pass to another AEM Forms method to perform an operation.
Perform a AEM Forms operation.
Perform a AEM Forms operation on the unlocked PDF document to meet your business requirements. For example, assuming that you want to apply usage rights to the unlocked PDF document, pass the BLOB
object that was returned by either the unlockPDFUsingPassword
or unlockPDFUsingCredential
methods to the ReaderExtensionsServiceClient
object’s applyUsageRights
method.
See also
Invoking AEM Forms using SwaRef
You can programmatically determine the type of encryption that is protecting a PDF document by using the Java Encryption Service API or the web service Encryption Service API. Sometimes it is necessary to dynamically determine whether a PDF document is encrypted and, if so, the encryption type. For example, you can determine whether a PDF document is protected with password-based encryption or a Rights Management policy.
A PDF document can be protected by the following encryption types:
For more information about the Encryption service, see Services Reference for AEM Forms.
To determine the type of encryption that is protecting a PDF document, perform the following steps:
Include project files
Include necessary files into your development project. If you are creating a client application using Java, include the necessary JAR files. If you are using web services, ensure that you include the proxy files.
The following JAR files must be added to your project’s class path:
Create a service client
To programmatically perform an Encryption service operation, you must create an Encryption service client. If you are using the Java Encryption Service API, create an EncrytionServiceClient
object. If you are using the web service Encryption Service API, create an EncryptionServiceService
object.
Get the encrypted PDF document
You must obtain a PDF document to determine the type of encryption that is protecting it.
Determine the encryption type
You can determine the type of encryption that is protecting a PDF document. If the PDF document is not protected, then the Encryption service informs you that the PDF document is not secured.
See also
Determine the encryption type using the Java API
Determine the encryption type using the web service API
Including AEM Forms Java library files
Encryption Service API Quick Starts
Protecting Documents with Policies
Determine the type of encryption that is protecting a PDF document by using the Encryption API (Java):
Include project files.
Include client JAR files, such as adobe-encryption-client.jar, in your Java project’s class path.
Create a service client.
ServiceClientFactory
object that contains connection properties.EncryptionServiceClient
object by using its constructor and passing the ServiceClientFactory
object.Get the encrypted PDF document.
java.io.FileInputStream
object that represents the PDF document by using its constructor and passing a string value that specifies the location of the PDF document.com.adobe.idp.Document
object by using its constructor and passing the java.io.FileInputStream
object.Determine the encryption type.
EncryptionServiceClient
object’s getPDFEncryption
method and passing the com.adobe.idp.Document
object that contains the PDF document. This method returns an EncryptionTypeResult
object.EncryptionTypeResult
object’s getEncryptionType
method. This method returns an EncryptionType
enum value that specifies the encryption type. For example, if the PDF document is protected with password-based encryption, this method returns EncryptionType.PASSWORD
.See also
Quick Start (SOAP mode): Determining encryption type using the Java API
Including AEM Forms Java library files
Determine the type of encryption that is protecting a PDF document by using the Encryption API (web service):
Include project files.
Create a Microsoft .NET project that uses MTOM. Ensure that you use the following WSDL definition: http://localhost:8080/soap/services/EncryptionService?WSDL&lc_version=9.0.1
.
Replace localhost
with the IP address of the server hosting AEM Forms.
Create a service client.
Create an EncryptionServiceClient
object by using its default constructor.
Create an EncryptionServiceClient.Endpoint.Address
object by using the System.ServiceModel.EndpointAddress
constructor. Pass a string value that specifies the WSDL to the AEM Forms service (for example, http://localhost:8080/soap/services/EncryptionService?WSDL
.) You do not need to use the lc_version
attribute. This attribute is used when you create a service reference.)
Create a System.ServiceModel.BasicHttpBinding
object by getting the value of the EncryptionServiceClient.Endpoint.Binding
field. Cast the return value to BasicHttpBinding
.
Set the System.ServiceModel.BasicHttpBinding
object’s MessageEncoding
field to WSMessageEncoding.Mtom
. This value ensures that MTOM is used.
Enable basic HTTP authentication by performing the following tasks:
EncryptionServiceClient.ClientCredentials.UserName.UserName
.EncryptionServiceClient.ClientCredentials.UserName.Password
.HttpClientCredentialType.Basic
to the field BasicHttpBindingSecurity.Transport.ClientCredentialType
.BasicHttpSecurityMode.TransportCredentialOnly
to the field BasicHttpBindingSecurity.Security.Mode
.Get the encrypted PDF document.
BLOB
object by using its constructor.System.IO.FileStream
object by invoking its constructor and passing a string value that represents the file location of the encrypted PDF document and the mode in which to open the file.System.IO.FileStream
object. You can determine the size of the byte array by getting the System.IO.FileStream
object’s Length
property.System.IO.FileStream
object’s Read
method and passing the byte array, the starting position, and the stream length to read.BLOB
object by assigning the contents of the byte array to the BLOB
object’s MTOM
data member.Determine the encryption type.
EncryptionServiceClient
object’s getPDFEncryption
method and pass the BLOB
object that contains the PDF document. This method returns an EncryptionTypeResult
object.EncryptionTypeResult
object’s encryptionType
data method. For example, if the PDF document is protected with password-based encryption, the value of this data member is EncryptionType.PASSWORD
.See also
Invoking AEM Forms using SwaRef