Quick Start (SwaRef): Inspecting policy protected PDF documents using the web service API

The following Java code example inspects a policy-protected PDF document named PolicyProtectedLoanDoc.pdf. (See Inspecting Policy Protected PDF Documents.)

/** 
    * Ensure that you create Java proxy files that consume 
    * the Rights Management services  WSDL. You can use JAX-WS to create 
    * the proxy Java files.   
    * 
    * For information, see "Invoking LiveCycle using SwaRef" in Programming with LiveCycle   
    */ 
import javax.activation.DataHandler; 
import javax.activation.FileDataSource; 
import javax.xml.ws.BindingProvider; 
import com.adobe.idp.services.*; 
 
public class InspectDocumentSwaRef { 
    public static void main(String[] args) { 
          try{ 
                 //Setting configurations to retrieve the LiveCycle 
                String url = "http://hiro-xp:8080/soap/services/RightsManagementService?blob=swaRef"; 
                String username = "administrator"; 
                String password = "password"; 
                 
                //Create the RightsManagementServiceService object 
                RightsManagementServiceService rightsManagementService = new RightsManagementServiceService(); 
                RightsManagementService rightsManagementClient = rightsManagementService.getRightsManagementService(); 
                 
                //Retrieve the Web services from the LiveCycle 
                ((BindingProvider) rightsManagementClient).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, url); 
                ((BindingProvider) rightsManagementClient).getRequestContext().put(BindingProvider.USERNAME_PROPERTY, username); 
                ((BindingProvider) rightsManagementClient).getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, password); 
                 
                //Reference a PDF document to inspect     
                String path = "C:\\Adobe\PolicyProtectedLoanDoc.pdf"; 
                FileDataSource ds = new FileDataSource(path);  
                DataHandler handler = new DataHandler(ds); 
                BLOB inDoc = new BLOB(); 
                inDoc.setSwaRef(handler); 
                 
                //Inspect the policy-protected PDF document 
                   RMInspectResult inspectResult = rightsManagementClient.inspectDocument(inDoc); 
 
                   //Get the document name 
                   String documentName = inspectResult.getDocName(); 
     
                   //Get the name of the policy 
                String policyName = inspectResult.getPolicyName(); 
                     
                //Display the name of the policy-protected document and the policy 
                System.out.println("The policy protected document "+documentName +" is protected with the policy "+policyName +"."); 
             
          }catch(Exception e) 
          { 
                 e.printStackTrace();  
          } 
    } 
} 
 

// Ethnio survey code removed