![]() |
Chilkat HOME Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi DLL Go Java Node.js Objective-C PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(SQL Server) Example: Crypt2.GetSignedAttributes methodDemonstrates how to call the GetSignedAttributes method.
-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls. -- CREATE PROCEDURE ChilkatSample AS BEGIN DECLARE @hr int DECLARE @iTmp0 int -- Important: Do not use nvarchar(max). See the warning about using nvarchar(max). DECLARE @sTmp0 nvarchar(4000) DECLARE @crypt int EXEC @hr = sp_OACreate 'Chilkat.Crypt2', @crypt OUT IF @hr <> 0 BEGIN PRINT 'Failed to create ActiveX component' RETURN END DECLARE @bdPkcs7 int EXEC @hr = sp_OACreate 'Chilkat.BinData', @bdPkcs7 OUT DECLARE @success int EXEC sp_OAMethod @bdPkcs7, 'LoadFile', @success OUT, 'qa_data/cades/CAdES-T/Signature-C-T-1.p7m' IF @success = 0 BEGIN EXEC sp_OAGetProperty @bdPkcs7, 'LastErrorText', @sTmp0 OUT PRINT @sTmp0 EXEC @hr = sp_OADestroy @crypt EXEC @hr = sp_OADestroy @bdPkcs7 RETURN END DECLARE @json int EXEC @hr = sp_OACreate 'Chilkat.JsonObject', @json OUT EXEC sp_OASetProperty @json, 'EmitCompact', 0 DECLARE @sbJson int EXEC @hr = sp_OACreate 'Chilkat.StringBuilder', @sbJson OUT DECLARE @i int SELECT @i = 0 DECLARE @tryNext int SELECT @tryNext = 1 WHILE @tryNext BEGIN EXEC sp_OAMethod @crypt, 'GetSignedAttributes', @iTmp0 OUT, @i, @bdPkcs7, @sbJson IF @iTmp0 = 1 BEGIN EXEC sp_OAMethod @json, 'LoadSb', @success OUT, @sbJson PRINT @i + ': ' EXEC sp_OAMethod @json, 'Emit', @sTmp0 OUT PRINT @sTmp0 END ELSE BEGIN SELECT @tryNext = 0 END SELECT @i = @i + 1 END -- Sample output: -- 0: -- { -- "signedAttributes": [ -- { -- "oid": "1.2.840.113549.1.9.3", -- "name": "Content Type" -- }, -- { -- "oid": "1.2.840.113549.1.9.5", -- "name": "Signing Time" -- }, -- { -- "oid": "1.2.840.113549.1.9.4", -- "name": "Message Digest" -- }, -- { -- "oid": "1.2.840.113549.1.9.16.2.47", -- "name": "Signing Certificate V2" -- } -- ] -- } EXEC @hr = sp_OADestroy @crypt EXEC @hr = sp_OADestroy @bdPkcs7 EXEC @hr = sp_OADestroy @json EXEC @hr = sp_OADestroy @sbJson END GO |
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.