Official Content

Note: This is part of the GeneXus JWT Module..

JWTOptions

It is used to add optional values for token creation and validation.

AddRegisteredClaim

Adds a standard registered claim value to the JWTOptions.

AddRegisteredClaim(registeredClaimkey,  registeredClaimValue)
  • Input registeredClaimkey: RegisteredClaim domain value
  • Input registeredClaimValue: Character(100), if it is a Date use Posix NumericDate format as it is defined on the RFC
  • Returns: Boolean, true if it was successfully added.

Example:

&result = &JWTOptions.AddRegisteredClaim(RegisteredClaim.iss, "GX SA")

AddPublicClaim

Adds a standard public claim value to the JWTOptions.

AddPublicClaim(publicClaimkey, publicClaimDomain)
  • Input publicClaimKey: Character(20)
  • Input publicClaimDomain: VarChar(256)
  • Returns: Boolean, true if it was successfully added.

Example:

 &result = &JWTOptions.AddPublicClaim(&key, &Uri)

SetSecret

Adds a secret to be used to sign or verify the token with a symmetric algorithm.

SetSecret(value)
  • Input value: VarChar(256) Hexadecimal secret for symmetric algorithm
  • Returns void

Example:

&JWTOptions.SetSecret(&secret)

AddCustomTimeValidationClaim

Adds a Registered Claim for time validation with tolerance in seconds. 

AddCustomTimeValidationClaim(String registeredClaimKey, String value, String customTime)
  • Input registeredClaimKey: RegisteredClaim domain value of time validation type (exp, nbf or iat).
  • Input value: Character(100) Date with the specific format yyyy/MM/dd HH:mm:ss.
  • Input customTime: Character(100) time in seconds to define tolerance for claim validation.
  • Returns: Boolean, true if it was successfully added.

Example:

&JWTOptions.AddCustomTimeValidationClaim(RegisteredClaim.iat, DateUtil.getCurrentDate(), "20")

SetPrivateKey

Adds a private key to be used on the token signature using an asymmetric algorithm.

SetPrivateKey(privateKey)
  • Input privateKey: PrivateKey type value 
  • Returns void

Example:

&JWTOptions.SetPrivateKey(&PrivateKey)

SetCertificate

Adds a public key to be used on the token verification using an asymmetric algorithm.

SetCertificate(certificate)
  • Input certificate: Certificate type value
  • Returns void

Example:

&JWTOptions.SetCertificate(&Certificate)

AddRevocationList

Adds a revocation list to be verified on token verification.

AddRevocationList(revocationList)
  • Input revocationList: RevocationList type value
  • Returns void

Example:

&JWTOptions.AddRevocationList(&revocationList)

DeleteRevocationList

Deletes the revocation list contained in this instance of the JWTOptions.

DeleteRevocationList()
  • Returns void

Example:

&JWTOptions.DeleteRevocationList()

AddHeaderParameter

This method is available since GeneXus 16 Upgrade 11

Generic method to add parameters to the token's header. It does not allow nested headers.

AddHeaderParameters(name, value)
  • Input name. Character(100)
  • Input value. Character(100)
  • Returns void

Example:

&JWTOptions.AddHeaderParameter(&name, &value)

SetPublicKey

This method is available since GeneXus 18 Upgrade 4

Adds a public key to be used on the token signature using an asymmetric algorithm.

SetPublicKey(publicKey)
  • Input publicKey: PublicKey type value
  • Returns void

Example:

&JWTOptions.SetPublicKey(&publicKey)




Last update: February 2024 | © GeneXus. All rights reserved. GeneXus Powered by Globant