Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 


Quelle  PkiObject.ts

  Sprache: JAVA
 

Spracherkennung für: .ts vermutete Sprache: Unknown {[0] [0] [0]} [Methode: Schwerpunktbildung, einfache Gewichte, sechs Dimensionen]

/* eslint-disable @typescript-eslint/no-unused-vars */
import * as asn1js from "asn1js";
import * as pvtsutils from "pvtsutils";
import { AsnError } from "./errors";
import * as Schema from "./Schema";

export interface PkiObjectParameters {
  schema?: Schema.SchemaType;
}

interface PkiObjectConstructor<T extends PkiObject = PkiObject> {
  new(params: PkiObjectParameters): T;
  CLASS_NAME: string;
}

export abstract class PkiObject {

  /**
   * Name of the class
   */
  public static CLASS_NAME = "PkiObject";

  /**
   * Returns block name
   * @returns Returns string block name
   */
  public static blockName(): string {
    return this.CLASS_NAME;
  }

  /**
   * Creates PKI object from the raw data
   * @param raw ASN.1 encoded raw data
   * @returns Initialized and filled current class object
   */
  public static fromBER<T extends PkiObject>(this: PkiObjectConstructor<T>, raw: BufferSource): T {
    const asn1 = asn1js.fromBER(raw);
    AsnError.assert(asn1, this.name);

    try {
      return new this({ schema: asn1.result });
    } catch (e) {
      throw new AsnError(`Cannot create '${this.CLASS_NAME}' from ASN.1 object`);
    }
  }

  /**
   * Returns default values for all class members
   * @param memberName String name for a class member
   * @returns Default value
   */
  public static defaultValues(memberName: string): any {
    throw new Error(`Invalid member name for ${this.CLASS_NAME} class: ${memberName}`);
  }

  /**
   * Returns value of pre-defined ASN.1 schema for current class
   * @param parameters Input parameters for the schema
   * @returns ASN.1 schema object
   */
  public static schema(parameters: Schema.SchemaParameters = {}): Schema.SchemaType {
    throw new Error(`Method '${this.CLASS_NAME}.schema' should be overridden`);
  }

  public get className(): string {
    return (this.constructor as unknown as { CLASS_NAME: string; }).CLASS_NAME;
  }

  /**
   * Converts parsed ASN.1 object into current class
   * @param schema ASN.1 schema
   */
  public abstract fromSchema(schema: Schema.SchemaType): void;

  /**
   * Converts current object to ASN.1 object and sets correct values
   * @param encodeFlag If param equal to `false` then creates schema via decoding stored value. In other case creates schema via assembling from cached parts
   * @returns ASN.1 object
   */
  public abstract toSchema(encodeFlag?: boolean): Schema.SchemaType;

  /**
   * Converts the class to JSON object
   * @returns JSON object
   */
  public abstract toJSON(): any;

  public toString(encoding: "hex" | "base64" | "base64url" = "hex"): string {
    let schema: Schema.SchemaType;

    try {
      schema = this.toSchema();
    } catch {
      schema = this.toSchema(true);
    }

    return pvtsutils.Convert.ToString(schema.toBER(), encoding);
  }

}

¤ Dauer der Verarbeitung: 0.20 Sekunden  (vorverarbeitet am  2026-04-26) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

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.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Software

     Produkte
     Quellcodebibliothek

Aktivitäten

     Artikel über Sicherheit
     Anleitung zur Aktivierung von SSL

Muße

     Gedichte
     Musik
     Bilder

Jenseits des Üblichen ....

Besucherstatistik

Besucherstatistik

Monitoring

Montastic status badge