Skip to content

Commit ef092ca

Browse files
committed
Got the jbds download to finally work, although it's messy...
1 parent db04a4a commit ef092ca

13 files changed

Lines changed: 68 additions & 13 deletions

File tree

windows/developer_platform_installer.iss

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ AppUpdatesURL={#AppURL}
2121
CreateAppDir=yes
2222
DefaultDirName={pf}\{#AppName}
2323
DefaultGroupName={#AppName}
24-
OutputBaseFilename=developer_platform
24+
OutputBaseFilename=developer_platform_setup
2525
Compression=lzma
2626
SolidCompression=yes
2727
;WizardSmallImageFile=blank.bmp
@@ -34,7 +34,7 @@ DisableFinishedPage=yes
3434
ExtraDiskSpaceRequired=1048576
3535

3636
[Files]
37-
Source: "EfTidy.dll"; Flags: dontcopy
37+
Source: "EfTidy.dll"; Flags: dontcopy;
3838

3939
#include "idp_source\idp.iss"
4040

@@ -68,6 +68,9 @@ type
6868
RelayState: String;
6969
end;
7070
71+
const
72+
JBDS_URL = 'https://access.redhat.com/jbossnetwork/restricted/softwareDownload.html?softwareId=40371';
73+
7174
var
7275
// Page IDs
7376
AuthPageID, ComponentPageID, DownloadPageID, GetStartedPageID, InstallPageID : Integer;
@@ -89,8 +92,8 @@ var
8992
// Flag indicating whether the user has authenticated successfully
9093
IsAuthenticated: Boolean;
9194
92-
// rh_sso cookie value for downloading JBDS
93-
RHSSOCookieValue: String;
95+
// cookie values for downloading JBDS
96+
RHSSOCookieValue, JSessionIdCookieValue: String;
9497
9598
// Converts a color String in the format '$rrggbb' to a TColor value
9699
function StringToColor(Color: String): TColor;
@@ -279,11 +282,8 @@ begin
279282
AuthLabel.Visible := True;
280283
AuthLabel.Refresh;
281284
282-
//Resource := 'https://access.redhat.com/jbossnetwork/restricted/listSoftware.html?product=jbossdeveloperstudio&downloadType=distributions';
283-
Resource := 'https://access.redhat.com/jbossnetwork/restricted/softwareDownload.html?softwareId=40371';
284-
285285
Url := 'https://idp.redhat.com/idp/authUser?j_username=' + UsernameEdit.Text + '&j_password=' + PasswordEdit.Text +
286-
'&redirect=' + Resource;
286+
'&redirect=' + JBDS_URL;
287287
288288
// Perform a SAML authentication for redhat.com
289289
WinHttpReq := CreateOleObject('WinHttp.WinHttpRequest.5.1');
@@ -296,6 +296,9 @@ begin
296296
297297
WinHttpReq.Send();
298298
299+
// Extract the JSESSIONID cookie
300+
JSessionIdCookieValue := 'JSESSIONID=' + GetCookieValue(WinHttpReq.getResponseHeader('Set-Cookie'), 'JSESSIONID');
301+
299302
if WinHttpReq.Status <> 200 then
300303
begin
301304
AuthLabel.Caption := 'Authentication Failed.';
@@ -376,8 +379,13 @@ begin
376379
AuthLabel.Font.Color := clRed;
377380
Exit;
378381
end else begin
379-
RHSSOCookieValue := GetCookieValue(WinHttpReq.getResponseHeader('Set-Cookie'), 'rh_sso')
382+
RHSSOCookieValue := 'rh_sso=' + GetCookieValue(WinHttpReq.getResponseHeader('Set-Cookie'), 'rh_sso');
380383
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+
381389
end;
382390
end;
383391
@@ -1026,15 +1034,15 @@ begin
10261034
10271035
// Zulu
10281036
//idpSetOption('Referer', 'http://www.azulsystems.com/products/zulu/downloads');
1029-
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'));
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'));
10301038
//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'));
10311039
10321040
// VirtualBox
1033-
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'));
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'));
10341042
//idpAddFile('http://192.168.1.114/~shane/VirtualBox-5.0.2-102096-Win.exe', ExpandConstant('{tmp}\VirtualBox-5.0.2-102096-Win.exe'));
10351043
10361044
// Vagrant
1037-
idpAddFile('https://dl.bintray.com/mitchellh/vagrant/vagrant_1.7.4.msi', ExpandConstant('{tmp}\vagrant_1.7.4.msi'));
1045+
//idpAddFile('https://dl.bintray.com/mitchellh/vagrant/vagrant_1.7.4.msi', ExpandConstant('{tmp}\vagrant_1.7.4.msi'));
10381046
//idpAddFile('http://192.168.1.114/~shane/vagrant_1.7.4.msi', ExpandConstant('{tmp}\vagrant_1.7.4.msi'));
10391047
10401048
idpDownloadAfter(wpReady);

windows/idp_source/ansi/idp.dll

1.4 MB
Binary file not shown.

windows/idp_source/idp.iss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ Source: "{#IDPDLLDIR}\idp.dll"; Flags: dontcopy;
4040

4141
[Code]
4242
procedure idpAddFile(url, filename: String); external 'idpAddFile@files:idp.dll cdecl';
43+
procedure idpSetCookie(url, cookiename, cookievalue: String); external 'idpSetCookie@files:idp.dll cdecl';
4344
procedure idpAddFileComp(url, filename, components: String); external 'idpAddFileComp@files:idp.dll cdecl';
4445
procedure idpAddMirror(url, mirror: String); external 'idpAddMirror@files:idp.dll cdecl';
4546
procedure idpAddFtpDir(url, mask, destdir: String; recursive: Boolean); external 'idpAddFtpDir@files:idp.dll cdecl';

windows/idp_source/idp/downloader.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ void Downloader::addFile(tstring url, tstring filename, DWORDLONG size, tstring
6262
}
6363
}
6464

65+
void Downloader::setCookie(tstring url, tstring domainUrl, tstring cookieValue)
66+
{
67+
files[url]->url.setCookie(domainUrl, cookieValue);
68+
}
69+
6570
void Downloader::addMirror(tstring url, tstring mirror)
6671
{
6772
mirrors.insert(pair<tstring, tstring>(url, mirror));

windows/idp_source/idp/downloader.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class Downloader
2828
~Downloader();
2929

3030
void addFile(tstring url, tstring filename, DWORDLONG size = FILE_SIZE_UNKNOWN, tstring comp = _T(""));
31+
void setCookie(tstring url, tstring domainUrl, tstring cookieValue);
3132
void addFtpDir(tstring url, tstring mask, tstring destdir, bool recursive, tstring comp = _T(""));
3233
void addMirror(tstring url, tstring mirror);
3334
void setMirrorList(Downloader *d);

windows/idp_source/idp/idp.aps

21 KB
Binary file not shown.

windows/idp_source/idp/idp.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ void idpAddFile(_TCHAR *url, _TCHAR *filename)
1212
downloader.addFile(STR(url), STR(filename));
1313
}
1414

15+
void idpSetCookie(_TCHAR *url, _TCHAR *domainurl, _TCHAR *cookievalue)
16+
{
17+
downloader.setCookie(STR(url), STR(domainurl), STR(cookievalue));
18+
}
19+
1520
void idpAddFileSize(_TCHAR *url, _TCHAR *filename, DWORDLONG filesize)
1621
{
1722
downloader.addFile(STR(url), STR(filename), filesize);

windows/idp_source/idp/idp.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
LIBRARY "idp"
22
EXPORTS
33
idpAddFile
4+
idpSetCookie
45
idpAddFileSize
56
idpAddFileComp
67
idpAddFileSizeComp

windows/idp_source/idp/idp.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
extern "C"
88
{
99
void idpAddFile(_TCHAR *url, _TCHAR *filename);
10+
void idpSetCookie(_TCHAR *url, _TCHAR *domainurl, _TCHAR *cookievalue);
1011
void idpAddFileSize(_TCHAR *url, _TCHAR *filename, DWORDLONG size);
1112
void idpAddFileSize32(_TCHAR *url, _TCHAR *filename, DWORD size);
1213
void idpAddFileComp(_TCHAR *url, _TCHAR *filename, _TCHAR *components);

windows/idp_source/idp/url.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@ HINTERNET Url::connect(HINTERNET internet)
8383
return connection;
8484
}
8585

86+
void Url::setCookie(tstring domainUrl, tstring value)
87+
{
88+
cookies.insert(pair<tstring, tstring>(domainUrl, value));
89+
}
90+
8691
HINTERNET Url::open(HINTERNET internet, const _TCHAR *httpVerb)
8792
{
8893
LPCTSTR acceptTypes[] = { _T("*/*"), NULL };
@@ -107,9 +112,20 @@ HINTERNET Url::open(HINTERNET internet, const _TCHAR *httpVerb)
107112

108113
tstring fullUrl = urlPath;
109114
fullUrl += extraInfo;
115+
116+
for (multimap<tstring, tstring>::iterator i = cookies.begin(); i != cookies.end(); i++)
117+
{
118+
tstring domainUrl = (*i).first;
119+
tstring cookievalue = (*i).second;
120+
InternetSetCookie(TEXT(domainUrl.c_str()), NULL, TEXT(cookievalue.c_str()));
121+
}
122+
110123
TRACE(_T("Opening %s..."), fullUrl.c_str());
111124
filehandle = HttpOpenRequest(connection, httpVerb, fullUrl.c_str(), NULL, internetOptions.hasReferer() ? internetOptions.referer.c_str() : NULL, acceptTypes, flags, NULL);
112125

126+
DWORD dwTimeout = 600 * 1000; // Timeout in milliseconds - 10 minutes
127+
128+
InternetSetOption(filehandle, INTERNET_OPTION_RECEIVE_TIMEOUT, &dwTimeout, sizeof(DWORD));
113129
retry:
114130
TRACE(_T("Sending request..."));
115131
if(!HttpSendRequest(filehandle, NULL, 0, NULL, 0))

0 commit comments

Comments
 (0)