Jws ActiveX Reference Documentation

Jws

Current Version: 10.1.2

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

Object Creation

Note:
For versions of Chilkat < 10.0.0, use "Chilkat_9_5_0.Jws" instead of "Chilkat.Jws"
For a specific major version, use "Chilkat.Jws.<major_version>", such as "Chilkat.Jws.10" for Chilkat v10.*.*
See Chilkat ActiveX Object Creation

(ASP)
set obj = Server.CreateObject("Chilkat.Jws")

(AutoIt)
$obj = ObjCreate("Chilkat.Jws")

(Visual Basic 6.0)
Dim obj As New ChilkatJws

(VBScript)
set obj = CreateObject("Chilkat.Jws")

(Delphi)
obj := TChilkatJws.Create(Self);

(FoxPro)
loObject = CreateObject('Chilkat.Jws')

(PowerBuilder)
lole_object = create oleobject
li_rc = lole_object.ConnectToNewObject("Chilkat.Jws")

(SQL Server)
EXEC @hr = sp_OACreate 'Chilkat.Jws', @obj OUT

(Javascript)
var obj = new ActiveXObject("Chilkat.Jws");

Properties

DebugLogFilePath
DebugLogFilePath As String

If set to a file path, this property logs the LastErrorText of each Chilkat method or property call to the specified file. This logging helps identify the context and history of Chilkat calls leading up to any crash or hang, aiding in debugging.

Enabling the VerboseLogging property provides more detailed information. This property is mainly used for debugging rare instances where a Chilkat method call causes a hang or crash, which should generally not happen.

Possible causes of hangs include:

  • A timeout property set to 0, indicating an infinite timeout.
  • A hang occurring within an event callback in the application code.
  • An internal bug in the Chilkat code causing the hang.

top
LastBinaryResult
LastBinaryResult As Variant (read-only)

This property is mainly used in SQL Server stored procedures to retrieve binary data from the last method call that returned binary data. It is only accessible if Chilkat.Global.KeepBinaryResult is set to 1. This feature allows for the retrieval of large varbinary results in an SQL Server environment, which has restrictions on returning large data via method calls, though temp tables can handle binary properties.

top
LastErrorHtml
LastErrorHtml As String (read-only)

Provides HTML-formatted information about the last called method or property. If a method call fails or behaves unexpectedly, check this property for details. Note that information is available regardless of the method call's success.

top
LastErrorText
LastErrorText As String (read-only)

Provides plain text information about the last called method or property. If a method call fails or behaves unexpectedly, check this property for details. Note that information is available regardless of the method call's success.

top
LastErrorXml
LastErrorXml As String (read-only)

Provides XML-formatted information about the last called method or property. If a method call fails or behaves unexpectedly, check this property for details. Note that information is available regardless of the method call's success.

top
LastMethodSuccess
LastMethodSuccess As Long

Indicates the success or failure of the most recent method call: 1 means success, 0 means failure. This property remains unchanged by property setters or getters. This method is present to address challenges in checking for null or Nothing returns in certain programming languages.

top
LastStringResult
LastStringResult As String (read-only)

In SQL Server stored procedures, this property holds the string return value of the most recent method call that returns a string. It is accessible only when Chilkat.Global.KeepStringResult is set to TRUE. SQL Server has limitations on string lengths returned from methods and properties, but temp tables can be used to access large strings.

top
LastStringResultLen
LastStringResultLen As Long (read-only)

The length, in characters, of the string contained in the LastStringResult property.

top
NumSignatures
NumSignatures As Long (read-only)
Introduced in version 9.5.0.66

The number of signatures contained in this JWS.

top
PreferCompact
PreferCompact As Long
Introduced in version 9.5.0.66

Controls whether to use the JWS Compact Serialization or JWS JSON Serialization when creating JWSs. The default value is 1, 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.

top
PreferFlattened
PreferFlattened As Long
Introduced in version 9.5.0.66

Controls whether to use the flattened or general JWE JSON Serialization when creating JWSs. The default value is 1, 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.

top
UncommonOptions
UncommonOptions As String
Introduced in version 10.1.0

This is a catch-all property to be used for uncommon needs. This property defaults to the empty string and should typically remain empty.

top
VerboseLogging
VerboseLogging As Long

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

top
Version
Version As String (read-only)

Version of the component/library, such as "10.1.0"

top

Methods

CreateJws
CreateJws() As String
Introduced in version 9.5.0.66

Creates and returns the JWS containing one or more signatures according to the previously set payload, headers, and keys.

Returns Nothing on failure

top
CreateJwsSb
CreateJwsSb(sbJws As ChilkatStringBuilder) As Long
Introduced in version 9.5.0.66

Creates and returns the JWS by appending it to the contents of sbJws.

Returns 1 for success, 0 for failure.

top
GetPayload
GetPayload(charset As String) As String
Introduced in version 9.5.0.66

Returns the JWS payload. 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.)

Returns Nothing on failure

top
GetPayloadBd
GetPayloadBd(binData As ChilkatBinData) As Long
Introduced in version 9.5.0.66

Returns the JWS payload by appending it to the binData.

Returns 1 for success, 0 for failure.

top
GetPayloadSb
GetPayloadSb(charset As String, sbPayload As ChilkatStringBuilder) As Long
Introduced in version 9.5.0.66

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.)

Returns 1 for success, 0 for failure.

top
GetProtectedHeader
GetProtectedHeader(ByVal index As Long) As ChilkatJsonObject
Introduced in version 9.5.0.66

Returns the protected header for the Nth signature. The index is the index of the signature. The 1st signature is at index 0. In most cases, a JWS contains a single signature at index 0.

Returns Nothing on failure

top
GetUnprotectedHeader
GetUnprotectedHeader(ByVal index As Long) As ChilkatJsonObject
Introduced in version 9.5.0.66

Returns the optional unprotected header for the Nth signature. The index is the index of the signature. The 1st signature is at index 0. In most cases, a JWS contains a single signature at index 0.

Returns Nothing on failure

top
LoadJws
LoadJws(jwsStr As String) As Long
Introduced in version 9.5.0.66

Loads a JWS contained in jwsStr.

Returns 1 for success, 0 for failure.

top
LoadJwsSb
LoadJwsSb(sbJws As ChilkatStringBuilder) As Long
Introduced in version 9.5.0.66

Loads a JWS from the contents of sbJws.

Returns 1 for success, 0 for failure.

top
SetMacKey
SetMacKey(ByVal index As Long, key As String, encoding As String) As Long
Introduced in version 9.5.0.66

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.)

Returns 1 for success, 0 for failure.

top
SetMacKeyBd
SetMacKeyBd(ByVal index As Long, key As ChilkatBinData) As Long
Introduced in version 9.5.0.66

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.

Returns 1 for success, 0 for failure.

top
SetPayload
SetPayload(payload As String, charset As String, ByVal includeBom As Long) As Long
Introduced in version 9.5.0.66

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 1, 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 0.

Returns 1 for success, 0 for failure.

top
SetPayloadBd
SetPayloadBd(binData As ChilkatBinData) As Long
Introduced in version 9.5.0.66

Sets the JWS payload from the contents of binData.

Returns 1 for success, 0 for failure.

top
SetPayloadSb
SetPayloadSb(sbPayload As ChilkatStringBuilder, charset As String, ByVal includeBom As Long) As Long
Introduced in version 9.5.0.66

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 1, 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 0.

Returns 1 for success, 0 for failure.

top
SetPrivateKey
SetPrivateKey(ByVal index As Long, privKey As PrivateKey) As Long
Introduced in version 9.5.0.66

Sets the private key (ECC or RSA) to be used in creating a signature for the following algorithms:

RS256
RS384
RS512
ES256
ES384
ES512
PS256
PS384
PS512
The JWS algorithms are described in RFC 7518, section 3.1. Here is a summary:
   +--------------+-------------------------------+--------------------+
   | "alg" Param  | Digital Signature or MAC      | Implementation     |
   | Value        | Algorithm                     | Requirements       |
   +--------------+-------------------------------+--------------------+
   | HS256        | HMAC using SHA-256            | Required           |
   | HS384        | HMAC using SHA-384            | Optional           |
   | HS512        | HMAC using SHA-512            | Optional           |
   | RS256        | RSASSA-PKCS1-v1_5 using       | Recommended        |
   |              | SHA-256                       |                    |
   | RS384        | RSASSA-PKCS1-v1_5 using       | Optional           |
   |              | SHA-384                       |                    |
   | RS512        | RSASSA-PKCS1-v1_5 using       | Optional           |
   |              | SHA-512                       |                    |
   | ES256        | ECDSA using P-256 and SHA-256 | Recommended+       |
   | ES384        | ECDSA using P-384 and SHA-384 | Optional           |
   | ES512        | ECDSA using P-521 and SHA-512 | Optional           |
   | PS256        | RSASSA-PSS using SHA-256 and  | Optional           |
   |              | MGF1 with SHA-256             |                    |
   | PS384        | RSASSA-PSS using SHA-384 and  | Optional           |
   |              | MGF1 with SHA-384             |                    |
   | PS512        | RSASSA-PSS using SHA-512 and  | Optional           |
   |              | MGF1 with SHA-512             |                    |
   | none         | No digital signature or MAC   | Optional           |
   |              | performed                     |                    |
   +--------------+-------------------------------+--------------------+

Returns 1 for success, 0 for failure.

top
SetProtectedHeader
SetProtectedHeader(ByVal index As Long, json As ChilkatJsonObject) As Long
Introduced in version 9.5.0.66

Sets a signature's protected header. The index is the index of the signature. The 1st signature is at index 0. In most cases, a JWS contains a single signature at index 0.

Returns 1 for success, 0 for failure.

top
SetPublicKey
SetPublicKey(ByVal index As Long, pubKey As PublicKey) As Long
Introduced in version 9.5.0.66

Sets the public key (ECC or RSA) to be used in validating a signature for the following algorithms:

RS256
RS384
RS512
ES256
ES384
ES512
PS256
PS384
PS512

Returns 1 for success, 0 for failure.

top
SetUnprotectedHeader
SetUnprotectedHeader(ByVal index As Long, json As ChilkatJsonObject) As Long
Introduced in version 9.5.0.66

Sets a signature's optional unprotected header. The index is the index of the signature. The 1st signature is at index 0. In most cases, a JWS contains a single signature at index 0.

Returns 1 for success, 0 for failure.

top
Validate
Validate(ByVal index As Long) As Long
Introduced in version 9.5.0.66

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.

More Information and Examples
(AutoIt) JWS Using HMAC SHA-256(Classic ASP) JWS Using HMAC SHA-256(PowerBuilder) JWS Using HMAC SHA-256(SQL Server) JWS Using HMAC SHA-256(VBScript) JWS Using HMAC SHA-256(Visual Basic 6.0) JWS Using HMAC SHA-256(Visual FoxPro) JWS Using HMAC SHA-256(AutoIt) Validate JWS Using RSASSA-PKCS1-v1_5 SHA-256(Classic ASP) Validate JWS Using RSASSA-PKCS1-v1_5 SHA-256(PowerBuilder) Validate JWS Using RSASSA-PKCS1-v1_5 SHA-256(SQL Server) Validate JWS Using RSASSA-PKCS1-v1_5 SHA-256(VBScript) Validate JWS Using RSASSA-PKCS1-v1_5 SHA-256(Visual Basic 6.0) Validate JWS Using RSASSA-PKCS1-v1_5 SHA-256(Visual FoxPro) Validate JWS Using RSASSA-PKCS1-v1_5 SHA-256(AutoIt) Validate a JWS Using ECDSA P-256 SHA-256(Classic ASP) Validate a JWS Using ECDSA P-256 SHA-256(PowerBuilder) Validate a JWS Using ECDSA P-256 SHA-256(SQL Server) Validate a JWS Using ECDSA P-256 SHA-256(VBScript) Validate a JWS Using ECDSA P-256 SHA-256(Visual Basic 6.0) Validate a JWS Using ECDSA P-256 SHA-256(Visual FoxPro) Validate a JWS Using ECDSA P-256 SHA-256(AutoIt) Validate JWS with Multiple Signatures using the General JSON Serialization Format(Classic ASP) Validate JWS with Multiple Signatures using the General JSON Serialization Format(PowerBuilder) Validate JWS with Multiple Signatures using the General JSON Serialization Format(SQL Server) Validate JWS with Multiple Signatures using the General JSON Serialization Format(VBScript) Validate JWS with Multiple Signatures using the General JSON Serialization Format(Visual Basic 6.0) Validate JWS with Multiple Signatures using the General JSON Serialization Format(Visual FoxPro) Validate JWS with Multiple Signatures using the General JSON Serialization Format
top