Class JsonWebKey

java.lang.Object
de.christofreichardt.json.webkey.JsonWebKey
All Implemented Interfaces:
de.christofreichardt.diagnosis.Traceable
Direct Known Subclasses:
JsonWebKeyPair, JsonWebPublicKey, JsonWebSecretKey

public abstract sealed class JsonWebKey extends Object implements de.christofreichardt.diagnosis.Traceable permits JsonWebKeyPair, JsonWebPublicKey, JsonWebSecretKey
Base class for JSON web keys.
Author:
Christof Reichardt
See Also:
  • Method Details

    • fromJson

      public static <T extends JsonWebKey> T fromJson(jakarta.json.JsonObject webKeyView, Class<T> clazz) throws GeneralSecurityException
      Generic method to create a JsonWebKey from a JSON representation.
      Type Parameters:
      T - the type of the JsonWebKey class, modeled by the given Class object.
      Parameters:
      webKeyView - the JSON representation.
      clazz - the actual JsonWebKey class, could be a JsonWebKeyPair, JsonWebPublicKey or JsonWebSecretKey.
      Returns:
      a JsonWebKey object.
      Throws:
      GeneralSecurityException - passed through from the underlying implementations of the algorithms by the JDK.
    • getKid

      public String getKid()
      Returns the "kid" (Key ID) parameter.
      Returns:
      the key id, may be null.
      See Also:
    • getKeyType

      public String getKeyType()
      Returns the required "kty" (Key Type) parameter.
      Returns:
      the key type.
      See Also:
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • toJson

      public jakarta.json.JsonObject toJson()
      Serializes the common JWK parameters.
      Returns:
      a JsonObject containing the shared JWK parameters.
    • getCurrentTracer

      public de.christofreichardt.diagnosis.AbstractTracer getCurrentTracer()
      Specified by:
      getCurrentTracer in interface de.christofreichardt.diagnosis.Traceable