-
-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathCloudAPI.Authenticator.Basic.pas
More file actions
48 lines (40 loc) · 1.06 KB
/
CloudAPI.Authenticator.Basic.pas
File metadata and controls
48 lines (40 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
unit CloudAPI.Authenticator.Basic;
interface
uses
CloudAPI.IAuthenticator,
CloudAPI.Request;
type
TBasicAuthenticator = class(TInterfacedObject, IAuthenticator)
private
FPassword: string;
FUser: string;
public
constructor Create(const AUser, APassword: string);
procedure Authenticate(ARequest: IcaRequest);
property Password: string read FPassword write FPassword;
property User: string read FUser write FUser;
end;
implementation
uses
CloudAPI.Types,
CloudAPI.Parameter,
System.NetEncoding,
System.Net.URLClient;
{ TBasicAuthenticator }
procedure TBasicAuthenticator.Authenticate(ARequest: IcaRequest);
var
LParam: TcaParameter;
begin
LParam.Name := 'Authorization';
LParam.Value := 'Basic ' + TNetEncoding.Base64.Encode(User + ':' + Password);
LParam.DefaultValue := '';
LParam.ParameterType := TcaParameterType.HttpHeader;
LParam.IsRequired := True;
ARequest.AddParam(LParam);
end;
constructor TBasicAuthenticator.Create(const AUser, APassword: string);
begin
FUser := AUser;
FPassword := APassword;
end;
end.