Class JsonWebStructure

java.lang.Object
org.jose4j.jwx.JsonWebStructure
Direct Known Subclasses:
JsonWebEncryption, JsonWebSignature

public abstract class JsonWebStructure extends Object
  • Field Details

    • base64url

      protected Base64Url base64url
    • headers

      protected Headers headers
    • doKeyValidation

      protected boolean doKeyValidation
    • rawCompactSerialization

      protected String rawCompactSerialization
  • Constructor Details

    • JsonWebStructure

      public JsonWebStructure()
  • Method Details

    • getCompactSerialization

      public abstract String getCompactSerialization() throws JoseException
      Throws:
      JoseException
    • setCompactSerializationParts

      protected abstract void setCompactSerializationParts(String[] parts) throws JoseException
      Throws:
      JoseException
    • getPayload

      public abstract String getPayload() throws JoseException
      Throws:
      JoseException
    • setPayload

      public abstract void setPayload(String payload)
    • getAlgorithm

      public abstract Algorithm getAlgorithm() throws InvalidAlgorithmException
      Throws:
      InvalidAlgorithmException
    • getAlgorithmNoConstraintCheck

      public abstract Algorithm getAlgorithmNoConstraintCheck() throws InvalidAlgorithmException
      Throws:
      InvalidAlgorithmException
    • fromCompactSerialization

      public static JsonWebStructure fromCompactSerialization(String cs) throws JoseException
      Throws:
      JoseException
    • setCompactSerialization

      public void setCompactSerialization(String compactSerialization) throws JoseException
      Throws:
      JoseException
    • getHeader

      public String getHeader()
      Returns:
      the header as JSON
    • getEncodedHeader

      protected String getEncodedHeader()
    • setHeader

      public void setHeader(String name, String value)
    • setEncodedHeader

      protected void setEncodedHeader(String encodedHeader) throws JoseException
      Throws:
      JoseException
    • getHeaders

      public Headers getHeaders()
    • checkNotEmptyPart

      protected void checkNotEmptyPart(String encodedPart, String partName) throws JoseException
      Throws:
      JoseException
    • getHeader

      public String getHeader(String name)
    • setHeader

      public void setHeader(String name, Object value)
    • getObjectHeader

      public Object getObjectHeader(String name)
    • setAlgorithmHeaderValue

      public void setAlgorithmHeaderValue(String alg)
    • getAlgorithmHeaderValue

      public String getAlgorithmHeaderValue()
    • setContentTypeHeaderValue

      public void setContentTypeHeaderValue(String cty)
    • getContentTypeHeaderValue

      public String getContentTypeHeaderValue()
    • setKeyIdHeaderValue

      public void setKeyIdHeaderValue(String kid)
    • getKeyIdHeaderValue

      public String getKeyIdHeaderValue()
    • getJwkHeader

      public PublicJsonWebKey getJwkHeader() throws JoseException
      Gets the "jwk" (JSON Web Key) Header Parameter per https://tools.ietf.org/html/rfc7515#section-4.1.3 and/or https://tools.ietf.org/html/rfc7516#section-4.1.5
      Returns:
      PublicJsonWebKey representation of the "jwk" header
      Throws:
      JoseException - if something goes wrong processing the "jwk" header content into a PublicJsonWebKey
    • setJwkHeader

      public void setJwkHeader(PublicJsonWebKey jwk)
      Sets the "jwk" (JSON Web Key) Header Parameter per https://tools.ietf.org/html/rfc7515#section-4.1.3 and/or https://tools.ietf.org/html/rfc7516#section-4.1.5
      Parameters:
      jwk - the PublicJsonWebKey representation of the JWK that will be set as the "jwk" header
    • getLeafCertificateHeaderValue

      public X509Certificate getLeafCertificateHeaderValue() throws JoseException
      Throws:
      JoseException
    • getCertificateChainHeaderValue

      public List<X509Certificate> getCertificateChainHeaderValue() throws JoseException
      Throws:
      JoseException
    • setCertificateChainHeaderValue

      public void setCertificateChainHeaderValue(X509Certificate... chain)
    • getX509CertSha1ThumbprintHeaderValue

      public String getX509CertSha1ThumbprintHeaderValue()
    • setX509CertSha1ThumbprintHeaderValue

      public void setX509CertSha1ThumbprintHeaderValue(String x5t)
    • setX509CertSha1ThumbprintHeaderValue

      public void setX509CertSha1ThumbprintHeaderValue(X509Certificate certificate)
    • getX509CertSha256ThumbprintHeaderValue

      public String getX509CertSha256ThumbprintHeaderValue()
    • setX509CertSha256ThumbprintHeaderValue

      public void setX509CertSha256ThumbprintHeaderValue(String x5tS256)
    • setX509CertSha256ThumbprintHeaderValue

      public void setX509CertSha256ThumbprintHeaderValue(X509Certificate certificate)
    • getKey

      public Key getKey()
    • setKey

      public void setKey(Key key)
    • onNewKey

      protected void onNewKey()
    • getIntegrity

      protected byte[] getIntegrity()
    • setIntegrity

      protected void setIntegrity(byte[] integrity)
    • isDoKeyValidation

      public boolean isDoKeyValidation()
    • setDoKeyValidation

      public void setDoKeyValidation(boolean doKeyValidation)
    • getAlgorithmConstraints

      protected AlgorithmConstraints getAlgorithmConstraints()
    • setAlgorithmConstraints

      public void setAlgorithmConstraints(AlgorithmConstraints algorithmConstraints)
    • setCriticalHeaderNames

      public void setCriticalHeaderNames(String... headerNames)
      Sets the value(s) of the critical ("crit") header, defined in section 4.1.11 of RFC 7515, which indicates that those headers MUST be understood and processed by the recipient.
      Parameters:
      headerNames - the name(s) of headers that will be marked as critical
    • setKnownCriticalHeaders

      public void setKnownCriticalHeaders(String... knownCriticalHeaders)
      Sets the values of the critical ("crit") header that are acceptable for the library to process. Basically calling this is telling the jose4j library to allow these headers marked as critical and saying that the caller knows how to process them and will do so.
      Parameters:
      knownCriticalHeaders - one or more header names that will be allowed as values of the critical header
    • checkCrit

      protected void checkCrit() throws JoseException
      Throws:
      JoseException
    • isSupportedCriticalHeader

      protected boolean isSupportedCriticalHeader(String headerName)
    • getProviderCtx

      protected ProviderContext getProviderCtx()
    • setProviderContext

      public void setProviderContext(ProviderContext providerCtx)
      Sets the ProviderContext for this JWS or JWE, which allows for a particular Java Cryptography Architecture provider to be indicated by name to be used for various cryptographic operations. A SecureRandom source of randomness can also be supplied.
      Parameters:
      providerCtx - the ProviderContext object indicating the Java Cryptography Architecture provider to be used for various cryptographic operations.
    • toString

      public String toString()
      Overrides:
      toString in class Object