Sample code for 30+ languages & platforms
Java

Example: Crypt2.LastSignerCert method

Demonstrates how to call the LastSignerCert method.

Chilkat Java Downloads

Java
import com.chilkatsoft.*;

public class ChilkatExample {

  static {
    try {
        System.loadLibrary("chilkat");
    } catch (UnsatisfiedLinkError e) {
      System.err.println("Native code library failed to load.\n" + e);
      System.exit(1);
    }
  }

  public static void main(String argv[])
  {
    boolean success = false;

    CkCrypt2 crypt = new CkCrypt2();

    String p7m_path = "qa_data/p7m/Firma.docx.p7m";
    String out_path = "qa_output/Firma.docx";

    success = crypt.VerifyP7M(p7m_path,out_path);
    if (success == false) {
        System.out.println(crypt.lastErrorText());
        return;
        }

    //  Examine the certificate(s) used for signing.
    int numSigners = crypt.get_NumSignerCerts();
    int i = 0;

    CkCert cert = new CkCert();

    while (i < numSigners) {
        crypt.LastSignerCert(i,cert);
        System.out.println("Signer: " + cert.subjectDN());
        i = i+1;
        }
  }
}