Removing Policies from Word Documents

You can remove a policy from a policy-protected Word document in order to remove security from the document. That is, if you no longer want the document to be protected by a policy. If you want to update a policy-protected Word document with a newer policy, then instead of removing the policy and adding the updated policy, it is more efficient to switch the policy.

Hinweis: For more information about the Rights Management service, see Services Reference for LiveCycle.

Summary of steps

To remove a policy from a policy-protected Word document, perform the following steps:

  1. Include project files

  2. Create a Rights Management Client API object.

  3. Retrieve a policy-protected Word document.

  4. Remove the policy from the Word document.

  5. Save the unsecured Word document.s

Include project files

Include necessary files into your development project. If you are creating a client application using Java, then include the necessary JAR files. If you are using web services, then make sure that you include the proxy files.

Create a Rights Management Client API object

Before you can programmatically perform a Rights Management service operation, create a Rights Management service client object.

Retrieve a policy-protected Word document

You must retrieve a policy-protected Word document in order to remove a policy. If you attempt to remove a policy from a Word document that is not protected by a policy, you will cause an exception.

Remove the policy from the Word document

You can remove a policy from a policy-protected Word document provided that an administrator is specified in the connection settings. If not, then the policy used to secure a document must contain the SWITCH_POLICY permission in order to remove a policy from a Word document. Also, the user specified in the LiveCycle connection settings must also have that permission. Otherwise, an exception is thrown.

Save the unsecured Word document

After the Rights Management service removes a policy from a Word document, you can save the unsecured Word document as a DOC file.

Remove a policy from a Word document using the Java API

Remove a policy from a policy-protected Word document by using the Rights Management API (Java):

  1. Include project files

    Include client JAR files, such as adobe-rightsmanagement-client.jar, in your Java project’s class path.

  2. Create a Rights Management Client API object

    • Create a ServiceClientFactory object that contains connection properties.

    • Create a RightsManagementClient object by using its constructor and passing the ServiceClientFactory object.

  3. Retrieve a policy-protected Word document

    • Create a java.io.FileInputStream object that represents the policy-protected Word document by using its constructor and passing a string value that specifies the location of the Word document.

    • Create a com.adobe.idp.Document object by using its constructor and passing the java.io.FileInputStream object.

  4. Remove the policy from the Word document

    • Create a DocumentManager object by invoking the RightsManagementClient object’s getDocumentManager method.

    • Remove a policy from the Word document by invoking the DocumentManager object’s removeSecurity method and passing the com.adobe.idp.Document object that contains the policy-protected Word document. This method returns a com.adobe.idp.Document object that contains an unsecured Word document.

  5. Save the unsecured Word document

    • Create a java.io.File object and ensure that the file extension is DOC.

    • Invoke the 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 removeSecurity method).

Code examples

For code examples using the Rights Management service, see the following Quick Start in API Quick Starts (Code Examples):

  • “Quick Start (EJB mode): Removing a policy from a Word document using the Java API ”

Remove a policy from a Word document using the web service API

Remove a policy from a policy-protected Word document by using the Rights Management API (web service):

  1. Include project files

    Create a Microsoft .NET project that uses MTOM. Ensure that you use the following WSDL definition: http://localhost:8080/soap/services/RightsManagementService?WSDL&lc_version=9.0.1.

    Hinweis: Replace localhost with the IP address of the server hosting LiveCycle.
  2. Create a Rights Management Client API object

    • Create a RightsManagementServiceClient object by using its default constructor.

    • Create a RightsManagementServiceClient.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/RightsManagementService?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 RightsManagementServiceClient.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 RightsManagementServiceClient.ClientCredentials.UserName.UserName.

      • Assign the corresponding password value to the field RightsManagementServiceClient.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.

  3. Retrieve a policy-protected Word document

    • Create a BLOB object by using its constructor. The BLOB object is used to store the policy-protected Word document from which the policy is removed.

    • Create a System.IO.FileStream object by invoking its constructor and passing a string value that represents the file location of the Word 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 its MTOM field with the contents of the byte array.

  4. Remove the policy from the Word document

    Remove the policy from the Word document by invoking the RightsManagementServiceClient object’s removePolicySecurity method and passing the BLOB object that contains the policy-protected Word document. This method returns a BLOB object that contains an unsecured Word document.

  5. Save the unsecured Word document

    • Create a System.IO.FileStream object by invoking its constructor and passing a string value that represents the file location of the unsecured Word document.

    • Create a byte array that stores the data content of the BLOB object that was returned by the removePolicySecurity method. Populate the byte array by getting the value of the BLOB object’s MTOM field.

    • Create a System.IO.BinaryWriter object by invoking its constructor and passing the System.IO.FileStream object.

Code examples

For code examples using the Rights Management service, see the following Quick Start in API Quick Starts (Code Examples):

  • “Quick Start (MTOM): Removing a policy from a Word document using the web service API”