Class JWSDecoder

java.lang.Object
org.webpki.jose.jws.JWSDecoder

public class JWSDecoder extends Object
JWS and JWS/CT decoder
  • Constructor Details

    • JWSDecoder

      public JWSDecoder(String jwsString)
      JWS compact mode signature decoder.
      Parameters:
      jwsString - The actual JWS string. If there is no payload detached mode is assumed
    • JWSDecoder

      public JWSDecoder(JSONObjectReader jwsCtObject, String signatureProperty)
      JWS/CT signature decoder. Note that the jwsCtObject remains unmodified.
      Parameters:
      jwsCtObject - The signed JSON object
      signatureProperty - Name of top-level property holding the JWS string
  • Method Details

    • getJWSHeaderAsJson

      public JSONObjectReader getJWSHeaderAsJson()
      Get JWS header.
      Returns:
      JWS header as a JSON object.
    • getJWSHeaderAsString

      public String getJWSHeaderAsString()
      Get JWS header.
      Returns:
      JWS header as a verbatim string copy after Base64Url-decoding.
    • getSignatureAlgorithm

      public SignatureAlgorithms getSignatureAlgorithm()
      Get signature algorithm.
    • getOptionalPublicKey

      public PublicKey getOptionalPublicKey()
      Get optional "jwk".
      Returns:
      Public key or null if there is no "jwk" property in the JWS header.
    • getOptionalCertificatePath

      public X509Certificate[] getOptionalCertificatePath()
      Get optional "x5c".
      Returns:
      Certificate path or null if there is no "x5c" property in the JWS header.
    • getOptionalKeyId

      public String getOptionalKeyId()
      Get optional "kid".
      Returns:
      Key identifier or null if there is no "kid" property in the JWS header.
    • getPayload

      public byte[] getPayload()
      Get JWS payload. Note that this method throws an exception if the JWSDecoder object signature have not yet been validated. For JWS/CT, the payload holds the canonicalized version of the jwsCtObject with the signatureProperty removed.
      Returns:
      Payload binary
    • getPayloadAsJson

      public JSONObjectReader getPayloadAsJson()
      Get JWS payload. Note that this method throws an exception if the JWSDecoder object signature have not yet been validated. For JWS/CT this method return the JSON that is actually signed. That is, all but the signatureProperty and its JWS argument.
      Returns:
      Payload as JSON