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 PrivateKeyUsagePeriodParameters = PkiObjectParameters & Partial<IPrivateKeyUsagePeriod>;
/** * Represents the PrivateKeyUsagePeriod structure described in [RFC5280](https://datatracker.ietf.org/doc/html/rfc5280)
*/
export class PrivateKeyUsagePeriod extends PkiObject implements IPrivateKeyUsagePeriod {
/** * Initializes a new instance of the {@link PrivateKeyUsagePeriod} class * @param parameters Initialization parameters
*/
constructor(parameters: PrivateKeyUsagePeriodParameters = {}) { super();
if (NOT_BEFORE in parameters) { this.notBefore = pvutils.getParametersValue(parameters, NOT_BEFORE, PrivateKeyUsagePeriod.defaultValues(NOT_BEFORE));
}
if (NOT_AFTER in parameters) { this.notAfter = pvutils.getParametersValue(parameters, NOT_AFTER, PrivateKeyUsagePeriod.defaultValues(NOT_AFTER));
}
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 NOT_BEFORE): Date; publicstatic override defaultValues(memberName: typeof NOT_AFTER): Date; publicstatic override defaultValues(memberName: string): any { switch (memberName) { case NOT_BEFORE: returnnew Date(); case NOT_AFTER: returnnew Date(); default: returnsuper.defaultValues(memberName);
}
}
// Get internal properties from parsed schema if (NOT_BEFORE in asn1.result) { const localNotBefore = new asn1js.GeneralizedTime();
localNotBefore.fromBuffer(asn1.result.notBefore.valueBlock.valueHex); this.notBefore = localNotBefore.toDate();
} if (NOT_AFTER in asn1.result) { const localNotAfter = new asn1js.GeneralizedTime({ valueHex: asn1.result.notAfter.valueBlock.valueHex });
localNotAfter.fromBuffer(asn1.result.notAfter.valueBlock.valueHex); this.notAfter = localNotAfter.toDate();
}
}
public toSchema(): asn1js.Sequence { //#region Create array for output sequence const outputArray = [];
if (NOT_BEFORE in this) {
outputArray.push(new asn1js.Primitive({
idBlock: {
tagClass: 3, // CONTEXT-SPECIFIC
tagNumber: 0// [0]
},
valueHex: (new asn1js.GeneralizedTime({ valueDate: this.notBefore })).valueBlock.valueHexView
}));
}
if (NOT_AFTER in this) {
outputArray.push(new asn1js.Primitive({
idBlock: {
tagClass: 3, // CONTEXT-SPECIFIC
tagNumber: 1// [1]
},
valueHex: (new asn1js.GeneralizedTime({ valueDate: this.notAfter })).valueBlock.valueHexView
}));
} //#endregion
//#region Construct and return new ASN.1 schema for this object return (new asn1js.Sequence({
value: outputArray
})); //#endregion
}
public toJSON(): PrivateKeyUsagePeriodJson { const res: PrivateKeyUsagePeriodJson = {};
if (this.notBefore) {
res.notBefore = this.notBefore;
}
if (this.notAfter) {
res.notAfter = this.notAfter;
}
return res;
}
}
Messung V0.5 in Prozent
¤ Diese beiden folgenden Angebotsgruppen bietet das Unternehmen0.21Angebot
(Wie Sie bei der Firma Beratungs- und Dienstleistungen beauftragen können 2026-06-06)
¤
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.