DEPRECATED - LacunaWebPKI: listing certificates (jQuery)

by Lacuna Software

HTML

<script src="https://webpki.lacunasoftware.com/Scripts/LacunaWebPKI/lacuna-web-pki-1.3.1.js"></script>
<button id="startButton" type="button">Start</button>
<div id="signatureControlsPanel">
    <select id="certificateSelect"></select>
    <button id="getSelectedCertButton" type="button">Get Selected Cert</button>
</div>
<div id="notInstalledPanel">
    <p id="notInstalledMessage"></p>
    <p>Click OK to install/update the component.</p>
    <button type="button">OK</button>
</div>
<div id="logPanel"></div>

CSS

#signatureControlsPanel {
    margin-top: 1em;
    display: none;
}
#notInstalledPanel {
    display: none;
    border: 1px solid #000;
    background-color: #eee;
    padding: 0.5em;
}

JavaScript

// ### DEPRECATED ###
// ------------------------------------------------------------------------------------------
// LacunaWebPKI: listing certificates (jQuery)

var pki = new LacunaWebPKI({
    license: 'ASYAanNmaWRkbGUubmV0LHdlYnBraS5sYWN1bmFzb2Z0d2FyZS5jb20AAAABClKvO1J22vAD+YmfANiKQLbcLE1lNraPKCel6tRM+ZxR+h6M/crtJYRRVGGz7hrdbM0Y0mfTu15RMYGqQMi1QNZS6GrT4vNzIayv552Fl0EFWQA7jWlctUwfYoHRHVEnCNx9YGXDiA9+yDoGlVwgTR7fjzNeS3Fen1MVIyKBF464gN0JvdiCRJMI47JGVDkPmKjcrYIvJs6y5Lg25RW4ZnBKVruS+HR2s3k8ZrV4y4RCQE4UYMKbukF9vsF+JqAEifRlPq2xLcrNdxBveVDSXS/LRHAcrZrMM+Iw4A79jl0ngWPcy+CwinAhT+3dxVo5ZWMRQFpmTkylEMDvTjV9wQ==',
    defaultError: function (message, error, origin) {
        log('Web PKI error originated at ' + origin + ': ' + error);
        alert('Web PKI error: ' + message);
    }
});

function start() {
    log('Checking component installation ...');
    pki.checkInstalled({
        installed: onWebPkiDetected,
        notInstalled: onWebPkiNotInstalled
    });
}

function onWebPkiNotInstalled (status, statusMsg) {
    log('Component not installed or outdated');
    $('#notInstalledMessage').html(statusMsg);
    $('#notInstalledPanel button').click(function() {
        pki.redirectToInstallPage();
    });
    $('#notInstalledPanel').show();
}

function onWebPkiDetected () {
    log('Component detected, listing certificates ...');
    pki.listCertificates().success(function (certificates) {
        log('Certificates listed.');
        var select = $('#certificateSelect');
        $.each(certificates, function() {
            select.append($("<option />").val(this.thumbprint).text(this.subjectName + '(issued by ' + this.issuerName + ')'));
        });
        $('#signatureControlsPanel').show();
    });
}

function getSelectedCert() {
    var selectedCertThumb = $('#certificateSelect').val();
    alert("The selected certificate's thumbprint is " + selectedCertThumb);
}

function log(message) {
    $('#logPanel').append('<p>' + message + '</p>');
    if (window.console)...