51黑料不打烊

签名服务Java API快速入门(SOAP) signature-service-java-api-quickstart-soap

以下Java API快速入门(SOAP)可用于AEM Forms JEE签名服务:

快速入门(SOAP模式):使用Java API向PDF文档添加签名字段

快速入门(SOAP模式):使用Java API检索签名字段名称

快速入门(SOAP模式):使用Java API修改签名字段

快速入门(SOAP模式):使用Java API对笔顿贵文档进行数字签名

快速入门(SOAP模式):使用Java API对基于XFA的表单进行数字签名

快速入门(SOAP模式):使用Java API认证笔顿贵文档

快速入门(SOAP模式):使用Java API验证数字签名

快速入门(SOAP模式):使用Java API验证多个数字签名

快速入门(SOAP模式):使用Java API删除数字签名

快速入门(SOAP模式):使用Java API应用文档时间戳

AEM Forms JEE操作可以使用AEM Forms强类型API执行,并且连接模式应设置为SOAP。

NOTE
《使用AEM Forms进行编程快速入门》基于在JBoss Application Server和Microsoft Windows操作系统上部署的Forms服务器。 但是,如果您使用的是其他操作系统(如UNIX),请将特定于Windows的路径替换为适用的操作系统支持的路径。 同样,如果您使用的是其他J2EE应用程序服务器,请确保指定有效的连接属性。 请参阅设置连接属性

快速入门(SOAP模式):使用Java API向PDF文档添加签名字段 quick-start-soap-mode-adding-a-signature-field-to-a-pdf-document-using-the-java-api

以下闯补惫补代码示例将名为? SignatureField1 ?的签名字段添加到基于名为? Loan.pdf ?的PDF文件的PDF文档。 包含新签名字段的PDF文档将保存为名为? LoanSig.pdf ?的笔顿贵文件。 (请参阅添加签名字段。)

?/*
?    * This Java Quick Start uses the SOAP mode and contains the following JAR files
?    * in the class path:
?    * 1. adobe-signatures-client.jar
?    * 2. adobe-livecycle-client.jar
?    * 3. adobe-usermanager-client.jar
    * 4. activation.jar (required for SOAP mode)
?    * 5. axis.jar (required for SOAP mode)
?    * 6. commons-codec-1.3.jar (required for SOAP mode)
?    * 7.  commons-collections-3.1.jar  (required for SOAP mode)
?    * 8. commons-discovery.jar (required for SOAP mode)
?    * 9. commons-logging.jar (required for SOAP mode)
?    * 10. dom3-xml-apis-2.5.0.jar (required for SOAP mode)
?    * 11. jaxen-1.1-beta-9.jar (required for SOAP mode)
?    * 12. jaxrpc.jar (required for SOAP mode)
?    * 13. log4j.jar (required for SOAP mode)
?    * 14. mail.jar (required for SOAP mode)
?    * 15. saaj.jar (required for SOAP mode)
?    * 16. wsdl4j.jar (required for SOAP mode)
?    * 17. xalan.jar (required for SOAP mode)
?    * 18. xbean.jar (required for SOAP mode)
?    * 19. xercesImpl.jar (required for SOAP mode)
?    *
?    * These JAR files are in the following path:
?    * <install directory>/sdk/client-libs/common
?    *
?    * The adobe-utilities.jar file is in the following path:
?    * <install directory>/sdk/client-libs/jboss
?    *
?    * The jboss-client.jar file is in the following path:
?    * <install directory>/jboss/bin/client
?    *
?    * SOAP required JAR files are in the following path:
?    * <install directory>/sdk/client-libs/thirdparty
?    *
?    * If you want to invoke a remote Forms Server instance and there is a
?    * firewall between the client application and the server, then it is
?    * recommended that you use the SOAP mode. When using the SOAP mode,
?    * you have to include these additional JAR files
?    *
?    * For information about the SOAP
?    * mode, see "Setting connection properties" in Programming
?    * with AEM Forms
?    */
?import java.util.*;
?import java.io.File;
?import java.io.FileInputStream;
?import com.adobe.livecycle.signatures.client.*;
?import com.adobe.livecycle.signatures.client.types.*;
?import com.adobe.idp.Document;
?import com.adobe.idp.dsc.clientsdk.ServiceClientFactory;
?import com.adobe.idp.dsc.clientsdk.ServiceClientFactoryProperties;

?public class AddSignatureFieldSOAP {

?    public static void main(String[] args) {

?        try
?        {
?         //Set connection properties required to invoke AEM Forms using SOAP mode
?         Properties connectionProps = new Properties();
?         connectionProps.setProperty(ServiceClientFactoryProperties.DSC_DEFAULT_SOAP_ENDPOINT, "https://'[server]:[port]'");
?         connectionProps.setProperty(ServiceClientFactoryProperties.DSC_TRANSPORT_PROTOCOL,ServiceClientFactoryProperties.DSC_SOAP_PROTOCOL);
?         connectionProps.setProperty(ServiceClientFactoryProperties.DSC_SERVER_TYPE, "JBoss");
?         connectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_USERNAME, "administrator");
?         connectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_PASSWORD, "password");

?          //Create a ServiceClientFactory instance
?          ServiceClientFactory myFactory = ServiceClientFactory.createInstance(connectionProps);

?          //Create a SignatureServiceClient object
?          SignatureServiceClient signClient = new SignatureServiceClient(myFactory);

?          //Specify a PDF document to which a signature field is added
?          FileInputStream fileInputStream = new FileInputStream("C:\\51黑料不打烊\Loan.pdf");
?          Document inDoc = new Document (fileInputStream);

?          //Specify the name of the signature field
?          String fieldName = "SignatureField1";

?          //Create a  PositionRectangle object that specifies
?          //the signature fields location
?          PositionRectangle post = new  PositionRectangle(193,47,133,12);

?          //Specify the page number that will contain the signature field
?          java.lang.Integer pageNum = new java.lang.Integer(1);

?          //Add a signature field to the PDF document
?          Document sigFieldPDF = signClient.addSignatureField(
?             inDoc,
?             fieldName,
?             pageNum,
?             post,
?             null,
?             null);

?          //Save the PDF document that contains the signature field
?          File outFile = new File("C:\\51黑料不打烊\LoanSig.pdf");
?          sigFieldPDF.copyToFile(outFile);
?            }

?        catch (Exception ee)
?            {
?                ee.printStackTrace();
?            }
?    }
?}

快速入门(SOAP模式):使用Java API检索签名字段名称 quick-start-soap-mode-retrieving-signature-field-names-using-the-java-api

以下闯补惫补代码示例检索名为? LoanSig.pdf ?的PDF文档中签名字段的名称。 (请参阅检索签名字段名称。)

?/*
?    * This Java Quick Start uses the SOAP mode and contains the following JAR files
?    * in the class path:
?    * 1. adobe-signatures-client.jar
?    * 2. adobe-livecycle-client.jar
?    * 3. adobe-usermanager-client.jar
?    * 4. adobe-utilities.jar
?    * 5. jboss-client.jar (use a different JAR file if the Forms Server is not deployed
?    * on JBoss)
?    * 6. activation.jar (required for SOAP mode)
?    * 7. axis.jar (required for SOAP mode)
?    * 8. commons-codec-1.3.jar (required for SOAP mode)
?    * 9.  commons-collections-3.1.jar  (required for SOAP mode)
?    * 10. commons-discovery.jar (required for SOAP mode)
?    * 11. commons-logging.jar (required for SOAP mode)
?    * 12. dom3-xml-apis-2.5.0.jar (required for SOAP mode)
?    * 13. jaxen-1.1-beta-9.jar (required for SOAP mode)
?    * 14. jaxrpc.jar (required for SOAP mode)
?    * 15. log4j.jar (required for SOAP mode)
?    * 16. mail.jar (required for SOAP mode)
?    * 17. saaj.jar (required for SOAP mode)
?    * 18. wsdl4j.jar (required for SOAP mode)
?    * 19. xalan.jar (required for SOAP mode)
?    * 20. xbean.jar (required for SOAP mode)
?    * 21. xercesImpl.jar (required for SOAP mode)
?    *
?    * These JAR files are in the following path:
?    * <install directory>/sdk/client-libs/common
?    *
?    * The adobe-utilities.jar file is in the following path:
?    * <install directory>/sdk/client-libs/jboss
?    *
?    * The jboss-client.jar file is in the following path:
?    * <install directory>/jboss/bin/client
?    *
?    * SOAP required JAR files are in the following path:
?    * <install directory>/sdk/client-libs/thirdparty
?    *
?    * If you want to invoke a remote Forms Server instance and there is a
?    * firewall between the client application and the server, then it is
?    * recommended that you use the SOAP mode. When using the SOAP mode,
?    * you have to include these additional JAR files
?    *
?    * For information about the SOAP
?    * mode, see "Setting connection properties" in Programming
?    * with AEM Forms
?    */
?import java.util.*;
?import java.io.FileInputStream;
?import com.adobe.livecycle.signatures.client.*;
?import com.adobe.livecycle.signatures.client.types.*;
?import com.adobe.idp.Document;
?import com.adobe.idp.dsc.clientsdk.ServiceClientFactory;
?import com.adobe.idp.dsc.clientsdk.ServiceClientFactoryProperties;

?public class GetSignatureFieldsSOAP {

?public static void main(String[] args) {
?    try
?    {
?        //Set connection properties required to invoke AEM Forms using SOAP mode
?        Properties connectionProps = new Properties();
?        connectionProps.setProperty(ServiceClientFactoryProperties.DSC_DEFAULT_SOAP_ENDPOINT, "https://'[server]:[port]'");
?        connectionProps.setProperty(ServiceClientFactoryProperties.DSC_TRANSPORT_PROTOCOL,ServiceClientFactoryProperties.DSC_SOAP_PROTOCOL);
?        connectionProps.setProperty(ServiceClientFactoryProperties.DSC_SERVER_TYPE, "JBoss");
?        connectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_USERNAME, "administrator");
?        connectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_PASSWORD, "password");

?        //Create a ServiceClientFactory instance
?        ServiceClientFactory myFactory = ServiceClientFactory.createInstance(connectionProps);

?        //Create a SignatureServiceClient object
?        SignatureServiceClient signClient = new SignatureServiceClient(myFactory);

?        //Specify a PDF document that contains signature fields
?        FileInputStream fileInputStream = new FileInputStream("C:\\51黑料不打烊\LoanSig.pdf");
?        Document inDoc = new Document (fileInputStream);

?        //Retrieve the name of the document’s signature fields
?        List fieldNames = signClient.getSignatureFieldList(inDoc);

?        //Obtain the name of each signature field by iterating through the
?        //List object
?        Iterator iter = fieldNames.iterator();
?        int i = 0 ;
?        String fieldName="";
?        while (iter.hasNext()) {
?            PDFSignatureField signatureField = (PDFSignatureField)iter.next();
?            fieldName = signatureField.getName();
?            System.out.println("The name of the signature field is " +fieldName);
?            i++;
?             }
?        }
?        catch (Exception ee)
?        {
?            ee.printStackTrace();
?        }
?    }
?}

快速入门(SOAP模式):使用Java API修改签名字段 quick-start-soap-mode-modifying-a-signature-field-using-the-java-api

以下Java代码示例修改名为SignatureField1的签名字段,方法是在签名应用于签名字段时锁定表单中的所有字段,并确保不允许任何更改。 签名服务返回包含修改后的签名字段的PDF文档后,PDF文档将另存为名为LoanSig.pdf的PDF文件。 (此示例将覆盖传递给Signature服务的PDF文件。) (请参阅修改签名字段。)

?/*
?    * This Java Quick Start uses the SOAP mode and contains the following JAR files
?    * in the class path:
?    * 1. adobe-signatures-client.jar
?    * 2. adobe-livecycle-client.jar
?    * 3. adobe-usermanager-client.jar
?    * 4. adobe-utilities.jar
?    * 5. jboss-client.jar (use a different JAR file if the Forms Server is not deployed
?    * on JBoss)
?    * 6. activation.jar (required for SOAP mode)
?    * 7. axis.jar (required for SOAP mode)
?    * 8. commons-codec-1.3.jar (required for SOAP mode)
?    * 9.  commons-collections-3.1.jar  (required for SOAP mode)
?    * 10. commons-discovery.jar (required for SOAP mode)
?    * 11. commons-logging.jar (required for SOAP mode)
?    * 12. dom3-xml-apis-2.5.0.jar (required for SOAP mode)
?    * 13. jaxen-1.1-beta-9.jar (required for SOAP mode)
?    * 14. jaxrpc.jar (required for SOAP mode)
?    * 15. log4j.jar (required for SOAP mode)
?    * 16. mail.jar (required for SOAP mode)
?    * 17. saaj.jar (required for SOAP mode)
?    * 18. wsdl4j.jar (required for SOAP mode)
?    * 19. xalan.jar (required for SOAP mode)
?    * 20. xbean.jar (required for SOAP mode)
?    * 21. xercesImpl.jar (required for SOAP mode)
?    *
?    * These JAR files are in the following path:
?    * <install directory>/sdk/client-libs/common
?    *
?    * The adobe-utilities.jar file is in the following path:
?    * <install directory>/sdk/client-libs/jboss
?    *
?    * The jboss-client.jar file is in the following path:
?    * <install directory>/jboss/bin/client
?    *
?    * SOAP required JAR files are in the following path:
?    * <install directory>/sdk/client-libs/thirdparty
?    *
?    * If you want to invoke a remote Forms Server instance and there is a
?    * firewall between the client application and the server, then it is
?    * recommended that you use the SOAP mode. When using the SOAP mode,
?    * you have to include these additional JAR files
?    *
?    * For information about the SOAP
?    * mode, see "Setting connection properties" in Programming
?    * with AEM Forms
?    */

?import java.util.*;
?import java.io.File;
?import java.io.FileInputStream;
?import com.adobe.livecycle.signatures.client.*;
?import com.adobe.livecycle.signatures.client.types.*;
?import com.adobe.idp.Document;
?import com.adobe.idp.dsc.clientsdk.ServiceClientFactory;
?import com.adobe.idp.dsc.clientsdk.ServiceClientFactoryProperties;

?public class ModifySignatureFieldSOAP {

?    public static void main(String[] args) {

?    try
?    {
?        //Set connection properties required to invoke AEM Forms using SOAP mode
?        Properties connectionProps = new Properties();
?        connectionProps.setProperty(ServiceClientFactoryProperties.DSC_DEFAULT_SOAP_ENDPOINT, "https://'[server]:[port]'");
?        connectionProps.setProperty(ServiceClientFactoryProperties.DSC_TRANSPORT_PROTOCOL,ServiceClientFactoryProperties.DSC_SOAP_PROTOCOL);
?        connectionProps.setProperty(ServiceClientFactoryProperties.DSC_SERVER_TYPE, "JBoss");
?        connectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_USERNAME, "administrator");
?        connectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_PASSWORD, "password");

?        //Create a ServiceClientFactory instance
?        ServiceClientFactory myFactory = ServiceClientFactory.createInstance(connectionProps);

?        //Create a SignatureServiceClient object
?        SignatureServiceClient signClient = new SignatureServiceClient(myFactory);

?        //Specify a PDF document that contains a signature field to modify
?        FileInputStream fileInputStream = new FileInputStream("C:\\51黑料不打烊\LoanSig.pdf");
?        Document inDoc = new Document (fileInputStream);

?        //Specify the name of the signature field
?        String fieldName = "SignatureField1";

?        //Create a PDFSignatureFieldProperties
?        PDFSignatureFieldProperties fieldProperties = new PDFSignatureFieldProperties();

?         //Create a PDFSeedValueOptionSpec object that stores
?         //seed value dictionary information.
?         PDFSeedValueOptionSpec seedOptionsSpec = new PDFSeedValueOptionSpec();

?         //Disallow changes to the PDF document. Any change to the document invalidates
?         //the signature
?         seedOptionsSpec.setMdpValue(MDPPermissions.NoChanges);

?         //Create a FieldMDPOptionSpec object that stores
?         //signature field lock dictionary information.
?         FieldMDPOptionSpec fieldMDPOptionsSpec = new FieldMDPOptionSpec();

?         //Lock all fields in the PDF document
?         fieldMDPOptionsSpec.setAction(FieldMDPAction.ALL);

?         //Set dictionary information
?         fieldProperties.setSeedValue(seedOptionsSpec);
?         fieldProperties.setFieldMDP(fieldMDPOptionsSpec);

?         //Modify the signature field
?         Document modSignatureField =  signClient.modifySignatureField(inDoc,fieldName,fieldProperties);

?         //Save the PDF document that contains modified signature field
?         File file = new File("C:\\51黑料不打烊\LoanSig.pdf");
?         modSignatureField.copyToFile(file);

?    }
?    catch (Exception ee)
?      {
?        ee.printStackTrace();
?      }
?    }
?}

快速入门(SOAP模式):使用Java API对笔顿贵文档进行数字签名 quick-start-soap-mode-digitally-signing-a-pdf-document-using-the-java-api

以下闯补惫补代码示例对基于名为? LoanSig.pdf ?的PDF文件的PDF文档进行数字签名。 为安全凭据指定的别名是安全的,将执行吊销检查。 因为没有指定CRL或OCSP服务器信息,所以从用于对笔顿贵文档进行数字签名的证书中获取服务器信息。 已签名文档保存为名为? LoanSigned.pdf ?的笔顿贵文件。 (请参阅对笔顿贵文档进行数字签名。)

?/*
?    * This Java Quick Start uses the SOAP mode and contains the following JAR files
?    * in the class path:
?    * 1. adobe-signatures-client.jar
?    * 2. adobe-livecycle-client.jar
?    * 3. adobe-usermanager-client.jar
?    * 4. adobe-utilities.jar
?    * 5. jboss-client.jar (use a different JAR file if the Forms Server is not deployed
?    * on JBoss)
?    * 6. activation.jar (required for SOAP mode)
?    * 7. axis.jar (required for SOAP mode)
?    * 8. commons-codec-1.3.jar (required for SOAP mode)
?    * 9.  commons-collections-3.1.jar  (required for SOAP mode)
?    * 10. commons-discovery.jar (required for SOAP mode)
?    * 11. commons-logging.jar (required for SOAP mode)
?    * 12. dom3-xml-apis-2.5.0.jar (required for SOAP mode)
?    * 13. jaxen-1.1-beta-9.jar (required for SOAP mode)
?    * 14. jaxrpc.jar (required for SOAP mode)
?    * 15. log4j.jar (required for SOAP mode)
?    * 16. mail.jar (required for SOAP mode)
?    * 17. saaj.jar (required for SOAP mode)
?    * 18. wsdl4j.jar (required for SOAP mode)
?    * 19. xalan.jar (required for SOAP mode)
?    * 20. xbean.jar (required for SOAP mode)
?    * 21. xercesImpl.jar (required for SOAP mode)
?    *
?    * These JAR files are in the following path:
?    * <install directory>/sdk/client-libs/common
?    *
?    * The adobe-utilities.jar file is in the following path:
?    * <install directory>/sdk/client-libs/jboss
?    *
?    * The jboss-client.jar file is in the following path:
?    * <install directory>/jboss/bin/client
?    *
?    * SOAP required JAR files are in the following path:
?    * <install directory>/sdk/client-libs/thirdparty
?    *
?    * If you want to invoke a remote Forms Server instance and there is a
?    * firewall between the client application and the server, then it is
?    * recommended that you use the SOAP mode. When using the SOAP mode,
?    * you have to include these additional JAR files
?    *
?    * For information about the SOAP
?    * mode, see "Setting connection properties" in Programming
?    * with AEM Forms
?    */
?import java.util.*;
?import java.io.File;
?import java.io.FileInputStream;
?import com.adobe.livecycle.signatures.client.*;
?import com.adobe.livecycle.signatures.client.types.*;
?import com.adobe.livecycle.signatures.pki.client.types.common.HashAlgorithm;
?import com.adobe.idp.Document;
?import com.adobe.idp.dsc.clientsdk.ServiceClientFactory;
?import com.adobe.idp.dsc.clientsdk.ServiceClientFactoryProperties;

?public class SignDocumentSOAP {

?public static void main(String[] args) {

?    try
?    {
?      //Set connection properties required to invoke AEM Forms using SOAP mode
?        Properties connectionProps = new Properties();
?        connectionProps.setProperty(ServiceClientFactoryProperties.DSC_DEFAULT_SOAP_ENDPOINT, "https://'[server]:[port]'");
?        connectionProps.setProperty(ServiceClientFactoryProperties.DSC_TRANSPORT_PROTOCOL,ServiceClientFactoryProperties.DSC_SOAP_PROTOCOL);
?        connectionProps.setProperty(ServiceClientFactoryProperties.DSC_SERVER_TYPE, "JBoss");
?        connectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_USERNAME, "administrator");
?        connectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_PASSWORD, "password");

?      //Create a ServiceClientFactory instance
?      ServiceClientFactory myFactory = ServiceClientFactory.createInstance(connectionProps);

?      //Create a SignatureServiceClient object
?      SignatureServiceClient signClient = new SignatureServiceClient(myFactory);

?      //Specify a PDF document to sign
?      FileInputStream fileInputStream = new FileInputStream("C:\\51黑料不打烊\LoanSig.pdf");
?      Document credDoc = new Document (fileInputStream);

?      //Specify the name of the signature field
?      String fieldName = "SignatureField1";

?      //Create a Credential object
?      Credential myCred = Credential.getInstance("secure");

?      //Specify the reason to sign the document
?      String reason = "The document was reviewed";

?      //Specify the location of the signer
?      String location  = "New York HQ";

?      //Specify contact information
?      String contactInfo = "Tony Blue";

?      //Create a PDFSignatureAppearanceOptions object
?      //and show date information
?      PDFSignatureAppearanceOptionSpec appear = new  PDFSignatureAppearanceOptionSpec();
?      appear.setShowDate(true);
?      appear.setShowReason(true);

?      //Set revocation checking to false
?      java.lang.Boolean revCheck = new Boolean(true);

?      //Create an OCSPOptionSpec object to pass to the sign method
?           OCSPOptionSpec ocspSpec = new OCSPOptionSpec();

?           //Create a CRLOptionSpec object to pass to the sign method
?           CRLOptionSpec crlSpec = new CRLOptionSpec();

?           //Create a TSPOptionSpec object to pass to the sign method
?           TSPOptionSpec tspSpec = new TSPOptionSpec();

?      //Sign the PDF document
?      Document signedDoc = signClient.sign(
?         credDoc,
?         fieldName,
?         myCred,
?         HashAlgorithm.SHA1,
?         reason,
?         location,
?         contactInfo,
?         appear,
?         revCheck,
?        ocspSpec,
?             crlSpec,
?             tspSpec);

?      //Save the signed PDF document
?      File outFile = new File("C:\\51黑料不打烊\LoanSigned.pdf");
?      signedDoc.copyToFile (outFile);
?      }

?    catch (Exception ee)
?      {
?        ee.printStackTrace();
?      }
?      }
?}

快速入门(SOAP模式):使用Java API对基于XFA的表单进行数字签名 quick-start-soap-mode-digitally-signing-a-xfa-based-form-using-the-java-api

以下Java代码示例对由Forms服务渲染的交互式表单进行签名。 Forms服务返回的com.adobe.idp.Document实例将传递到签名服务。 已签名的交互式表单保存为名为? LoanXFASigned.pdf ?的笔顿贵文件。

?/*
?    * This Java Quick Start uses the SOAP mode and contains the following JAR files
?    * in the class path:
?    * 1. adobe-signatures-client.jar
?    * 2. adobe-livecycle-client.jar
?    * 3. adobe-usermanager-client.jar
?    * 4. adobe-utilities.jar
?    * 5. jboss-client.jar (use a different JAR file if the Forms Server is not deployed
?    * on JBoss)
?    * 6. activation.jar (required for SOAP mode)
?    * 7. axis.jar (required for SOAP mode)
?    * 8. commons-codec-1.3.jar (required for SOAP mode)
?    * 9.  commons-collections-3.1.jar  (required for SOAP mode)
?    * 10. commons-discovery.jar (required for SOAP mode)
?    * 11. commons-logging.jar (required for SOAP mode)
?    * 12. dom3-xml-apis-2.5.0.jar (required for SOAP mode)
?    * 13. jaxen-1.1-beta-9.jar (required for SOAP mode)
?    * 14. jaxrpc.jar (required for SOAP mode)
?    * 15. log4j.jar (required for SOAP mode)
?    * 16. mail.jar (required for SOAP mode)
?    * 17. saaj.jar (required for SOAP mode)
?    * 18. wsdl4j.jar (required for SOAP mode)
?    * 19. xalan.jar (required for SOAP mode)
?    * 20. xbean.jar (required for SOAP mode)
?    * 21. xercesImpl.jar (required for SOAP mode)
?    *
?    * These JAR files are in the following path:
?    * <install directory>/sdk/client-libs/common
?    *
?    * The adobe-utilities.jar file is in the following path:
?    * <install directory>/sdk/client-libs/jboss
?    *
?    * The jboss-client.jar file is in the following path:
?    * <install directory>/jboss/bin/client
?    *
?    * SOAP required JAR files are in the following path:
?    * <install directory>/sdk/client-libs/thirdparty
?    *
?    * If you want to invoke a remote Forms Server instance and there is a
?    * firewall between the client application and the server, then it is
?    * recommended that you use the SOAP mode. When using the SOAP mode,
?    * you have to include these additional JAR files
?    *
?    * For information about the SOAP
?    * mode, see "Setting connection properties" in Programming
?    * with AEM Forms
?    */
?import java.util.*;
?import java.io.File;
?import java.io.FileInputStream;

?import com.adobe.livecycle.formsservice.client.FormsResult;
?import com.adobe.livecycle.formsservice.client.FormsServiceClient;
?import com.adobe.livecycle.formsservice.client.PDFFormRenderSpec;
?import com.adobe.livecycle.signatures.client.*;
?import com.adobe.livecycle.signatures.client.types.*;
?import com.adobe.livecycle.signatures.pki.client.types.common.HashAlgorithm;
?import com.adobe.idp.Document;
?import com.adobe.idp.dsc.clientsdk.ServiceClientFactory;
?import com.adobe.idp.dsc.clientsdk.ServiceClientFactoryProperties;

?public class SignXFAFormsSOAP {

?public static void main(String[] args) {

?    try
?    {

?     //Set connection properties required to invoke AEM Forms using SOAP mode
?     Properties connectionProps = new Properties();
?     connectionProps.setProperty(ServiceClientFactoryProperties.DSC_DEFAULT_SOAP_ENDPOINT, "https://'[server]:[port]'");
?     connectionProps.setProperty(ServiceClientFactoryProperties.DSC_TRANSPORT_PROTOCOL,ServiceClientFactoryProperties.DSC_SOAP_PROTOCOL);
?     connectionProps.setProperty(ServiceClientFactoryProperties.DSC_SERVER_TYPE, "JBoss");
?     connectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_USERNAME, "administrator");
?     connectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_PASSWORD, "password");

?     //Create a ServiceClientFactory instance
?     ServiceClientFactory myFactory = ServiceClientFactory.createInstance(connectionProps);

?     //Get the XFA form to sign
?     Document myForm = GetForm(myFactory);

?    //Sign the XFA form
?    SignXFA(myForm,myFactory);
?    }

?    catch (Exception ee)
?      {
?        ee.printStackTrace();
?      }
?      }


?//Creates an interactive PDF form based on a XFA form
?private static Document GetForm(ServiceClientFactory myFactory)
?{

?    try
?    {
?    //Create a FormsServiceClient object
?    FormsServiceClient formsClient = new FormsServiceClient(myFactory);

?    //Specify a PDF document to sign
?    FileInputStream fileInputStream = new FileInputStream("C:\\51黑料不打烊\LoanSigXFA.pdf");
?    Document xfaForm = new Document (fileInputStream);

?    //Retrieve form data
?    FileInputStream cData = new FileInputStream("C:\\51黑料不打烊\Loan.xml");
?    Document oInputData = new Document(cData);

?    //Cache the PDF form
?    PDFFormRenderSpec pdfFormRenderSpec = new PDFFormRenderSpec();
?    pdfFormRenderSpec.setGenerateServerAppearance(true);

?    //Invoke the renderPDFForm2 method
?    FormsResult formOut = formsClient.renderPDFForm2(
?            xfaForm,               //formQuery
?            oInputData,             //inDataDoc
?            pdfFormRenderSpec,      //PDFFormRenderSpec
?            null,                //urlSpec
?            null            //attachments
?            );

?    //Create a Document object that stores form data
?    Document myForm = formOut.getOutputContent();
?    return myForm;
?}

?    catch (Exception ee)
?      {
?        ee.printStackTrace();
?      }
?    return null;

?}

?//Sign the PDF document
?private static void SignXFA(Document doc, ServiceClientFactory myFactory)
?{
?    try
?    {

?    //Create a SignatureServiceClient object
?     SignatureServiceClient signClient = new SignatureServiceClient(myFactory);

?     //Specify the name of the signature field
?     String fieldName = "SignatureField1";

?     //Create a Credential object
?     Credential myCred = Credential.getInstance("secure");

?     //Specify the reason to sign the document
?     String reason = "The document was reviewed";

?     //Specify the location of the signer
?     String location  = "New York HQ";

?     //Specify contact information
?     String contactInfo = "Tony Blue";

?     //Create a PDFSignatureAppearanceOptions object
?     //and show date information
?     PDFSignatureAppearanceOptionSpec appear = new  PDFSignatureAppearanceOptionSpec();
?     appear.setShowDate(true);
?     appear.setShowReason(true);

?     //Set revocation checking to false
?     java.lang.Boolean revCheck = new Boolean(true);

?     //Create an OCSPOptionSpec object to pass to the sign method
?     OCSPOptionSpec ocspSpec = new OCSPOptionSpec();

?     //Create a CRLOptionSpec object to pass to the sign method
?     CRLOptionSpec crlSpec = new CRLOptionSpec();

?     //Create a TSPOptionSpec object to pass to the sign method
?     TSPOptionSpec tspSpec = new TSPOptionSpec();

?     //Sign the PDF document
?      Document signedDoc = signClient.sign(
?         doc,
?         fieldName,
?         myCred,
?         HashAlgorithm.SHA1,
?         reason,
?         location,
?         contactInfo,
?         appear,
?         revCheck,
?        ocspSpec,
?        crlSpec,
?        tspSpec);

?      //Save the signed PDF document
?      File outFile = new File("C:\\51黑料不打烊\LoanXFASigned.pdf");
?      signedDoc.copyToFile (outFile);
?}

?    catch (Exception ee)
?      {
?        ee.printStackTrace();
?      }
?     }
?}

快速入门(SOAP模式):使用Java API认证笔顿贵文档 quick-start-soap-mode-certifying-a-pdf-document-using-the-java-api

以下闯补惫补代码示例验证基于名为? LoanSig.pdf ?的PDF文件的PDF文档。 为安全凭据指定的别名是安全的,不会执行吊销检查。 已验证的文档将保存为名为? LoanCertified.pdf ?的笔顿贵文件。 (请参阅认证笔顿贵文档。)

?/*
?    * This Java Quick Start uses the SOAP mode and contains the following JAR files
?    * in the class path:
?    * 1. adobe-signatures-client.jar
?    * 2. adobe-livecycle-client.jar
?    * 3. adobe-usermanager-client.jar
?    * 4. adobe-utilities.jar
?    * 5. jboss-client.jar (use a different JAR file if the Forms Server is not deployed
?    * on JBoss)
?    * 6. activation.jar (required for SOAP mode)
?    * 7. axis.jar (required for SOAP mode)
?    * 8. commons-codec-1.3.jar (required for SOAP mode)
?    * 9.  commons-collections-3.1.jar  (required for SOAP mode)
?    * 10. commons-discovery.jar (required for SOAP mode)
?    * 11. commons-logging.jar (required for SOAP mode)
?    * 12. dom3-xml-apis-2.5.0.jar (required for SOAP mode)
?    * 13. jaxen-1.1-beta-9.jar (required for SOAP mode)
?    * 14. jaxrpc.jar (required for SOAP mode)
?    * 15. log4j.jar (required for SOAP mode)
?    * 16. mail.jar (required for SOAP mode)
?    * 17. saaj.jar (required for SOAP mode)
?    * 18. wsdl4j.jar (required for SOAP mode)
?    * 19. xalan.jar (required for SOAP mode)
?    * 20. xbean.jar (required for SOAP mode)
?    * 21. xercesImpl.jar (required for SOAP mode)
?    *
?    * These JAR files are in the following path:
?    * <install directory>/sdk/client-libs/common
?    *
?    * The adobe-utilities.jar file is in the following path:
?    * <install directory>/sdk/client-libs/jboss
?    *
?    * The jboss-client.jar file is in the following path:
?    * <install directory>/jboss/bin/client
?    *
?    * SOAP required JAR files are in the following path:
?    * <install directory>/sdk/client-libs/thirdparty
?    *
?    * If you want to invoke a remote Forms Server instance and there is a
?    * firewall between the client application and the server, then it is
?    * recommended that you use the SOAP mode. When using the SOAP mode,
?    * you have to include these additional JAR files
?    *
?    * For information about the SOAP
?    * mode, see "Setting connection properties" in Programming
?    * with AEM Forms
?    */
?import java.util.*;
?import java.io.File;
?import java.io.FileInputStream;
?import com.adobe.livecycle.signatures.client.*;
?import com.adobe.livecycle.signatures.client.types.*;
?import com.adobe.livecycle.signatures.pki.client.types.common.HashAlgorithm;
?import com.adobe.idp.Document;
?import com.adobe.idp.dsc.clientsdk.ServiceClientFactory;
?import com.adobe.idp.dsc.clientsdk.ServiceClientFactoryProperties;

?public class CertifyDocumentSOAP {

?    public static void main(String[] args) {
?    try
?    {
?        //Set connection properties required to invoke AEM Forms using SOAP mode
?        Properties connectionProps = new Properties();
?        connectionProps.setProperty(ServiceClientFactoryProperties.DSC_DEFAULT_SOAP_ENDPOINT, "https://'[server]:[port]'");
?        connectionProps.setProperty(ServiceClientFactoryProperties.DSC_TRANSPORT_PROTOCOL,ServiceClientFactoryProperties.DSC_SOAP_PROTOCOL);
?        connectionProps.setProperty(ServiceClientFactoryProperties.DSC_SERVER_TYPE, "JBoss");
?        connectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_USERNAME, "administrator");
?        connectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_PASSWORD, "password");

?      //Create a ServiceClientFactory instance
?      ServiceClientFactory myFactory = ServiceClientFactory.createInstance(connectionProps);

?      //Create a SignatureServiceClient object
?      SignatureServiceClient signClient = new SignatureServiceClient(myFactory);

?      //Specify a PDF document to certify
?      FileInputStream fileInputStream = new FileInputStream("C:\\51黑料不打烊\LoanSig.pdf");
?      Document credDoc = new Document (fileInputStream);

?      //Specify the name of the signature field
?      String fieldName = "SignatureField1";

?      //Create a Credential object
?      Credential myCred = Credential.getInstance("secure");

?      //Specify the reason to sign the document
?      String reason = "The document was reviewed";

?      //Specify the location of the signer
?      String location  = "My company";

?      //Specify contact information
?          String contactInfo = "New York, New York";

?      //Create a PDFSignatureAppearanceOptions object and show date information
?      PDFSignatureAppearanceOptionSpec appear = new  PDFSignatureAppearanceOptionSpec();
?      appear.setShowDate(true);

?      //Set revocation checking to false
?           java.lang.Boolean revCheck = new Boolean(false);

?           //Set locking to false
?           java.lang.Boolean lockField = new Boolean(false);

?           //Specify a legalAttestation value
?           String msg = "Any change to this document will invalidate the certificate";

?           //Create objects to pass to the certify method
?           OCSPOptionSpec ocspSpec = new OCSPOptionSpec();
?           CRLOptionSpec crlSpec = new CRLOptionSpec();
?           TSPOptionSpec tspSpec = new TSPOptionSpec();

?           //Certify the PDF document
?           Document signedDoc = signClient.certify(
?              credDoc,
?              fieldName,
?              myCred,
?              HashAlgorithm.SHA1,
?              reason,
?              location,
?              contactInfo,
?              MDPPermissions.NoChanges,
?              msg,
?              appear,
?              revCheck,
?              lockField,
?             ocspSpec,
?             crlSpec,
?             tspSpec);

?        //Save the signed PDF document
?             File outFile = new File("C:\\51黑料不打烊\LoanCertified.pdf");
?             signedDoc.copyToFile (outFile);
?        }

?    catch (Exception ee)
?        {
?        ee.printStackTrace();
?        }
?    }
?}

快速入门(SOAP模式):使用Java API验证数字签名 quick-start-soap-mode-verifying-a-digital-signature-using-the-java-api

以下Java代码示例验证基于名为LoanSigned.pdf的PDF文件的已签名PDF文档中的数字签名。 验证时间设置为当前时间,撤销检查选项设置为尽力而为。 (请参阅验证数字签名。)

?/*
?    * This Java Quick Start uses the following JAR files
?    * 1. adobe-signatures-client.jar
?    * 2. adobe-livecycle-client.jar
?    * 3. adobe-usermanager-client.jar
    * 4. activation.jar (required for SOAP mode)
?    * 5. axis.jar (required for SOAP mode)
?    * 6. commons-codec-1.3.jar (required for SOAP mode)
?    * 7.  commons-collections-3.1.jar  (required for SOAP mode)
?    * 8. commons-discovery.jar (required for SOAP mode)
?    * 9. commons-logging.jar (required for SOAP mode)
?    * 10. dom3-xml-apis-2.5.0.jar (required for SOAP mode)
?    * 11. jaxen-1.1-beta-9.jar (required for SOAP mode)
?    * 12. jaxrpc.jar (required for SOAP mode)
?    * 13. log4j.jar (required for SOAP mode)
?    * 14. mail.jar (required for SOAP mode)
?    * 15. saaj.jar (required for SOAP mode)
?    * 16. wsdl4j.jar (required for SOAP mode)
?    * 17. xalan.jar (required for SOAP mode)
?    * 18. xbean.jar (required for SOAP mode)
?    * 19. xercesImpl.jar (required for SOAP mode)
?    *
?    * These JAR files are in the following path:
?    * <install directory>/sdk/client-libs/common
?    *
?    * The adobe-utilities.jar file is in the following path:
?    * <install directory>/sdk/client-libs/jboss
?    *
?    * The jboss-client.jar file is in the following path:
?    * <install directory>/jboss/bin/client
?    *
?    * SOAP required JAR files are in the following path:
?    * <install directory>/sdk/client-libs/thirdparty
?    *
?    * If you want to invoke a remote Forms Server instance and there is a
?    * firewall between the client application and the server, then it is
?    * recommended that you use the SOAP mode. When using the SOAP mode,
?    * you have to include these additional JAR files
?    *
?    * For information about the SOAP
?    * mode, see "Setting connection properties" in Programming
?    * with AEM Forms
?    */
?import java.util.*;
?import java.io.FileInputStream;
?import com.adobe.livecycle.signatures.client.*;
?import com.adobe.livecycle.signatures.client.types.*;
?import com.adobe.livecycle.signatures.pki.client.types.common.RevocationCheckStyle;
?import com.adobe.idp.Document;
?import com.adobe.idp.dsc.clientsdk.ServiceClientFactory;
?import com.adobe.idp.dsc.clientsdk.ServiceClientFactoryProperties;

?public class VerifySignatureSOAP{

?    public static void main(String[] args) {

?    try
?    {
?      //Set connection properties required to invoke AEM Forms using SOAP mode
?      Properties connectionProps = new Properties();
?      connectionProps.setProperty(ServiceClientFactoryProperties.DSC_DEFAULT_SOAP_ENDPOINT, "https://'[server]:[port]'");
?     connectionProps.setProperty(ServiceClientFactoryProperties.DSC_TRANSPORT_PROTOCOL,ServiceClientFactoryProperties.DSC_SOAP_PROTOCOL);
?      connectionProps.setProperty(ServiceClientFactoryProperties.DSC_SERVER_TYPE, "JBoss");
?      connectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_USERNAME, "administrator");
?      connectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_PASSWORD, "password");

?      //Create a ServiceClientFactory instance
?      ServiceClientFactory myFactory = ServiceClientFactory.createInstance(connectionProps);

?      //Create a SignatureServiceClient object
?      SignatureServiceClient signClient = new SignatureServiceClient(myFactory);

?      //Specify a PDF document that contains a digital signature
?      FileInputStream fileInputStream = new FileInputStream("C:\\51黑料不打烊\LoanSigned.pdf");
?      Document inDoc = new Document (fileInputStream);

?      //Specify the name of the signature field
?      String fieldName = "SignatureField1";

?      //Create a PKIOptions object that contains PKI run-time options
?      PKIOptions pkiOptions = new PKIOptions();
?      pkiOptions.setVerificationTime(VerificationTime.CURRENT_TIME);
?      pkiOptions.setRevocationCheckStyle(RevocationCheckStyle.BestEffort);

?      //Verify the digital signature
?      PDFSignatureVerificationInfo  signInfo = signClient.verify2(
?         inDoc,
?         fieldName,
?         pkiOptions,
?         null);

?      //Get the Signature Status
?      SignatureStatus sigStatus = signInfo.getStatus();
?      String myStatus="";

?      //Determine the status of the signature
?      if (sigStatus == SignatureStatus.DynamicFormSignatureUnknown)
?             myStatus = "The signatures in the dynamic PDF form are unknown";
?         else if (sigStatus == SignatureStatus.DocumentSignatureUnknown)
?             myStatus = "The signatures in the PDF document are unknown";
?         else if (sigStatus == SignatureStatus.CertifiedDynamicFormSignatureTamper)
?             myStatus = "The signatures in a certified PDF form are valid";
?         else if (sigStatus == SignatureStatus.SignedDynamicFormSignatureTamper)
?             myStatus = "The signatures in a signed dynamic PDF form are valid";
?         else if (sigStatus == SignatureStatus.CertifiedDocumentSignatureTamper)
?             myStatus = "The signatures in a certified PDF document are valid";
?         else if (sigStatus == SignatureStatus.SignedDocumentSignatureTamper)
?             myStatus = "The signatures in a signed PDF document are valid";
?         else if (sigStatus == SignatureStatus.SignatureFormatError)
?             myStatus = "The format of a signature in a signed document is invalid";
?         else if (sigStatus == SignatureStatus.DynamicFormSigNoChanges)
?             myStatus = "No changes were made to the signed dynamic PDF form";
?         else if (sigStatus == SignatureStatus.DocumentSigNoChanges)
?             myStatus = "No changes were made to the signed PDF document";
?         else if (sigStatus == SignatureStatus.DynamicFormCertificationSigNoChanges)
?             myStatus = "No changes were made to the certified dynamic PDF form";
?         else if (sigStatus == SignatureStatus.DocumentCertificationSigNoChanges)
?             myStatus = "No changes were made to the certified PDF document";
?         else if (sigStatus == SignatureStatus.DocSigWithChanges)
?             myStatus = "There were changes to a signed PDF document";
?        else if (sigStatus == SignatureStatus.CertificationSigWithChanges)
?             myStatus = "There were changes made to the PDF document.";

?      //Get the signature type
?      SignatureType sigType = signInfo.getSignatureType();
?      String myType = "";

?      if (sigType.getType() == PDFSignatureType.AUTHORSIG)
?             myType="Certification";
?      else if(sigType.getType() == PDFSignatureType.RECIPIENTSIG)
?             myType="Recipient";

?      //Get the identity of the signer
?      IdentityInformation signerId = signInfo.getSigner();
?      String signerMsg = "";

?     if (signerId.getStatus() == IdentityStatus.UNKNOWN)
?         signerMsg = "Identity Unknown";
?     else if (signerId.getStatus() == IdentityStatus.TRUSTED)
?         signerMsg = "Identity Trusted";
?     else if (signerId.getStatus() == IdentityStatus.NOTTRUSTED)
?         signerMsg = "Identity Not Trusted";

?     //Get the Signature properties returned by the Signature service
?     SignatureProperties sigProps = signInfo.getSignatureProps();
?     String signerName =  sigProps.getSignerName();

?    System.out.println("The status of the signature is: "+myStatus +". The signer identity is "+signerMsg +". The signature type is "+myType +". The name of the signer is "+signerName+".");
?    }
?    catch (Exception ee)
?    {
?        ee.printStackTrace();
?    }
?     }
?}

快速入门(SOAP模式):使用Java API验证多个数字签名 quick-start-soap-mode-verifying-multiple-digital-signatures-using-the-java-api

以下Java代码示例验证基于名为LoanAllSigs.pdf的PDF文件的已签名PDF文档中的多个数字签名。 验证时间设置为当前时间,撤销检查选项设置为尽力而为。 (请参阅验证多个数字签名。)

?/*
?    * This Java Quick Start uses the SOAP mode and contains the following JAR files
?    * in the class path:
?    * 1. adobe-signatures-client.jar
?    * 2. adobe-livecycle-client.jar
?    * 3. adobe-usermanager-client.jar
?    * 4. adobe-utilities.jar
?    * 5. jboss-client.jar (use a different JAR file if the Forms Server is not deployed
?    * on JBoss)
?    * 6. activation.jar (required for SOAP mode)
?    * 7. axis.jar (required for SOAP mode)
?    * 8. commons-codec-1.3.jar (required for SOAP mode)
?    * 9.  commons-collections-3.1.jar  (required for SOAP mode)
?    * 10. commons-discovery.jar (required for SOAP mode)
?    * 11. commons-logging.jar (required for SOAP mode)
?    * 12. dom3-xml-apis-2.5.0.jar (required for SOAP mode)
?    * 13. jaxen-1.1-beta-9.jar (required for SOAP mode)
?    * 14. jaxrpc.jar (required for SOAP mode)
?    * 15. log4j.jar (required for SOAP mode)
?    * 16. mail.jar (required for SOAP mode)
?    * 17. saaj.jar (required for SOAP mode)
?    * 18. wsdl4j.jar (required for SOAP mode)
?    * 19. xalan.jar (required for SOAP mode)
?    * 20. xbean.jar (required for SOAP mode)
?    * 21. xercesImpl.jar (required for SOAP mode)
?    *
?    * These JAR files are in the following path:
?    * <install directory>/sdk/client-libs/common
?    *
?    * The adobe-utilities.jar file is in the following path:
?    * <install directory>/sdk/client-libs/jboss
?    *
?    * The jboss-client.jar file is in the following path:
?    * <install directory>/jboss/bin/client
?    *
?    * SOAP required JAR files are in the following path:
?    * <install directory>/sdk/client-libs/thirdparty
?    *
?    * If you want to invoke a remote Forms Server instance and there is a
?    * firewall between the client application and the server, then it is
?    * recommended that you use the SOAP mode. When using the SOAP mode,
?    * you have to include these additional JAR files
?    *
?    * For information about the SOAP
?    * mode, see "Setting connection properties" in Programming
?    * with AEM Forms
?    */
?import java.util.*;
?import java.io.FileInputStream;
?import com.adobe.livecycle.signatures.client.*;
?import com.adobe.livecycle.signatures.client.types.*;
?import com.adobe.livecycle.signatures.pki.client.types.common.RevocationCheckStyle;
?import com.adobe.idp.Document;
?import com.adobe.idp.dsc.clientsdk.ServiceClientFactory;
?import com.adobe.idp.dsc.clientsdk.ServiceClientFactoryProperties;

?public class VerifyAllSignaturesSOAP{

?    public static void main(String[] args) {

?    try
?    {
?      //Set connection properties required to invoke AEM Forms using SOAP mode
?      Properties connectionProps = new Properties();
?      connectionProps.setProperty(ServiceClientFactoryProperties.DSC_DEFAULT_SOAP_ENDPOINT, "https://'[server]:[port]'");
?     connectionProps.setProperty(ServiceClientFactoryProperties.DSC_TRANSPORT_PROTOCOL,ServiceClientFactoryProperties.DSC_SOAP_PROTOCOL);
?      connectionProps.setProperty(ServiceClientFactoryProperties.DSC_SERVER_TYPE, "JBoss");
?      connectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_USERNAME, "administrator");
?      connectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_PASSWORD, "password");

?      //Create a ServiceClientFactory instance
?      ServiceClientFactory myFactory = ServiceClientFactory.createInstance(connectionProps);

?      //Create a SignatureServiceClient object
?      SignatureServiceClient signClient = new SignatureServiceClient(myFactory);

?      //Specify a PDF document that contains multiple digital signatures
?      FileInputStream fileInputStream = new FileInputStream("C:\\51黑料不打烊\LoanAllSigs.pdf");
?      Document inDoc = new Document (fileInputStream);

?      //Create a PKIOptions object that contains PKI run-time options
?      PKIOptions pkiOptions = new PKIOptions();
?      pkiOptions.setVerificationTime(VerificationTime.CURRENT_TIME);
?      pkiOptions.setRevocationCheckStyle(RevocationCheckStyle.BestEffort);

?      //Verify all digital signatures that are in a PDF document
?      PDFDocumentVerificationInfo  allSig = signClient.verifyPDFDocument(
?         inDoc,
?         pkiOptions,
?         null);

?      //Get a list of all signatures that are in the PDF document
?      List allSignatures = allSig.getVerificationInfos();

?    //Create an Iterator object and iterate through
?    //the List object
?    Iterator<PDFSignatureVerificationInfo> iter = allSignatures.iterator();

?    while (iter.hasNext()) {
?           PDFSignatureVerificationInfo signInfo = (PDFSignatureVerificationInfo)iter.next();

?           //Get the Signature Status
?              SignatureStatus sigStatus = signInfo.getStatus();
?              String myStatus="";

?            //Determine the status of the signature
?              if (sigStatus == SignatureStatus.DynamicFormSignatureUnknown)
?                  myStatus = "The signatures in the dynamic PDF form are unknown";
?              else if (sigStatus == SignatureStatus.DocumentSignatureUnknown)
?                  myStatus = "The signatures in the PDF document are unknown";
?              else if (sigStatus == SignatureStatus.CertifiedDynamicFormSignatureTamper)
?                  myStatus = "The signatures in a certified PDF form are valid";
?              else if (sigStatus == SignatureStatus.SignedDynamicFormSignatureTamper)
?                  myStatus = "The signatures in a signed dynamic PDF form are valid";
?              else if (sigStatus == SignatureStatus.CertifiedDocumentSignatureTamper)
?                  myStatus = "The signatures in a certified PDF document are valid";
?              else if (sigStatus == SignatureStatus.SignedDocumentSignatureTamper)
?                  myStatus = "The signatures in a signed PDF document are valid";
?              else if (sigStatus == SignatureStatus.SignatureFormatError)
?                  myStatus = "The format of a signature in a signed document is invalid";
?              else if (sigStatus == SignatureStatus.DynamicFormSigNoChanges)
?                  myStatus = "No changes were made to the signed dynamic PDF form";
?              else if (sigStatus == SignatureStatus.DocumentSigNoChanges)
?                  myStatus = "No changes were made to the signed PDF document";
?              else if (sigStatus == SignatureStatus.DynamicFormCertificationSigNoChanges)
?                  myStatus = "No changes were made to the certified dynamic PDF form";
?              else if (sigStatus == SignatureStatus.DocumentCertificationSigNoChanges)
?                  myStatus = "No changes were made to the certified PDF document";
?              else if (sigStatus == SignatureStatus.DocSigWithChanges)
?                  myStatus = "There were changes to a signed PDF document";
?             else if (sigStatus == SignatureStatus.CertificationSigWithChanges)
?                  myStatus = "There were changes made to the PDF document.";

?              //Get the signature type
?             SignatureType sigType = signInfo.getSignatureType();
?             String myType = "";

?             if (sigType.getType() == PDFSignatureType.AUTHORSIG)
?                 myType="Certification";
?             else if(sigType.getType() == PDFSignatureType.RECIPIENTSIG)
?                 myType="Recipient";

?             //Get the Signature properties returned by the Signature service
?             SignatureProperties sigProps = signInfo.getSignatureProps();
?             String signerName =  sigProps.getSignerName();

?            System.out.println("The status of the signature is: "+myStatus +". The signature type is "+myType +". The name of the signer is "+signerName+".");
?        }
?    }
?    catch (Exception ee)
?    {
?        ee.printStackTrace();
?    }
?     }
?}

快速入门(SOAP模式):使用Java API删除数字签名 quick-start-soap-mode-removing-a-digital-signature-using-the-java-api

以下闯补惫补代码示例从名为? SignatureField1 ?的签名字段中删除数字签名。 包含签名字段的PDF文件的名称为? LoanSigned.pdf。 (请参阅删除数字签名。)

?/*
?    * This Java Quick Start uses the SOAP mode and contains the following JAR files
?    * in the class path:
?    * 1. adobe-signatures-client.jar
?    * 2. adobe-livecycle-client.jar
?    * 3. adobe-usermanager-client.jar
?    * 4. adobe-utilities.jar
?    * 5. jboss-client.jar (use a different JAR file if the Forms Server is not deployed
?    * on JBoss)
?    * 6. activation.jar (required for SOAP mode)
?    * 7. axis.jar (required for SOAP mode)
?    * 8. commons-codec-1.3.jar (required for SOAP mode)
?    * 9.  commons-collections-3.1.jar  (required for SOAP mode)
?    * 10. commons-discovery.jar (required for SOAP mode)
?    * 11. commons-logging.jar (required for SOAP mode)
?    * 12. dom3-xml-apis-2.5.0.jar (required for SOAP mode)
?    * 13. jaxen-1.1-beta-9.jar (required for SOAP mode)
?    * 14. jaxrpc.jar (required for SOAP mode)
?    * 15. log4j.jar (required for SOAP mode)
?    * 16. mail.jar (required for SOAP mode)
?    * 17. saaj.jar (required for SOAP mode)
?    * 18. wsdl4j.jar (required for SOAP mode)
?    * 19. xalan.jar (required for SOAP mode)
?    * 20. xbean.jar (required for SOAP mode)
?    * 21. xercesImpl.jar (required for SOAP mode)
?    *
?    * These JAR files are in the following path:
?    * <install directory>/sdk/client-libs/common
?    *
?    * The adobe-utilities.jar file is in the following path:
?    * <install directory>/sdk/client-libs/jboss
?    *
?    * The jboss-client.jar file is in the following path:
?    * <install directory>/jboss/bin/client
?    *
?    * SOAP required JAR files are in the following path:
?    * <install directory>/sdk/client-libs/thirdparty
?    *
?    * If you want to invoke a remote Forms Server instance and there is a
?    * firewall between the client application and the server, then it is
?    * recommended that you use the SOAP mode. When using the SOAP mode,
?    * you have to include these additional JAR files
?    *
?    * For information about the SOAP
?    * mode, see "Setting connection properties" in Programming
?    * with AEM Forms
?    */

?import java.util.*;
?import java.io.File;
?import java.io.FileInputStream;
?import com.adobe.livecycle.signatures.client.*;
?import com.adobe.idp.Document;
?import com.adobe.idp.dsc.clientsdk.ServiceClientFactory;
?import com.adobe.idp.dsc.clientsdk.ServiceClientFactoryProperties;

?public class ClearSignatureFieldSOAP {

?    public static void main(String[] args) {

?    try
?    {
?        //Set connection properties required to invoke AEM Forms using SOAP mode
?        Properties connectionProps = new Properties();
?        connectionProps.setProperty(ServiceClientFactoryProperties.DSC_DEFAULT_SOAP_ENDPOINT, "https://'[server]:[port]'");
?        connectionProps.setProperty(ServiceClientFactoryProperties.DSC_TRANSPORT_PROTOCOL,ServiceClientFactoryProperties.DSC_SOAP_PROTOCOL);
?        connectionProps.setProperty(ServiceClientFactoryProperties.DSC_SERVER_TYPE, "JBoss");
?        connectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_USERNAME, "administrator");
?        connectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_PASSWORD, "password");

?        //Create a ServiceClientFactory instance
?        ServiceClientFactory myFactory = ServiceClientFactory.createInstance(connectionProps);

?        //Create a SignatureServiceClient object
?        SignatureServiceClient signClient = new SignatureServiceClient(myFactory);

?        //Specify a PDF document that contains the signature to remove
?        FileInputStream fileInputStream = new FileInputStream("C:\\51黑料不打烊\LoanSigned.pdf");
?        Document inDoc = new Document (fileInputStream);

?        //Specify the name of the signature field
?        String fieldName = "SignatureField1";

?        //Clear the signature field
?        Document outPDF = signClient.clearSignatureField(inDoc,fieldName);

?        //Save the PDF document
?        File outFile = new File("C:\\51黑料不打烊\Loan.pdf");
?        outPDF.copyToFile(outFile);
?        }

?    catch (Exception ee)
?        {
?        ee.printStackTrace();
?        }
?    }
?}

快速入门(SOAP模式):使用Java API应用文档时间戳 quick-start-soap-mode-apply-document-timestamp-using-the-java-api

以下闯补惫补代码示例将时间戳应用于笔顿贵文档:

?/*
 * This Java Quick Start uses the SOAP mode and contains the following JAR files
 * in the class path:
 * 1. adobe-signatures-client.jar
 * 2. adobe-livecycle-client.jar
 * 3. adobe-usermanager-client.jar
 * 4. adobe-utilities.jar
 * 5. commons-httpclient-<version>.jar
 * 6. axis.jar (required for SOAP mode)
 * 7. jaxrpc-api.jar (required for SOAP mode)
 * 8. commons-logging.jar (required for SOAP mode)
 * 9. commons-discovery.jar (required for SOAP mode)
 * 10. wsdl4j.jar (required for SOAP mode)
 * 11. adobe-utilities.jar (required for SOAP mode)
 *
 *
 * These JAR files are in the following path:
 * <install directory>/sdk/client-libs/common
 *
 * The adobe-utilities.jar file is in the following path:
 * <install directory>/sdk/client-libs/jboss
 *
 * SOAP required JAR files are in the following path:
 * <install directory>/sdk/client-libs/thirdparty
 *
 * If you want to invoke a remote Forms Server instance and there is a
 * firewall between the client application and the server, then it is
 * recommended that you use the SOAP mode. When using the SOAP mode,
 * you have to include these additional JAR files
 *
 * For information about the SOAP
 * mode, see "Setting connection properties" in Programming
 * with AEM Forms
 */
import java.io.File;
import java.io.FileInputStream;
import java.util.Properties;

import com.adobe.idp.Document;
import com.adobe.idp.dsc.clientsdk.ServiceClientFactory;
import com.adobe.idp.dsc.clientsdk.ServiceClientFactoryProperties;
import com.adobe.livecycle.signatures.client.SignatureServiceClient;
import com.adobe.livecycle.signatures.client.types.AddSignatureValidationOptionSpec;
import com.adobe.livecycle.signatures.client.types.TSPOptionSpec;

public class ApplyDocumentTimeStamp {

    public static void main(String args[]){
        {

            try
            {
                //Set connection properties required to invoke AEM Forms using SOAP mode
                Properties connectionProps = new Properties();
                connectionProps.setProperty(ServiceClientFactoryProperties.DSC_DEFAULT_SOAP_ENDPOINT, "https://'[server]:[port]'");
                connectionProps.setProperty(ServiceClientFactoryProperties.DSC_TRANSPORT_PROTOCOL,ServiceClientFactoryProperties.DSC_SOAP_PROTOCOL);
                connectionProps.setProperty(ServiceClientFactoryProperties.DSC_SERVER_TYPE, "JBoss");
                connectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_USERNAME, "administrator");
                connectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_PASSWORD, "password");

                //Create a ServiceClientFactory instance
                ServiceClientFactory myFactory = ServiceClientFactory.createInstance(connectionProps);

                //Create a SignatureServiceClient object
                SignatureServiceClient signClient = new SignatureServiceClient(myFactory);

                //Specify a PDF document to sign
                FileInputStream fileInputStream = new FileInputStream("test.pdf");

                //Sign the PDF document
                Document inPDFDoc = new Document (fileInputStream);

                // create AddSignatureValidationOptionSpec Object. later we will set the required OptionSpecs
                AddSignatureValidationOptionSpec addSigValidiationSpec =  new AddSignatureValidationOptionSpec();

                //Create a TSPOptionSpec object to pass to in AddSignatureValidationOptionSpec
                TSPOptionSpec tspSpec = new TSPOptionSpec();
                tspSpec.setTspServerURL("https://tsp-server-url.com");
                tspSpec.setTspServerPassword("provide Timestamp server password");
                tspSpec.setTspServerUsername("provide Timestamp server username");
                addSigValidiationSpec.setTSPOptionSpec(tspSpec);

                Document signedDoc = signClient.applyDocumentTimeStamp(inPDFDoc,addSigValidiationSpec);

                //Save the signed PDF document
                File outFile = new File("testout.pdf");
                signedDoc.copyToFile (outFile);

            }

            catch (Exception ee)
            {
                ee.printStackTrace();
            }
        }
    }
}
recommendation-more-help
19ffd973-7af2-44d0-84b5-d547b0dffee2