@@ -36,6 +36,7 @@ DisableFinishedPage=yes
3636ExtraDiskSpaceRequired = 1048576
3737
3838[Files]
39+ Source : " EfTidy.dll" ; Flags : dontcopy
3940
4041[Languages]
4142Name : " english" ; MessagesFile : " compiler:Default.isl"
@@ -46,6 +47,9 @@ Root: HKLM; Subkey: "Software\Red Hat\{#AppName}"; Flags: uninsdeletekey
4647Root : HKLM; Subkey : " Software\Red Hat\{#AppName}" ; ValueType : string ; ValueName : " InstallDir" ; ValueData : " {app} "
4748
4849[Code]
50+ // function xxxx
51+ // external 'xxx@files:EfTidy.dll stdcall setuponly';
52+
4953
5054type
5155 ComponentGroup = record
@@ -102,11 +106,11 @@ end;
102106
103107procedure LoginButtonOnClick (Sender: TObject);
104108var
105- Url, Resource: String;
106-
109+ Url, Resource, ResponseText, SAMLRequest, RelayState : String;
110+ I, J, K: Integer;
107111 Page: TWizardPage;
108112 Button: TNewButton;
109- WinHttpReq: Variant;
113+ WinHttpReq, EfTidy, XMLDoc, NodeList, FormNode, InputNode : Variant;
110114begin
111115 Page := PageFromID(AuthPageID);
112116
@@ -115,7 +119,8 @@ begin
115119 AuthLabel.Visible := True;
116120 AuthLabel.Refresh;
117121
118- Resource := ' https://access.redhat.com/jbossnetwork/restricted/listSoftware.html?product=jbossdeveloperstudio&downloadType=distributions' ;
122+ // Resource := 'https://access.redhat.com/jbossnetwork/restricted/listSoftware.html?product=jbossdeveloperstudio&downloadType=distributions';
123+ Resource := ' https://access.redhat.com/jbossnetwork/restricted/softwareDownload.html?softwareId=40371' ;
119124
120125 Url := ' https://idp.redhat.com/idp/authUser?j_username=' + UsernameEdit.Text + ' &j_password=' + PasswordEdit.Text +
121126 ' &redirect=' + Resource;
@@ -139,6 +144,65 @@ begin
139144 AuthLabel.Caption := ' Authentication Successful.' ;
140145 AuthLabel.Font.Color := clGreen;
141146
147+ // MsgBox(WinHttpReq.ResponseText, mbInformation, MB_OK);
148+
149+
150+ // Perform a SAML authentication for redhat.com
151+ WinHttpReq := CreateOleObject(' WinHttp.WinHttpRequest.5.1' );
152+ WinHttpReq.Open(' GET' , Resource, false);
153+ WinHttpReq.SetClientCertificate(' LOCAL_MACHINE\Personal\My Certificate' );
154+ WinHttpReq.SetRequestHeader(' Content-Type' , ' application/x-www-form-urlencoded' );
155+ WinHttpReq.Send();
156+
157+ ResponseText := WinHttpReq.ResponseText;
158+
159+ ExtractTemporaryFile(' EfTidy.dll' );
160+ RegisterServer(True, ExpandConstant(' {tmp}\EfTidy.dll' ), False);
161+
162+ // Tidy up the (non well-formed) response with EfTidy
163+ EfTidy := CreateOleObject(' EfTidy.tidyCom' );
164+ EfTidy.Option.Clean := True;
165+ EfTidy.Option.OutputType := 1 ; // XhtmlOut
166+ EfTidy.Option.DoctypeMode := 3 ; // DoctypeLoose
167+ ResponseText := EfTidy.TidyMemToMem(ResponseText);
168+
169+ XMLDoc := CreateOleObject(' MSXML2.DOMDocument' );
170+ XMLDoc.async := False;
171+ XMLDoc.resolveExternals := False;
172+ XMLDoc.validateOnParse := False;
173+ XMLDoc.setProperty(' ProhibitDTD' , False);
174+ XMLDoc.loadXML(ResponseText);
175+
176+ if XMLDoc.parseError.errorCode <> 0 then
177+ begin
178+ MsgBox(' Error on line ' + IntToStr(XMLDoc.parseError.line) + ' , position ' +
179+ IntToStr(XMLDoc.parseError.linepos) + ' : ' + XMLDoc.parseError.reason, mbInformation, MB_OK);
180+ end else begin
181+ NodeList := XMLDoc.getElementsByTagName(' form' );
182+
183+ for I := 0 to NodeList.length - 1 do
184+ begin
185+ FormNode := NodeList.item(i);
186+
187+ for J := 0 to FormNode.childNodes.length - 1 do
188+ begin
189+ if FormNode.childNodes.item(J).nodeName = ' input' then
190+ begin
191+ InputNode := FormNode.childNodes.item[J];
192+
193+ if InputNode.attributes.getNamedItem(' name' ).nodeValue = ' SAMLRequest' then
194+ SAMLRequest := InputNode.attributes.getNamedItem(' value' ).nodeValue;
195+ if InputNode.attributes.getNamedItem(' name' ).nodeValue = ' RelayState' then
196+ RelayState := InputNode.attributes.getNamedItem(' value' ).nodeValue;
197+ end ;
198+ end ;
199+ end ;
200+ end ;
201+
202+
203+ // MsgBox('SAMLRequest: ' + SAMLRequest + ' RelayState: ' + RelayState, mbInformation, MB_OK);
204+
205+
142206 // Simulate a click of the Next button
143207 WizardForm.NextButton.OnClick(nil );
144208 end ;
@@ -682,7 +746,7 @@ begin
682746
683747
684748 // Install Vagrant
685- ShellExec(' ' , ' msiexec' , ExpandConstant(' /i {tmp}\vagrant_1.7.4.msi INSTALLDIR ="{app}\Vagrant" /passive /norestart' ),
749+ ShellExec(' ' , ' msiexec' , ExpandConstant(' /i {tmp}\vagrant_1.7.4.msi VAGRANTAPPDIR ="{app}\Vagrant" /passive /norestart' ),
686750 ' ' , SW_SHOW, ewWaitUntilTerminated, ErrorCode);
687751 end ;
688752
@@ -784,16 +848,16 @@ begin
784848
785849 // Zulu
786850 // idpSetOption('Referer', 'http://www.azulsystems.com/products/zulu/downloads');
787- // 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'));
788- 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' ));
851+ 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' ));
852+ // 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'));
789853
790854 // VirtualBox
791- // 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'));
792- idpAddFile(' http://192.168.1.114/~shane/VirtualBox-5.0.2-102096-Win.exe' , ExpandConstant(' {tmp}\VirtualBox-5.0.2-102096-Win.exe' ));
855+ 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' ));
856+ // idpAddFile('http://192.168.1.114/~shane/VirtualBox-5.0.2-102096-Win.exe', ExpandConstant('{tmp}\VirtualBox-5.0.2-102096-Win.exe'));
793857
794858 // Vagrant
795- // idpAddFile('https://dl.bintray.com/mitchellh/vagrant/vagrant_1.7.4.msi', ExpandConstant('{tmp}\vagrant_1.7.4.msi'));
796- idpAddFile(' http://192.168.1.114/~shane/vagrant_1.7.4.msi' , ExpandConstant(' {tmp}\vagrant_1.7.4.msi' ));
859+ idpAddFile(' https://dl.bintray.com/mitchellh/vagrant/vagrant_1.7.4.msi' , ExpandConstant(' {tmp}\vagrant_1.7.4.msi' ));
860+ // idpAddFile('http://192.168.1.114/~shane/vagrant_1.7.4.msi', ExpandConstant('{tmp}\vagrant_1.7.4.msi'));
797861
798862 idpDownloadAfter(wpReady);
799863
0 commit comments