SQL Server
SQL Server
Set the JWS Payload from a StringBuilder
See more JSON Web Signatures (JWS) Examples
Demonstrates Jws.SetPayloadSb, which sets the payload to be signed from a StringBuilder.
Background. JWS (JSON Web Signature) integrity-protects a payload with a signature or MAC. The header
alg names the algorithm; this example uses HMAC-SHA256 (HS256) with a symmetric MAC key.Chilkat SQL Server Downloads
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
DECLARE @hr int
DECLARE @sTmp0 nvarchar(4000)
DECLARE @success int
SELECT @success = 0
DECLARE @jws int
EXEC @hr = sp_OACreate 'Chilkat.Jws', @jws OUT
IF @hr <> 0
BEGIN
PRINT 'Failed to create ActiveX component'
RETURN
END
-- Set the payload from a StringBuilder.
DECLARE @sbPayload int
EXEC @hr = sp_OACreate 'Chilkat.StringBuilder', @sbPayload OUT
EXEC sp_OAMethod @sbPayload, 'Append', @success OUT, 'This is the content to sign.'
DECLARE @bIncludeBom int
SELECT @bIncludeBom = 0
EXEC sp_OAMethod @jws, 'SetPayloadSb', @success OUT, @sbPayload, 'utf-8', @bIncludeBom
IF @success = 0
BEGIN
EXEC sp_OAGetProperty @jws, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @jws
EXEC @hr = sp_OADestroy @sbPayload
RETURN
END
PRINT 'Payload set.'
EXEC @hr = sp_OADestroy @jws
EXEC @hr = sp_OADestroy @sbPayload
END
GO