Class JwsHeader


  • public final class JwsHeader
    extends java.lang.Object
    The JSON Web Signature (JWS) header is a JSON object representing the header parameters of a JSON Web Token, that describe the cryptographic operations used to digitally sign or create a MAC of the contents of the JWS Protected Header and JWS Payload.
    Since:
    5.6
    See Also:
    JWS JOSE Header
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static JwsHeader.Builder from​(JwsHeader headers)
      Returns a new JwsHeader.Builder, initialized with the provided headers.
      JwsAlgorithm getAlgorithm()
      Returns the JWA algorithm used to digitally sign the JWS or encrypt the JWE.
      java.lang.String getContentType()
      Returns the content type header that declares the media type of the secured content (the payload).
      java.util.Set<java.lang.String> getCritical()
      Returns the critical headers that indicates which extensions to the JWS/JWE/JWA specifications are being used that MUST be understood and processed.
      <T> T getHeader​(java.lang.String name)
      Returns the header value.
      java.util.Map<java.lang.String,​java.lang.Object> getHeaders()
      Returns the headers.
      java.util.Map<java.lang.String,​java.lang.Object> getJwk()
      Returns the JSON Web Key which is the public key that corresponds to the key used to digitally sign the JWS or encrypt the JWE.
      java.net.URL getJwkSetUrl()
      Returns the JWK Set URL that refers to the resource of a set of JSON-encoded public keys, one of which corresponds to the key used to digitally sign the JWS or encrypt the JWE.
      java.lang.String getKeyId()
      Returns the key ID that is a hint indicating which key was used to secure the JWS or JWE.
      java.lang.String getType()
      Returns the type header that declares the media type of the JWS/JWE.
      java.util.List<java.lang.String> getX509CertificateChain()
      Returns the X.509 certificate chain that contains the X.509 public key certificate or certificate chain corresponding to the key used to digitally sign the JWS or encrypt the JWE.
      java.lang.String getX509SHA1Thumbprint()
      Returns the X.509 certificate SHA-1 thumbprint that is a base64url-encoded SHA-1 thumbprint (a.k.a.
      java.lang.String getX509SHA256Thumbprint()
      Returns the X.509 certificate SHA-256 thumbprint that is a base64url-encoded SHA-256 thumbprint (a.k.a.
      java.net.URL getX509Url()
      Returns the X.509 URL that refers to the resource for the X.509 public key certificate or certificate chain corresponding to the key used to digitally sign the JWS or encrypt the JWE.
      static JwsHeader.Builder with​(JwsAlgorithm jwsAlgorithm)
      Returns a new JwsHeader.Builder, initialized with the provided JwsAlgorithm.
      • Methods inherited from class java.lang.Object

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

      • getJwkSetUrl

        public java.net.URL getJwkSetUrl()
        Returns the JWK Set URL that refers to the resource of a set of JSON-encoded public keys, one of which corresponds to the key used to digitally sign the JWS or encrypt the JWE.
        Returns:
        the JWK Set URL
      • getJwk

        public java.util.Map<java.lang.String,​java.lang.Object> getJwk()
        Returns the JSON Web Key which is the public key that corresponds to the key used to digitally sign the JWS or encrypt the JWE.
        Returns:
        the JSON Web Key
      • getKeyId

        public java.lang.String getKeyId()
        Returns the key ID that is a hint indicating which key was used to secure the JWS or JWE.
        Returns:
        the key ID
      • getX509Url

        public java.net.URL getX509Url()
        Returns the X.509 URL that refers to the resource for the X.509 public key certificate or certificate chain corresponding to the key used to digitally sign the JWS or encrypt the JWE.
        Returns:
        the X.509 URL
      • getX509CertificateChain

        public java.util.List<java.lang.String> getX509CertificateChain()
        Returns the X.509 certificate chain that contains the X.509 public key certificate or certificate chain corresponding to the key used to digitally sign the JWS or encrypt the JWE. The certificate or certificate chain is represented as a List of certificate value Strings. Each String in the List is a Base64-encoded DER PKIX certificate value.
        Returns:
        the X.509 certificate chain
      • getX509SHA1Thumbprint

        public java.lang.String getX509SHA1Thumbprint()
        Returns the X.509 certificate SHA-1 thumbprint that is a base64url-encoded SHA-1 thumbprint (a.k.a. digest) of the DER encoding of the X.509 certificate corresponding to the key used to digitally sign the JWS or encrypt the JWE.
        Returns:
        the X.509 certificate SHA-1 thumbprint
      • getX509SHA256Thumbprint

        public java.lang.String getX509SHA256Thumbprint()
        Returns the X.509 certificate SHA-256 thumbprint that is a base64url-encoded SHA-256 thumbprint (a.k.a. digest) of the DER encoding of the X.509 certificate corresponding to the key used to digitally sign the JWS or encrypt the JWE.
        Returns:
        the X.509 certificate SHA-256 thumbprint
      • getType

        public java.lang.String getType()
        Returns the type header that declares the media type of the JWS/JWE.
        Returns:
        the type header
      • getContentType

        public java.lang.String getContentType()
        Returns the content type header that declares the media type of the secured content (the payload).
        Returns:
        the content type header
      • getCritical

        public java.util.Set<java.lang.String> getCritical()
        Returns the critical headers that indicates which extensions to the JWS/JWE/JWA specifications are being used that MUST be understood and processed.
        Returns:
        the critical headers
      • getHeaders

        public java.util.Map<java.lang.String,​java.lang.Object> getHeaders()
        Returns the headers.
        Returns:
        the headers
      • getHeader

        public <T> T getHeader​(java.lang.String name)
        Returns the header value.
        Type Parameters:
        T - the type of the header value
        Parameters:
        name - the header name
        Returns:
        the header value