import * as asn1js from "asn1js"; import * as pvutils from "pvutils"; import { EMPTY_STRING } from "./constants"; import { AsnError } from "./errors"; import { PkiObject, PkiObjectParameters } from "./PkiObject"; import * as Schema from "./Schema";
export type CertificateTemplateParameters = PkiObjectParameters & Partial<ICertificateTemplate>;
/** * Class from "[MS-WCCE]: Windows Client Certificate Enrollment Protocol"
*/
export class CertificateTemplate extends PkiObject implements ICertificateTemplate {
public templateID!: string; public templateMajorVersion?: number; public templateMinorVersion?: number;
/** * Initializes a new instance of the {@link CertificateTemplate} class * @param parameters Initialization parameters
*/
constructor(parameters: CertificateTemplateParameters = {}) { super();
this.templateID = pvutils.getParametersValue(parameters, TEMPLATE_ID, CertificateTemplate.defaultValues(TEMPLATE_ID)); if (TEMPLATE_MAJOR_VERSION in parameters) { this.templateMajorVersion = pvutils.getParametersValue(parameters, TEMPLATE_MAJOR_VERSION, CertificateTemplate.defaultValues(TEMPLATE_MAJOR_VERSION));
} if (TEMPLATE_MINOR_VERSION in parameters) { this.templateMinorVersion = pvutils.getParametersValue(parameters, TEMPLATE_MINOR_VERSION, CertificateTemplate.defaultValues(TEMPLATE_MINOR_VERSION));
}
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 TEMPLATE_MINOR_VERSION): number; publicstatic override defaultValues(memberName: typeof TEMPLATE_MAJOR_VERSION): number; publicstatic override defaultValues(memberName: typeof TEMPLATE_ID): string; publicstatic override defaultValues(memberName: string): any { switch (memberName) { case TEMPLATE_ID: return EMPTY_STRING; case TEMPLATE_MAJOR_VERSION: case TEMPLATE_MINOR_VERSION: return0; default: returnsuper.defaultValues(memberName);
}
}
// Get internal properties from parsed schema this.templateID = asn1.result.templateID.valueBlock.toString(); if (TEMPLATE_MAJOR_VERSION in asn1.result) { this.templateMajorVersion = asn1.result.templateMajorVersion.valueBlock.valueDec;
} if (TEMPLATE_MINOR_VERSION in asn1.result) { this.templateMinorVersion = asn1.result.templateMinorVersion.valueBlock.valueDec;
}
}
public toSchema(): asn1js.Sequence { // Create array for output sequence const outputArray = [];
outputArray.push(new asn1js.ObjectIdentifier({ value: this.templateID })); if (TEMPLATE_MAJOR_VERSION in this) {
outputArray.push(new asn1js.Integer({ value: this.templateMajorVersion }));
} if (TEMPLATE_MINOR_VERSION in this) {
outputArray.push(new asn1js.Integer({ value: this.templateMinorVersion }));
}
// Construct and return new ASN.1 schema for this object return (new asn1js.Sequence({
value: 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.