Class JWS

java.lang.Object
eu.europa.esig.dss.jades.validation.JWS
All Implemented Interfaces:
Serializable

public class JWS extends Object implements Serializable
Extension of a JSON web Signature according to RFC 7515
See Also:
  • Field Details

    • COMPACT_SERIALIZATION_PARTS

      public static final short COMPACT_SERIALIZATION_PARTS
      See Also:
    • base64url

      protected org.jose4j.base64url.Base64Url base64url
    • headers

      protected org.jose4j.jwx.Headers headers
    • doKeyValidation

      protected boolean doKeyValidation
    • rawCompactSerialization

      protected String rawCompactSerialization
  • Constructor Details

    • JWS

      public JWS()
      The default constructor creating an empty JsonWebSignature
    • JWS

      public JWS(String[] parts)
      The constructor to instantiate a JWSCompactSerialization objects (RFC 7515)
      Parameters:
      parts - an array of String with the header, optional payload and the signature
  • Method Details

    • getEncodedHeader

      public String getEncodedHeader()
    • setPayloadOctets

      public void setPayloadOctets(byte[] payload)
      Sets payload binaries depending on the 'b64' header's value
      Parameters:
      payload - a byte array representing a payload (unencoded or encoded)
    • getSignedPayload

      public String getSignedPayload()
      Returns payload string based on a 'b64' value in the protected header (The actual signed payload value)
      Returns:
      String payload to be signed
    • isRfc7797UnencodedPayload

      public boolean isRfc7797UnencodedPayload()
      Checks if the signature's payload is 'b64' unencoded (see RFC 7797)
      Returns:
      TRUE if 'b64' is present and set to false, FALSE otherwise
    • getSignatureValue

      public byte[] getSignatureValue()
      Returns SignatureValue bytes
      Returns:
      byte array representing a signature value
    • setSignature

      public void setSignature(byte[] signature)
    • setProtected

      public void setProtected(String protectedBase64Url) throws org.jose4j.lang.JoseException
      Sets the protected header
      Parameters:
      protectedBase64Url - String base64url encoded protected header
      Throws:
      org.jose4j.lang.JoseException - if a format exception occurs
    • getUnprotected

      public Map<String,Object> getUnprotected()
      Gets unprotected header map
      Returns:
      unprotected header map
    • setUnprotected

      public void setUnprotected(Map<String,Object> unprotected)
      Sets the unprotected header
      Parameters:
      unprotected - the unprotected header map
    • getJwsJsonSerializationObject

      public JWSJsonSerializationObject getJwsJsonSerializationObject()
      Gets the JWSJsonSerializationObject
      Returns:
      JWSJsonSerializationObject
    • setJwsJsonSerializationObject

      public void setJwsJsonSerializationObject(JWSJsonSerializationObject jwsJsonSerializationObject)
      Sets the JWSJsonSerializationObject
      Parameters:
      jwsJsonSerializationObject - JWSJsonSerializationObject
    • getJwsSerializationType

      public eu.europa.esig.dss.enumerations.JWSSerializationType getJwsSerializationType()
      Gets the signature's serialization type (compact, flattened, etc.)
      Returns:
      JWSSerializationType
    • setKnownCriticalHeaders

      public void setKnownCriticalHeaders(Collection<String> knownCriticalHeaders)
      Sets values of the 'crit' header that must be known and proceeded
      Parameters:
      knownCriticalHeaders - a collection of supported String headers
    • checkCrit

      protected void checkCrit() throws org.jose4j.lang.JoseException
      Throws:
      org.jose4j.lang.JoseException
    • getProtectedHeaderValueAsString

      public String getProtectedHeaderValueAsString(String key)
      Returns a protected header value with the key
      Parameters:
      key - String
      Returns:
      String value if present, empty string otherwise
    • getProtectedHeaderValueAsNumber

      public Number getProtectedHeaderValueAsNumber(String key)
      Returns a protected header value with the key
      Parameters:
      key - String
      Returns:
      Number value if present, NULL otherwise
    • getProtectedHeaderValueAsMap

      public Map<?,?> getProtectedHeaderValueAsMap(String key)
      Returns a protected header value with the key
      Parameters:
      key - String
      Returns:
      Map value if present, empty map otherwise
    • getProtectedHeaderValueAsList

      public List<?> getProtectedHeaderValueAsList(String key)
      Returns a protected header value with the key
      Parameters:
      key - String
      Returns:
      List value if present, empty list otherwise
    • setPayload

      public void setPayload(String arg0)
    • getPayloadBytes

      public byte[] getPayloadBytes() throws org.jose4j.lang.JoseException
      Throws:
      org.jose4j.lang.JoseException
    • getUnverifiedPayloadBytes

      public byte[] getUnverifiedPayloadBytes()
    • setPayloadBytes

      public void setPayloadBytes(byte[] arg0)
    • setCompactSerializationParts

      protected void setCompactSerializationParts(String[] arg0) throws org.jose4j.lang.JoseException
      Throws:
      org.jose4j.lang.JoseException
    • getCompactSerialization

      public String getCompactSerialization() throws org.jose4j.lang.JoseException
      Throws:
      org.jose4j.lang.JoseException
    • getDetachedContentCompactSerialization

      public String getDetachedContentCompactSerialization() throws org.jose4j.lang.JoseException
      Throws:
      org.jose4j.lang.JoseException
    • prepareSigningPrimitive

      public org.jose4j.jwa.CryptoPrimitive prepareSigningPrimitive() throws org.jose4j.lang.JoseException
      Throws:
      org.jose4j.lang.JoseException
    • sign

      public void sign() throws org.jose4j.lang.JoseException
      Throws:
      org.jose4j.lang.JoseException
    • onNewKey

      protected void onNewKey()
    • verifySignature

      public boolean verifySignature() throws org.jose4j.lang.JoseException
      Throws:
      org.jose4j.lang.JoseException
    • isSupportedCriticalHeader

      protected boolean isSupportedCriticalHeader(String arg0)
    • getAlgorithm

      public org.jose4j.jws.JsonWebSignatureAlgorithm getAlgorithm() throws org.jose4j.lang.InvalidAlgorithmException
      Throws:
      org.jose4j.lang.InvalidAlgorithmException
    • getAlgorithmNoConstraintCheck

      public org.jose4j.jws.JsonWebSignatureAlgorithm getAlgorithmNoConstraintCheck() throws org.jose4j.lang.InvalidAlgorithmException
      Throws:
      org.jose4j.lang.InvalidAlgorithmException
    • getPayload

      public String getPayload() throws org.jose4j.lang.JoseException
      Throws:
      org.jose4j.lang.JoseException
    • getUnverifiedPayload

      public String getUnverifiedPayload()
    • getPayloadCharEncoding

      public String getPayloadCharEncoding()
    • setPayloadCharEncoding

      public void setPayloadCharEncoding(String arg0)
    • getKeyType

      public String getKeyType() throws org.jose4j.lang.InvalidAlgorithmException
      Throws:
      org.jose4j.lang.InvalidAlgorithmException
    • getKeyPersuasion

      public org.jose4j.keys.KeyPersuasion getKeyPersuasion() throws org.jose4j.lang.InvalidAlgorithmException
      Throws:
      org.jose4j.lang.InvalidAlgorithmException
    • setEncodedPayload

      public void setEncodedPayload(String arg0)
    • getEncodedPayload

      public String getEncodedPayload()
    • getEncodedSignature

      public String getEncodedSignature()
    • getSignature

      protected byte[] getSignature()
    • fromCompactSerialization

      public static org.jose4j.jwx.JsonWebStructure fromCompactSerialization(String arg0) throws org.jose4j.lang.JoseException
      Throws:
      org.jose4j.lang.JoseException
    • setCompactSerialization

      public void setCompactSerialization(String arg0) throws org.jose4j.lang.JoseException
      Throws:
      org.jose4j.lang.JoseException
    • getHeader

      public String getHeader()
      Deprecated.
    • setHeader

      public void setHeader(String arg0, String arg1)
    • setEncodedHeader

      protected void setEncodedHeader(String arg0) throws org.jose4j.lang.JoseException
      Throws:
      org.jose4j.lang.JoseException
    • getHeaders

      public org.jose4j.jwx.Headers getHeaders()
    • checkNotEmptyPart

      protected void checkNotEmptyPart(String arg0, String arg1) throws org.jose4j.lang.JoseException
      Throws:
      org.jose4j.lang.JoseException
    • getHeader

      public String getHeader(String arg0)
    • setHeader

      public void setHeader(String arg0, Object arg1)
    • getObjectHeader

      public Object getObjectHeader(String arg0)
    • setAlgorithmHeaderValue

      public void setAlgorithmHeaderValue(String arg0)
    • getAlgorithmHeaderValue

      public String getAlgorithmHeaderValue()
    • setContentTypeHeaderValue

      public void setContentTypeHeaderValue(String arg0)
    • getContentTypeHeaderValue

      public String getContentTypeHeaderValue()
    • setKeyIdHeaderValue

      public void setKeyIdHeaderValue(String arg0)
    • getKeyIdHeaderValue

      public String getKeyIdHeaderValue()
    • getJwkHeader

      public org.jose4j.jwk.PublicJsonWebKey getJwkHeader() throws org.jose4j.lang.JoseException
      Throws:
      org.jose4j.lang.JoseException
    • setJwkHeader

      public void setJwkHeader(org.jose4j.jwk.PublicJsonWebKey arg0)
    • getLeafCertificateHeaderValue

      public X509Certificate getLeafCertificateHeaderValue() throws org.jose4j.lang.JoseException
      Throws:
      org.jose4j.lang.JoseException
    • getCertificateChainHeaderValue

      public List<X509Certificate> getCertificateChainHeaderValue() throws org.jose4j.lang.JoseException
      Throws:
      org.jose4j.lang.JoseException
    • setCertificateChainHeaderValue

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

      public String getX509CertSha1ThumbprintHeaderValue()
    • setX509CertSha1ThumbprintHeaderValue

      public void setX509CertSha1ThumbprintHeaderValue(String arg0)
    • setX509CertSha1ThumbprintHeaderValue

      public void setX509CertSha1ThumbprintHeaderValue(X509Certificate arg0)
    • getX509CertSha256ThumbprintHeaderValue

      public String getX509CertSha256ThumbprintHeaderValue()
    • setX509CertSha256ThumbprintHeaderValue

      public void setX509CertSha256ThumbprintHeaderValue(String arg0)
    • setX509CertSha256ThumbprintHeaderValue

      public void setX509CertSha256ThumbprintHeaderValue(X509Certificate arg0)
    • getKey

      public Key getKey()
    • setKey

      public void setKey(Key arg0)
    • getIntegrity

      protected byte[] getIntegrity()
    • setIntegrity

      protected void setIntegrity(byte[] arg0)
    • isDoKeyValidation

      public boolean isDoKeyValidation()
    • setDoKeyValidation

      public void setDoKeyValidation(boolean arg0)
    • getAlgorithmConstraints

      protected org.jose4j.jwa.AlgorithmConstraints getAlgorithmConstraints()
    • setAlgorithmConstraints

      public void setAlgorithmConstraints(org.jose4j.jwa.AlgorithmConstraints arg0)
    • setCriticalHeaderNames

      public void setCriticalHeaderNames(String... arg0)
    • setKnownCriticalHeaders

      public void setKnownCriticalHeaders(String... arg0)
    • getProviderCtx

      protected org.jose4j.jca.ProviderContext getProviderCtx()
    • setProviderContext

      public void setProviderContext(org.jose4j.jca.ProviderContext arg0)
    • toString

      public String toString()
      Overrides:
      toString in class Object