unit Chilkat.CertChain;

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

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

interface

uses
  SysUtils,
  Chilkat.Base;

type

  { TCertChain wraps CkCertChain via the C bridge layer. }
  TCertChain = 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  GetNumCerts: Integer;
    function  GetNumExpiredCerts: Integer;
    function  GetReachesRoot: 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 NumCerts: Integer read GetNumCerts;
    property NumExpiredCerts: Integer read GetNumExpiredCerts;
    property ReachesRoot: Boolean read GetReachesRoot;
    property UncommonOptions: string read GetUncommonOptions write SetUncommonOptions;

    function  IsRootTrusted(trustedRoots: TChilkatBase): Boolean;
    function  VerifyCertSignatures: Boolean;
    function  LoadX5C(jwk: TChilkatBase): Boolean;
    function  X509PKIPathv1: string;
    function  CertAt(index: Integer; cert: TChilkatBase): Boolean;
  end;

implementation

uses
  CkDllLoader,
  Chilkat.Utils;

{ ---- C bridge function pointer types ---- }
type
  TCkCertChain_Create  = function(): Pointer; cdecl;
  TCkCertChain_Dispose = procedure(handle: Pointer); cdecl;
  TCkCertChain_get_LastErrorHtml = function(handle: Pointer): PAnsiChar; cdecl;
  TCkCertChain_get_LastErrorText = function(handle: Pointer): PAnsiChar; cdecl;
  TCkCertChain_get_LastErrorXml = function(handle: Pointer): PAnsiChar; cdecl;
  TCkCertChain_get_Version = function(handle: Pointer): PAnsiChar; cdecl;
  TCkCertChain_get_DebugLogFilePath = function(handle: Pointer): PAnsiChar; cdecl;
  TCkCertChain_put_DebugLogFilePath = procedure(handle: Pointer; value: PAnsiChar); cdecl;
  TCkCertChain_get_VerboseLogging = function(handle: Pointer): LongBool; cdecl;
  TCkCertChain_put_VerboseLogging = procedure(handle: Pointer; value: LongBool); cdecl;
  TCkCertChain_get_LastMethodSuccess = function(handle: Pointer): LongBool; cdecl;
  TCkCertChain_put_LastMethodSuccess = procedure(handle: Pointer; value: LongBool); cdecl;
  TCkCertChain_get_NumCerts = function(handle: Pointer): Integer; cdecl;
  TCkCertChain_get_NumExpiredCerts = function(handle: Pointer): Integer; cdecl;
  TCkCertChain_get_ReachesRoot = function(handle: Pointer): LongBool; cdecl;
  TCkCertChain_get_UncommonOptions = function(handle: Pointer): PAnsiChar; cdecl;
  TCkCertChain_put_UncommonOptions = procedure(handle: Pointer; value: PAnsiChar); cdecl;
  TCkCertChain_IsRootTrusted = function(handle: Pointer; trustedRoots: Pointer): LongBool; cdecl;
  TCkCertChain_VerifyCertSignatures = function(handle: Pointer): LongBool; cdecl;
  TCkCertChain_LoadX5C = function(handle: Pointer; jwk: Pointer): LongBool; cdecl;
  TCkCertChain_X509PKIPathv1 = function(handle: Pointer): PAnsiChar; cdecl;
  TCkCertChain_CertAt = function(handle: Pointer; index: Integer; cert: Pointer): LongBool; cdecl;

{ ---- C bridge function pointer variables ---- }
var
  CkCertChain_Create:  TCkCertChain_Create  = nil;
  CkCertChain_Dispose: TCkCertChain_Dispose = nil;
  CkCertChain_get_LastErrorHtml: TCkCertChain_get_LastErrorHtml = nil;
  CkCertChain_get_LastErrorText: TCkCertChain_get_LastErrorText = nil;
  CkCertChain_get_LastErrorXml: TCkCertChain_get_LastErrorXml = nil;
  CkCertChain_get_Version: TCkCertChain_get_Version = nil;
  CkCertChain_get_DebugLogFilePath: TCkCertChain_get_DebugLogFilePath = nil;
  CkCertChain_put_DebugLogFilePath: TCkCertChain_put_DebugLogFilePath = nil;
  CkCertChain_get_VerboseLogging: TCkCertChain_get_VerboseLogging = nil;
  CkCertChain_put_VerboseLogging: TCkCertChain_put_VerboseLogging = nil;
  CkCertChain_get_LastMethodSuccess: TCkCertChain_get_LastMethodSuccess = nil;
  CkCertChain_put_LastMethodSuccess: TCkCertChain_put_LastMethodSuccess = nil;
  CkCertChain_get_NumCerts: TCkCertChain_get_NumCerts = nil;
  CkCertChain_get_NumExpiredCerts: TCkCertChain_get_NumExpiredCerts = nil;
  CkCertChain_get_ReachesRoot: TCkCertChain_get_ReachesRoot = nil;
  CkCertChain_get_UncommonOptions: TCkCertChain_get_UncommonOptions = nil;
  CkCertChain_put_UncommonOptions: TCkCertChain_put_UncommonOptions = nil;
  CkCertChain_IsRootTrusted: TCkCertChain_IsRootTrusted = nil;
  CkCertChain_VerifyCertSignatures: TCkCertChain_VerifyCertSignatures = nil;
  CkCertChain_LoadX5C: TCkCertChain_LoadX5C = nil;
  CkCertChain_X509PKIPathv1: TCkCertChain_X509PKIPathv1 = nil;
  CkCertChain_CertAt: TCkCertChain_CertAt = nil;

constructor TCertChain.Create;
begin
  inherited Create;
  FHandle := CkCertChain_Create();
end;

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

function TCertChain.GetLastErrorHtml: string;
begin
  Result := CkToStr(CkCertChain_get_LastErrorHtml(FHandle));
end;

function TCertChain.GetLastErrorText: string;
begin
  Result := CkToStr(CkCertChain_get_LastErrorText(FHandle));
end;

function TCertChain.GetLastErrorXml: string;
begin
  Result := CkToStr(CkCertChain_get_LastErrorXml(FHandle));
end;

function TCertChain.GetVersion: string;
begin
  Result := CkToStr(CkCertChain_get_Version(FHandle));
end;

function TCertChain.GetDebugLogFilePath: string;
begin
  Result := CkToStr(CkCertChain_get_DebugLogFilePath(FHandle));
end;

procedure TCertChain.SetDebugLogFilePath(AValue: string);
begin
  CkCertChain_put_DebugLogFilePath(FHandle, PAnsiChar(StrToCk(AValue)));
end;

function TCertChain.GetVerboseLogging: Boolean;
begin
  Result := Boolean(CkCertChain_get_VerboseLogging(FHandle));
end;

procedure TCertChain.SetVerboseLogging(AValue: Boolean);
begin
  CkCertChain_put_VerboseLogging(FHandle, LongBool(AValue));
end;

function TCertChain.GetLastMethodSuccess: Boolean;
begin
  Result := Boolean(CkCertChain_get_LastMethodSuccess(FHandle));
end;

procedure TCertChain.SetLastMethodSuccess(AValue: Boolean);
begin
  CkCertChain_put_LastMethodSuccess(FHandle, LongBool(AValue));
end;

function TCertChain.GetNumCerts: Integer;
begin
  Result := CkCertChain_get_NumCerts(FHandle);
end;

function TCertChain.GetNumExpiredCerts: Integer;
begin
  Result := CkCertChain_get_NumExpiredCerts(FHandle);
end;

function TCertChain.GetReachesRoot: Boolean;
begin
  Result := Boolean(CkCertChain_get_ReachesRoot(FHandle));
end;

function TCertChain.GetUncommonOptions: string;
begin
  Result := CkToStr(CkCertChain_get_UncommonOptions(FHandle));
end;

procedure TCertChain.SetUncommonOptions(AValue: string);
begin
  CkCertChain_put_UncommonOptions(FHandle, PAnsiChar(StrToCk(AValue)));
end;

function TCertChain.IsRootTrusted(trustedRoots: TChilkatBase): Boolean;
begin
  Result := Boolean(CkCertChain_IsRootTrusted(FHandle, trustedRoots.Handle));
end;

function TCertChain.VerifyCertSignatures: Boolean;
begin
  Result := Boolean(CkCertChain_VerifyCertSignatures(FHandle));
end;

function TCertChain.LoadX5C(jwk: TChilkatBase): Boolean;
begin
  Result := Boolean(CkCertChain_LoadX5C(FHandle, jwk.Handle));
end;

function TCertChain.X509PKIPathv1: string;
begin
  Result := CkToStr(CkCertChain_X509PKIPathv1(FHandle));
end;

function TCertChain.CertAt(index: Integer; cert: TChilkatBase): Boolean;
begin
  Result := Boolean(CkCertChain_CertAt(FHandle, index, cert.Handle));
end;

initialization
  Chilkat_GetProcedureAddress(CkCertChain_Create,  'CkCertChain_Create');
  Chilkat_GetProcedureAddress(CkCertChain_Dispose, 'CkCertChain_Dispose');
  Chilkat_GetProcedureAddress(CkCertChain_get_LastErrorHtml, 'CkCertChain_get_LastErrorHtml');
  Chilkat_GetProcedureAddress(CkCertChain_get_LastErrorText, 'CkCertChain_get_LastErrorText');
  Chilkat_GetProcedureAddress(CkCertChain_get_LastErrorXml, 'CkCertChain_get_LastErrorXml');
  Chilkat_GetProcedureAddress(CkCertChain_get_Version, 'CkCertChain_get_Version');
  Chilkat_GetProcedureAddress(CkCertChain_get_DebugLogFilePath, 'CkCertChain_get_DebugLogFilePath');
  Chilkat_GetProcedureAddress(CkCertChain_put_DebugLogFilePath, 'CkCertChain_put_DebugLogFilePath');
  Chilkat_GetProcedureAddress(CkCertChain_get_VerboseLogging, 'CkCertChain_get_VerboseLogging');
  Chilkat_GetProcedureAddress(CkCertChain_put_VerboseLogging, 'CkCertChain_put_VerboseLogging');
  Chilkat_GetProcedureAddress(CkCertChain_get_LastMethodSuccess, 'CkCertChain_get_LastMethodSuccess');
  Chilkat_GetProcedureAddress(CkCertChain_put_LastMethodSuccess, 'CkCertChain_put_LastMethodSuccess');
  Chilkat_GetProcedureAddress(CkCertChain_get_NumCerts, 'CkCertChain_get_NumCerts');
  Chilkat_GetProcedureAddress(CkCertChain_get_NumExpiredCerts, 'CkCertChain_get_NumExpiredCerts');
  Chilkat_GetProcedureAddress(CkCertChain_get_ReachesRoot, 'CkCertChain_get_ReachesRoot');
  Chilkat_GetProcedureAddress(CkCertChain_get_UncommonOptions, 'CkCertChain_get_UncommonOptions');
  Chilkat_GetProcedureAddress(CkCertChain_put_UncommonOptions, 'CkCertChain_put_UncommonOptions');
  Chilkat_GetProcedureAddress(CkCertChain_IsRootTrusted, 'CkCertChain_IsRootTrusted');
  Chilkat_GetProcedureAddress(CkCertChain_VerifyCertSignatures, 'CkCertChain_VerifyCertSignatures');
  Chilkat_GetProcedureAddress(CkCertChain_LoadX5C, 'CkCertChain_LoadX5C');
  Chilkat_GetProcedureAddress(CkCertChain_X509PKIPathv1, 'CkCertChain_X509PKIPathv1');
  Chilkat_GetProcedureAddress(CkCertChain_CertAt, 'CkCertChain_CertAt');

end.
