JWS Class

Contains methods that apply a digital signature to a JSON Web Token (JWT), using a JSON Web Signature (JWS) data structure. This class creates the signed JWT bearer token, which can be used to request an OAuth access token in the OAuth 2.0 JWT bearer token flow.

Namespace

Auth

Usage

Use the methods in this class to sign the JWT bearer token with the X509 certificate.

JWS Constructors

The following are constructors for JWS.

JWS(jwt, certDevName)

Creates an instance of the JWS class using the specified Auth.JWT payload and the certificate used for signing the JWT bearer token.

Signature

public JWS(Auth.JWT jwt, String certDevName)

Parameters

jwt
Type: Auth.JWT
The Base64-encoded JSON Claims Set in the JWT bearer token generated by Auth.JWT.
certDevName
Type: String
The Unique Name for a certificate stored in the Salesforce org’s Certificate and Key Management page to use for signing the JWT bearer token.

Usage

Calls the toJSONString() method in Auth.JWT and sets the resulting string as the payload of the JWT bearer token. Alternatively, you can specify the payload directly using JWS(payload, certDevName).

JWS(payload, certDevName)

Creates an instance of the JWS class using the specified payload and certificate used for signing the JWT bearer token.

Signature

public JWS(String payload, String certDevName)

Parameters

payload
Type: String
The Base64-encoded JSON Claims Set in the JWT bearer token.
certDevName
Type: String
The Unique Name for a certificate stored in the Salesforce org’s Certificate and Key Management page to use for signing the JWT bearer token.

Usage

Sets the payload string as the payload of the JWT bearer token. Alternatively, if you generate the payload using Auth.JWT, you can use JWS(jwt, certDevName) instead.

JWS Methods

The following are methods for JWS. All are instance methods.

clone()

Makes a duplicate copy of the JWS object.

Signature

public Object clone()

Return Value

Type: JWS

getCompactSerialization()

Returns the compact serialization representation of the JWS as a concatenated string, with the encoded JWS header, encoded JWS payload, and encoded JWS signature strings separated by period ('.') characters.

Signature

public String getCompactSerialization()

Return Value

Type: String