all files / core/security/digital-signature/ pdf-certificate-identifier.js

28.57% Statements 8/28
0% Branches 0/17
40% Functions 2/5
28.57% Lines 8/28
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43                                                                      
define(["require", "exports", "./pdf-cryptography-certificate"], function (require, exports, pdf_cryptography_certificate_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var _PdfCertificateIdentifier = (function () {
        function _PdfCertificateIdentifier(params) {
            if (params.pubicKey && params.id) {
                this._identifier = new pdf_cryptography_certificate_1._PdfPublicKeyCryptographyCertificate()._createSubjectKeyID(params.pubicKey, params.id)._bytes;
            }
            else if (params.id) {
                this._identifier = params.id;
            }
        }
        _PdfCertificateIdentifier.prototype.equals = function (other) {
            if (!(other instanceof _PdfCertificateIdentifier)) {
                return false;
            }
            if (!this._identifier || !other._identifier || this._identifier.length !== other._identifier.length) {
                return false;
            }
            for (var i = 0; i < this._identifier.length; i++) {
                if (this._identifier[i] !== other._identifier[i]) {
                    return false;
                }
            }
            return true;
        };
        _PdfCertificateIdentifier.prototype._getHashCode = function () {
            if (!this._identifier) {
                return 0;
            }
            var hash = 0;
            for (var i = 0; i < this._identifier.length; i++) {
                var byte = this._identifier[i];
                hash = ((hash << 5) - hash) + byte;
                hash |= 0;
            }
            return hash;
        };
        return _PdfCertificateIdentifier;
    }());
    exports._PdfCertificateIdentifier = _PdfCertificateIdentifier;
});