Delphi concept

This commit is contained in:
Olaf Monien
2026-02-10 23:55:42 +01:00
parent adaff67219
commit 645fd71e45
12 changed files with 529 additions and 0 deletions
+19
View File
@@ -0,0 +1,19 @@
program App;
{$APPTYPE CONSOLE}
uses
System.SysUtils,
UAuth in 'UAuth.pas';
var
Svc: TAuthService;
begin
Svc := TAuthService.Create;
try
Writeln(Svc.Login('olaf', 'secret'));
finally
Svc.Free;
end;
end.
+36
View File
@@ -0,0 +1,36 @@
unit UAuth;
interface
uses
System.SysUtils,
System.Classes;
type
ITokenValidator = interface
['{11111111-1111-1111-1111-111111111111}']
function Validate(const AToken: string): Boolean;
end;
TAuthService = class(TInterfacedObject, ITokenValidator)
public
function Validate(const AToken: string): Boolean;
function Login(const AUser, APass: string): string;
end;
implementation
function TAuthService.Validate(const AToken: string): Boolean;
begin
Result := AToken <> '';
end;
function TAuthService.Login(const AUser, APass: string): string;
begin
if Validate(AUser + ':' + APass) then
Result := 'ok'
else
Result := '';
end;
end.