Class JSONWebKey


  • public class JSONWebKey
    extends java.lang.Object
    JSONWebKey

    Describes an [RFC7517](https://datatracker.ietf.org/doc/html/rfc7517) web key.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  JSONWebKey.Builder  
    • Constructor Summary

      Constructors 
      Constructor Description
      JSONWebKey​(java.lang.String kty)  
      JSONWebKey​(java.lang.String kty, java.util.Optional<? extends Use> use, java.util.Optional<? extends java.util.List<java.lang.String>> keyOps, java.util.Optional<java.lang.String> alg, java.util.Optional<java.lang.String> kid, java.util.Optional<java.lang.String> crv, java.util.Optional<java.lang.String> x, java.util.Optional<java.lang.String> y, java.util.Optional<java.lang.String> n, java.util.Optional<java.lang.String> e)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.Optional<java.lang.String> alg()
      The algorithm intended for use with the key, e.g., 'RS256' or 'ES256'.
      static JSONWebKey.Builder builder()  
      java.util.Optional<java.lang.String> crv()
      The curve for Elliptic Curve keys, e.g., 'P-256', 'P-384', or 'P-521'.
      java.util.Optional<java.lang.String> e()
      The exponent value for RSA keys.
      boolean equals​(java.lang.Object o)  
      int hashCode()  
      java.util.Optional<java.util.List<java.lang.String>> keyOps()
      The permitted operations for the key, e.g., 'sign', 'verify', 'encrypt', 'decrypt'.
      java.util.Optional<java.lang.String> kid()
      A unique identifier for the key.
      java.lang.String kty()
      The cryptographic algorithm family used with the key (e.g., 'RSA', 'EC', 'oct').
      java.util.Optional<java.lang.String> n()
      The modulus value for RSA keys.
      java.lang.String toString()  
      java.util.Optional<Use> use()
      The intended use of the key.
      JSONWebKey withAlg​(java.lang.String alg)
      The algorithm intended for use with the key, e.g., 'RS256' or 'ES256'.
      JSONWebKey withAlg​(java.util.Optional<java.lang.String> alg)
      The algorithm intended for use with the key, e.g., 'RS256' or 'ES256'.
      JSONWebKey withCrv​(java.lang.String crv)
      The curve for Elliptic Curve keys, e.g., 'P-256', 'P-384', or 'P-521'.
      JSONWebKey withCrv​(java.util.Optional<java.lang.String> crv)
      The curve for Elliptic Curve keys, e.g., 'P-256', 'P-384', or 'P-521'.
      JSONWebKey withE​(java.lang.String e)
      The exponent value for RSA keys.
      JSONWebKey withE​(java.util.Optional<java.lang.String> e)
      The exponent value for RSA keys.
      JSONWebKey withKeyOps​(java.util.List<java.lang.String> keyOps)
      The permitted operations for the key, e.g., 'sign', 'verify', 'encrypt', 'decrypt'.
      JSONWebKey withKeyOps​(java.util.Optional<? extends java.util.List<java.lang.String>> keyOps)
      The permitted operations for the key, e.g., 'sign', 'verify', 'encrypt', 'decrypt'.
      JSONWebKey withKid​(java.lang.String kid)
      A unique identifier for the key.
      JSONWebKey withKid​(java.util.Optional<java.lang.String> kid)
      A unique identifier for the key.
      JSONWebKey withKty​(java.lang.String kty)
      The cryptographic algorithm family used with the key (e.g., 'RSA', 'EC', 'oct').
      JSONWebKey withN​(java.lang.String n)
      The modulus value for RSA keys.
      JSONWebKey withN​(java.util.Optional<java.lang.String> n)
      The modulus value for RSA keys.
      JSONWebKey withUse​(Use use)
      The intended use of the key.
      JSONWebKey withUse​(java.util.Optional<? extends Use> use)
      The intended use of the key.
      JSONWebKey withX​(java.lang.String x)
      The x coordinate for Elliptic Curve keys.
      JSONWebKey withX​(java.util.Optional<java.lang.String> x)
      The x coordinate for Elliptic Curve keys.
      JSONWebKey withY​(java.lang.String y)
      The y coordinate for Elliptic Curve keys.
      JSONWebKey withY​(java.util.Optional<java.lang.String> y)
      The y coordinate for Elliptic Curve keys.
      java.util.Optional<java.lang.String> x()
      The x coordinate for Elliptic Curve keys.
      java.util.Optional<java.lang.String> y()
      The y coordinate for Elliptic Curve keys.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • JSONWebKey

        public JSONWebKey​(java.lang.String kty,
                          java.util.Optional<? extends Use> use,
                          java.util.Optional<? extends java.util.List<java.lang.String>> keyOps,
                          java.util.Optional<java.lang.String> alg,
                          java.util.Optional<java.lang.String> kid,
                          java.util.Optional<java.lang.String> crv,
                          java.util.Optional<java.lang.String> x,
                          java.util.Optional<java.lang.String> y,
                          java.util.Optional<java.lang.String> n,
                          java.util.Optional<java.lang.String> e)
      • JSONWebKey

        public JSONWebKey​(java.lang.String kty)
    • Method Detail

      • kty

        public java.lang.String kty()
        The cryptographic algorithm family used with the key (e.g., 'RSA', 'EC', 'oct').
      • use

        public java.util.Optional<Use> use()
        The intended use of the key. 'sig' for signature, 'enc' for encryption.
      • keyOps

        public java.util.Optional<java.util.List<java.lang.String>> keyOps()
        The permitted operations for the key, e.g., 'sign', 'verify', 'encrypt', 'decrypt'.
      • alg

        public java.util.Optional<java.lang.String> alg()
        The algorithm intended for use with the key, e.g., 'RS256' or 'ES256'.
      • kid

        public java.util.Optional<java.lang.String> kid()
        A unique identifier for the key.
      • crv

        public java.util.Optional<java.lang.String> crv()
        The curve for Elliptic Curve keys, e.g., 'P-256', 'P-384', or 'P-521'.

        This field is required when `kty` is 'EC'.

      • x

        public java.util.Optional<java.lang.String> x()
        The x coordinate for Elliptic Curve keys.

        This field is required when `kty` is 'EC'.

      • y

        public java.util.Optional<java.lang.String> y()
        The y coordinate for Elliptic Curve keys.

        This field is required when `kty` is 'EC'.

      • n

        public java.util.Optional<java.lang.String> n()
        The modulus value for RSA keys.

        This field is required when `kty` is 'RSA'.

      • e

        public java.util.Optional<java.lang.String> e()
        The exponent value for RSA keys.

        This field is required when `kty` is 'RSA'.

      • withKty

        public JSONWebKey withKty​(java.lang.String kty)
        The cryptographic algorithm family used with the key (e.g., 'RSA', 'EC', 'oct').
      • withUse

        public JSONWebKey withUse​(Use use)
        The intended use of the key. 'sig' for signature, 'enc' for encryption.
      • withUse

        public JSONWebKey withUse​(java.util.Optional<? extends Use> use)
        The intended use of the key. 'sig' for signature, 'enc' for encryption.
      • withKeyOps

        public JSONWebKey withKeyOps​(java.util.List<java.lang.String> keyOps)
        The permitted operations for the key, e.g., 'sign', 'verify', 'encrypt', 'decrypt'.
      • withKeyOps

        public JSONWebKey withKeyOps​(java.util.Optional<? extends java.util.List<java.lang.String>> keyOps)
        The permitted operations for the key, e.g., 'sign', 'verify', 'encrypt', 'decrypt'.
      • withAlg

        public JSONWebKey withAlg​(java.lang.String alg)
        The algorithm intended for use with the key, e.g., 'RS256' or 'ES256'.
      • withAlg

        public JSONWebKey withAlg​(java.util.Optional<java.lang.String> alg)
        The algorithm intended for use with the key, e.g., 'RS256' or 'ES256'.
      • withKid

        public JSONWebKey withKid​(java.lang.String kid)
        A unique identifier for the key.
      • withKid

        public JSONWebKey withKid​(java.util.Optional<java.lang.String> kid)
        A unique identifier for the key.
      • withCrv

        public JSONWebKey withCrv​(java.lang.String crv)
        The curve for Elliptic Curve keys, e.g., 'P-256', 'P-384', or 'P-521'.

        This field is required when `kty` is 'EC'.

      • withCrv

        public JSONWebKey withCrv​(java.util.Optional<java.lang.String> crv)
        The curve for Elliptic Curve keys, e.g., 'P-256', 'P-384', or 'P-521'.

        This field is required when `kty` is 'EC'.

      • withX

        public JSONWebKey withX​(java.lang.String x)
        The x coordinate for Elliptic Curve keys.

        This field is required when `kty` is 'EC'.

      • withX

        public JSONWebKey withX​(java.util.Optional<java.lang.String> x)
        The x coordinate for Elliptic Curve keys.

        This field is required when `kty` is 'EC'.

      • withY

        public JSONWebKey withY​(java.lang.String y)
        The y coordinate for Elliptic Curve keys.

        This field is required when `kty` is 'EC'.

      • withY

        public JSONWebKey withY​(java.util.Optional<java.lang.String> y)
        The y coordinate for Elliptic Curve keys.

        This field is required when `kty` is 'EC'.

      • withN

        public JSONWebKey withN​(java.lang.String n)
        The modulus value for RSA keys.

        This field is required when `kty` is 'RSA'.

      • withN

        public JSONWebKey withN​(java.util.Optional<java.lang.String> n)
        The modulus value for RSA keys.

        This field is required when `kty` is 'RSA'.

      • withE

        public JSONWebKey withE​(java.lang.String e)
        The exponent value for RSA keys.

        This field is required when `kty` is 'RSA'.

      • withE

        public JSONWebKey withE​(java.util.Optional<java.lang.String> e)
        The exponent value for RSA keys.

        This field is required when `kty` is 'RSA'.

      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object