Skip to content

Commit

Permalink
Repo initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
perevoznyk committed Mar 5, 2021
1 parent cd79087 commit aa4029a
Show file tree
Hide file tree
Showing 38 changed files with 9,877 additions and 0 deletions.
95 changes: 95 additions & 0 deletions Delphi/AsicContainer.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
unit AsicContainer;

interface

uses
Windows,
SwelioEngine,
Classes;

type

//ASIC file container allows to create and sign digital document containers
TAsicContainer = class
private
FCertificateSelected : boolean;
ctx : pointer;
FReaderNumber : integer;
public
constructor Create; virtual;
destructor Destroy; override;
procedure Close;
property ReaderNumber : integer read FReaderNumber write FReaderNumber;
property CertificateSelected : boolean read FCertificateSelected;
function Save(FileName : WideString) : boolean;
function SelectCertificate(EID : boolean) : boolean; overload;
function SelectCertificate(FileName : WideString; Password : WideString) : boolean; overload;
function AddFile(FileName : AnsiString) : boolean;
end;

implementation

{ TAsicContainer }

function TAsicContainer.AddFile(FileName: AnsiString): boolean;
begin
result := AddFileToContainer(ctx, PAnsiChar(FileName));
end;

procedure TAsicContainer.Close;
begin
if (ctx <> nil) then
begin
FreeContainer(ctx);
ctx := nil;
end;
end;

constructor TAsicContainer.Create;
begin
inherited Create;
ctx := InitializeContainer;
end;

destructor TAsicContainer.Destroy;
begin
Close;
inherited;
end;

function TAsicContainer.Save(FileName: WideString): boolean;
begin
result := false;
if not FCertificateSelected then
exit;
if ctx <> nil then
begin
result := SaveContainer(ctx, PWideChar(FileName));
end;
end;

function TAsicContainer.SelectCertificate(EID: boolean): boolean;
begin
result := false;
if ctx <> nil then
begin
if EID then
result := ContainerEidCertificate(ctx, ReaderNumber)
else
result := ContainerPickCertificate(ctx);
end;
FCertificateSelected := result;
end;

function TAsicContainer.SelectCertificate(FileName,
Password: WideString): boolean;
begin
result := false;
if ctx <> nil then
begin
result := ContainerCertificate(ctx, PWideChar(FileName), PWideChar(password));
end;
FCertificateSelected := result;
end;

end.
Binary file added Delphi/Component.bmp
Binary file not shown.
42 changes: 42 additions & 0 deletions Delphi/EidFormatter.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
//===============================================================================
//= Copyright (c) Serhiy Perevoznyk. All rights reserved.
//= THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
//= OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
//= LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
//= FITNESS FOR A PARTICULAR PURPOSE.
//===============================================================================

unit EidFormatter;

interface

uses
Windows, SysUtils, SwelioEngine;

type
TEidFormatter = class
public
class function FormatDate(const Value : string) : string;
class function FormatNationalNumber(const Value : string) : string;
class function FormatCardNumber(const Value : string) : string;
end;
implementation

{ TEidFormatter }

class function TEidFormatter.FormatCardNumber(const Value: string): string;
begin
Result := SwelioEngine.FormatCardNumber(Value);
end;

class function TEidFormatter.FormatDate(const Value: string): string;
begin
Result := SwelioEngine.FormatEIDDate(Value);
end;

class function TEidFormatter.FormatNationalNumber(const Value: string): string;
begin
Result := SwelioEngine.FormatNationalNumber(Value);
end;

end.
Binary file added Delphi/EidReader.RES
Binary file not shown.
Loading

0 comments on commit aa4029a

Please sign in to comment.