Jwt ActiveX Reference Documentation

Jwt

A class for signing and verifying JWT's (Java Web Tokens).

Object Creation

(Visual Basic 6.0)
Dim obj As New ChilkatJwt

(ASP)
set obj = Server.CreateObject("Chilkat_9_5_0.Jwt")

(VBScript)
set obj = CreateObject("Chilkat_9_5_0.Jwt")

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

(FoxPro)
loObject = CreateObject('Chilkat_9_5_0.Jwt')

(PowerBuilder)
lole_object = create oleobject
li_rc = lole_object.ConnectToNewObject("Chilkat_9_5_0.Jwt")

(SQL Server)
EXEC @hr = sp_OACreate 'Chilkat_9_5_0.Jwt', @obj OUT

(Javascript)
var obj = new ActiveXObject("Chilkat_9_5_0.Jwt");

Properties

AutoCompact As Long

Introduced in version 9.5.0.58

If 1, the JSON passed to CreateJwt and CreateJwtPk will be compacted to remove unnecessary whitespace. This will result in the smallest possible JWT. The default value is 1.

DebugLogFilePath As String

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:

  1. a timeout related property was set to 0 to explicitly indicate that an infinite timeout is desired,
  2. the hang is actually a hang within an event callback (i.e. it is a hang within the application code), or
  3. there is an internal problem (bug) in the Chilkat code that causes the hang.

LastBinaryResult As Variant (read-only)

Introduced in version 9.5.0.52

The binary data returned by the last (binary data returning) method called. Only available if Chilkat.Global.KeepBinaryResult is set to 1. This provides a means for obtaining large varbinary results in the SQL Server environment (where limitations exist in getting large amounts of data returned by method calls, but where temp tables can be used for binary properties).

LastErrorHtml As String (read-only)

Provides information in HTML 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.

LastErrorText As String (read-only)

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.

Concept of LastErrorText

LastErrorText Standard Information

LastErrorXml As String (read-only)

Provides information in XML 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 As Long

Introduced in version 9.5.0.52

Indicate whether the last method call succeeded or failed. A value of 1 indicates success, a value of 0 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:

  • Any method that returns a string.
  • Any method returning a Chilkat object, binary bytes, or a date/time.
  • Any method returning a standard boolean status value where success = 1 and failure = 0.
  • Any method returning an integer where failure is defined by a return value less than zero.

Note: Methods that do not fit the above requirements will always set this property equal to 1. For example, a method that returns no value (such as a "void" in C++) will technically always succeed.

LastStringResult As String (read-only)

Introduced in version 9.5.0.52

The string return value of the last (string returning) method called. Only available if Chilkat.Global.KeepStringResult is set to 1. This provides a means for obtaining large string results in the SQL Server environment (where limitations exist in getting long strings returned by method calls, but where temp tables can be used for string properties).

Long Strings Returned by ActiveX Methods in SQL Server

LastStringResultLen As Long (read-only)

Introduced in version 9.5.0.53

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

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.

Version As String (read-only)

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

Methods

CreateJwt(header As String, payload As String, password As String) As String

Introduced in version 9.5.0.58

Creates a JWT. The header is the JOSE JSON header. It can be the full JOSE JSON, or it can be a shorthand string such as "HS256", "HS384", or "HS512", in which case the standard JOSE header for the given algorithm will be used.

The payload is the JSON payload that contains the claims. The password is the secret. Given that the secret is a shared passwod string, this method should only be called for creating JWT's where the JOSE header's "alg" is HS256, HS384, or HS512. For RS256, RS384, RS512, ES256, ES384, and ES512, call CreateJwtPk instead.

When successful, this method returns a JWT with the format xxxxx.yyyyy.zzzzz, where xxxxx is the base64url encoded JOSE header, yyyyy is the base64url encoded payload, and zzzzz is the base64url signature.

Returns Nothing on failure

(Classic ASP) Create JWT Using HS256, HS384, or HS512

(Visual FoxPro) Create JWT Using HS256, HS384, or HS512

(PowerBuilder) Create JWT Using HS256, HS384, or HS512

(SQL Server) Create JWT Using HS256, HS384, or HS512

(Visual Basic 6.0) Create JWT Using HS256, HS384, or HS512

(VBScript) Create JWT Using HS256, HS384, or HS512

(Classic ASP) Firebase JWT User Authentication

(Visual FoxPro) Firebase JWT User Authentication

(PowerBuilder) Firebase JWT User Authentication

(SQL Server) Firebase JWT User Authentication

(Visual Basic 6.0) Firebase JWT User Authentication

(VBScript) Firebase JWT User Authentication

CreateJwtPk(header As String, payload As String, key As PrivateKey) As String

Introduced in version 9.5.0.58

Creates a JWT using an RSA or ECC private key. The header is the JOSE JSON header. It can be the full JOSE JSON, or it can be a shorthand string such as "RS256", "RS384", "RS512", "ES256", "ES384", or "ES512", in which case the standard JOSE header for the given algorithm will be used.

The payload is the JSON payload that contains the claims. The key is the private key. This method should only be called for creating JWT's where the JOSE header's "alg" is RS256, RS384, RS512, ES256, ES384, and ES512. If the secret is a shared password string, then call CreateJwt instead.

When successful, this method returns a JWT with the format xxxxx.yyyyy.zzzzz, where xxxxx is the base64url encoded JOSE header, yyyyy is the base64url encoded payload, and zzzzz is the base64url signature.

Returns Nothing on failure

(Classic ASP) Create JWT Using RSA (RS256, RS384, or RS512)

(Visual FoxPro) Create JWT Using RSA (RS256, RS384, or RS512)

(PowerBuilder) Create JWT Using RSA (RS256, RS384, or RS512)

(SQL Server) Create JWT Using RSA (RS256, RS384, or RS512)

(Visual Basic 6.0) Create JWT Using RSA (RS256, RS384, or RS512)

(VBScript) Create JWT Using RSA (RS256, RS384, or RS512)

(Classic ASP) Create JWT Using ECC (ES256, ES384, or ES512)

(Visual FoxPro) Create JWT Using ECC (ES256, ES384, or ES512)

(PowerBuilder) Create JWT Using ECC (ES256, ES384, or ES512)

(SQL Server) Create JWT Using ECC (ES256, ES384, or ES512)

(Visual Basic 6.0) Create JWT Using ECC (ES256, ES384, or ES512)

(VBScript) Create JWT Using ECC (ES256, ES384, or ES512)

GenNumericDate(ByVal numSecOffset As Long) As Long

Introduced in version 9.5.0.58

Generates a JSON numeric value representing the number of seconds from 1970-01-01T00:00:00Z UTC until the specified UTC date/time, ignoring leap seconds. The date/time generated is equal to the current system time plus the number of seconds specified by numSecOffset. The numSecOffset can be negative.

(Classic ASP) Create JWT Using HS256, HS384, or HS512

(Visual FoxPro) Create JWT Using HS256, HS384, or HS512

(PowerBuilder) Create JWT Using HS256, HS384, or HS512

(SQL Server) Create JWT Using HS256, HS384, or HS512

(Visual Basic 6.0) Create JWT Using HS256, HS384, or HS512

(VBScript) Create JWT Using HS256, HS384, or HS512

GetHeader(token As String) As String

Introduced in version 9.5.0.58

Decodes the first part of a JWT (the "xxxxx" part of the "xxxxx.yyyyy.zzzzz" JWT) and returns the JSON string. This is the JOSE header of the JWT.

Returns Nothing on failure

(Classic ASP) Verify JWT Using HS256, HS384, or HS512

(Visual FoxPro) Verify JWT Using HS256, HS384, or HS512

(PowerBuilder) Verify JWT Using HS256, HS384, or HS512

(SQL Server) Verify JWT Using HS256, HS384, or HS512

(Visual Basic 6.0) Verify JWT Using HS256, HS384, or HS512

(VBScript) Verify JWT Using HS256, HS384, or HS512

GetPayload(token As String) As String

Introduced in version 9.5.0.58

Decodes the second part of a JWT (the "yyyyy" part of the "xxxxx.yyyyy.zzzzz" JWT) and returns the JSON string. This is the claims payload of the JWT.

Returns Nothing on failure

(Classic ASP) Verify JWT Using HS256, HS384, or HS512

(Visual FoxPro) Verify JWT Using HS256, HS384, or HS512

(PowerBuilder) Verify JWT Using HS256, HS384, or HS512

(SQL Server) Verify JWT Using HS256, HS384, or HS512

(Visual Basic 6.0) Verify JWT Using HS256, HS384, or HS512

(VBScript) Verify JWT Using HS256, HS384, or HS512

IsTimeValid(jwt As String, ByVal leeway As Long) As Long

Introduced in version 9.5.0.58

Verifies the "exp" and/or "nbf" claims and returns 1 if the current system date/time is within range. Returns 0 if the current system date/time is outside the allowed range of time. The leeway may be set to a non-zero number of seconds to allow for some small leeway (usually no more than a few minutes) to account for clock skew.

(Classic ASP) Verify JWT Using HS256, HS384, or HS512

(Visual FoxPro) Verify JWT Using HS256, HS384, or HS512

(PowerBuilder) Verify JWT Using HS256, HS384, or HS512

(SQL Server) Verify JWT Using HS256, HS384, or HS512

(Visual Basic 6.0) Verify JWT Using HS256, HS384, or HS512

(VBScript) Verify JWT Using HS256, HS384, or HS512

VerifyJwt(token As String, password As String) As Long

Introduced in version 9.5.0.58

Verifies a JWT that requires a shared password string for verification. The token should be a JWT with the format xxxxx.yyyyy.zzzzz. This method should only be called for JWT's using the HS256, HS384, or HS512 algorithms. The VerifyJwtPk method should be called for verifying JWT's requiring an RSA or ECC key.

Returns 1 if the signature was verified. Returns 0 if the signature was not successfully verified.

Returns 1 for success, 0 for failure.

(Classic ASP) Verify JWT Using HS256, HS384, or HS512

(Visual FoxPro) Verify JWT Using HS256, HS384, or HS512

(PowerBuilder) Verify JWT Using HS256, HS384, or HS512

(SQL Server) Verify JWT Using HS256, HS384, or HS512

(Visual Basic 6.0) Verify JWT Using HS256, HS384, or HS512

(VBScript) Verify JWT Using HS256, HS384, or HS512

VerifyJwtPk(token As String, key As PublicKey) As Long

Introduced in version 9.5.0.58

Verifies a JWT that requires an RSA or ECC public key for verification. The token should be a JWT with the format xxxxx.yyyyy.zzzzz. This method should only be called for JWT's using the RS256, RS384, RS512, ES256, ES384, or ES512 algorithms.

Returns 1 if the signature was verified. Returns 0 if the signature was not successfully verified.

Returns 1 for success, 0 for failure.

(Classic ASP) Verify JWT Using an RSA Public Key (RS256, RS384, RS512)

(Visual FoxPro) Verify JWT Using an RSA Public Key (RS256, RS384, RS512)

(PowerBuilder) Verify JWT Using an RSA Public Key (RS256, RS384, RS512)

(SQL Server) Verify JWT Using an RSA Public Key (RS256, RS384, RS512)

(Visual Basic 6.0) Verify JWT Using an RSA Public Key (RS256, RS384, RS512)

(VBScript) Verify JWT Using an RSA Public Key (RS256, RS384, RS512)

(Classic ASP) Verify JWT Using an ECC Public Key (ES256, ES384, ES512)

(Visual FoxPro) Verify JWT Using an ECC Public Key (ES256, ES384, ES512)

(PowerBuilder) Verify JWT Using an ECC Public Key (ES256, ES384, ES512)

(SQL Server) Verify JWT Using an ECC Public Key (ES256, ES384, ES512)

(Visual Basic 6.0) Verify JWT Using an ECC Public Key (ES256, ES384, ES512)

(VBScript) Verify JWT Using an ECC Public Key (ES256, ES384, ES512)