CryptoServer Class

Properties   Methods   Events   Config Settings   Errors  

The CryptoServer class offers capabilities in processing PKI Proxy REST protocol messages.

Syntax

pkiproxy.cryptoserver()

Remarks

TBD

Property List


The following is the full list of the properties of the class with short descriptions. Click on the links for further details.

KeysAn accessor to the collection of keys contained in the key store.
MechanismsAn accessor to the collection of mechanisms supported by the key store.
ObjectsAn accessor to the collection of objects - such as certificates - contained in the key store.
PinnedKeyA pinned key.
PinnedMechanismAn accessor to the collection of mechanism properties.
PinnedObjectA pinned object.
RequestProvides access to request properties after reading it or before saving.
RequestKeyA request key.
RequestObjectA request object.
ResponseProvides access to response properties after reading it or before saving.

Method List


The following is the full list of the methods of the class with short descriptions. Click on the links for further details.

AddKeyRegisters object information in the response.
AddMechanismRegisters mechanism information in the response.
AddObjectRegisters object information in the response.
ConfigSets or retrieves a configuration setting.
CreateWebRequestCreates a new REST request.
CreateWebResponseCreates a new REST response.
GetRequestParamLooks up for a parameter in various request locations.
GetResponseParamLooks up for a parameter in various response locations.
OpenWebRequestOpens a REST request and populates it in the Request property.
OpenWebResponseOpens a REST response and populates it in the Response property.
ResetClear all list.
SetRequestParamSets up a request parameter in the designated location.
SetResponseParamSets up a response parameter in the designated location.

Event List


The following is the full list of the events fired by the class with short descriptions. Click on the links for further details.

ErrorInformation about errors during data delivery.

Config Settings


The following is a list of config settings for the class with short descriptions. Click on the links for further details.

ResponseFormatThe format of response.
TempPathPath for storing temporary files.

CryptoServer.Keys Property

An accessor to the collection of keys contained in the key store.

Syntax


 getKeys(): CryptoKeyList;


Default Value

Remarks

Use this property after loading the response to access, browse, or iterate over keys contained in the storage.

This property is read-only and not available at design time.

Please refer to the CryptoKey type for a complete list of fields.

CryptoServer.Mechanisms Property

An accessor to the collection of mechanisms supported by the key store.

Syntax


 getMechanisms(): CryptoMechanismList;


Default Value

Remarks

Use this property after loading the response to access cryptographic mechanisms supported by the key store.

This property is read-only and not available at design time.

Please refer to the CryptoMechanism type for a complete list of fields.

CryptoServer.Objects Property

An accessor to the collection of objects - such as certificates - contained in the key store.

Syntax


 getObjects(): CryptoObjectList;


Default Value

Remarks

Use this property after loading the response to access, browse, or iterate over objects contained in the storage.

This property is read-only and not available at design time.

Please refer to the CryptoObject type for a complete list of fields.

CryptoServer.PinnedKey Property

A pinned key.

Syntax


 getPinnedKey(): CryptoKey;

 setPinnedKey(pinnedKey: CryptoKey): void;

Default Value

Remarks

Use this property to pin an key before registering it with the response with AddKey method.

This property is not available at design time.

Please refer to the CryptoKey type for a complete list of fields.

CryptoServer.PinnedMechanism Property

An accessor to the collection of mechanism properties.

Syntax


 getPinnedMechanism(): CryptoMechanism;


Default Value

Remarks

Use this property to access cryptographic mechanism properties included in the request, or prepare them before adding to the response.

This property is read-only and not available at design time.

Please refer to the CryptoMechanism type for a complete list of fields.

CryptoServer.PinnedObject Property

A pinned object.

Syntax


 getPinnedObject(): CryptoObject;

 setPinnedObject(pinnedObject: CryptoObject): void;

Default Value

Remarks

Use this property to pin an object before registering it with the response with AddObject method.

This property is not available at design time.

Please refer to the CryptoObject type for a complete list of fields.

CryptoServer.Request Property

Provides access to request properties after reading it or before saving.

Syntax


 getRequest(): CryptoRequest;


Default Value

Remarks

Use this property to access the request properties or adjust them before creating a request.

This property is read-only.

Please refer to the CryptoRequest type for a complete list of fields.

CryptoServer.RequestKey Property

A request key.

Syntax


 getRequestKey(): CryptoKey;


Default Value

Remarks

Use this property to publishes the details of the key POSTed in the request.

This property is read-only and not available at design time.

Please refer to the CryptoKey type for a complete list of fields.

CryptoServer.RequestObject Property

A request object.

Syntax


 getRequestObject(): CryptoObject;


Default Value

Remarks

Use this property to publishes the details of the object POSTed in the request.

This property is read-only and not available at design time.

Please refer to the CryptoObject type for a complete list of fields.

CryptoServer.Response Property

Provides access to response properties after reading it or before saving.

Syntax


 getResponse(): CryptoResponse;


Default Value

Remarks

Use this property to access the response properties or adjust them before creating a response.

This property is read-only.

Please refer to the CryptoResponse type for a complete list of fields.

CryptoServer.addKey Method

Registers object information in the response.

Syntax

async cryptoserver.addKey(): Promise<void>

Remarks

Use this method to register a single key details, provided via the PinnedKey property, in the response for GetObjectInfo or ListObjects requests.

If the ListObjects request you are handling results in truncated content, remember to set the Token property of the response to provide continuity.In the same manner, the Token property of the request lets you continue previously started listing requests.The key is added to the Keys list.

CryptoServer.addMechanism Method

Registers mechanism information in the response.

Syntax

async cryptoserver.addMechanism(): Promise<void>

Remarks

Use this method to register a single mechanism details, provided via the PinnedMechanism property, in the response for GetMechanismInfo or ListMechanism requests.

The mechanism info is added to the Mechanisms list.

CryptoServer.addObject Method

Registers object information in the response.

Syntax

async cryptoserver.addObject(): Promise<void>

Remarks

Use this method to register a single object details, provided via the PinnedObject property, in the response for GetObjectInfo or ListObjects requests.

If the ListObjects request you are handling results in truncated content, remember to set the Token property of the response to provide continuity.In the same manner, the Token property of the request lets you continue previously started listing requests.The object is added to the Objects list.

CryptoServer.config Method

Sets or retrieves a configuration setting.

Syntax

async cryptoserver.config(configurationString : string): Promise<string>

Remarks

Config is a generic method available in every class. It is used to set and retrieve configuration settings for the class.

These settings are similar in functionality to properties, but they are rarely used. In order to avoid "polluting" the property namespace of the class, access to these internal properties is provided through the Config method.

To set a configuration setting named PROPERTY, you must call Config("PROPERTY=VALUE"), where VALUE is the value of the setting expressed as a string. For boolean values, use the strings "True", "False", "0", "1", "Yes", or "No" (case does not matter).

To read (query) the value of a configuration setting, you must call Config("PROPERTY"). The value will be returned as a string.

CryptoServer.createWebRequest Method

Creates a new REST request.

Syntax

async cryptoserver.createWebRequest(): Promise<void>

Remarks

Use this method to create a new web request. Call this method after filling in the properties of the Request object.

Once this method completes, the Verb, Url, Headers, and Body fields of the Request object are updated to match the new request parameters.

CryptoServer.createWebResponse Method

Creates a new REST response.

Syntax

async cryptoserver.createWebResponse(): Promise<void>

Remarks

Use this method to create a new web request. Call this method after filling in the properties of the Response object.

Once this method completes, the Status, Headers, and Body fields of the Response object are updated to match the new response parameters.

CryptoServer.getRequestParam Method

Looks up for a parameter in various request locations.

Syntax

async cryptoserver.getRequestParam(paramName : string, lookIn : number, def : string): Promise<string>

Remarks

Use this method to retrieve secondary or custom request parameters not available via the Request object properties.

LookIn is a bit mask that specifies where to look: 1 in query, 2 in headers, 4 in the request body. Combine them as required. If no parameter with the requested name is found, the value of Def is returned.

CryptoServer.getResponseParam Method

Looks up for a parameter in various response locations.

Syntax

async cryptoserver.getResponseParam(paramName : string, lookIn : number, def : string): Promise<string>

Remarks

Use this method to retrieve secondary or custom request parameters not available via the Response object properties.

LookIn is a bit mask that specifies where to look: 1 in query, 2 in headers, 4 in the response body. Combine them as required. If no parameter with the requested name is found, the value of Def is returned.

CryptoServer.openWebRequest Method

Opens a REST request and populates it in the Request property.

Syntax

async cryptoserver.openWebRequest(verb : string, url : string, headers : string, body : string, bodyLen : number): Promise<void>

Remarks

Use this method to process a REST request and populate its parameters in the Request property.

CryptoServer.openWebResponse Method

Opens a REST response and populates it in the Response property.

Syntax

async cryptoserver.openWebResponse(statusCode : number, reasonPhrase : string, headers : string, body : string, bodyLen : number, operation : number): Promise<void>

Remarks

Use this method to process a REST response and populate its parameters in the Response property.

CryptoServer.reset Method

Clear all list.

Syntax

async cryptoserver.reset(): Promise<void>

Remarks

Use this method to clear all list (objects, keys, mechanisms).

CryptoServer.setRequestParam Method

Sets up a request parameter in the designated location.

Syntax

async cryptoserver.setRequestParam(paramName : string, paramValue : string, location : number): Promise<void>

Remarks

Use this method to set a secondary or custom request parameter not available via the Request object properties.

Location specifies what part of the request to use for the parameter: 1 in query, 2 in headers, 4 in the request body.

CryptoServer.setResponseParam Method

Sets up a response parameter in the designated location.

Syntax

async cryptoserver.setResponseParam(paramName : string, paramValue : string, location : number): Promise<void>

Remarks

Use this method to set a secondary or custom response parameter not available via the Response object properties.

Location specifies what part of the request to use for the parameter: 1 in query, 2 in headers, 4 in the response body.

CryptoServer.Error Event

Information about errors during data delivery.

Syntax

cryptoserver.on('Error', listener: (e: {readonly errorCode: number, readonly description: string}) => void )

Remarks

The Error event is fired in case of exceptional conditions during message processing.

ErrorCode contains an error code and Description contains a textual description of the error. For a list of valid error codes and their descriptions, please refer to the Error Codes section.

CryptoKey Type

This container represents a cryptographic key.

Remarks

This type is a universal placeholder for cryptographic keys.

Fields

Constructors

public CryptoKey();

Creates an empty crypto key object.

CryptoMechanism Type

This container represents a cryptographic mechanism information.

Remarks

This type is a universal placeholder for cryptographic mechanisms.

Fields

Constructors

public CryptoMechanism();

Creates an empty crypto mechanism object.

CryptoObject Type

This container represents a cryptographic object.

Remarks

This type is a universal placeholder for cryptographic objects that are not keys: certificates, data objects, and similar.

Fields

Constructors

public CryptoObject();

Creates an empty crypto object.

CryptoRequest Type

A container for the PKI Proxy request.

Remarks

The class represents an PKI Proxy request, such as list objects or sign.

Fields

Constructors

public CryptoRequest();

Creates an empty request object.

CryptoResponse Type

A container for the PKI Proxy response.

Remarks

The class represents an PKI Proxy response, such as the object list or the signing result..

Fields

RawContentType
string

Use this property to provide the raw response content type. If this property is set, the is used as the response content (be it set or not). If this property is not set but is, the content type is generated automatically basing on the processed operation expectations. If neither this property nor are set - which will be the case for the majority of uses - the response body is generated automaticallybasing on the data provided to the Response object properties.

StatusCode
number

The service status code to return. This is different to and contains service-local operation result code. The code of 0 indicates successful processing.

Constructors

public CryptoResponse();

Creates an empty response object.

Config Settings (class pkiproxy.cryptoserver)

The class accepts one or more of the following configuration settings. Configuration settings are similar in functionality to properties, but they are rarely used. In order to avoid "polluting" the property namespace of the class, access to these internal properties is provided through the Config method.

CryptoServer Config Settings

ResponseFormat:   The format of response.

The format of response

TempPath:   Path for storing temporary files.

This setting specifies an absolute path to the location on disk where temporary files are stored.

Trappable Errors (class pkiproxy.cryptoserver)