5858 // Page IDs
5959 AuthPageID, ComponentPageID, DownloadPageID, GetStartedPageID, InstallPageID : Integer;
6060
61+ UsernameEdit: TNewEdit;
62+ PasswordEdit: TPasswordEdit;
63+
6164 AuthLabel: TNewStaticText;
6265
6366 // "Standard" blue color used throughout the installer
9396
9497procedure LoginButtonOnClick (Sender: TObject);
9598var
99+ Url, Resource: String;
96100 Page: TWizardPage;
97101 Button: TNewButton;
102+ WinHttpReq: Variant;
98103begin
99104 Page := PageFromID(AuthPageID);
100105
101- // Set the flag to true for now
102- IsAuthenticated := True;
106+ AuthLabel.Caption := ' Authenticating, please wait...' ;
107+ AuthLabel.Font.Color := clBlack;
108+ AuthLabel.Visible := True;
109+ AuthLabel.Refresh;
110+
111+ Resource := ' https://access.redhat.com/jbossnetwork/restricted/listSoftware.html?product=jbossdeveloperstudio&downloadType=distributions' ;
103112
104- // Display the 'authentication successful' message
105- // AuthLabel.Visible := IsAuthenticated ;
113+ Url := ' https://idp.redhat.com/idp/authUser?j_username= ' + UsernameEdit.Text + ' &j_password= ' + PasswordEdit.Text +
114+ ' &redirect= ' + Resource ;
106115
107- // Simulate a click of the Next button
108- WizardForm.NextButton.OnClick(nil );
116+ // Perform a SAML authentication for redhat.com
117+ WinHttpReq := CreateOleObject(' WinHttp.WinHttpRequest.5.1' );
118+ WinHttpReq.Open(' POST' , Url, false);
119+ WinHttpReq.SetClientCertificate(' LOCAL_MACHINE\Personal\My Certificate' );
120+ WinHttpReq.SetRequestHeader(' Content-Type' , ' application/x-www-form-urlencoded' );
121+ WinHttpReq.Send();
122+
123+ if WinHttpReq.Status <> 200 then
124+ begin
125+ AuthLabel.Caption := ' Authentication Failed.' ;
126+ AuthLabel.Font.Color := clRed;
127+ Exit;
128+ end else begin
129+ // Set the authenticated flag to true
130+ IsAuthenticated := True;
131+
132+ AuthLabel.Caption := ' Authentication Successful.' ;
133+ AuthLabel.Font.Color := clGreen;
134+
135+ // Simulate a click of the Next button
136+ WizardForm.NextButton.OnClick(nil );
137+ end ;
109138end ;
110139
111140procedure ForgotLabelOnClick (Sender: TObject);
122151 LoginLabel: TNewStaticText;
123152 ForgotLabel: TNewStaticText;
124153 Button: TNewButton;
125- Edit: TNewEdit;
126- PasswordEdit: TPasswordEdit;
127154begin
128155 Page := CreateCustomPage(wpWelcome, ' ' , ' ' );
129156
@@ -139,16 +166,16 @@ begin
139166 LoginLabel.Font.Size := 10 ;
140167
141168 // Create an edit control for the user's login name
142- Edit := TNewEdit.Create(Page);
143- Edit .Top := LoginLabel.Top + LoginLabel.Height + ScaleY(8 );
144- Edit .Width := Page.SurfaceWidth div 2 - ScaleX(8 );
145- Edit .Text := ' Red Hat Login' ;
146- Edit .Parent := Page.Surface;
169+ UsernameEdit := TNewEdit.Create(Page);
170+ UsernameEdit .Top := LoginLabel.Top + LoginLabel.Height + ScaleY(8 );
171+ UsernameEdit .Width := Page.SurfaceWidth div 2 - ScaleX(8 );
172+ UsernameEdit .Text := ' Red Hat Login' ;
173+ UsernameEdit .Parent := Page.Surface;
147174
148175 // Create a password control for the user's password
149176 PasswordEdit := TPasswordEdit.Create(Page);
150- PasswordEdit.Top := Edit .Top + Edit .Height + ScaleY(8 );
151- PasswordEdit.Width := Edit .Width;
177+ PasswordEdit.Top := UsernameEdit .Top +UsernameEdit .Height + ScaleY(8 );
178+ PasswordEdit.Width := UsernameEdit .Width;
152179 PasswordEdit.Text := ' Password' ;
153180 PasswordEdit.Parent := Page.Surface;
154181
@@ -175,15 +202,12 @@ begin
175202 ForgotLabel.Top := Button.Top + ((Button.Height - ForgotLabel.Height) / 2 ) + ScaleY(0 );
176203 ForgotLabel.Left := Button.Left + Button.Width + ScaleX(20 );
177204
178- // Create the 'auth successful' label. We set its visibility to false at first, then display it later when
179- // auth is successful
180- // AuthLabel := TNewStaticText.Create(Page);
181- // AuthLabel.Caption := 'Authentication Successful';
182- // AuthLabel.Parent := Page.Surface;
183- // AuthLabel.Color := clWhite;
184- // AuthLabel.Font.Color := clGreen;
185- // AuthLabel.Visible := False;
186- // AuthLabel.Top := Button.Top + Button.Height + ScaleY(8);
205+ // Create the authentication label. We set its visibility to false at first, then display it later when needed
206+ AuthLabel := TNewStaticText.Create(Page);
207+ AuthLabel.Parent := Page.Surface;
208+ AuthLabel.Color := clWhite;
209+ AuthLabel.Visible := False;
210+ AuthLabel.Top := Button.Top + Button.Height + ScaleY(8 );
187211
188212 result := Page;
189213end ;
0 commit comments