- Timestamp:
- 2008-10-28T19:04:39+13:00 (15 years ago)
- Location:
- gli/trunk/src/org/greenstone/gatherer
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
gli/trunk/src/org/greenstone/gatherer/GAuthenticator.java
r17551 r17621 68 68 /** The default size of this dialog. */ 69 69 static final private Dimension SIZE = new Dimension(470,160); 70 70 71 /** For Wget downloads, we want to avoid the second automatic request for proxy authentication 72 * But the settings for that specific case will otherwise interfere with how this GAuthenticator 73 * is to function in the usual situation. For this reason, we use two modes.*/ 74 static final public int REGULAR = 0; 75 static final public int DOWNLOAD = 1; 76 static private int operationMode = REGULAR; 77 78 public static void setMode(int mode) { 79 operationMode = mode; 80 } 81 71 82 /** Constructor. */ 72 83 public GAuthenticator() { … … 79 90 */ 80 91 protected PasswordAuthentication getPasswordAuthentication(String username_str, String password_str) { 81 82 // Don't prompt if the details were already saved for the same host and port. This is necessary 83 // when running wget because wget requires proxy authentication. And without the following, the 84 // regular proxy authentication would also popup a dialog requesting the same information. 85 86 String key = getRequestingHost() + ":" + getRequestingPort(); 87 String value = (String)authentications.get(key); 88 89 if(value != null) { // authentication for this host and port was already stored 90 // Arguments may be null. If so, retrieve them from the stored value 91 if(username_str == null) { 92 username_str = value.substring(0, value.indexOf("@")); 93 } 94 if(password_str == null) { 95 password_str = value.substring(value.indexOf("@") + 1); 92 if(operationMode == DOWNLOAD) { // special handling of proxy authentication popup for Wget downloads 93 94 // Don't prompt if the details were already saved for the same host and port. This is necessary 95 // when running wget because wget requires proxy authentication. And without the following, the 96 // regular proxy authentication would also popup a dialog requesting the same information. 97 98 String key = getRequestingHost() + ":" + getRequestingPort(); 99 String value = (String)authentications.get(key); 100 101 if(value != null) { // authentication for this host and port was already stored 102 // Arguments may be null. If so, retrieve them from the stored value 103 if(username_str == null) { 104 username_str = value.substring(0, value.indexOf("@")); 105 } 106 if(password_str == null) { 107 password_str = value.substring(value.indexOf("@") + 1); 108 } 109 return new PasswordAuthentication(username_str, password_str.toCharArray()); 96 110 } 97 return new PasswordAuthentication(username_str, password_str.toCharArray());98 111 } 99 112 -
gli/trunk/src/org/greenstone/gatherer/gui/DownloadPane.java
r17282 r17621 634 634 635 635 int count = 0; 636 // Only for wget, need to avoid a second automatic authentication popup (first asks 637 // the proxy authentication for wget, and the second will ask the same for the realm) 638 GAuthenticator.setMode(GAuthenticator.DOWNLOAD); 636 639 while(count < 3 && (user_pass = (String) GAuthenticator.authentications.get(address)) == null) { 637 640 Authenticator.requestPasswordAuthentication(proxy_host, null, Integer.parseInt(proxy_port), "http://", Dictionary.get("WGet.Prompt"), "HTTP"); 638 641 count++; 639 642 } 640 643 GAuthenticator.setMode(GAuthenticator.REGULAR); // reset the state to default (of how the authentication popup functions) 641 644 if(count >= 3) { 642 645 return false;
Note:
See TracChangeset
for help on using the changeset viewer.