@syncfusion/ej2-pdf
Version:
Feature-rich JavaScript PDF library with built-in support for loading and manipulating PDF document.
67 lines (66 loc) • 2.56 kB
JavaScript
import { _bytesToString } from '../../../utils';
import { _PdfBasicEncodingElement } from '../asn1/basic-encoding-element';
import { _PdfUniqueEncodingElement } from '../asn1/unique-encoding-element';
import { _PdfObjectIdentifier } from '../asn1/identifier-mapping';
/**
* Representation of an X.509 distinguished name (RDN sequence) and helpers to access values.
*
* @private
*/
var _PdfX509Name = /** @class */ (function () {
function _PdfX509Name(sequence) {
var _this = this;
/**
* Ordered list of attribute OIDs encountered in the name.
*
* @private
* @type {_PdfObjectIdentifier[]}
*/
this._ordering = [];
/**
* Corresponding string values for the ordered attributes.
*
* @private
* @type {string[]}
*/
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 _PdfObjectIdentifier()._fromBytes(sequences[0]._getValue());
_this._ordering.push(oid);
var valueElement = sequences[1];
var value = '';
if (valueElement instanceof _PdfUniqueEncodingElement || valueElement instanceof _PdfBasicEncodingElement) {
value = _bytesToString(valueElement._getOctetString());
}
_this._values.push(value);
_this._added.push(idx !== 0);
}
});
}
});
}
return _PdfX509Name;
}());
export { _PdfX509Name };