Class JSONWebKey

  • All Implemented Interfaces:
    java.lang.Comparable<JSONWebKey>

    public class JSONWebKey
    extends java.lang.Object
    implements java.lang.Comparable<JSONWebKey>
    Version:
    February 12, 2019
    Author:
    Javier Rojas Blum
    • Constructor Summary

      Constructors 
      Constructor Description
      JSONWebKey()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int compareTo​(JSONWebKey o)  
      static JSONWebKey fromJSONObject​(org.json.JSONObject jwkJSONObject)  
      Algorithm getAlg()  
      ECEllipticCurve getCrv()
      Returns the curve member that identifies the cryptographic curve used with the key.
      java.lang.String getE()
      Returns the exponent value for the RSA public key.
      java.lang.Long getExp()  
      java.lang.String getKid()
      Returns the Key ID.
      KeyType getKty()  
      java.lang.String getN()
      Returns the modulus value for the RSA public key.
      Use getUse()
      Returns the intended use of the key: signature or encryption.
      java.lang.String getX()
      Returns the x member that contains the x coordinate for the elliptic curve point.
      java.util.List<java.lang.String> getX5c()  
      java.lang.String getY()
      Returns the y member that contains the x coordinate for the elliptic curve point.
      void setAlg​(Algorithm alg)  
      void setCrv​(ECEllipticCurve crv)
      Sets the curve member that identifies the cryptographic curve used with the key.
      void setE​(java.lang.String e)
      Sets the exponent value for the RSA public key.
      void setExp​(java.lang.Long exp)  
      void setKid​(java.lang.String kid)
      Sets the Key ID.
      void setKty​(KeyType kty)  
      void setN​(java.lang.String n)
      Sets the modulus value for the RSA public key.
      void setUse​(Use use)
      Sets the intended use of the key: signature or encryption.
      void setX​(java.lang.String x)
      Sets the x member that contains the x coordinate for the elliptic curve point.
      void setX5c​(java.util.List<java.lang.String> x5c)  
      void setY​(java.lang.String y)
      Sets the y member that contains the y coordinate for the elliptic curve point.
      org.json.JSONObject toJSONObject()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • JSONWebKey

        public JSONWebKey()
    • Method Detail

      • getKid

        public java.lang.String getKid()
        Returns the Key ID. The Key ID member can be used to match a specific key. This can be used, for instance, to choose among a set of keys within the JWK during key rollover.
        Returns:
        The Key ID.
      • setKid

        public void setKid​(java.lang.String kid)
        Sets the Key ID.
        Parameters:
        kid - The Key ID.
      • setKty

        public void setKty​(KeyType kty)
      • getUse

        public Use getUse()
        Returns the intended use of the key: signature or encryption.
        Returns:
        The intended use of the key.
      • setUse

        public void setUse​(Use use)
        Sets the intended use of the key: signature or encryption.
        Parameters:
        use - The intended use of the key.
      • setAlg

        public void setAlg​(Algorithm alg)
      • getExp

        public java.lang.Long getExp()
      • setExp

        public void setExp​(java.lang.Long exp)
      • getCrv

        public ECEllipticCurve getCrv()
        Returns the curve member that identifies the cryptographic curve used with the key.
        Returns:
        The curve member that identifies the cryptographic curve used with the key.
      • setCrv

        public void setCrv​(ECEllipticCurve crv)
        Sets the curve member that identifies the cryptographic curve used with the key.
        Parameters:
        crv - The curve member that identifies the cryptographic curve used with the key.
      • getX5c

        public java.util.List<java.lang.String> getX5c()
      • setX5c

        public void setX5c​(java.util.List<java.lang.String> x5c)
      • getN

        public java.lang.String getN()
        Returns the modulus value for the RSA public key. It is represented as the base64url encoding of the value's representation.
        Returns:
        The modulus value for the RSA public key.
      • setN

        public void setN​(java.lang.String n)
        Sets the modulus value for the RSA public key.
        Parameters:
        n - The modulus value for the RSA public key.
      • getE

        public java.lang.String getE()
        Returns the exponent value for the RSA public key.
        Returns:
        The exponent value for the RSA public key.
      • setE

        public void setE​(java.lang.String e)
        Sets the exponent value for the RSA public key.
        Parameters:
        e - The exponent value for the RSA public key.
      • getX

        public java.lang.String getX()
        Returns the x member that contains the x coordinate for the elliptic curve point. It is represented as the base64url encoding of the coordinate's big endian representation.
        Returns:
        The x member that contains the x coordinate for the elliptic curve point.
      • setX

        public void setX​(java.lang.String x)
        Sets the x member that contains the x coordinate for the elliptic curve point.
        Parameters:
        x - The x member that contains the x coordinate for the elliptic curve point.
      • getY

        public java.lang.String getY()
        Returns the y member that contains the x coordinate for the elliptic curve point. It is represented as the base64url encoding of the coordinate's big endian representation.
        Returns:
        The y member that contains the x coordinate for the elliptic curve point.
      • setY

        public void setY​(java.lang.String y)
        Sets the y member that contains the y coordinate for the elliptic curve point.
        Parameters:
        y - The y member that contains the y coordinate for the elliptic curve point.
      • toJSONObject

        public org.json.JSONObject toJSONObject()
                                         throws org.json.JSONException
        Throws:
        org.json.JSONException
      • compareTo

        public int compareTo​(JSONWebKey o)
        Specified by:
        compareTo in interface java.lang.Comparable<JSONWebKey>
      • fromJSONObject

        public static JSONWebKey fromJSONObject​(org.json.JSONObject jwkJSONObject)
                                         throws org.json.JSONException
        Throws:
        org.json.JSONException