all files / core/security/digital-signature/x509/ x509-name.js

18.18% Statements 6/33
0% Branches 0/12
40% Functions 2/5
18.18% Lines 6/33
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                                                                                        
define(["require", "exports", "../../../utils", "../asn1/basic-encoding-element", "../asn1/unique-encoding-element", "../asn1/identifier-mapping"], function (require, exports, utils_1, basic_encoding_element_1, unique_encoding_element_1, identifier_mapping_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var _PdfX509Name = (function () {
        function _PdfX509Name(sequence) {
            var _this = this;
            this._ordering = [];
            this._values = [];
            this._added = [];
            this._countryNameOid = '2.5.4.6';
            this._organizationNameOid = '2.5.4.10';
            this._organizationalUnitNameOid = '2.5.4.11';
            this._titleOid = '2.5.4.12';
            this._commonNameOid = '2.5.4.3';
            this._sequence = sequence;
            this._defaultSymbols = new Map([
                [this._countryNameOid, 'C'],
                [this._organizationNameOid, 'O'],
                [this._organizationalUnitNameOid, 'OU'],
                [this._titleOid, 'T'],
                [this._commonNameOid, 'CN']
            ]);
            sequence.forEach(function (element) {
                if (element) {
                    var sequence_1 = element._getSequence();
                    sequence_1.forEach(function (setElement, idx) {
                        var sequences = [];
                        if (setElement) {
                            sequences = setElement._getSequence();
                        }
                        if (sequences && sequences.length >= 2) {
                            var oid = new identifier_mapping_1._PdfObjectIdentifier()._fromBytes(sequences[0]._getValue());
                            _this._ordering.push(oid);
                            var valueElement = sequences[1];
                            var value = '';
                            if (valueElement instanceof unique_encoding_element_1._PdfUniqueEncodingElement || valueElement instanceof basic_encoding_element_1._PdfBasicEncodingElement) {
                                value = utils_1._bytesToString(valueElement._getOctetString());
                            }
                            _this._values.push(value);
                            _this._added.push(idx !== 0);
                        }
                    });
                }
            });
        }
        return _PdfX509Name;
    }());
    exports._PdfX509Name = _PdfX509Name;
});