dw.crypto
Class JWS
Object
dw.crypto.JWS
This class represents a JSON Web Signature (JWS) object.
Properties
algorithm :  String  (Read Only)
Get the algorithm (alg) from the header.
header  :  JWSHeader  (Read Only)
Get a copy of the JWS header.
headerMap  :  Map  (Read Only)
Get a copy of the JWS header as a Map.
payload  :  String  (Read Only)
Get the payload from this object.

This is available even if the signature has not been verified.

Constructor Summary
JWS(header : JWSHeader, payload : String)
Construct a new JWS for signing.
JWS(header : JWSHeader, payload : Bytes)
Construct a new JWS for signing.
Method Summary
getAlgorithm() : String
Get the algorithm (alg) from the header.
getHeader() : JWSHeader
Get a copy of the JWS header.
getHeaderMap() : Map
Get a copy of the JWS header as a Map.
getPayload() : String
Get the payload from this object.
static parse(jws : String) : JWS
Parse a JSON Web Signature (JWS) object from its compact serialization format.
static parse(jws : String, payload : String) : JWS
Parse a JSON Web Signature (JWS) object from its compact serialization format.
static parse(jws : String, payload : Bytes) : JWS
Parse a JSON Web Signature (JWS) object from its compact serialization format.
serialize(detachPayload : boolean) : String
Get this JWS in compact serialization form.
sign(keyRef : KeyRef) : void
Sign the payload using the given private key.
verify(certificateRef : CertificateRef) : boolean
Verifies the signature of the payload.
Salesforce Commerce Cloud Courses
Salesforce B2C Commerce Developer - Certification Tests
Why risk failing the SFCC exam? Get 180 real questions, killer content, and everything you need to crush the Salesforce B2C Commerce Developer certification.

Becoming a Salesforce B2C Commerce Developer is your ticket to higher salaries, better job opportunities, and the credibility to stand out from the competition. But let's be honestβ€”passing the certification exam isn't easy. That's where we come in.
Salesforce Javascript Developer I - Certification Tests
Not just another prep courseβ€”this is your shortcut to passing. Master JavaScript for Salesforce and go from 'hoping to pass' to knowing you will. Ready to start?

This isn't just another prep courseβ€”it's your shortcut to mastering the skills and confidence you need to pass. With multiple practice tests covering every section and a final exam simulation designed to mirror the real thing, you'll feel like you've already aced it before test day.
Salesforce B2C Commerce Architect - Certification Tests
Think the Developer exam was hard? Welcome to the next level.

The Salesforce B2C Commerce Architect certification is a whole different gameβ€”complex solutions, elevated difficulty, and skills that set you apart in the eCommerce industry. That's why we're including 11 downloadable PDF guides, packed with best practices and strategies to help you prepare for the exam and build confidence in every topic.
Constructor Detail
JWS
public JWS(header : JWSHeader, payload : String)
Construct a new JWS for signing.
Parameters:
header - JWS header. This must include a valid algorithm (alg). See verify(CertificateRef) for a list of supported algorithms.
payload - Content that will be signed.

JWS
public JWS(header : JWSHeader, payload : Bytes)
Construct a new JWS for signing.
Parameters:
header - JWS header. This must include a valid algorithm (alg). See verify(CertificateRef) for a list of supported algorithms.
payload - Content that will be signed.

Method Detail
getAlgorithm
getAlgorithm() : String
Get the algorithm (alg) from the header.
Returns:
Value of the algorithm or null if missing.

getHeader
getHeader() : JWSHeader
Get a copy of the JWS header.
Returns:
Copy of the JWS header.

getHeaderMap
getHeaderMap() : Map
Get a copy of the JWS header as a Map.
Returns:
Copy of the JWS header.

getPayload
getPayload() : String
Get the payload from this object.

This is available even if the signature has not been verified.

Returns:
UTF-8 encoded payload.

parse
static parse(jws : String) : JWS
Parse a JSON Web Signature (JWS) object from its compact serialization format.
Parameters:
jws - JWS in compact serialization format.
Returns:
JWS object.

parse
static parse(jws : String, payload : String) : JWS
Parse a JSON Web Signature (JWS) object from its compact serialization format.
Parameters:
jws - JWS without a payload in compact serialization format.
payload - Detached payload
Returns:
JWS object.

parse
static parse(jws : String, payload : Bytes) : JWS
Parse a JSON Web Signature (JWS) object from its compact serialization format.
Parameters:
jws - JWS without a payload in compact serialization format.
payload - Detached payload
Returns:
JWS object.

serialize
serialize(detachPayload : boolean) : String
Get this JWS in compact serialization form.
Parameters:
detachPayload - true for a detached payload compliant with RFC-7797, or false to serialize the payload too.
Returns:
Compact serialized object.

sign
sign(keyRef : KeyRef) : void
Sign the payload using the given private key.

The key type and size must match the algorithm given in the JWS header.

Parameters:
keyRef - Reference to the private key.
Throws:
Exception - if there is an error while signing the payload.

verify
verify(certificateRef : CertificateRef) : boolean
Verifies the signature of the payload.

If the x5c header parameter is present, then that certificate chain will be used to verify the signature and the given certificateRef must be its root certificate. If this parameter is not present then the given certificateRef will be used to directly verify the signature.

The following algorithms are supported:

  • ES256
  • ES256K
  • ES384
  • ES512
  • RS256
  • RS384
  • RS512
  • PS256
  • PS384
  • PS512
Parameters:
certificateRef - Reference to the certificate to use for verification.
Returns:
a boolean indicating success (true) or failure (false).
Throws:
Exception - if there is an error while processing the certificate (for example if the x5c is not signed by the given certificate) or the algorithm is unsupported.

β™₯
Notifications pending to read