java.lang.Object
org.jose4j.jwx.JsonWebStructure
org.jose4j.jws.JsonWebSignature
eu.europa.esig.dss.jades.validation.JWS
All Implemented Interfaces:
Serializable

public class JWS extends org.jose4j.jws.JsonWebSignature implements Serializable
Extension of a JSON web Signature according to RFC 7515
See Also:
  • Field Summary

    Fields inherited from class org.jose4j.jws.JsonWebSignature

    COMPACT_SERIALIZATION_PARTS

    Fields inherited from class org.jose4j.jwx.JsonWebStructure

    base64url, doKeyValidation, headers, rawCompactSerialization
  • Constructor Summary

    Constructors
    Constructor
    Description
    JWS()
    The default constructor creating an empty JsonWebSignature
    JWS(String[] parts)
    The constructor to instantiate a JWSCompactSerialization objects (RFC 7515)
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
     
     
    Gets the JWSJsonSerializationObject
    List<?>
    Returns a protected header value with the key
    Map<?,?>
    Returns a protected header value with the key
    Returns a protected header value with the key
    byte[]
    Returns SignatureValue bytes
    Returns payload string based on a 'b64' value in the protected header (The actual signed payload value)
    Gets unprotected header map
    boolean
    Checks if the signature's payload is 'b64' unencoded (see RFC 7797)
    void
    Sets the JWSJsonSerializationObject
    void
    setKnownCriticalHeaders(Collection<String> knownCriticalHeaders)
    Sets values of the 'crit' header that must be known and proceeded
    void
    setPayloadOctets(byte[] payload)
    Sets payload binaries depending on the 'b64' header's value
    void
    setProtected(String protectedBase64Url)
    Sets the protected header
    void
    setSignature(byte[] signature)
     
    void
    Sets the unprotected header

    Methods inherited from class org.jose4j.jws.JsonWebSignature

    getAlgorithm, getAlgorithmNoConstraintCheck, getCompactSerialization, getDetachedContentCompactSerialization, getEncodedPayload, getEncodedSignature, getKeyPersuasion, getKeyType, getPayload, getPayloadBytes, getPayloadCharEncoding, getSignature, getUnverifiedPayload, getUnverifiedPayloadBytes, isSupportedCriticalHeader, onNewKey, prepareSigningPrimitive, setCompactSerializationParts, setEncodedPayload, setPayload, setPayloadBytes, setPayloadCharEncoding, sign, verifySignature

    Methods inherited from class org.jose4j.jwx.JsonWebStructure

    checkNotEmptyPart, fromCompactSerialization, getAlgorithmConstraints, getAlgorithmHeaderValue, getCertificateChainHeaderValue, getContentTypeHeaderValue, getHeader, getHeader, getHeaders, getIntegrity, getJwkHeader, getKey, getKeyIdHeaderValue, getLeafCertificateHeaderValue, getObjectHeader, getProviderCtx, getX509CertSha1ThumbprintHeaderValue, getX509CertSha256ThumbprintHeaderValue, isDoKeyValidation, setAlgorithmConstraints, setAlgorithmHeaderValue, setCertificateChainHeaderValue, setCompactSerialization, setContentTypeHeaderValue, setCriticalHeaderNames, setDoKeyValidation, setEncodedHeader, setHeader, setHeader, setIntegrity, setJwkHeader, setKey, setKeyIdHeaderValue, setKnownCriticalHeaders, setProviderContext, setX509CertSha1ThumbprintHeaderValue, setX509CertSha1ThumbprintHeaderValue, setX509CertSha256ThumbprintHeaderValue, setX509CertSha256ThumbprintHeaderValue, toString

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • 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()
      Overrides:
      getEncodedHeader in class org.jose4j.jwx.JsonWebStructure
    • 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)
      Overrides:
      isRfc7797UnencodedPayload in class org.jose4j.jws.JsonWebSignature
      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)
      Overrides:
      setSignature in class org.jose4j.jws.JsonWebSignature
    • 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
    • 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
      Overrides:
      checkCrit in class org.jose4j.jwx.JsonWebStructure
      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
    • 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