-
Notifications
You must be signed in to change notification settings - Fork 1
/
createfrm.pas
111 lines (102 loc) · 2.41 KB
/
createfrm.pas
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
unit createfrm;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, DateUtils;
type
TCreateCertForm = class(TForm)
btnOK: TButton;
btnCancel: TButton;
Label3: TLabel;
edtStoreName: TEdit;
Label1: TLabel;
edtCN: TEdit;
Label2: TLabel;
Label4: TLabel;
edtSerial: TEdit;
edtValidFrom: TEdit;
edtValidTo: TEdit;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
Label10: TLabel;
edtO: TEdit;
edtOU: TEdit;
edtL: TEdit;
edtC: TEdit;
edtE: TEdit;
Label11: TLabel;
edtKeyName: TEdit;
Label12: TLabel;
edtKeyLength: TEdit;
Label13: TLabel;
cbServerAuth: TCheckBox;
cbClientAuth: TCheckBox;
cbCodeSigning: TCheckBox;
cbEmailProtection: TCheckBox;
Label14: TLabel;
edtFriendlyName: TEdit;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
function BuildSubjectString: string;
end;
implementation
{$R *.dfm}
function TCreateCertForm.BuildSubjectString: string;
begin
Result := '';
if (edtCN.Text <> '') then
begin
Result := Result + ',CN=' + edtCN.Text;
end;
if (edtOU.Text <> '') then
begin
Result := Result + ',OU=' + edtOU.Text;
end;
if (edtO.Text <> '') then
begin
Result := Result + ',O=' + edtO.Text;
end;
if (edtL.Text <> '') then
begin
Result := Result + ',L=' + edtL.Text;
end;
if (edtC.Text <> '') then
begin
Result := Result + ',C=' + edtC.Text;
end;
if (edtE.Text <> '') then
begin
Result := Result + ',E=' + edtE.Text;
end;
if (Result <> '') then
begin
Delete(Result, 1, 1);
end;
end;
//Îïðåäåëÿåì âûñîêîñíûé ãîä
function IsLeapYear(Year : Integer) : Boolean;
{-Return True if Year is a leap year}
begin
IsLeapYear := (Year mod 4 = 0)
and (Year mod 4000 <> 0) and
((Year mod 100 <> 0) or (Year mod 400 = 0));
end;
procedure TCreateCertForm.FormCreate(Sender: TObject);
var
god: Integer;
begin
god:=YearOf(Now);
if IsLeapYear(god) then begin
edtValidFrom.Text := DateToStr(Date());
edtValidTo.Text := DateToStr(Date() + 366);
end else begin
edtValidFrom.Text := DateToStr(Date());
edtValidTo.Text := DateToStr(Date() + 365);
end;
end;
end.