unit Chilkat.Jws;

{
  Pascal wrapper for Chilkat Jws.
  Auto-generated by PascalWrapperGenerator -- do not edit manually.
}

{$IFDEF FPC}
  {$MODE DELPHI}
{$ENDIF}

interface

uses
  SysUtils,
  Chilkat.Base;

type

  { TJws wraps CkJws via the C bridge layer. }
  TJws = class(TChilkatBase)
  private
    function  GetLastErrorHtml: string;
    function  GetLastErrorText: string;
    function  GetLastErrorXml: string;
    function  GetVersion: string;
    function  GetDebugLogFilePath: string;
    procedure SetDebugLogFilePath(AValue: string);
    function  GetVerboseLogging: Boolean;
    procedure SetVerboseLogging(AValue: Boolean);
    function  GetLastMethodSuccess: Boolean;
    procedure SetLastMethodSuccess(AValue: Boolean);
    function  GetNumSignatures: Integer;
    function  GetPreferCompact: Boolean;
    procedure SetPreferCompact(AValue: Boolean);
    function  GetPreferFlattened: Boolean;
    procedure SetPreferFlattened(AValue: Boolean);
    function  GetUncommonOptions: string;
    procedure SetUncommonOptions(AValue: string);
  public
    constructor Create;
    destructor  Destroy; override;

    property LastErrorHtml: string read GetLastErrorHtml;
    property LastErrorText: string read GetLastErrorText;
    property LastErrorXml: string read GetLastErrorXml;
    property Version: string read GetVersion;
    property DebugLogFilePath: string read GetDebugLogFilePath write SetDebugLogFilePath;
    property VerboseLogging: Boolean read GetVerboseLogging write SetVerboseLogging;
    property LastMethodSuccess: Boolean read GetLastMethodSuccess write SetLastMethodSuccess;
    property NumSignatures: Integer read GetNumSignatures;
    property PreferCompact: Boolean read GetPreferCompact write SetPreferCompact;
    property PreferFlattened: Boolean read GetPreferFlattened write SetPreferFlattened;
    property UncommonOptions: string read GetUncommonOptions write SetUncommonOptions;

    function  SetProtectedHeader(index: Integer; json: TChilkatBase): Boolean;
    function  SetUnprotectedHeader(index: Integer; json: TChilkatBase): Boolean;
    function  CreateJws: string;
    function  CreateJwsSb(sbJws: TChilkatBase): Boolean;
    function  SetPayloadSb(sbPayload: TChilkatBase; const charset: string; includeBom: Boolean): Boolean;
    function  SetPayloadBd(binData: TChilkatBase): Boolean;
    function  GetPayloadSb(const charset: string; sbPayload: TChilkatBase): Boolean;
    function  GetPayloadBd(binData: TChilkatBase): Boolean;
    function  LoadJwsSb(sbJws: TChilkatBase): Boolean;
    function  LoadJws(const jwsStr: string): Boolean;
    function  SetMacKey(index: Integer; const key: string; const encoding: string): Boolean;
    function  SetMacKeyBd(index: Integer; key: TChilkatBase): Boolean;
    function  SetPrivateKey(index: Integer; privKey: TChilkatBase): Boolean;
    function  SetPublicKey(index: Integer; pubKey: TChilkatBase): Boolean;
    function  Validate(index: Integer): Integer;
    function  SetPayload(const payload: string; const charset: string; includeBom: Boolean): Boolean;
    function  GetPayload(const charset: string): string;
    function  GetProtectedH(index: Integer; json: TChilkatBase): Boolean;
    function  GetUnprotectedH(index: Integer; json: TChilkatBase): Boolean;
    function  SetSigningCert(index: Integer; cert: TChilkatBase): Boolean;
  end;

implementation

uses
  CkDllLoader,
  Chilkat.Utils;

{ ---- C bridge function pointer types ---- }
type
  TCkJws_Create  = function(): Pointer; cdecl;
  TCkJws_Dispose = procedure(handle: Pointer); cdecl;
  TCkJws_get_LastErrorHtml = function(handle: Pointer): PAnsiChar; cdecl;
  TCkJws_get_LastErrorText = function(handle: Pointer): PAnsiChar; cdecl;
  TCkJws_get_LastErrorXml = function(handle: Pointer): PAnsiChar; cdecl;
  TCkJws_get_Version = function(handle: Pointer): PAnsiChar; cdecl;
  TCkJws_get_DebugLogFilePath = function(handle: Pointer): PAnsiChar; cdecl;
  TCkJws_put_DebugLogFilePath = procedure(handle: Pointer; value: PAnsiChar); cdecl;
  TCkJws_get_VerboseLogging = function(handle: Pointer): LongBool; cdecl;
  TCkJws_put_VerboseLogging = procedure(handle: Pointer; value: LongBool); cdecl;
  TCkJws_get_LastMethodSuccess = function(handle: Pointer): LongBool; cdecl;
  TCkJws_put_LastMethodSuccess = procedure(handle: Pointer; value: LongBool); cdecl;
  TCkJws_get_NumSignatures = function(handle: Pointer): Integer; cdecl;
  TCkJws_get_PreferCompact = function(handle: Pointer): LongBool; cdecl;
  TCkJws_put_PreferCompact = procedure(handle: Pointer; value: LongBool); cdecl;
  TCkJws_get_PreferFlattened = function(handle: Pointer): LongBool; cdecl;
  TCkJws_put_PreferFlattened = procedure(handle: Pointer; value: LongBool); cdecl;
  TCkJws_get_UncommonOptions = function(handle: Pointer): PAnsiChar; cdecl;
  TCkJws_put_UncommonOptions = procedure(handle: Pointer; value: PAnsiChar); cdecl;
  TCkJws_SetProtectedHeader = function(handle: Pointer; index: Integer; json: Pointer): LongBool; cdecl;
  TCkJws_SetUnprotectedHeader = function(handle: Pointer; index: Integer; json: Pointer): LongBool; cdecl;
  TCkJws_CreateJws = function(handle: Pointer): PAnsiChar; cdecl;
  TCkJws_CreateJwsSb = function(handle: Pointer; sbJws: Pointer): LongBool; cdecl;
  TCkJws_SetPayloadSb = function(handle: Pointer; sbPayload: Pointer; charset: PAnsiChar; includeBom: LongBool): LongBool; cdecl;
  TCkJws_SetPayloadBd = function(handle: Pointer; binData: Pointer): LongBool; cdecl;
  TCkJws_GetPayloadSb = function(handle: Pointer; charset: PAnsiChar; sbPayload: Pointer): LongBool; cdecl;
  TCkJws_GetPayloadBd = function(handle: Pointer; binData: Pointer): LongBool; cdecl;
  TCkJws_LoadJwsSb = function(handle: Pointer; sbJws: Pointer): LongBool; cdecl;
  TCkJws_LoadJws = function(handle: Pointer; jwsStr: PAnsiChar): LongBool; cdecl;
  TCkJws_SetMacKey = function(handle: Pointer; index: Integer; key: PAnsiChar; encoding: PAnsiChar): LongBool; cdecl;
  TCkJws_SetMacKeyBd = function(handle: Pointer; index: Integer; key: Pointer): LongBool; cdecl;
  TCkJws_SetPrivateKey = function(handle: Pointer; index: Integer; privKey: Pointer): LongBool; cdecl;
  TCkJws_SetPublicKey = function(handle: Pointer; index: Integer; pubKey: Pointer): LongBool; cdecl;
  TCkJws_Validate = function(handle: Pointer; index: Integer): Integer; cdecl;
  TCkJws_SetPayload = function(handle: Pointer; payload: PAnsiChar; charset: PAnsiChar; includeBom: LongBool): LongBool; cdecl;
  TCkJws_GetPayload = function(handle: Pointer; charset: PAnsiChar): PAnsiChar; cdecl;
  TCkJws_GetProtectedH = function(handle: Pointer; index: Integer; json: Pointer): LongBool; cdecl;
  TCkJws_GetUnprotectedH = function(handle: Pointer; index: Integer; json: Pointer): LongBool; cdecl;
  TCkJws_SetSigningCert = function(handle: Pointer; index: Integer; cert: Pointer): LongBool; cdecl;

{ ---- C bridge function pointer variables ---- }
var
  CkJws_Create:  TCkJws_Create  = nil;
  CkJws_Dispose: TCkJws_Dispose = nil;
  CkJws_get_LastErrorHtml: TCkJws_get_LastErrorHtml = nil;
  CkJws_get_LastErrorText: TCkJws_get_LastErrorText = nil;
  CkJws_get_LastErrorXml: TCkJws_get_LastErrorXml = nil;
  CkJws_get_Version: TCkJws_get_Version = nil;
  CkJws_get_DebugLogFilePath: TCkJws_get_DebugLogFilePath = nil;
  CkJws_put_DebugLogFilePath: TCkJws_put_DebugLogFilePath = nil;
  CkJws_get_VerboseLogging: TCkJws_get_VerboseLogging = nil;
  CkJws_put_VerboseLogging: TCkJws_put_VerboseLogging = nil;
  CkJws_get_LastMethodSuccess: TCkJws_get_LastMethodSuccess = nil;
  CkJws_put_LastMethodSuccess: TCkJws_put_LastMethodSuccess = nil;
  CkJws_get_NumSignatures: TCkJws_get_NumSignatures = nil;
  CkJws_get_PreferCompact: TCkJws_get_PreferCompact = nil;
  CkJws_put_PreferCompact: TCkJws_put_PreferCompact = nil;
  CkJws_get_PreferFlattened: TCkJws_get_PreferFlattened = nil;
  CkJws_put_PreferFlattened: TCkJws_put_PreferFlattened = nil;
  CkJws_get_UncommonOptions: TCkJws_get_UncommonOptions = nil;
  CkJws_put_UncommonOptions: TCkJws_put_UncommonOptions = nil;
  CkJws_SetProtectedHeader: TCkJws_SetProtectedHeader = nil;
  CkJws_SetUnprotectedHeader: TCkJws_SetUnprotectedHeader = nil;
  CkJws_CreateJws: TCkJws_CreateJws = nil;
  CkJws_CreateJwsSb: TCkJws_CreateJwsSb = nil;
  CkJws_SetPayloadSb: TCkJws_SetPayloadSb = nil;
  CkJws_SetPayloadBd: TCkJws_SetPayloadBd = nil;
  CkJws_GetPayloadSb: TCkJws_GetPayloadSb = nil;
  CkJws_GetPayloadBd: TCkJws_GetPayloadBd = nil;
  CkJws_LoadJwsSb: TCkJws_LoadJwsSb = nil;
  CkJws_LoadJws: TCkJws_LoadJws = nil;
  CkJws_SetMacKey: TCkJws_SetMacKey = nil;
  CkJws_SetMacKeyBd: TCkJws_SetMacKeyBd = nil;
  CkJws_SetPrivateKey: TCkJws_SetPrivateKey = nil;
  CkJws_SetPublicKey: TCkJws_SetPublicKey = nil;
  CkJws_Validate: TCkJws_Validate = nil;
  CkJws_SetPayload: TCkJws_SetPayload = nil;
  CkJws_GetPayload: TCkJws_GetPayload = nil;
  CkJws_GetProtectedH: TCkJws_GetProtectedH = nil;
  CkJws_GetUnprotectedH: TCkJws_GetUnprotectedH = nil;
  CkJws_SetSigningCert: TCkJws_SetSigningCert = nil;

constructor TJws.Create;
begin
  inherited Create;
  FHandle := CkJws_Create();
end;

destructor TJws.Destroy;
begin
  if FHandle <> nil then
    CkJws_Dispose(FHandle);
  FHandle := nil;
  inherited;
end;

function TJws.GetLastErrorHtml: string;
begin
  Result := CkToStr(CkJws_get_LastErrorHtml(FHandle));
end;

function TJws.GetLastErrorText: string;
begin
  Result := CkToStr(CkJws_get_LastErrorText(FHandle));
end;

function TJws.GetLastErrorXml: string;
begin
  Result := CkToStr(CkJws_get_LastErrorXml(FHandle));
end;

function TJws.GetVersion: string;
begin
  Result := CkToStr(CkJws_get_Version(FHandle));
end;

function TJws.GetDebugLogFilePath: string;
begin
  Result := CkToStr(CkJws_get_DebugLogFilePath(FHandle));
end;

procedure TJws.SetDebugLogFilePath(AValue: string);
begin
  CkJws_put_DebugLogFilePath(FHandle, PAnsiChar(StrToCk(AValue)));
end;

function TJws.GetVerboseLogging: Boolean;
begin
  Result := Boolean(CkJws_get_VerboseLogging(FHandle));
end;

procedure TJws.SetVerboseLogging(AValue: Boolean);
begin
  CkJws_put_VerboseLogging(FHandle, LongBool(AValue));
end;

function TJws.GetLastMethodSuccess: Boolean;
begin
  Result := Boolean(CkJws_get_LastMethodSuccess(FHandle));
end;

procedure TJws.SetLastMethodSuccess(AValue: Boolean);
begin
  CkJws_put_LastMethodSuccess(FHandle, LongBool(AValue));
end;

function TJws.GetNumSignatures: Integer;
begin
  Result := CkJws_get_NumSignatures(FHandle);
end;

function TJws.GetPreferCompact: Boolean;
begin
  Result := Boolean(CkJws_get_PreferCompact(FHandle));
end;

procedure TJws.SetPreferCompact(AValue: Boolean);
begin
  CkJws_put_PreferCompact(FHandle, LongBool(AValue));
end;

function TJws.GetPreferFlattened: Boolean;
begin
  Result := Boolean(CkJws_get_PreferFlattened(FHandle));
end;

procedure TJws.SetPreferFlattened(AValue: Boolean);
begin
  CkJws_put_PreferFlattened(FHandle, LongBool(AValue));
end;

function TJws.GetUncommonOptions: string;
begin
  Result := CkToStr(CkJws_get_UncommonOptions(FHandle));
end;

procedure TJws.SetUncommonOptions(AValue: string);
begin
  CkJws_put_UncommonOptions(FHandle, PAnsiChar(StrToCk(AValue)));
end;

function TJws.SetProtectedHeader(index: Integer; json: TChilkatBase): Boolean;
begin
  Result := Boolean(CkJws_SetProtectedHeader(FHandle, index, json.Handle));
end;

function TJws.SetUnprotectedHeader(index: Integer; json: TChilkatBase): Boolean;
begin
  Result := Boolean(CkJws_SetUnprotectedHeader(FHandle, index, json.Handle));
end;

function TJws.CreateJws: string;
begin
  Result := CkToStr(CkJws_CreateJws(FHandle));
end;

function TJws.CreateJwsSb(sbJws: TChilkatBase): Boolean;
begin
  Result := Boolean(CkJws_CreateJwsSb(FHandle, sbJws.Handle));
end;

function TJws.SetPayloadSb(sbPayload: TChilkatBase; const charset: string; includeBom: Boolean): Boolean;
begin
  Result := Boolean(CkJws_SetPayloadSb(FHandle, sbPayload.Handle, PAnsiChar(StrToCk(charset)), LongBool(includeBom)));
end;

function TJws.SetPayloadBd(binData: TChilkatBase): Boolean;
begin
  Result := Boolean(CkJws_SetPayloadBd(FHandle, binData.Handle));
end;

function TJws.GetPayloadSb(const charset: string; sbPayload: TChilkatBase): Boolean;
begin
  Result := Boolean(CkJws_GetPayloadSb(FHandle, PAnsiChar(StrToCk(charset)), sbPayload.Handle));
end;

function TJws.GetPayloadBd(binData: TChilkatBase): Boolean;
begin
  Result := Boolean(CkJws_GetPayloadBd(FHandle, binData.Handle));
end;

function TJws.LoadJwsSb(sbJws: TChilkatBase): Boolean;
begin
  Result := Boolean(CkJws_LoadJwsSb(FHandle, sbJws.Handle));
end;

function TJws.LoadJws(const jwsStr: string): Boolean;
begin
  Result := Boolean(CkJws_LoadJws(FHandle, PAnsiChar(StrToCk(jwsStr))));
end;

function TJws.SetMacKey(index: Integer; const key: string; const encoding: string): Boolean;
begin
  Result := Boolean(CkJws_SetMacKey(FHandle, index, PAnsiChar(StrToCk(key)), PAnsiChar(StrToCk(encoding))));
end;

function TJws.SetMacKeyBd(index: Integer; key: TChilkatBase): Boolean;
begin
  Result := Boolean(CkJws_SetMacKeyBd(FHandle, index, key.Handle));
end;

function TJws.SetPrivateKey(index: Integer; privKey: TChilkatBase): Boolean;
begin
  Result := Boolean(CkJws_SetPrivateKey(FHandle, index, privKey.Handle));
end;

function TJws.SetPublicKey(index: Integer; pubKey: TChilkatBase): Boolean;
begin
  Result := Boolean(CkJws_SetPublicKey(FHandle, index, pubKey.Handle));
end;

function TJws.Validate(index: Integer): Integer;
begin
  Result := CkJws_Validate(FHandle, index);
end;

function TJws.SetPayload(const payload: string; const charset: string; includeBom: Boolean): Boolean;
begin
  Result := Boolean(CkJws_SetPayload(FHandle, PAnsiChar(StrToCk(payload)), PAnsiChar(StrToCk(charset)), LongBool(includeBom)));
end;

function TJws.GetPayload(const charset: string): string;
begin
  Result := CkToStr(CkJws_GetPayload(FHandle, PAnsiChar(StrToCk(charset))));
end;

function TJws.GetProtectedH(index: Integer; json: TChilkatBase): Boolean;
begin
  Result := Boolean(CkJws_GetProtectedH(FHandle, index, json.Handle));
end;

function TJws.GetUnprotectedH(index: Integer; json: TChilkatBase): Boolean;
begin
  Result := Boolean(CkJws_GetUnprotectedH(FHandle, index, json.Handle));
end;

function TJws.SetSigningCert(index: Integer; cert: TChilkatBase): Boolean;
begin
  Result := Boolean(CkJws_SetSigningCert(FHandle, index, cert.Handle));
end;

initialization
  Chilkat_GetProcedureAddress(CkJws_Create,  'CkJws_Create');
  Chilkat_GetProcedureAddress(CkJws_Dispose, 'CkJws_Dispose');
  Chilkat_GetProcedureAddress(CkJws_get_LastErrorHtml, 'CkJws_get_LastErrorHtml');
  Chilkat_GetProcedureAddress(CkJws_get_LastErrorText, 'CkJws_get_LastErrorText');
  Chilkat_GetProcedureAddress(CkJws_get_LastErrorXml, 'CkJws_get_LastErrorXml');
  Chilkat_GetProcedureAddress(CkJws_get_Version, 'CkJws_get_Version');
  Chilkat_GetProcedureAddress(CkJws_get_DebugLogFilePath, 'CkJws_get_DebugLogFilePath');
  Chilkat_GetProcedureAddress(CkJws_put_DebugLogFilePath, 'CkJws_put_DebugLogFilePath');
  Chilkat_GetProcedureAddress(CkJws_get_VerboseLogging, 'CkJws_get_VerboseLogging');
  Chilkat_GetProcedureAddress(CkJws_put_VerboseLogging, 'CkJws_put_VerboseLogging');
  Chilkat_GetProcedureAddress(CkJws_get_LastMethodSuccess, 'CkJws_get_LastMethodSuccess');
  Chilkat_GetProcedureAddress(CkJws_put_LastMethodSuccess, 'CkJws_put_LastMethodSuccess');
  Chilkat_GetProcedureAddress(CkJws_get_NumSignatures, 'CkJws_get_NumSignatures');
  Chilkat_GetProcedureAddress(CkJws_get_PreferCompact, 'CkJws_get_PreferCompact');
  Chilkat_GetProcedureAddress(CkJws_put_PreferCompact, 'CkJws_put_PreferCompact');
  Chilkat_GetProcedureAddress(CkJws_get_PreferFlattened, 'CkJws_get_PreferFlattened');
  Chilkat_GetProcedureAddress(CkJws_put_PreferFlattened, 'CkJws_put_PreferFlattened');
  Chilkat_GetProcedureAddress(CkJws_get_UncommonOptions, 'CkJws_get_UncommonOptions');
  Chilkat_GetProcedureAddress(CkJws_put_UncommonOptions, 'CkJws_put_UncommonOptions');
  Chilkat_GetProcedureAddress(CkJws_SetProtectedHeader, 'CkJws_SetProtectedHeader');
  Chilkat_GetProcedureAddress(CkJws_SetUnprotectedHeader, 'CkJws_SetUnprotectedHeader');
  Chilkat_GetProcedureAddress(CkJws_CreateJws, 'CkJws_CreateJws');
  Chilkat_GetProcedureAddress(CkJws_CreateJwsSb, 'CkJws_CreateJwsSb');
  Chilkat_GetProcedureAddress(CkJws_SetPayloadSb, 'CkJws_SetPayloadSb');
  Chilkat_GetProcedureAddress(CkJws_SetPayloadBd, 'CkJws_SetPayloadBd');
  Chilkat_GetProcedureAddress(CkJws_GetPayloadSb, 'CkJws_GetPayloadSb');
  Chilkat_GetProcedureAddress(CkJws_GetPayloadBd, 'CkJws_GetPayloadBd');
  Chilkat_GetProcedureAddress(CkJws_LoadJwsSb, 'CkJws_LoadJwsSb');
  Chilkat_GetProcedureAddress(CkJws_LoadJws, 'CkJws_LoadJws');
  Chilkat_GetProcedureAddress(CkJws_SetMacKey, 'CkJws_SetMacKey');
  Chilkat_GetProcedureAddress(CkJws_SetMacKeyBd, 'CkJws_SetMacKeyBd');
  Chilkat_GetProcedureAddress(CkJws_SetPrivateKey, 'CkJws_SetPrivateKey');
  Chilkat_GetProcedureAddress(CkJws_SetPublicKey, 'CkJws_SetPublicKey');
  Chilkat_GetProcedureAddress(CkJws_Validate, 'CkJws_Validate');
  Chilkat_GetProcedureAddress(CkJws_SetPayload, 'CkJws_SetPayload');
  Chilkat_GetProcedureAddress(CkJws_GetPayload, 'CkJws_GetPayload');
  Chilkat_GetProcedureAddress(CkJws_GetProtectedH, 'CkJws_GetProtectedH');
  Chilkat_GetProcedureAddress(CkJws_GetUnprotectedH, 'CkJws_GetUnprotectedH');
  Chilkat_GetProcedureAddress(CkJws_SetSigningCert, 'CkJws_SetSigningCert');

end.
