DEPRECATED - LacunaWebPKI: reading a certificate's binary encoding (AngularJS)

by Lacuna Software

HTML

<script src="https://webpki.lacunasoftware.com/Scripts/LacunaWebPKI/lacuna-web-pki-1.3.1.js"></script>
<div ng-app>
    <div ng-controller="ExampleController">
        <form>
            <button type="button" ng-click="start()">Start</button>
            <div id="signatureControlsPanel" ng-show="showSignatureControls">
                <select ng-model="selectedCertificate" ng-options="getCertificateDisplayName(cert) for cert in certificates">
                    <option value="">Choose a certificate ...</option>
                </select>
                <button type="button" ng-click="readSelectedCert()">Read Cert Encoding</button>
            </div>
        </form>
        <div ng-show='showNotInstalledPanel' class='not-installed-panel'>
            <p>{{notInstalledMessage}}</p>
            <p>Click OK to install/update the component.</p>
            <button type="button" ng-click="redirectToInstall()">OK</button>
        </div>
        <p ng-repeat="log in logs">{{log.message}}</p>
    </div>
</div>

CSS

.not-installed-panel {
    border: 1px solid #000;
    background-color: #eee;
    padding: 0.5em;
}
#signatureControlsPanel {
    margin-top: 1em;
}

JavaScript

// ### DEPRECATED ###
// ------------------------------------------------------------------------------------------
// LacunaWebPKI: reading a certificate's binary encoding (AngularJS)

function ExampleController($scope) {
    
    $scope.notInstalledMessage = '';
    $scope.showNotInstalledPanel = false;
    $scope.logs = [];
    $scope.certificates = [];
    $scope.selectedCertificate = null;
    $scope.showSignatureControls = false;
    
    var pki = new LacunaWebPKI({
        license: 'ASYAanNmaWRkbGUubmV0LHdlYnBraS5sYWN1bmFzb2Z0d2FyZS5jb20AAAABClKvO1J22vAD+YmfANiKQLbcLE1lNraPKCel6tRM+ZxR+h6M/crtJYRRVGGz7hrdbM0Y0mfTu15RMYGqQMi1QNZS6GrT4vNzIayv552Fl0EFWQA7jWlctUwfYoHRHVEnCNx9YGXDiA9+yDoGlVwgTR7fjzNeS3Fen1MVIyKBF464gN0JvdiCRJMI47JGVDkPmKjcrYIvJs6y5Lg25RW4ZnBKVruS+HR2s3k8ZrV4y4RCQE4UYMKbukF9vsF+JqAEifRlPq2xLcrNdxBveVDSXS/LRHAcrZrMM+Iw4A79jl0ngWPcy+CwinAhT+3dxVo5ZWMRQFpmTkylEMDvTjV9wQ==',
        angularScope: $scope,
        defaultError: function (message, error, origin) {
            log('Web PKI error originated at ' + origin + ': ' + error);
            alert('Web PKI error: ' + message);
        }
    });
    
    $scope.start = function () {
        log('Checking component installation ...');
        pki.checkInstalled({
            installed: onWebPkiDetected,
            notInstalled: onWebPkiNotInstalled
        });
    };
    
    var onWebPkiNotInstalled = function (status, statusMsg) {
        log('Component not installed or outdated');
        $scope.notInstalledMessage = statusMsg;
        $scope.showNotInstalledPanel = true;
    };
    
    $scope.redirectToInstall = function() {
        pki.redirectToInstallPage();
    };
    
    var onWebPkiDetected = function () {
        log('Component detected, listing certificates ...');
        pki.listCertificates().success(function (certificates) {
            log('Certificates listed.');
            $scope.certificates = certificates;
            $scope.showSignatureControls = true;
        });
    };
...