Android™
Android™
Get an S/MIME Signing Time
See more MIME Examples
Demonstrates the Chilkat Mime.GetSignatureSigningTimeStr method, which returns the CMS signingTime attribute for the signer at a zero-based index, as an RFC 822-style date string in GMT. The only argument is the signer index.
Note: The file paths are relative to the application's current working directory. Absolute paths may also be used. Supply the paths appropriate to your own environment.
Background: This is the timestamp the signer asserted at signing — useful for "when was this signed" audit trails and for evaluating whether the signing certificate was valid at that moment. Because it is a signed attribute, it is tamper-evident. Guard the call with
HasSignatureSigningTime, since the attribute is optional. Note it is the signer's claim, not a trusted third-party timestamp.Chilkat Android™ Downloads
// 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;
CkMime mime = new CkMime();
success = mime.LoadMimeFile("qa_data/signed.eml");
if (success == false) {
Log.i(TAG, mime.lastErrorText());
return;
}
// After verifying, get the CMS signingTime for each signer that has one, as an RFC 822 date string
// in GMT. The only argument is the zero-based signer index.
success = mime.Verify();
if (success != true) {
Log.i(TAG, mime.lastErrorText());
return;
}
int n = mime.get_NumSignerCerts();
int i;
for (i = 0; i <= n - 1; i++) {
// Only signers that included a signing time have one to retrieve.
if (mime.HasSignatureSigningTime(i)) {
String signingTime = mime.getSignatureSigningTimeStr(i);
if (mime.get_LastMethodSuccess() == false) {
Log.i(TAG, mime.lastErrorText());
return;
}
Log.i(TAG, "Signer " + String.valueOf(i) + " signing time: " + signingTime);
}
}
}
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."
}
}