Skip to content

Commit

Permalink
[JENKINS-47448] Make JDKInstaller work for old login site as well (#3136
Browse files Browse the repository at this point in the history
)

* Fix JDKInstaller to work with old and new Oracle login flow

* Update Javadoc to explain that both login flows are supported
  • Loading branch information
dwnusbaum authored and oleg-nenashev committed Nov 12, 2017
1 parent 1734bf7 commit 5c1fd7d
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions core/src/main/java/hudson/tools/JDKInstaller.java
Expand Up @@ -477,17 +477,22 @@ public URL locate(TaskListener log, Platform platform, CPU cpu) throws IOExcepti
throw new IOException("Failed to request " + m.getURI() +" exit code="+r);

if (m.getURI().getHost().equals("login.oracle.com")) {
/* Login flow:
/* Oracle switched from old to new, and then back to old. This code should work for either.
* Old Login flow:
* 1. /mysso/signon.jsp: Form for username + password: Submit actions is:
* 2. /oam/server/sso/auth_cred_submit: Returns a 302 to:
* 3. https://edelivery.oracle.com/osso_login_success: Returns a 302 to the download.
* New Login flow:
* 1. /oaam_server/oamLoginPage.jsp: Form for username + password. Submit action is:
* 2. /oaam_server/login.do: Returns a 302 to:
* 3. /oaam_server/loginAuth.do: After 2 seconds, JS sets window.location to:
* 4. /oaam_server/authJump.do: Contains a single form with hidden inputs and JS that submits the form to:
* 5. /oam/server/dap/cred_submit: Returns a 302 to:
* 6. https://edelivery.oracle.com/osso_login_success: Returns a 302 to the download.
*/
if (m.getURI().getPath().contains("/loginAuth.do")) { // You are redirected to this page immediately after logging in.
if (m.getURI().getPath().contains("/loginAuth.do")) {
try {
Thread.sleep(2000); // Oracle website waits 2 seconds after logging in before redirecting.
Thread.sleep(2000);
m.releaseConnection();
m = new GetMethod(new URI(m.getURI(), "/oaam_server/authJump.do?jump=false", true).toString());
continue;
Expand Down Expand Up @@ -523,9 +528,9 @@ public URL locate(TaskListener log, Platform platform, CPU cpu) throws IOExcepti
String n = extractAttribute(fragment,"name");
String v = extractAttribute(fragment,"value");
if (n==null || v==null) continue;
if (n.equals("userid"))
if (n.equals("userid") || n.equals("ssousername"))
v = u;
if (n.equals("pass")) {
if (n.equals("pass") || n.equals("password")) {
v = p.getPlainText();
if (authCount++ > 3) {
log.hyperlink(getCredentialPageUrl(),"Your Oracle account doesn't appear valid. Please specify a valid username/password\n");
Expand Down

0 comments on commit 5c1fd7d

Please sign in to comment.