Class JsonWebPublicKey

java.lang.Object
de.christofreichardt.json.webkey.JsonWebKey
de.christofreichardt.json.webkey.JsonWebPublicKey
All Implemented Interfaces:
de.christofreichardt.diagnosis.Traceable

public final class JsonWebPublicKey extends JsonWebKey
Convenient for the handling of public keys in the spirit of RFC 7517 (JSON Web Key) and RFC 7518 (JSON Web Algorithms).
Author:
Christof Reichardt
See Also:
  • Method Details

    • of

      public static JsonWebPublicKey.Builder of(PublicKey publicKey)
      Creates the builder for a JsonWebPublicKey.
      Parameters:
      publicKey - the given public key.
      Returns:
      a JsonWebPublicKey.Builder.
    • getPublicKey

      public PublicKey getPublicKey()
      Returns the contained public key.
      Returns:
      the contained PublicKey.
    • getAlgorithmParameterSpec

      public AlgorithmParameterSpec getAlgorithmParameterSpec()
      Returns the applied AlgorithmParameterSpec, may be null.
      Returns:
      the applied AlgorithmParameterSpec.
    • toString

      public String toString()
      Returns a textual representation of this JsonWebPublicKey.
      Overrides:
      toString in class JsonWebKey
      Returns:
      a textual representation of this JsonWebPublicKey.
    • equals

      public boolean equals(Object object)
      Compares this JsonWebPublicKey with another JsonWebPublicKey. Compares this JsonWebPublicKey with another ensuring that it contains the same configuration. Only objects of type JsonWebPublicKey are considered, other types return false.
      Overrides:
      equals in class Object
      Parameters:
      object - the object to check, null returns false
      Returns:
      true if this is equal to the other JsonWebPublicKey
    • hashCode

      public int hashCode()
      A hash code for this JsonWebPublicKey.
      Overrides:
      hashCode in class Object
      Returns:
      a suitable hash code.
    • toJson

      public jakarta.json.JsonObject toJson()
      Converts this JsonWebPublicKey into a plain JsonObject.
      Overrides:
      toJson in class JsonWebKey
      Returns:
      a JsonObject corresponding to this JsonWebPublicKey.
      See Also:
    • fromJson

      public static JsonWebPublicKey fromJson(jakarta.json.JsonObject jwkView) throws GeneralSecurityException
      Factory method to create a JsonWebPublicKey instance from a plain JsonObject.
      Parameters:
      jwkView - the given JsonObject.
      Returns:
      a JsonWebPublicKey
      Throws:
      GeneralSecurityException - passed through from the underlying implementations of the algorithms by the JDK.