Subject: [PATCH] 23707
---
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
diff --git a/src/org/openstreetmap/josm/gui/preferences/server/AuthenticationPreferencesPanel.java b/src/org/openstreetmap/josm/gui/preferences/server/AuthenticationPreferencesPanel.java
|
a
|
b
|
|
| 17 | 17 | import javax.swing.JPanel; |
| 18 | 18 | import javax.swing.JRadioButton; |
| 19 | 19 | |
| 20 | | import org.openstreetmap.josm.actions.ExpertToggleAction; |
| 21 | 20 | import org.openstreetmap.josm.data.UserIdentityManager; |
| 22 | 21 | import org.openstreetmap.josm.data.oauth.OAuthAccessTokenHolder; |
| 23 | 22 | import org.openstreetmap.josm.data.oauth.OAuthVersion; |
| … |
… |
|
| 47 | 46 | /** the panel for the OAuth 2.0 authentication parameters */ |
| 48 | 47 | private OAuthAuthenticationPreferencesPanel pnlOAuth20Preferences; |
| 49 | 48 | |
| 50 | | /** Used to determine which API we are using for disabling/enabling Basic Auth/OAuth 1.0a */ |
| 51 | | private String apiUrl = OsmApi.getOsmApi().getServerUrl(); |
| 52 | | /** ExpertToggleAction uses weak references; we don't want this listener to be garbage collected */ |
| 53 | | private final ExpertToggleAction.ExpertModeChangeListener expertModeChangeListener = isExpert -> { |
| 54 | | final String authMethod = OsmApi.getAuthMethod(); |
| 55 | | final boolean defaultApi = JosmUrls.getInstance().getDefaultOsmApiUrl().equals(apiUrl); |
| 56 | | rbBasicAuthentication.setEnabled(rbBasicAuthentication.isSelected() || "basic".equals(authMethod) || isExpert || !defaultApi); |
| 57 | | }; |
| 58 | | |
| 59 | 49 | /** |
| 60 | 50 | * Constructs a new {@code AuthenticationPreferencesPanel}. |
| 61 | 51 | */ |
| … |
… |
|
| 108 | 98 | pnlBasicAuthPreferences = new BasicAuthenticationPreferencesPanel(); |
| 109 | 99 | pnlOAuth20Preferences = new OAuthAuthenticationPreferencesPanel(OAuthVersion.OAuth20); |
| 110 | 100 | |
| 111 | | ExpertToggleAction.addExpertModeChangeListener(expertModeChangeListener, true); |
| 112 | | |
| 113 | 101 | pnlAuthenticationParameters.add(pnlOAuth20Preferences, BorderLayout.CENTER); |
| | 102 | this.updateAcceptableAuthenticationMethods(OsmApi.getOsmApi().getServerUrl()); |
| 114 | 103 | } |
| 115 | 104 | |
| 116 | 105 | /** |
| … |
… |
|
| 166 | 155 | UserIdentityManager.getInstance().setAnonymous(); |
| 167 | 156 | } |
| 168 | 157 | } |
| 169 | | ExpertToggleAction.removeExpertModeChangeListener(this.expertModeChangeListener); |
| 170 | 158 | } |
| 171 | 159 | |
| 172 | 160 | /** |
| … |
… |
|
| 195 | 183 | pnlOAuth20Preferences.propertyChange(evt); |
| 196 | 184 | } |
| 197 | 185 | if (OsmApiUrlInputPanel.API_URL_PROP.equals(evt.getPropertyName())) { |
| 198 | | this.apiUrl = (String) evt.getNewValue(); |
| 199 | | this.expertModeChangeListener.expertChanged(ExpertToggleAction.isExpert()); |
| | 186 | this.updateAcceptableAuthenticationMethods((String) evt.getNewValue()); |
| 200 | 187 | } |
| 201 | 188 | } |
| | 189 | |
| | 190 | /** |
| | 191 | * Update the acceptable authentications methods |
| | 192 | * @param apiUrl The API url to check |
| | 193 | */ |
| | 194 | private void updateAcceptableAuthenticationMethods(String apiUrl) { |
| | 195 | final String authMethod = OsmApi.getAuthMethod(); |
| | 196 | final boolean defaultApi = JosmUrls.getInstance().getDefaultOsmApiUrl().equals(apiUrl); |
| | 197 | rbBasicAuthentication.setEnabled(rbBasicAuthentication.isSelected() || "basic".equals(authMethod) || !defaultApi); |
| | 198 | } |
| | 199 | |
| 202 | 200 | } |
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
diff --git a/src/org/openstreetmap/josm/data/Preferences.java b/src/org/openstreetmap/josm/data/Preferences.java
|
a
|
b
|
|
| 37 | 37 | |
| 38 | 38 | import org.openstreetmap.josm.data.preferences.ColorInfo; |
| 39 | 39 | import org.openstreetmap.josm.data.preferences.JosmBaseDirectories; |
| | 40 | import org.openstreetmap.josm.data.preferences.JosmUrls; |
| 40 | 41 | import org.openstreetmap.josm.data.preferences.NamedColorProperty; |
| 41 | 42 | import org.openstreetmap.josm.data.preferences.PreferencesReader; |
| 42 | 43 | import org.openstreetmap.josm.data.preferences.PreferencesWriter; |
| 43 | 44 | import org.openstreetmap.josm.gui.MainApplication; |
| 44 | 45 | import org.openstreetmap.josm.io.NetworkManager; |
| | 46 | import org.openstreetmap.josm.io.OsmApi; |
| 45 | 47 | import org.openstreetmap.josm.spi.preferences.AbstractPreferences; |
| 46 | 48 | import org.openstreetmap.josm.spi.preferences.Config; |
| 47 | 49 | import org.openstreetmap.josm.spi.preferences.DefaultPreferenceChangeEvent; |
| … |
… |
|
| 910 | 912 | } |
| 911 | 913 | modifiedDefault = false; |
| 912 | 914 | } |
| | 915 | // As of June 1st, 2024, the OSM.org instance no longer allows basic authentication. |
| | 916 | if (JosmUrls.getInstance().getDefaultOsmApiUrl().equals(OsmApi.getOsmApi().getServerUrl()) && "basic".equals(OsmApi.getAuthMethod())) { |
| | 917 | put("osm-server.auth-method", null); |
| | 918 | put("osm-server.username", null); |
| | 919 | put("osm-server.password", null); |
| | 920 | } |
| 913 | 921 | } |
| 914 | 922 | |
| 915 | 923 | /** |