Menu

[r1]: / trunk / indy / IdAuthenticationManager.pas  Maximize  Restore  History

Download this file

174 lines (141 with data), 4.1 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
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
{
$Project$
$Workfile$
$Revision$
$DateUTC$
$Id$
This file is part of the Indy (Internet Direct) project, and is offered
under the dual-licensing agreement described on the Indy website.
(http://www.indyproject.org/)
Copyright:
(c) 1993-2005, Chad Z. Hower and the Indy Pit Crew. All rights reserved.
}
{
$Log$
}
{
Rev 1.4 10/26/2004 10:59:30 PM JPMugaas
Updated ref.
Rev 1.3 5/29/2004 10:02:20 AM DSiders
Corrected case in Create parameter.
Rev 1.2 2004.02.03 5:44:54 PM czhower
Name changes
Rev 1.1 2004.01.21 1:04:52 PM czhower
InitComponenet
Rev 1.0 11/14/2002 02:13:40 PM JPMugaas
}
unit IdAuthenticationManager;
interface
{$i IdCompilerDefines.inc}
uses
Classes,
IdAuthentication,
IdBaseComponent,
IdURI;
type
TIdAuthenticationItem = class(TCollectionItem)
protected
FURI: TIdURI;
FParams: TStrings;
procedure SetParams(const Value: TStrings);
procedure SetURI(const Value: TIdURI);
public
constructor Create(ACollection: TCollection); override;
destructor Destroy; override;
procedure Assign(Source: TPersistent); override;
property URL: TIdURI read FURI write SetURI;
property Params: TStrings read FParams write SetParams;
end;
TIdAuthenticationCollection = class(TOwnedCollection)
protected
function GetAuthItem(AIndex: Integer): TIdAuthenticationItem;
procedure SetAuthItem(AIndex: Integer; const Value: TIdAuthenticationItem);
public
function Add: TIdAuthenticationItem;
constructor Create(AOwner: TPersistent);
//
property Items[AIndex: Integer]: TIdAuthenticationItem read GetAuthItem write SetAuthItem;
end;
TIdAuthenticationManager = class(TIdBaseComponent)
protected
FAuthentications: TIdAuthenticationCollection;
//
procedure InitComponent; override;
public
destructor Destroy; override;
procedure AddAuthentication(AAuthentication: TIdAuthentication; AURL: TIdURI);
property Authentications: TIdAuthenticationCollection read FAuthentications;
end;
implementation
uses
IdGlobal, SysUtils;
{ TIdAuthenticationManager }
function TIdAuthenticationCollection.Add: TIdAuthenticationItem;
begin
Result := TIdAuthenticationItem(inherited Add);
end;
constructor TIdAuthenticationCollection.Create(AOwner: TPersistent);
begin
inherited Create(AOwner, TIdAuthenticationItem);
end;
function TIdAuthenticationCollection.GetAuthItem(AIndex: Integer): TIdAuthenticationItem;
begin
Result := TIdAuthenticationItem(inherited GetItem(AIndex));
end;
procedure TIdAuthenticationCollection.SetAuthItem(AIndex: Integer;
const Value: TIdAuthenticationItem);
begin
inherited SetItem(AIndex, Value);
end;
{ TIdAuthenticationManager }
procedure TIdAuthenticationManager.AddAuthentication(
AAuthentication: TIdAuthentication; AURL: TIdURI);
begin
with Authentications.Add do begin
URL.URI := AURL.URI;
Params.Assign(AAuthentication.Params);
end;
end;
destructor TIdAuthenticationManager.Destroy;
begin
FreeAndNil(FAuthentications);
inherited Destroy;
end;
procedure TIdAuthenticationManager.InitComponent;
begin
inherited InitComponent;
FAuthentications := TIdAuthenticationCollection.Create(Self);
end;
{ TIdAuthenticationItem }
constructor TIdAuthenticationItem.Create(ACollection: TCollection);
begin
inherited Create(ACollection);
FURI := TIdURI.Create;
FParams := TStringList.Create;
end;
destructor TIdAuthenticationItem.Destroy;
begin
FreeAndNil(FURI);
FreeAndNil(FParams);
inherited Destroy;
end;
procedure TIdAuthenticationItem.Assign(Source: TPersistent);
begin
if Source is TIdAuthenticationItem then begin
with TIdAuthenticationItem(Source) do begin
Self.URL.URI := URL.URI;
Self.Params.Assign(Params);
end;
end else begin
inherited Assign(Source);
end;
end;
procedure TIdAuthenticationItem.SetParams(const Value: TStrings);
begin
FParams.Assign(Value);
end;
procedure TIdAuthenticationItem.SetURI(const Value: TIdURI);
begin
FURI.URI := Value.URI;
end;
end.
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.