提交 9ddd3256 编写于 作者: K Kohsuke Kawaguchi

gracefully handle incorrect username/password

上级 19468588
......@@ -328,6 +328,8 @@ public class JDKInstaller extends ToolInstaller {
wc.setJavaScriptEnabled(false);
wc.setCssEnabled(false);
Page page = wc.getPage(src);
int authCount=0;
int totalPageCount=0;
while (page instanceof HtmlPage) {
// some times we are redirected to the SSO login page.
HtmlPage html = (HtmlPage) page;
......@@ -338,10 +340,13 @@ public class JDKInstaller extends ToolInstaller {
String u = getDescriptor().getUsername();
Secret p = getDescriptor().getPassword();
if (u==null || p==null) {
log.hyperlink("/"+getDescriptor().getDescriptorUrl(),"Oracle now requires Oracle account to download previous versions of JDK. Please specify your Oracle account username/password.");
log.hyperlink(getCredentialPageUrl(),"Oracle now requires Oracle account to download previous versions of JDK. Please specify your Oracle account username/password.");
throw new AbortException("Unable to install JDK unless a valid username/password is provided.");
}
if (totalPageCount>16) // looping too much
throw new IOException("Unable to find the login form in "+html.asXml());
try {
// JavaScript check page. Just submit and move on
HtmlForm loginForm = html.getFormByName("myForm");
......@@ -354,6 +359,10 @@ public class JDKInstaller extends ToolInstaller {
try {
// real authentication page
if (authCount++ > 3) {
log.hyperlink(getCredentialPageUrl(),"Your Oracle account doesn't appear valid. Please specify a valid username/password");
throw new AbortException("Unable to install JDK unless a valid username/password is provided.");
}
HtmlForm loginForm = html.getFormByName("LoginForm");
loginForm.getInputByName("ssousername").setValueAttribute(u);
loginForm.getInputByName("password").setValueAttribute(p.getPlainText());
......@@ -387,6 +396,10 @@ public class JDKInstaller extends ToolInstaller {
}
}
private String getCredentialPageUrl() {
return "/"+getDescriptor().getDescriptorUrl()+"/enterCredential";
}
public enum Preference {
PRIMARY, SECONDARY, UNACCEPTABLE
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册