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

32.14% Statements 9/28
0% Branches 0/10
28.57% Functions 2/7
33.33% Lines 9/27
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                                                          
define(["require", "exports", "../asn1/enumerator", "../asn1/abstract-syntax", "../asn1/unique-encoding-element", "./x509-algorithm", "./x509-bit-string-handler", "./x509-signed-certificate"], function (require, exports, enumerator_1, abstract_syntax_1, unique_encoding_element_1, x509_algorithm_1, x509_bit_string_handler_1, x509_signed_certificate_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var _PdfX509CertificateStructure = (function () {
        function _PdfX509CertificateStructure(seq) {
            if (seq) {
                if (!Array.isArray(seq) || seq.length !== 3) {
                    throw new Error("Invalid certificate sequence length: " + seq.length);
                }
                this._sequence = seq;
                this._toBeSignedCertificate = new x509_signed_certificate_1._PdfSignedCertificate(seq[0]);
                this._signatureAlgorithmIdentifier = new x509_algorithm_1._PdfAlgorithms(seq[1]);
                this._signature = new x509_bit_string_handler_1._PdfUniqueBitString(seq[2]._getValue());
            }
        }
        _PdfX509CertificateStructure.prototype._getSignedCertificate = function () {
            return this._toBeSignedCertificate;
        };
        _PdfX509CertificateStructure.prototype._getInstance = function (obj) {
            if (Array.isArray(obj) && obj.every(function (e) { return e instanceof abstract_syntax_1._PdfAbstractSyntaxElement; })) {
                var seq = obj;
                return new _PdfX509CertificateStructure(seq);
            }
            return null;
        };
        _PdfX509CertificateStructure.prototype._getDerEncoded = 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 _PdfX509CertificateStructure;
    }());
    exports._PdfX509CertificateStructure = _PdfX509CertificateStructure;
});