Card Viewer Extended Technical Documentation

De Trustedbird Client Wiki
English | Français

> Documentation > Add-on: Card Viewer Extended > Technical Documentation


Architecture

Architecture

GUI files

On the level of the GUI only the card contact is modified by overlay to add a button allowing to display the corresponding certificate.

Card viewer extended en.gif Card viewer extended certificat en.gif

XPCOM files

We must distinguish two types of certificate: local certificate, stored in the mail client and a remote certificate, stored in the LDAP server. Indeed, the mode to recover both types is different. In all cases, the key used to retrieve the certificate for a contact is the email address. The card of a local or remote contact is displayed by the same XUL file. This one manages these two cases differently: for example, editable fields. The LDAP attribute read to get a certificate is "userCertificate". This attribute is binary data.

Local Certificate

The nsIX509CertDB service recover a local certificate using an address mail as a key with the following method :

nsIX509Cert findCertByEmailAddress(nsISupports token , char* emailAddress)


This certificate object must be passed to this nsICertificateDialogs service, which will be given entirely the responsability to display the certificate in a dedicated window. The Javascript code to be implemented can be taken from the existing file pippki.js:

 const nsICertificateDialogs = Components.interfaces.nsICertificateDialogs;
 const nsCertificateDialogs = "@mozilla.org/nsCertificateDialogs;1"

 function viewCertHelper(parent, cert) {
  if (!cert) {
    return;
  }

  var cd = Components.classes[nsCertificateDialogs].getService(nsICertificateDialogs);
  cd.viewCert(parent, cert);
}


It will be better to duplicate this code in a dedicated file abCardOverlay_overlay.js, to be sure that the evolutions of the file pippki.js does not make a regression.

Remote Certificate

To communicate with LDAP directory, the XPCOM API provide an interface nsILDAPOperation and the method:

void searchExt( AUTF8String baseDn , PRInt32 scope , AUTF8String filter , PRUint32 attrCount , arrayof char* attributes , PRIntervalTime timeOut , PRInt32 sizeLimit )

The LDAP attribute read to get a certificate is "userCertificate". During the read, it is needed to use the following attribute "userCertificate;binary" to specify that this attribute is binary. A sample to get a certificate from a LDAP directory is available in the library certFetchingStatus.js. The request is in the kickOffSearch() method.