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

36.36% Statements 8/22
0% Branches 0/14
40% Functions 2/5
36.36% Lines 8/22
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                                                  
define(["require", "exports", "./x509-algorithm", "./x509-bit-string-handler"], function (require, exports, x509_algorithm_1, x509_bit_string_handler_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var _PdfPublicKeyInformation = (function () {
        function _PdfPublicKeyInformation(algorithms, publicKey) {
            if (algorithms && publicKey) {
                this._algorithms = algorithms;
                this._publicKey = publicKey;
            }
        }
        _PdfPublicKeyInformation.prototype._fromAbstractSyntax = function (abstractSyntaxSequence) {
            var sequence = abstractSyntaxSequence._getSequence();
            if (!Array.isArray(sequence) || sequence.length !== 2) {
                throw new Error('Invalid length in sequence');
            }
            var algorithms = new x509_algorithm_1._PdfAlgorithms()._getAlgorithms(sequence[0]);
            var publicKey = new x509_bit_string_handler_1._PdfUniqueBitString()._fromAbstractSyntaxOctets(sequence[1]._getValue());
            return new _PdfPublicKeyInformation(algorithms, publicKey);
        };
        _PdfPublicKeyInformation.prototype._getPublicKeyInformation = function (obj) {
            if (obj instanceof _PdfPublicKeyInformation) {
                return obj;
            }
            if (obj && obj._getSequence()) {
                return this._fromAbstractSyntax(obj);
            }
            return undefined;
        };
        return _PdfPublicKeyInformation;
    }());
    exports._PdfPublicKeyInformation = _PdfPublicKeyInformation;
});