Changeset 17621

Show
Ignore:
Timestamp:
28.10.2008 19:04:39 (11 years ago)
Author:
ak19
Message:

Correction to previous changes I made to GAuthenticator: it now only uses any previously stored values for username and password when the GAuthenticator operates in the new DOWNLOAD mode, which is set (and soon thereafter restored to the default REGULAR mode) in DownloadPane?.java for (wget) downloads.

Location:
gli/trunk/src/org/greenstone/gatherer
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • gli/trunk/src/org/greenstone/gatherer/GAuthenticator.java

    r17551 r17621  
    6868    /** The default size of this dialog. */ 
    6969    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     
    7182    /** Constructor. */ 
    7283    public GAuthenticator() { 
     
    7990     */ 
    8091    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()); 
    96110        } 
    97         return new PasswordAuthentication(username_str, password_str.toCharArray()); 
    98111    } 
    99112     
  • gli/trunk/src/org/greenstone/gatherer/gui/DownloadPane.java

    r17282 r17621  
    634634         
    635635            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); 
    636639        while(count < 3 && (user_pass = (String) GAuthenticator.authentications.get(address)) == null) { 
    637640        Authenticator.requestPasswordAuthentication(proxy_host, null, Integer.parseInt(proxy_port), "http://", Dictionary.get("WGet.Prompt"), "HTTP"); 
    638641        count++; 
    639642        } 
    640  
     643        GAuthenticator.setMode(GAuthenticator.REGULAR); // reset the state to default (of how the authentication popup functions) 
    641644        if(count >= 3) { 
    642645        return false;