import * as asn1js from "asn1js"; import * as pvutils from "pvutils"; import { EMPTY_STRING } from "./constants"; import { AsnError } from "./errors"; import { GeneralSubtree, GeneralSubtreeJson } from "./GeneralSubtree"; import { PkiObject, PkiObjectParameters } from "./PkiObject"; import * as Schema from "./Schema";
export type NameConstraintsParameters = PkiObjectParameters & Partial<INameConstraints>;
/** * Represents the NameConstraints structure described in [RFC5280](https://datatracker.ietf.org/doc/html/rfc5280)
*/
export class NameConstraints extends PkiObject implements INameConstraints {
public permittedSubtrees?: GeneralSubtree[]; public excludedSubtrees?: GeneralSubtree[];
/** * Initializes a new instance of the {@link NameConstraints} class * @param parameters Initialization parameters
*/
constructor(parameters: NameConstraintsParameters = {}) { super();
if (PERMITTED_SUBTREES in parameters) { this.permittedSubtrees = pvutils.getParametersValue(parameters, PERMITTED_SUBTREES, NameConstraints.defaultValues(PERMITTED_SUBTREES));
} if (EXCLUDED_SUBTREES in parameters) { this.excludedSubtrees = pvutils.getParametersValue(parameters, EXCLUDED_SUBTREES, NameConstraints.defaultValues(EXCLUDED_SUBTREES));
}
if (parameters.schema) { this.fromSchema(parameters.schema);
}
}
/** * Returns default values for all class members * @param memberName String name for a class member * @returns Default value
*/ publicstatic override defaultValues(memberName: typeof PERMITTED_SUBTREES): GeneralSubtree[]; publicstatic override defaultValues(memberName: typeof EXCLUDED_SUBTREES): GeneralSubtree[]; publicstatic override defaultValues(memberName: string): any { switch (memberName) { case PERMITTED_SUBTREES: case EXCLUDED_SUBTREES: return []; default: returnsuper.defaultValues(memberName);
}
}
// Get internal properties from parsed schema if (PERMITTED_SUBTREES in asn1.result) this.permittedSubtrees = Array.from(asn1.result.permittedSubtrees, element => new GeneralSubtree({ schema: element })); if (EXCLUDED_SUBTREES in asn1.result) this.excludedSubtrees = Array.from(asn1.result.excludedSubtrees, element => new GeneralSubtree({ schema: element }));
}
public toSchema(): asn1js.Sequence { //#region Create array for output sequence const outputArray = [];
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.