- Timestamp:
- 2020-05-16T16:38:31+02:00 (5 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/preferences/server/OAuthAuthenticationPreferencesPanel.java
r14977 r16422 34 34 import org.openstreetmap.josm.io.OsmApi; 35 35 import org.openstreetmap.josm.io.auth.CredentialsManager; 36 import org.openstreetmap.josm.tools.GBC; 36 37 import org.openstreetmap.josm.tools.ImageProvider; 37 38 import org.openstreetmap.josm.tools.Logging; … … 47 48 */ 48 49 public class OAuthAuthenticationPreferencesPanel extends JPanel implements PropertyChangeListener { 49 private final JCheckBox cbShowAdvancedParameters = new JCheckBox(); 50 private final JCheckBox cbUseForAllRequests = new JCheckBox(); 51 private final JCheckBox cbShowAdvancedParameters = new JCheckBox(tr("Display Advanced OAuth Parameters")); 50 52 private final JCheckBox cbSaveToPreferences = new JCheckBox(tr("Save to preferences")); 51 53 private final JPanel pnlAuthorisationMessage = new JPanel(new BorderLayout()); … … 70 72 protected JPanel buildAdvancedPropertiesPanel() { 71 73 JPanel pnl = new JPanel(new GridBagLayout()); 72 GridBagConstraints gc = new GridBagConstraints(); 73 74 gc.anchor = GridBagConstraints.NORTHWEST; 75 gc.fill = GridBagConstraints.HORIZONTAL; 76 gc.weightx = 0.0; 77 gc.insets = new Insets(0, 0, 0, 3); 78 pnl.add(cbShowAdvancedParameters, gc); 74 75 cbUseForAllRequests.setText(tr("Use OAuth for all requests to {0}", OsmApi.getOsmApi().getServerUrl())); 76 cbUseForAllRequests.setToolTipText(tr("For user-based bandwith limit instead of IP-based one")); 77 pnl.add(cbUseForAllRequests, GBC.eol().fill(GBC.HORIZONTAL)); 78 79 pnl.add(cbShowAdvancedParameters, GBC.eol().fill(GBC.HORIZONTAL)); 79 80 cbShowAdvancedParameters.setSelected(false); 80 81 cbShowAdvancedParameters.addItemListener( … … 82 83 ); 83 84 84 gc.gridx = 1; 85 gc.weightx = 1.0; 86 JMultilineLabel lbl = new JMultilineLabel(tr("Display Advanced OAuth Parameters")); 87 lbl.setFont(lbl.getFont().deriveFont(Font.PLAIN)); 88 pnl.add(lbl, gc); 89 90 gc.gridy = 1; 91 gc.gridx = 1; 92 gc.insets = new Insets(3, 0, 3, 0); 93 gc.fill = GridBagConstraints.BOTH; 94 gc.weightx = 1.0; 95 gc.weighty = 1.0; 96 pnl.add(pnlAdvancedProperties, gc); 85 pnl.add(pnlAdvancedProperties, GBC.eol().fill(GBC.HORIZONTAL).insets(0, 3, 0, 0)); 97 86 pnlAdvancedProperties.initialize(OsmApi.getOsmApi().getServerUrl()); 98 87 pnlAdvancedProperties.setBorder( … … 153 142 public void initFromPreferences() { 154 143 setApiUrl(OsmApi.getOsmApi().getServerUrl().trim()); 144 cbUseForAllRequests.setSelected(OsmApi.USE_OAUTH_FOR_ALL_REQUESTS.get()); 155 145 refreshView(); 156 146 } … … 162 152 OAuthAccessTokenHolder.getInstance().setSaveToPreferences(cbSaveToPreferences.isSelected()); 163 153 OAuthAccessTokenHolder.getInstance().save(CredentialsManager.getInstance()); 154 OsmApi.USE_OAUTH_FOR_ALL_REQUESTS.put(cbUseForAllRequests.isSelected()); 164 155 pnlAdvancedProperties.rememberPreferences(); 165 156 } -
trunk/src/org/openstreetmap/josm/io/OsmApi.java
r15969 r16422 31 31 import org.openstreetmap.josm.data.osm.OsmPrimitive; 32 32 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 33 import org.openstreetmap.josm.data.preferences.BooleanProperty; 33 34 import org.openstreetmap.josm.gui.progress.NullProgressMonitor; 34 35 import org.openstreetmap.josm.gui.progress.ProgressMonitor; … … 69 70 */ 70 71 public static final int MAX_DOWNLOAD_THREADS = 2; 72 73 /** 74 * Defines whether all OSM API requests should be signed with an OAuth token (user-based bandwith limit instead of IP-based one) 75 */ 76 public static final BooleanProperty USE_OAUTH_FOR_ALL_REQUESTS = new BooleanProperty("oauth.use-for-all-requests", true); 71 77 72 78 // The collection of instantiated OSM APIs -
trunk/src/org/openstreetmap/josm/io/OsmServerReader.java
r15969 r16422 50 50 public OsmServerReader() { 51 51 try { 52 doAuthenticate = OsmApi.isUsingOAuth() && CredentialsManager.getInstance().lookupOAuthAccessToken() != null; 52 doAuthenticate = OsmApi.isUsingOAuth() 53 && CredentialsManager.getInstance().lookupOAuthAccessToken() != null 54 && OsmApi.USE_OAUTH_FOR_ALL_REQUESTS.get(); 53 55 } catch (CredentialsAgentException e) { 54 56 Logging.warn(e);
Note:
See TracChangeset
for help on using the changeset viewer.