- Timestamp:
- 2009-01-12T11:19:54+13:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gli/branches/rtl-gli/src/org/greenstone/gatherer/GAuthenticator.java
r14567 r18363 42 42 import java.util.*; 43 43 import javax.swing.*; 44 45 44 46 import org.greenstone.gatherer.gui.GLIButton; 47 45 48 46 49 /** Provides a graphic authenticator for network password requests. … … 65 68 /** The default size of this dialog. */ 66 69 static final private Dimension SIZE = new Dimension(470,160); 67 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 68 82 /** Constructor. */ 69 83 public GAuthenticator() { … … 75 89 * @see org.greenstone.gatherer.GAuthenticator.RequestFocusListener 76 90 */ 77 protected PasswordAuthentication getPasswordAuthentication() { 91 protected PasswordAuthentication getPasswordAuthentication(String username_str, String password_str) { 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 operationMode = REGULAR; // reset the state of the Authenticator to normal mode 110 return new PasswordAuthentication(username_str, password_str.toCharArray()); 111 } 112 } 113 78 114 // Component definition. 79 115 dialog = new JDialog (Gatherer.g_man, Dictionary.get("GAuthenticator.Title"), true); … … 82 118 JPanel content_pane = (JPanel) dialog.getContentPane(); 83 119 JLabel title_label = new JLabel(getMessageString()); 120 84 121 JPanel user_panel = new JPanel(); 85 122 JLabel username_label = new JLabel(Dictionary.get("GAuthenticator.Username")); 86 123 JTextField username = new JTextField(); 87 124 username.setToolTipText(Dictionary.get("GAuthenticator.Username_Tooltip")); 125 if (username_str != null) { 126 username.setText(username_str); 127 } 128 88 129 JPanel password_panel = new JPanel(); 89 130 JLabel password_label = new JLabel(Dictionary.get("GAuthenticator.Password")); … … 91 132 password.setEchoChar('*'); 92 133 password.setToolTipText(Dictionary.get("GAuthenticator.Password_Tooltip")); 134 if (password_str != null) { 135 password.setText(password_str); 136 } 137 93 138 JPanel button_panel = new JPanel(); 94 139 ok_button = new GLIButton(Dictionary.get("General.OK"), Dictionary.get("General.OK_Tooltip")); … … 134 179 } 135 180 181 protected PasswordAuthentication getPasswordAuthentication() { 182 return getPasswordAuthentication(null,null); 183 } 136 184 137 185 /** This is defined so it can be overridden by subclasses (getRequestingPrompt is final). */
Note:
See TracChangeset
for help on using the changeset viewer.