unit Chilkat.Jwe;

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

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

interface

uses
  SysUtils,
  Chilkat.Base;

type

  { TJwe wraps CkJwe via the C bridge layer. }
  TJwe = 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  GetNumRecipients: 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 NumRecipients: Integer read GetNumRecipients;
    property PreferCompact: Boolean read GetPreferCompact write SetPreferCompact;
    property PreferFlattened: Boolean read GetPreferFlattened write SetPreferFlattened;
    property UncommonOptions: string read GetUncommonOptions write SetUncommonOptions;

    function  SetProtectedHeader(json: TChilkatBase): Boolean;
    function  SetUnprotectedHeader(json: TChilkatBase): Boolean;
    function  SetRecipientHeader(index: Integer; json: TChilkatBase): Boolean;
    function  SetPrivateKey(index: Integer; privKey: TChilkatBase): Boolean;
    function  SetPublicKey(index: Integer; pubKey: TChilkatBase): Boolean;
    function  SetWrappingKey(index: Integer; const encodedKey: string; const encoding: string): Boolean;
    function  SetPassword(index: Integer; const password: string): Boolean;
    function  Encrypt(const content: string; const charset: string): string;
    function  EncryptSb(contentSb: TChilkatBase; const charset: string; jweSb: TChilkatBase): Boolean;
    function  EncryptBd(contentBd: TChilkatBase; jweSb: TChilkatBase): Boolean;
    function  Decrypt(index: Integer; const charset: string): string;
    function  DecryptSb(index: Integer; const charset: string; contentSb: TChilkatBase): Boolean;
    function  DecryptBd(index: Integer; bd: TChilkatBase): Boolean;
    function  LoadJwe(const jwe: string): Boolean;
    function  LoadJweSb(sb: TChilkatBase): Boolean;
    function  SetAad(const aad: string; const charset: string): Boolean;
    function  SetAadBd(aad: TChilkatBase): Boolean;
    function  FindRecipient(const paramName: string; const paramValue: string; caseSensitive: Boolean): Integer;
    function  GetHeader(json: TChilkatBase): Boolean;
    function  GetProtectedHeader(json: TChilkatBase): Boolean;
  end;

implementation

uses
  CkDllLoader,
  Chilkat.Utils;

{ ---- C bridge function pointer types ---- }
type
  TCkJwe_Create  = function(): Pointer; cdecl;
  TCkJwe_Dispose = procedure(handle: Pointer); cdecl;
  TCkJwe_get_LastErrorHtml = function(handle: Pointer): PAnsiChar; cdecl;
  TCkJwe_get_LastErrorText = function(handle: Pointer): PAnsiChar; cdecl;
  TCkJwe_get_LastErrorXml = function(handle: Pointer): PAnsiChar; cdecl;
  TCkJwe_get_Version = function(handle: Pointer): PAnsiChar; cdecl;
  TCkJwe_get_DebugLogFilePath = function(handle: Pointer): PAnsiChar; cdecl;
  TCkJwe_put_DebugLogFilePath = procedure(handle: Pointer; value: PAnsiChar); cdecl;
  TCkJwe_get_VerboseLogging = function(handle: Pointer): LongBool; cdecl;
  TCkJwe_put_VerboseLogging = procedure(handle: Pointer; value: LongBool); cdecl;
  TCkJwe_get_LastMethodSuccess = function(handle: Pointer): LongBool; cdecl;
  TCkJwe_put_LastMethodSuccess = procedure(handle: Pointer; value: LongBool); cdecl;
  TCkJwe_get_NumRecipients = function(handle: Pointer): Integer; cdecl;
  TCkJwe_get_PreferCompact = function(handle: Pointer): LongBool; cdecl;
  TCkJwe_put_PreferCompact = procedure(handle: Pointer; value: LongBool); cdecl;
  TCkJwe_get_PreferFlattened = function(handle: Pointer): LongBool; cdecl;
  TCkJwe_put_PreferFlattened = procedure(handle: Pointer; value: LongBool); cdecl;
  TCkJwe_get_UncommonOptions = function(handle: Pointer): PAnsiChar; cdecl;
  TCkJwe_put_UncommonOptions = procedure(handle: Pointer; value: PAnsiChar); cdecl;
  TCkJwe_SetProtectedHeader = function(handle: Pointer; json: Pointer): LongBool; cdecl;
  TCkJwe_SetUnprotectedHeader = function(handle: Pointer; json: Pointer): LongBool; cdecl;
  TCkJwe_SetRecipientHeader = function(handle: Pointer; index: Integer; json: Pointer): LongBool; cdecl;
  TCkJwe_SetPrivateKey = function(handle: Pointer; index: Integer; privKey: Pointer): LongBool; cdecl;
  TCkJwe_SetPublicKey = function(handle: Pointer; index: Integer; pubKey: Pointer): LongBool; cdecl;
  TCkJwe_SetWrappingKey = function(handle: Pointer; index: Integer; encodedKey: PAnsiChar; encoding: PAnsiChar): LongBool; cdecl;
  TCkJwe_SetPassword = function(handle: Pointer; index: Integer; password: PAnsiChar): LongBool; cdecl;
  TCkJwe_Encrypt = function(handle: Pointer; content: PAnsiChar; charset: PAnsiChar): PAnsiChar; cdecl;
  TCkJwe_EncryptSb = function(handle: Pointer; contentSb: Pointer; charset: PAnsiChar; jweSb: Pointer): LongBool; cdecl;
  TCkJwe_EncryptBd = function(handle: Pointer; contentBd: Pointer; jweSb: Pointer): LongBool; cdecl;
  TCkJwe_Decrypt = function(handle: Pointer; index: Integer; charset: PAnsiChar): PAnsiChar; cdecl;
  TCkJwe_DecryptSb = function(handle: Pointer; index: Integer; charset: PAnsiChar; contentSb: Pointer): LongBool; cdecl;
  TCkJwe_DecryptBd = function(handle: Pointer; index: Integer; bd: Pointer): LongBool; cdecl;
  TCkJwe_LoadJwe = function(handle: Pointer; jwe: PAnsiChar): LongBool; cdecl;
  TCkJwe_LoadJweSb = function(handle: Pointer; sb: Pointer): LongBool; cdecl;
  TCkJwe_SetAad = function(handle: Pointer; aad: PAnsiChar; charset: PAnsiChar): LongBool; cdecl;
  TCkJwe_SetAadBd = function(handle: Pointer; aad: Pointer): LongBool; cdecl;
  TCkJwe_FindRecipient = function(handle: Pointer; paramName: PAnsiChar; paramValue: PAnsiChar; caseSensitive: LongBool): Integer; cdecl;
  TCkJwe_GetHeader = function(handle: Pointer; json: Pointer): LongBool; cdecl;
  TCkJwe_GetProtectedHeader = function(handle: Pointer; json: Pointer): LongBool; cdecl;

{ ---- C bridge function pointer variables ---- }
var
  CkJwe_Create:  TCkJwe_Create  = nil;
  CkJwe_Dispose: TCkJwe_Dispose = nil;
  CkJwe_get_LastErrorHtml: TCkJwe_get_LastErrorHtml = nil;
  CkJwe_get_LastErrorText: TCkJwe_get_LastErrorText = nil;
  CkJwe_get_LastErrorXml: TCkJwe_get_LastErrorXml = nil;
  CkJwe_get_Version: TCkJwe_get_Version = nil;
  CkJwe_get_DebugLogFilePath: TCkJwe_get_DebugLogFilePath = nil;
  CkJwe_put_DebugLogFilePath: TCkJwe_put_DebugLogFilePath = nil;
  CkJwe_get_VerboseLogging: TCkJwe_get_VerboseLogging = nil;
  CkJwe_put_VerboseLogging: TCkJwe_put_VerboseLogging = nil;
  CkJwe_get_LastMethodSuccess: TCkJwe_get_LastMethodSuccess = nil;
  CkJwe_put_LastMethodSuccess: TCkJwe_put_LastMethodSuccess = nil;
  CkJwe_get_NumRecipients: TCkJwe_get_NumRecipients = nil;
  CkJwe_get_PreferCompact: TCkJwe_get_PreferCompact = nil;
  CkJwe_put_PreferCompact: TCkJwe_put_PreferCompact = nil;
  CkJwe_get_PreferFlattened: TCkJwe_get_PreferFlattened = nil;
  CkJwe_put_PreferFlattened: TCkJwe_put_PreferFlattened = nil;
  CkJwe_get_UncommonOptions: TCkJwe_get_UncommonOptions = nil;
  CkJwe_put_UncommonOptions: TCkJwe_put_UncommonOptions = nil;
  CkJwe_SetProtectedHeader: TCkJwe_SetProtectedHeader = nil;
  CkJwe_SetUnprotectedHeader: TCkJwe_SetUnprotectedHeader = nil;
  CkJwe_SetRecipientHeader: TCkJwe_SetRecipientHeader = nil;
  CkJwe_SetPrivateKey: TCkJwe_SetPrivateKey = nil;
  CkJwe_SetPublicKey: TCkJwe_SetPublicKey = nil;
  CkJwe_SetWrappingKey: TCkJwe_SetWrappingKey = nil;
  CkJwe_SetPassword: TCkJwe_SetPassword = nil;
  CkJwe_Encrypt: TCkJwe_Encrypt = nil;
  CkJwe_EncryptSb: TCkJwe_EncryptSb = nil;
  CkJwe_EncryptBd: TCkJwe_EncryptBd = nil;
  CkJwe_Decrypt: TCkJwe_Decrypt = nil;
  CkJwe_DecryptSb: TCkJwe_DecryptSb = nil;
  CkJwe_DecryptBd: TCkJwe_DecryptBd = nil;
  CkJwe_LoadJwe: TCkJwe_LoadJwe = nil;
  CkJwe_LoadJweSb: TCkJwe_LoadJweSb = nil;
  CkJwe_SetAad: TCkJwe_SetAad = nil;
  CkJwe_SetAadBd: TCkJwe_SetAadBd = nil;
  CkJwe_FindRecipient: TCkJwe_FindRecipient = nil;
  CkJwe_GetHeader: TCkJwe_GetHeader = nil;
  CkJwe_GetProtectedHeader: TCkJwe_GetProtectedHeader = nil;

constructor TJwe.Create;
begin
  inherited Create;
  FHandle := CkJwe_Create();
end;

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

function TJwe.GetLastErrorHtml: string;
begin
  Result := CkToStr(CkJwe_get_LastErrorHtml(FHandle));
end;

function TJwe.GetLastErrorText: string;
begin
  Result := CkToStr(CkJwe_get_LastErrorText(FHandle));
end;

function TJwe.GetLastErrorXml: string;
begin
  Result := CkToStr(CkJwe_get_LastErrorXml(FHandle));
end;

function TJwe.GetVersion: string;
begin
  Result := CkToStr(CkJwe_get_Version(FHandle));
end;

function TJwe.GetDebugLogFilePath: string;
begin
  Result := CkToStr(CkJwe_get_DebugLogFilePath(FHandle));
end;

procedure TJwe.SetDebugLogFilePath(AValue: string);
begin
  CkJwe_put_DebugLogFilePath(FHandle, PAnsiChar(StrToCk(AValue)));
end;

function TJwe.GetVerboseLogging: Boolean;
begin
  Result := Boolean(CkJwe_get_VerboseLogging(FHandle));
end;

procedure TJwe.SetVerboseLogging(AValue: Boolean);
begin
  CkJwe_put_VerboseLogging(FHandle, LongBool(AValue));
end;

function TJwe.GetLastMethodSuccess: Boolean;
begin
  Result := Boolean(CkJwe_get_LastMethodSuccess(FHandle));
end;

procedure TJwe.SetLastMethodSuccess(AValue: Boolean);
begin
  CkJwe_put_LastMethodSuccess(FHandle, LongBool(AValue));
end;

function TJwe.GetNumRecipients: Integer;
begin
  Result := CkJwe_get_NumRecipients(FHandle);
end;

function TJwe.GetPreferCompact: Boolean;
begin
  Result := Boolean(CkJwe_get_PreferCompact(FHandle));
end;

procedure TJwe.SetPreferCompact(AValue: Boolean);
begin
  CkJwe_put_PreferCompact(FHandle, LongBool(AValue));
end;

function TJwe.GetPreferFlattened: Boolean;
begin
  Result := Boolean(CkJwe_get_PreferFlattened(FHandle));
end;

procedure TJwe.SetPreferFlattened(AValue: Boolean);
begin
  CkJwe_put_PreferFlattened(FHandle, LongBool(AValue));
end;

function TJwe.GetUncommonOptions: string;
begin
  Result := CkToStr(CkJwe_get_UncommonOptions(FHandle));
end;

procedure TJwe.SetUncommonOptions(AValue: string);
begin
  CkJwe_put_UncommonOptions(FHandle, PAnsiChar(StrToCk(AValue)));
end;

function TJwe.SetProtectedHeader(json: TChilkatBase): Boolean;
begin
  Result := Boolean(CkJwe_SetProtectedHeader(FHandle, json.Handle));
end;

function TJwe.SetUnprotectedHeader(json: TChilkatBase): Boolean;
begin
  Result := Boolean(CkJwe_SetUnprotectedHeader(FHandle, json.Handle));
end;

function TJwe.SetRecipientHeader(index: Integer; json: TChilkatBase): Boolean;
begin
  Result := Boolean(CkJwe_SetRecipientHeader(FHandle, index, json.Handle));
end;

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

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

function TJwe.SetWrappingKey(index: Integer; const encodedKey: string; const encoding: string): Boolean;
begin
  Result := Boolean(CkJwe_SetWrappingKey(FHandle, index, PAnsiChar(StrToCk(encodedKey)), PAnsiChar(StrToCk(encoding))));
end;

function TJwe.SetPassword(index: Integer; const password: string): Boolean;
begin
  Result := Boolean(CkJwe_SetPassword(FHandle, index, PAnsiChar(StrToCk(password))));
end;

function TJwe.Encrypt(const content: string; const charset: string): string;
begin
  Result := CkToStr(CkJwe_Encrypt(FHandle, PAnsiChar(StrToCk(content)), PAnsiChar(StrToCk(charset))));
end;

function TJwe.EncryptSb(contentSb: TChilkatBase; const charset: string; jweSb: TChilkatBase): Boolean;
begin
  Result := Boolean(CkJwe_EncryptSb(FHandle, contentSb.Handle, PAnsiChar(StrToCk(charset)), jweSb.Handle));
end;

function TJwe.EncryptBd(contentBd: TChilkatBase; jweSb: TChilkatBase): Boolean;
begin
  Result := Boolean(CkJwe_EncryptBd(FHandle, contentBd.Handle, jweSb.Handle));
end;

function TJwe.Decrypt(index: Integer; const charset: string): string;
begin
  Result := CkToStr(CkJwe_Decrypt(FHandle, index, PAnsiChar(StrToCk(charset))));
end;

function TJwe.DecryptSb(index: Integer; const charset: string; contentSb: TChilkatBase): Boolean;
begin
  Result := Boolean(CkJwe_DecryptSb(FHandle, index, PAnsiChar(StrToCk(charset)), contentSb.Handle));
end;

function TJwe.DecryptBd(index: Integer; bd: TChilkatBase): Boolean;
begin
  Result := Boolean(CkJwe_DecryptBd(FHandle, index, bd.Handle));
end;

function TJwe.LoadJwe(const jwe: string): Boolean;
begin
  Result := Boolean(CkJwe_LoadJwe(FHandle, PAnsiChar(StrToCk(jwe))));
end;

function TJwe.LoadJweSb(sb: TChilkatBase): Boolean;
begin
  Result := Boolean(CkJwe_LoadJweSb(FHandle, sb.Handle));
end;

function TJwe.SetAad(const aad: string; const charset: string): Boolean;
begin
  Result := Boolean(CkJwe_SetAad(FHandle, PAnsiChar(StrToCk(aad)), PAnsiChar(StrToCk(charset))));
end;

function TJwe.SetAadBd(aad: TChilkatBase): Boolean;
begin
  Result := Boolean(CkJwe_SetAadBd(FHandle, aad.Handle));
end;

function TJwe.FindRecipient(const paramName: string; const paramValue: string; caseSensitive: Boolean): Integer;
begin
  Result := CkJwe_FindRecipient(FHandle, PAnsiChar(StrToCk(paramName)), PAnsiChar(StrToCk(paramValue)), LongBool(caseSensitive));
end;

function TJwe.GetHeader(json: TChilkatBase): Boolean;
begin
  Result := Boolean(CkJwe_GetHeader(FHandle, json.Handle));
end;

function TJwe.GetProtectedHeader(json: TChilkatBase): Boolean;
begin
  Result := Boolean(CkJwe_GetProtectedHeader(FHandle, json.Handle));
end;

initialization
  Chilkat_GetProcedureAddress(CkJwe_Create,  'CkJwe_Create');
  Chilkat_GetProcedureAddress(CkJwe_Dispose, 'CkJwe_Dispose');
  Chilkat_GetProcedureAddress(CkJwe_get_LastErrorHtml, 'CkJwe_get_LastErrorHtml');
  Chilkat_GetProcedureAddress(CkJwe_get_LastErrorText, 'CkJwe_get_LastErrorText');
  Chilkat_GetProcedureAddress(CkJwe_get_LastErrorXml, 'CkJwe_get_LastErrorXml');
  Chilkat_GetProcedureAddress(CkJwe_get_Version, 'CkJwe_get_Version');
  Chilkat_GetProcedureAddress(CkJwe_get_DebugLogFilePath, 'CkJwe_get_DebugLogFilePath');
  Chilkat_GetProcedureAddress(CkJwe_put_DebugLogFilePath, 'CkJwe_put_DebugLogFilePath');
  Chilkat_GetProcedureAddress(CkJwe_get_VerboseLogging, 'CkJwe_get_VerboseLogging');
  Chilkat_GetProcedureAddress(CkJwe_put_VerboseLogging, 'CkJwe_put_VerboseLogging');
  Chilkat_GetProcedureAddress(CkJwe_get_LastMethodSuccess, 'CkJwe_get_LastMethodSuccess');
  Chilkat_GetProcedureAddress(CkJwe_put_LastMethodSuccess, 'CkJwe_put_LastMethodSuccess');
  Chilkat_GetProcedureAddress(CkJwe_get_NumRecipients, 'CkJwe_get_NumRecipients');
  Chilkat_GetProcedureAddress(CkJwe_get_PreferCompact, 'CkJwe_get_PreferCompact');
  Chilkat_GetProcedureAddress(CkJwe_put_PreferCompact, 'CkJwe_put_PreferCompact');
  Chilkat_GetProcedureAddress(CkJwe_get_PreferFlattened, 'CkJwe_get_PreferFlattened');
  Chilkat_GetProcedureAddress(CkJwe_put_PreferFlattened, 'CkJwe_put_PreferFlattened');
  Chilkat_GetProcedureAddress(CkJwe_get_UncommonOptions, 'CkJwe_get_UncommonOptions');
  Chilkat_GetProcedureAddress(CkJwe_put_UncommonOptions, 'CkJwe_put_UncommonOptions');
  Chilkat_GetProcedureAddress(CkJwe_SetProtectedHeader, 'CkJwe_SetProtectedHeader');
  Chilkat_GetProcedureAddress(CkJwe_SetUnprotectedHeader, 'CkJwe_SetUnprotectedHeader');
  Chilkat_GetProcedureAddress(CkJwe_SetRecipientHeader, 'CkJwe_SetRecipientHeader');
  Chilkat_GetProcedureAddress(CkJwe_SetPrivateKey, 'CkJwe_SetPrivateKey');
  Chilkat_GetProcedureAddress(CkJwe_SetPublicKey, 'CkJwe_SetPublicKey');
  Chilkat_GetProcedureAddress(CkJwe_SetWrappingKey, 'CkJwe_SetWrappingKey');
  Chilkat_GetProcedureAddress(CkJwe_SetPassword, 'CkJwe_SetPassword');
  Chilkat_GetProcedureAddress(CkJwe_Encrypt, 'CkJwe_Encrypt');
  Chilkat_GetProcedureAddress(CkJwe_EncryptSb, 'CkJwe_EncryptSb');
  Chilkat_GetProcedureAddress(CkJwe_EncryptBd, 'CkJwe_EncryptBd');
  Chilkat_GetProcedureAddress(CkJwe_Decrypt, 'CkJwe_Decrypt');
  Chilkat_GetProcedureAddress(CkJwe_DecryptSb, 'CkJwe_DecryptSb');
  Chilkat_GetProcedureAddress(CkJwe_DecryptBd, 'CkJwe_DecryptBd');
  Chilkat_GetProcedureAddress(CkJwe_LoadJwe, 'CkJwe_LoadJwe');
  Chilkat_GetProcedureAddress(CkJwe_LoadJweSb, 'CkJwe_LoadJweSb');
  Chilkat_GetProcedureAddress(CkJwe_SetAad, 'CkJwe_SetAad');
  Chilkat_GetProcedureAddress(CkJwe_SetAadBd, 'CkJwe_SetAadBd');
  Chilkat_GetProcedureAddress(CkJwe_FindRecipient, 'CkJwe_FindRecipient');
  Chilkat_GetProcedureAddress(CkJwe_GetHeader, 'CkJwe_GetHeader');
  Chilkat_GetProcedureAddress(CkJwe_GetProtectedHeader, 'CkJwe_GetProtectedHeader');

end.
