Sample code for 30+ languages & platforms
Android™

Example: Crypt2.LastSignerCert method

Demonstrates how to call the LastSignerCert method.

Chilkat Android™ Downloads

Android™
// Important: Don't forget to include the call to System.loadLibrary
// as shown at the bottom of this code sample.
package com.test;

import android.app.Activity;
import com.chilkatsoft.*;

import android.widget.TextView;
import android.os.Bundle;

public class SimpleActivity extends Activity {

  private static final String TAG = "Chilkat";

  // Called when the activity is first created.
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    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) {
        Log.i(TAG, 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);
        Log.i(TAG, "Signer: " + cert.subjectDN());
        i = i + 1;
        }


  }

  static {
      System.loadLibrary("chilkat");

      // Note: If the incorrect library name is passed to System.loadLibrary,
      // then you will see the following error message at application startup:
      //"The application <your-application-name> has stopped unexpectedly. Please try again."
  }
}