all files / core/security/digital-signature/x509/ x509-signed-certificate.js

20% Statements 8/40
0% Branches 0/7
40% Functions 2/5
20% Lines 8/40
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 44 45 46 47 48 49 50 51 52 53 54 55                                                                                              
define(["require", "exports", "../asn1/enumerator", "../asn1/unique-encoding-element", "./x509-algorithm", "./x509-bit-string-handler", "./x509-certificate-key", "./x509-extensions", "./x509-name", "./x509-time"], function (require, exports, enumerator_1, unique_encoding_element_1, x509_algorithm_1, x509_bit_string_handler_1, x509_certificate_key_1, x509_extensions_1, x509_name_1, x509_time_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var _PdfSignedCertificate = (function () {
        function _PdfSignedCertificate(sequenceElement) {
            this._sequence = sequenceElement._getSequence();
            var seqStart = 0;
            if (this._sequence[0]._getTagNumber() === 0 && this._sequence[0]._tagClass === 2) {
                this._version = 2;
            }
            else {
                seqStart = -1;
                this._version = 0;
            }
            this._serialNumber = this._sequence[seqStart + 1]._getValue();
            this._signature = new x509_algorithm_1._PdfAlgorithms(this._sequence[seqStart + 2]);
            this._issuer = new x509_name_1._PdfX509Name(this._sequence[seqStart + 3]._getSequence());
            var dates = this._sequence[seqStart + 4]._getSequence();
            this._startDate = new x509_time_1._PdfX509Time(dates[0]);
            this._endDate = new x509_time_1._PdfX509Time(dates[1]);
            this._subject = new x509_name_1._PdfX509Name(this._sequence[seqStart + 5]._getSequence());
            this._publicKeyInformation = new x509_certificate_key_1._PdfPublicKeyInformation()._getPublicKeyInformation(this._sequence[seqStart + 6]);
            var base = seqStart + 6;
            for (var i = this._sequence.length - 1; i > base; i--) {
                var extra = this._sequence[i];
                var derString = new x509_bit_string_handler_1._PdfUniqueBitString();
                switch (extra._getTagNumber()) {
                    case 1:
                        this._issuerID = derString._getUniqueBitStringFromTag(extra, false);
                        break;
                    case 2:
                        this._subjectID = derString._getUniqueBitStringFromTag(extra, false);
                        break;
                    case 3:
                        this._extensions = new x509_extensions_1._PdfX509Extensions()._getInstance(extra);
                        break;
                }
            }
        }
        _PdfSignedCertificate.prototype._getVersion = function () {
            return this._version + 1;
        };
        _PdfSignedCertificate.prototype._getDistinguishEncoded = function () {
            var der = new unique_encoding_element_1._PdfUniqueEncodingElement();
            der._tagClass = enumerator_1._TagClassType.universal;
            der._construction = enumerator_1._ConstructionType.constructed;
            der._setTagNumber(enumerator_1._UniversalType.sequence);
            der._setSequence(this._sequence);
            return der._toBytes();
        };
        return _PdfSignedCertificate;
    }());
    exports._PdfSignedCertificate = _PdfSignedCertificate;
});