22; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
33
44#define AppName " Red Hat Developer Platform"
5- #define AppVersion " 1.0"
5+ #define AppVersion " 1.0.Alpha1 "
66#define AppPublisher " Red Hat"
77#define AppURL " http://www.redhat.com/"
88
@@ -35,6 +35,7 @@ ExtraDiskSpaceRequired=1048576
3535
3636[Files]
3737Source : " EfTidy.dll" ; Flags : dontcopy ;
38+ Source : " InstallConfigRecord.xml" ; Flags : dontcopy ;
3839
3940#include " idp_source\idp.iss"
4041
@@ -47,6 +48,11 @@ Root: HKLM; Subkey: "Software\Red Hat\{#AppName}"; Flags: uninsdeletekey
4748Root : HKLM; Subkey : " Software\Red Hat\{#AppName}" ; ValueType : string ; ValueName : " InstallDir" ; ValueData : " {app} "
4849
4950[Code]
51+ #IFDEF UNICODE
52+ #DEFINE AW " W"
53+ #ELSE
54+ #DEFINE AW " A"
55+ #ENDIF
5056
5157type
5258 ComponentGroup = record
6874 RelayState: String;
6975 end ;
7076
77+ TShellExecuteInfo = record
78+ cbSize: DWORD;
79+ fMask: Cardinal;
80+ Wnd: HWND;
81+ lpVerb: string;
82+ lpFile: string;
83+ lpParameters: string;
84+ lpDirectory: string;
85+ nShow: Integer;
86+ hInstApp: THandle;
87+ lpIDList: DWORD;
88+ lpClass: string;
89+ hkeyClass: THandle;
90+ dwHotKey: DWORD;
91+ hMonitor: THandle;
92+ hProcess: THandle;
93+ end ;
94+
7195const
7296 JBDS_URL = ' https://access.redhat.com/jbossnetwork/restricted/softwareDownload.html?softwareId=40371' ;
97+ JBDS_FILENAME = ' jboss-devstudio-9.0.1.Beta1-v20151105-0411-B134-installer-standalone.jar' ;
98+ WAIT_TIMEOUT = $00000102 ;
99+ SEE_MASK_NOCLOSEPROCESS = $00000040 ;
73100
74101var
75102 // Page IDs
95122 // cookie values for downloading JBDS
96123 RHSSOCookieValue, JSessionIdCookieValue: String;
97124
125+ function ShellExecuteEx (var lpExecInfo: TShellExecuteInfo): BOOL;
126+ external ' ShellExecuteEx{#AW}@shell32.dll stdcall' ;
127+
128+ function WaitForSingleObject (hHandle: THandle; dwMilliseconds: DWORD): DWORD;
129+ external ' WaitForSingleObject@kernel32.dll stdcall' ;
130+
131+ function TerminateProcess (hProcess: THandle; uExitCode: UINT): BOOL;
132+ external ' TerminateProcess@kernel32.dll stdcall' ;
133+
98134// Converts a color String in the format '$rrggbb' to a TColor value
99135function StringToColor (Color: String): TColor;
100136var
@@ -207,6 +243,34 @@ begin
207243 end ;
208244end ;
209245
246+ // Replaces a String value in a file
247+ function FileReplaceString (const FileName, SearchString, ReplaceString: string): boolean;
248+ var
249+ MyFile : TStrings;
250+ MyText : string;
251+ begin
252+ MyFile := TStringList.Create;
253+
254+ try
255+ result := true;
256+
257+ try
258+ MyFile.LoadFromFile(FileName);
259+ MyText := MyFile.Text;
260+
261+ if StringChangeEx(MyText, SearchString, ReplaceString, True) > 0 then // Only save if text has been changed.
262+ begin ;
263+ MyFile.Text := MyText;
264+ MyFile.SaveToFile(FileName);
265+ end ;
266+ except
267+ result := false;
268+ end ;
269+ finally
270+ MyFile.Free;
271+ end ;
272+ end ;
273+
210274// Extracts a particular cookie value from the Set-Cookie response header
211275function GetCookieValue (const CookieText: String; const CookieName: String): String;
212276var
@@ -315,79 +379,85 @@ begin
315379 ExtractTemporaryFile(' EfTidy.dll' );
316380 RegisterServer(True, ExpandConstant(' {tmp}\EfTidy.dll' ), False);
317381
318- // We are going to tidy up the (non well-formed) response with EfTidy -
319- // the first step is to create the EfTidy object
320- EfTidy := CreateOleObject(' EfTidy.tidyCom' );
321- EfTidy.Option.Clean := True;
322- EfTidy.Option.OutputType := 1 ; // XhtmlOut
323- EfTidy.Option.DoctypeMode := 3 ; // DoctypeLoose
324-
325- // Tidy up the response to make it valid XML so we can parse it
326- ResponseText := EfTidy.TidyMemToMem(WinHttpReq.ResponseText);
327-
328- Log(' Got response: ' + ResponseText);
329-
330- // Parse the now-valid XML response and extract the values we're interested in
331- SAMLValues := ExtractSAMLFormValues(ResponseText);
332-
333- RequestText := ' SAMLRequest=' + URLEncode(SAMLValues.SAMLRequest) +
334- ' &RelayState=' + URLEncode(SAMLValues.RelayState);
382+ Try
383+ // We are going to tidy up the (non well-formed) response with EfTidy -
384+ // the first step is to create the EfTidy object
335385
336- // POST the SAMLRequest and RelayState to the URL specified in the returned action attribute,
337- // which in this case should be the IdP
338- WinHttpReq.Open(' POST' , SAMLValues.Action, false);
339- WinHttpReq.SetRequestHeader(' Content-Type' , ' application/x-www-form-urlencoded' );
340- WinHttpReq.SetRequestHeader(' Content-Length' , IntToStr(Length(RequestText)));
341- WinHttpReq.Send(RequestText);
386+ EfTidy := CreateOleObject(' EfTidy.tidyCom' );
387+ EfTidy.Option.Clean := True;
388+ EfTidy.Option.OutputType := 1 ; // XhtmlOut
389+ EfTidy.Option.DoctypeMode := 3 ; // DoctypeLoose
342390
343- Log(' Sending request: ' + RequestText);
344-
345- if WinHttpReq.Status <> 200 then
346- begin
347- AuthLabel.Caption := ' Authentication Failed.' ;
348- AuthLabel.Font.Color := clRed;
349- Exit;
350- end else begin
351391 // Tidy up the response to make it valid XML so we can parse it
352392 ResponseText := EfTidy.TidyMemToMem(WinHttpReq.ResponseText);
353393
354394 Log(' Got response: ' + ResponseText);
355395
356- // Extract the Action, SAMLResponse and RelayState parameter values from the response
396+ // Parse the now-valid XML response and extract the values we're interested in
357397 SAMLValues := ExtractSAMLFormValues(ResponseText);
358398
359- Log(' Posting SAMLResponse to ' + SAMLValues.Action + ' , Request length: ' +
360- IntToStr(Length(SAMLValues.SAMLResponse)) +
361- ' , SAMLResponse: ' + Copy(SAMLValues.SAMLResponse, 1 , 1000 ) +
362- ' , RelayState: ' + SAMLValues.RelayState);
363-
364- RequestText := ' SAMLResponse=' + URLEncode(SAMLValues.SAMLResponse) +
399+ RequestText := ' SAMLRequest=' + URLEncode(SAMLValues.SAMLRequest) +
365400 ' &RelayState=' + URLEncode(SAMLValues.RelayState);
366401
402+ // POST the SAMLRequest and RelayState to the URL specified in the returned action attribute,
403+ // which in this case should be the IdP
367404 WinHttpReq.Open(' POST' , SAMLValues.Action, false);
368-
369- // Do not follow redirects here
370- WinHttpReq.Option(6 ) := False;
371-
372405 WinHttpReq.SetRequestHeader(' Content-Type' , ' application/x-www-form-urlencoded' );
373406 WinHttpReq.SetRequestHeader(' Content-Length' , IntToStr(Length(RequestText)));
374407 WinHttpReq.Send(RequestText);
375408
376- if WinHttpReq.Status <> 302 then
409+ Log(' Sending request: ' + RequestText);
410+
411+ if WinHttpReq.Status <> 200 then
377412 begin
378413 AuthLabel.Caption := ' Authentication Failed.' ;
379414 AuthLabel.Font.Color := clRed;
380- Exit;
381- end else begin
382- RHSSOCookieValue := ' rh_sso=' + GetCookieValue(WinHttpReq.getResponseHeader(' Set-Cookie' ), ' rh_sso' );
383- Log(' Got rh_sso cookie: ' + RHSSOCookieValue);
384-
385- idpAddFile(JBDS_URL, ExpandConstant(' {tmp}\jboss-devstudio-9.0.0.GA-installer-standalone.jar' ));
386- idpSetCookie(JBDS_URL, ' http://access.redhat.com/' , JSessionIdCookieValue);
387- idpSetCookie(JBDS_URL, ' http://access.redhat.com/' , RHSSOCookieValue);
388-
415+ Exit;
416+ end else begin
417+ // Tidy up the response to make it valid XML so we can parse it
418+ ResponseText := EfTidy.TidyMemToMem(WinHttpReq.ResponseText);
419+
420+ Log(' Got response: ' + ResponseText);
421+
422+ // Extract the Action, SAMLResponse and RelayState parameter values from the response
423+ SAMLValues := ExtractSAMLFormValues(ResponseText);
424+
425+ Log(' Posting SAMLResponse to ' + SAMLValues.Action + ' , Request length: ' +
426+ IntToStr(Length(SAMLValues.SAMLResponse)) +
427+ ' , SAMLResponse: ' + Copy(SAMLValues.SAMLResponse, 1 , 1000 ) +
428+ ' , RelayState: ' + SAMLValues.RelayState);
429+
430+ RequestText := ' SAMLResponse=' + URLEncode(SAMLValues.SAMLResponse) +
431+ ' &RelayState=' + URLEncode(SAMLValues.RelayState);
432+
433+ WinHttpReq.Open(' POST' , SAMLValues.Action, false);
434+
435+ // Do not follow redirects here
436+ WinHttpReq.Option(6 ) := False;
437+
438+ WinHttpReq.SetRequestHeader(' Content-Type' , ' application/x-www-form-urlencoded' );
439+ WinHttpReq.SetRequestHeader(' Content-Length' , IntToStr(Length(RequestText)));
440+ WinHttpReq.Send(RequestText);
441+
442+ if WinHttpReq.Status <> 302 then
443+ begin
444+ AuthLabel.Caption := ' Authentication Failed.' ;
445+ AuthLabel.Font.Color := clRed;
446+ Exit;
447+ end else begin
448+ RHSSOCookieValue := ' rh_sso=' + GetCookieValue(WinHttpReq.getResponseHeader(' Set-Cookie' ), ' rh_sso' );
449+ Log(' Got rh_sso cookie: ' + RHSSOCookieValue);
450+
451+ // idpAddFile(JBDS_URL, ExpandConstant('{tmp}\jboss-devstudio-9.0.0.GA-installer-standalone.jar'));
452+ // idpSetCookie(JBDS_URL, 'http://access.redhat.com/', JSessionIdCookieValue);
453+ // idpSetCookie(JBDS_URL, 'http://access.redhat.com/', RHSSOCookieValue);
454+
455+ end ;
389456 end ;
390- end ;
457+ Finally
458+ UnregisterServer(True, ExpandConstant(' {tmp}\EfTidy.dll' ), False);
459+ CoFreeUnusedLibraries();
460+ End ;
391461
392462 // Simulate a click of the Next button
393463 WizardForm.NextButton.OnClick(nil );
@@ -915,12 +985,39 @@ end;
915985procedure CurStepChanged (CurStep: TSetupStep);
916986var
917987 ErrorCode: Integer;
988+ ExecInfo: TShellExecuteInfo;
918989begin
919990 if CurStep = ssInstall then
920991 begin
921992 // Install Zulu JDK
922- ShellExec(' ' , ' msiexec' , ExpandConstant(' /i {tmp}\zulu1.8.0_60-8.9.0.4-win64.msi INSTALLDIR="{app}\zulu-8" /passive /norestart' ),
923- ' ' , SW_SHOW, ewWaitUntilTerminated, ErrorCode);
993+ // ShellExec('', 'msiexec', ExpandConstant('/i {tmp}\zulu1.8.0_60-8.9.0.4-win64.msi INSTALLDIR="{app}\zulu-8" /passive /norestart'),
994+ // '', SW_SHOW, ewWaitUntilTerminated, ErrorCode);
995+
996+ // Extract the install config and batch file for JBDS
997+ ExtractTemporaryFile(' InstallConfigRecord.xml' );
998+
999+ // Replace the {installDir} token in the XML config file with the application directory
1000+ FileReplaceString(ExpandConstant(' {tmp}\InstallConfigRecord.xml' ), ' {installDir}' , ExpandConstant(' {app}' ));
1001+
1002+ // Install JBDS
1003+ ExecInfo.cbSize := SizeOf(ExecInfo);
1004+ ExecInfo.fMask := SEE_MASK_NOCLOSEPROCESS;
1005+ ExecInfo.Wnd := 0 ;
1006+
1007+ ExecInfo.lpFile := ExpandConstant(' {app}\zulu-8\bin\javaw.exe' );
1008+ ExecInfo.lpParameters := ExpandConstant(' -jar {tmp}\' + JBDS_FILENAME + ' {tmp}\InstallConfigRecord.xml' );
1009+
1010+ ExecInfo.nShow := SW_SHOW; // SW_HIDE
1011+
1012+ if ShellExecuteEx(ExecInfo) then
1013+ begin
1014+ if WaitForSingleObject(ExecInfo.hProcess, 10 * 60 * 1000 { 10 minutes} ) = WAIT_TIMEOUT then
1015+ begin
1016+ TerminateProcess(ExecInfo.hProcess, 666 );
1017+ Log(' JBoss Developer Studio Installer Failed' );
1018+ end ;
1019+ end ;
1020+
9241021
9251022 // Extract the VirtualBox msi files from the downloaded exe
9261023 Shellexec(' ' , ExpandConstant(' {tmp}\VirtualBox-5.0.2-102096-Win.exe' ), ExpandConstant(' --extract -path {tmp} --silent' ),
@@ -1033,16 +1130,21 @@ begin
10331130 idpSetOption(' DetailsButton' , ' 0' );
10341131
10351132 // Zulu
1036- // idpSetOption('Referer', 'http://www.azulsystems.com/products/zulu/downloads');
1037- // idpAddFile('http://cdn.azulsystems.com/zulu/2015-07-8.8-bin/zulu1.8.0_51-8.8.0.3-win64.msi', ExpandConstant('{tmp}\zulu1.8.0_51-8.8.0.3-win64.msi'));
1133+ idpSetOption(' Referer' , ' http://www.azulsystems.com/products/zulu/downloads' );
1134+ idpAddFile(' http://cdn.azulsystems.com/zulu/2015-07-8.8-bin/zulu1.8.0_51-8.8.0.3-win64.msi' , ExpandConstant(' {tmp}\zulu1.8.0_51-8.8.0.3-win64.msi' ));
10381135 // idpAddFile('http://192.168.1.114/~shane/zulu1.8.0_60-8.9.0.4-win64.msi', ExpandConstant('{tmp}\zulu1.8.0_60-8.9.0.4-win64.msi'));
1136+
1137+ // JBDS - JBoss Developer Studio
1138+ idpAddFile(' https://devstudio.redhat.com/9.0/snapshots/builds/devstudio.product_9.0.mars/latest/all/jboss-devstudio-9.0.1.Beta1-v20151105-0411-B134-installer-standalone.jar' ,
1139+ ExpandConstant(' {tmp}\jboss-devstudio-9.0.1.Beta1-v20151105-0411-B134-installer-standalone.jar' ));
1140+ // idpAddFile('http://192.168.1.114/~shane/' + JBDS_FILENAME, ExpandConstant('{tmp}\') + JBDS_FILENAME);
10391141
10401142 // VirtualBox
1041- // idpAddFile('http://download.virtualbox.org/virtualbox/5.0.2/VirtualBox-5.0.2-102096-Win.exe', ExpandConstant('{tmp}\VirtualBox-5.0.2-102096-Win.exe'));
1143+ idpAddFile(' http://download.virtualbox.org/virtualbox/5.0.2/VirtualBox-5.0.2-102096-Win.exe' , ExpandConstant(' {tmp}\VirtualBox-5.0.2-102096-Win.exe' ));
10421144 // idpAddFile('http://192.168.1.114/~shane/VirtualBox-5.0.2-102096-Win.exe', ExpandConstant('{tmp}\VirtualBox-5.0.2-102096-Win.exe'));
10431145
10441146 // Vagrant
1045- // idpAddFile('https://dl.bintray.com/mitchellh/vagrant/vagrant_1.7.4.msi', ExpandConstant('{tmp}\vagrant_1.7.4.msi'));
1147+ idpAddFile(' https://dl.bintray.com/mitchellh/vagrant/vagrant_1.7.4.msi' , ExpandConstant(' {tmp}\vagrant_1.7.4.msi' ));
10461148 // idpAddFile('http://192.168.1.114/~shane/vagrant_1.7.4.msi', ExpandConstant('{tmp}\vagrant_1.7.4.msi'));
10471149
10481150 idpDownloadAfter(wpReady);
0 commit comments