Jws C# WinRT Reference Documentation

Jws

Current Version: 9.5.0.76

An API for JSON Web Signature (JWS). Provides the ability to create and verify JWSs.

Object Creation

Chilkat.Jws obj = new Chilkat.Jws();

Properties

DebugLogFilePath

public string DebugLogFilePath {get; set; }

If set to a file path, causes each Chilkat method or property call to automatically append it's LastErrorText to the specified log file. The information is appended such that if a hang or crash occurs, it is possible to see the context in which the problem occurred, as well as a history of all Chilkat calls up to the point of the problem. The VerboseLogging property can be set to provide more detailed information.

This property is typically used for debugging the rare cases where a Chilkat method call hangs or generates an exception that halts program execution (i.e. crashes).
A hang or crash should generally never happen. The typical causes of a hang are:

a timeout related property was set to 0 to explicitly indicate that an infinite timeout is desired,

the hang is actually a hang within an event callback (i.e. it is a hang within the application code), or

there is an internal problem (bug) in the Chilkat code that causes the hang.

LastErrorText

public string LastErrorText {get; }

Provides information in plain-text format about the last method/property called. If a method call returns a value indicating failure, or behaves unexpectedly, examine this property to get more information.

LastMethodSuccess

Indicate whether the last method call succeeded or failed. A value of true indicates success, a value of false indicates failure. This property is automatically set for method calls. It is not modified by property accesses. The property is automatically set to indicate success for the following types of method calls:

NumSignatures

PreferCompact

Controls whether to use the JWS Compact Serialization or JWS JSON Serialization when creating JWSs. The default value is true, which is to choose the compact serialization when possible. If multiple signatures exist, or if any unprotected headers exist, then JWS JSON Serialization is used regardless of this property setting.

PreferFlattened

Controls whether to use the flattened or general JWE JSON Serialization when creating JWSs. The default value is true, which is to choose the flattened serialization when possible. If multiple signatures exist, then the general (non-flattened) JWS JSON Serialization is used regardless of this property setting.

VerboseLogging

public bool VerboseLogging {get; set; }

If set to true, then the contents of LastErrorText (or LastErrorXml, or LastErrorHtml) may contain more verbose information. The default value is false. Verbose logging should only be used for debugging. The potentially large quantity of logged information may adversely affect peformance.

GetPayloadSb

Returns the JWS payload by appending it to the sbPayload. The charset specifies the byte representation to be used in interpreting the bytes of the payload. (For example, "utf-8", "windows-1252", "utf-16", etc.)

SetMacKey

Sets the MAC key to be used for creating or validating a signature for the algorithms "HS256", "HS384", or "HS512". The key is an encoded string representation of the MAC key bytes. The encoding is an encoding, such as "base64url", "base64", "hex", etc. The 1st signature is at index 0. (Most JWSs only contain a single signature.)

SetMacKeyBd

Sets the MAC key to be used for creating or validating a signature for the algorithms "HS256", "HS384", or "HS512". The key contains the binary bytes of the MAC key for the Nth signature. The 1st signature is at index 0.

SetPayload

Sets the JWS payload from the contents of payload. The charset specifies the byte representation to be used for the string that is to be the payload. (For example, "utf-8", "windows-1252", "utf-16", etc.). If includeBom is true, then the byte-order-mark (BOM), also known as preamble, if one exists for the given charset, is included in the payload. Normally, includeBom should be set to false.

SetPayloadSb

Sets the JWS payload from the contents of sbPayload. The charset specifies the byte representation to be used for the string that is to be the payload. (For example, "utf-8", "windows-1252", "utf-16", etc.). If includeBom is true, then the byte-order-mark (BOM), also known as preamble, if one exists for the given charset, is included in the payload. Normally, includeBom should be set to false.

Validate

Validates the Nth signature or MAC using the Nth public key or MAC key.

Returns 1 if the signature was validated, thus verifying that the signer used the same MAC key or the matching private key.
Returns 0 if the incorrect public key or MAC key was provided.
Returns -1 for any other error, such as if no public key or MAC key was previously set for the given index.

Prior to calling this method, a program should provide the public key or MAC key via the SetPublicKey, SetMacKey, or SetMacKeyBd methods.