Package org.webpki.jose.jws
Class JWSDecoder
java.lang.Object
org.webpki.jose.jws.JWSDecoder
JWS and JWS/CT decoder
-
Constructor Summary
ConstructorDescriptionJWSDecoder
(String jwsString) JWS compact mode signature decoder.JWSDecoder
(JSONObjectReader jwsCtObject, String signatureProperty) JWS/CT signature decoder. -
Method Summary
Modifier and TypeMethodDescriptionGet JWS header.Get JWS header.Get optional "x5c".Get optional "kid".Get optional "jwk".byte[]
Get JWS payload.Get JWS payload.Get signature algorithm.
-
Constructor Details
-
JWSDecoder
JWS compact mode signature decoder.- Parameters:
jwsString
- The actual JWS string. If there is no payload detached mode is assumed
-
JWSDecoder
JWS/CT signature decoder. Note that thejwsCtObject
remains unmodified.- Parameters:
jwsCtObject
- The signed JSON objectsignatureProperty
- Name of top-level property holding the JWS string
-
-
Method Details
-
getJWSHeaderAsJson
Get JWS header.- Returns:
- JWS header as a JSON object.
-
getJWSHeaderAsString
Get JWS header.- Returns:
- JWS header as a verbatim string copy after Base64Url-decoding.
-
getSignatureAlgorithm
Get signature algorithm. -
getOptionalPublicKey
Get optional "jwk".- Returns:
- Public key or null if there is no "jwk" property in the JWS header.
-
getOptionalCertificatePath
Get optional "x5c".- Returns:
- Certificate path or null if there is no "x5c" property in the JWS header.
-
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 theJWSDecoder
object signature have not yet beenvalidated
. For JWS/CT, the payload holds the canonicalized version of thejwsCtObject
with thesignatureProperty
removed.- Returns:
- Payload binary
-
getPayloadAsJson
Get JWS payload. Note that this method throws an exception if theJWSDecoder
object signature have not yet beenvalidated
. For JWS/CT this method return the JSON that is actually signed. That is, all but thesignatureProperty
and its JWS argument.- Returns:
- Payload as JSON
-