Quick Start (SwaRef): Retrieving credential information using the web service API

The following Java code example retrieves information about the credential that is used to apply usage-rights to a rights-enabled PDF document named LoanUsageRights.pdf. (See Retrieving Credential Information.)

/** 
    * Ensure that you create Java proxy files that consume 
    * the Reader Extension services  WSDL. You can use JAX-WS to create 
    * the proxy Java files.   
    *  
    * If you are supplying a set of associated files, add the file name to the BLOB attribute. 
    * The create3DPDF service uses those file names to resolve references from the main assembly file. 
    *    
    * For information, see "Invoking LiveCycle using SwaRef" in Programming with LiveCycle   
    */ 
     
import java.io.*; 
 
import javax.activation.DataHandler; 
import javax.activation.FileDataSource; 
import javax.xml.ws.BindingProvider; 
 
import com.adobe.idp.services.*; 
 
public class RetrieveCredentialInformationSWAref { 
 
    public static void main(String[] args) { 
      try{ 
                  
            // Setting configurations to retrieve the Web service 
            String url = "http://hiro-xp:8080/soap/services/ReaderExtensionsService?blob=swaRef"; 
            String username = "administrator"; 
            String password = "password"; 
             
            // Create the service Client objects needed 
            ReaderExtensionsServiceService readerExtensionService = new ReaderExtensionsServiceService(); 
            ReaderExtensionsService readerExtensionClient = readerExtensionService.getReaderExtensionsService(); 
             
            //Set connection properties required to invoke LiveCycle 
            ((BindingProvider) readerExtensionClient).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, url); 
            ((BindingProvider) readerExtensionClient).getRequestContext().put(BindingProvider.USERNAME_PROPERTY, username); 
            ((BindingProvider) readerExtensionClient).getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, password);  
 
            //Retrieve the PDF document to which to apply usage rights 
            //Set an input file as a BLOB         
            String path1 = "C:\\Adobe\LoanUsageRights.pdf"; 
            FileDataSource ds1 = new FileDataSource(path1);  
            DataHandler handler1 = new DataHandler(ds1); 
            BLOB inputPDF = new BLOB(); 
            inputPDF.setSwaRef(handler1); 
 
            //Retrieve credential information 
            GetUsageRightsResult usageRightsResult = readerExtensionClient.getDocumentUsageRights(inputPDF);  
         
            //Get the message displayed in Adobe Reader when the rights-enabled 
            //document is opened 
            String message = usageRightsResult.getMessage(); 
         
            //Get usage rights to see if the enableFormFillIn is enabled 
            UsageRights myRights = usageRightsResult.getRights(); 
            boolean ans = myRights.isEnabledFormFillIn(); 
         
            if (ans==true) 
                System.out.println("The enableFormFillIn usage right is enabled"); 
            else 
                System.out.println("The enableFormFillIn usage right is not enabled"); 
                                                  
        }catch (Exception e) { 
             e.printStackTrace(); 
        }     
                 
    } 
} 

// Ethnio survey code removed