Skip to main content

%Net.JSON.JWKS

class %Net.JSON.JWKS extends %Library.RegisteredObject

This class provides methods to create and manage JSON Web Key Sets, as defined in RFC 7517.

Method Inventory

Methods

classmethod GetJWK(alg As %String, kid As %String, JWKS As %String, Output JWK As %DynamicObject) as %Status
This method returns a JSON Web Key (JWK) that matches the provided algorithm and/or key ID from the given JSON Web Key Set (JWKS).

Input parameters:
  • alg - The algorithm of the desired JWK.
  • kid - The key ID of the desired JWK.
  • JWKS - The JWKS to search for the desired key.

Output parameters:
  • JWK - The JWK that matches the provided algorithm and/or key ID.

Return value:
  • A status indicating whether or not the method was able to use the provided inputs to search the given JWKS, where error values indicate that it was unable to search and describe the reason why.

Notes:
  • This method uses the following criteria, listed in order of priority, to determine which key to return:
    1. alg/kid combination exact match
    2. alg (but not kid) match
    3. kid match and the key is for an algorithm with the same key type as alg
    4. kid match
  • If more than one key is found for a given criterium, then the last key that meets that criterium is returned.
  • This method will return an error if it finds a key in the JWKS that is not a valid JWK.
  • This method will succeed if no key is found for the given alg/kid, but the JWK output value will be emtpy.
classmethod InitializeJWKS(Output JWKS As %String) as %Status
This method creates a new JSON Web Key Set (JWKS).

Output parameters:
  • JWKS - An empty JWKS.

Return value:
  • A status value indicating whether or not the JWKS was created, where errors indicate that it wasn't created and describe why.

Notes:
  • This simply creates an empty JWKS.
classmethod PutJWK(JWK As %DynamicObject, ByRef JWKS As %String) as %Status
This methods adds a JSON Web Key (JWK) to a JSON Web Key Set (JWKS).

Input parameters:
  • JWK - The JWK to add to the JWKS.
  • JWKS - The JWKS to add the JWK into.

Return value:
  • A status indicating whether or not the provided JWK was added to the JWKS, where error values indicate that it was not added and describe the reason why.

Notes:
  • If JWKS is null, then a new JWKS will be created and the key will be added to it.
  • This method does not add a kid to keys when it puts them in the JWKS. In order to use kids, they must be added before the key is added to the JWKS. For example:
    Set JWK.kid=1
    Do ##class(%Net.JSON.JWKS).PutJWK(JWK,.JWKS)
classmethod RemoveJWK(alg As %String, kid As %String, ByRef JWKS As %String) as %Status
This method removes JSON Web Keys (JWK) that match the provided algorithm and/or key ID from a JSON Web Key Set (JWKS).

Input parameters:
  • alg - The algorithm of the JWKs that are to be removed from the JWKS.
  • kid - The key ID of the JWKs that are to be removed from the JWKS.
  • JWKS - The JWKS to remove keys from.

Return value:
  • A status indicating whether or not the method was able to use the provided inputs to search the given JWKS to attempt to remove keys, where error values indicate that it was unable to search and describe the reason why.

Notes:
  • If both alg and kid are defined, this method will remove only those keys that match both alg and kid.
  • If only alg is defined, this method will remove all keys for that algorithm.
  • If only kid is defined, this method will remove all keys with that key ID.

Inherited Members

Inherited Methods

FeedbackOpens in a new tab