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:
Password-based encryption
Certificate-based encryption
A policy that is created by the Rights Management service
Another type of encryption
Summary of stepsTo determine the type of encryption that is protecting
a PDF document, perform the following steps:
Include project files.
Create an encryption service client.
Get the encrypted PDF document.
Determine the encryption type.
Include project filesInclude 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:
adobe-livecycle-client.jar
adobe-usermanager-client.jar
adobe-encryption-client.jar
adobe-utilities.jar (required if LiveCycle is deployed
on JBoss Application Server)
jbossall-client.jar (required if LiveCycle is deployed
on JBoss Application Server)
Create a service clientTo 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 documentYou must obtain a PDF document
to determine the type of encryption that is protecting it.
Determine the encryption typeYou 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.
Determine the encryption type using the Java APIDetermine 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.
Get the encrypted PDF document.
Create a 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.
Create a com.adobe.idp.Document object by
using its constructor and passing the java.io.FileInputStream object.
Determine the encryption type.
Determine the
encryption type by invoking the EncryptionServiceClient object’s getPDFEncryption method
and passing thecom.adobe.idp.Document object that contains
the PDF document. This method returns an EncryptionTypeResult object.
Invoke the 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.
Determine the encryption type using the web service APIDetermine 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.
Note: Replace localhost with the IP
address of the server hosting LiveCycle.
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 LiveCycle 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:
Assign the LiveCycle user name to the field EncryptionServiceClient.ClientCredentials.UserName.UserName.
Assign the corresponding password value to the field EncryptionServiceClient.ClientCredentials.UserName.Password.
Assign the constant value HttpClientCredentialType.Basic to
the field BasicHttpBindingSecurity.Transport.ClientCredentialType.
Assign the constant value BasicHttpSecurityMode.TransportCredentialOnly to
the field BasicHttpBindingSecurity.Security.Mode.
Get the encrypted PDF document.
Create a BLOB object
by using its constructor.
Create a 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.
Create a byte array that stores the content of the System.IO.FileStream object.
You can determine the size of the byte array by getting the System.IO.FileStream object’s Length property.
Populate the byte array with stream data by invoking the System.IO.FileStream object’s Read method
and passing the byte array, the starting position, and the stream
length to read.
Populate the BLOB object by assigning the contents
of the byte array to the BLOB object’s MTOM data
member.
Determine the encryption type.
Invoke the EncryptionServiceClient object’s getPDFEncryption method
and pass the BLOB object that contains the PDF
document. This method returns an EncryptionTypeResult object.
Get the value of the 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.
|
|
|