Subject: [PATCH] 23707
---
Index: src/org/openstreetmap/josm/gui/preferences/server/AuthenticationPreferencesPanel.java
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/src/org/openstreetmap/josm/gui/preferences/server/AuthenticationPreferencesPanel.java	(revision 86e4d775139717e88166dc0245ad517a409cb322)
+++ b/src/org/openstreetmap/josm/gui/preferences/server/AuthenticationPreferencesPanel.java	(date 1717427695825)
@@ -17,7 +17,6 @@
 import javax.swing.JPanel;
 import javax.swing.JRadioButton;
 
-import org.openstreetmap.josm.actions.ExpertToggleAction;
 import org.openstreetmap.josm.data.UserIdentityManager;
 import org.openstreetmap.josm.data.oauth.OAuthAccessTokenHolder;
 import org.openstreetmap.josm.data.oauth.OAuthVersion;
@@ -47,15 +46,6 @@
     /** the panel for the OAuth 2.0 authentication parameters */
     private OAuthAuthenticationPreferencesPanel pnlOAuth20Preferences;
 
-    /** Used to determine which API we are using for disabling/enabling Basic Auth/OAuth 1.0a */
-    private String apiUrl = OsmApi.getOsmApi().getServerUrl();
-    /** ExpertToggleAction uses weak references; we don't want this listener to be garbage collected */
-    private final ExpertToggleAction.ExpertModeChangeListener expertModeChangeListener = isExpert -> {
-        final String authMethod = OsmApi.getAuthMethod();
-        final boolean defaultApi = JosmUrls.getInstance().getDefaultOsmApiUrl().equals(apiUrl);
-        rbBasicAuthentication.setEnabled(rbBasicAuthentication.isSelected() || "basic".equals(authMethod) || isExpert || !defaultApi);
-    };
-
     /**
      * Constructs a new {@code AuthenticationPreferencesPanel}.
      */
@@ -108,9 +98,8 @@
         pnlBasicAuthPreferences = new BasicAuthenticationPreferencesPanel();
         pnlOAuth20Preferences = new OAuthAuthenticationPreferencesPanel(OAuthVersion.OAuth20);
 
-        ExpertToggleAction.addExpertModeChangeListener(expertModeChangeListener, true);
-
         pnlAuthenticationParameters.add(pnlOAuth20Preferences, BorderLayout.CENTER);
+        this.updateAcceptableAuthenticationMethods(OsmApi.getOsmApi().getServerUrl());
     }
 
     /**
@@ -166,7 +155,6 @@
                 UserIdentityManager.getInstance().setAnonymous();
             }
         }
-        ExpertToggleAction.removeExpertModeChangeListener(this.expertModeChangeListener);
     }
 
     /**
@@ -195,8 +183,18 @@
             pnlOAuth20Preferences.propertyChange(evt);
         }
         if (OsmApiUrlInputPanel.API_URL_PROP.equals(evt.getPropertyName())) {
-            this.apiUrl = (String) evt.getNewValue();
-            this.expertModeChangeListener.expertChanged(ExpertToggleAction.isExpert());
+            this.updateAcceptableAuthenticationMethods((String) evt.getNewValue());
         }
     }
+
+    /**
+     * Update the acceptable authentications methods
+     * @param apiUrl The API url to check
+     */
+    private void updateAcceptableAuthenticationMethods(String apiUrl) {
+        final String authMethod = OsmApi.getAuthMethod();
+        final boolean defaultApi = JosmUrls.getInstance().getDefaultOsmApiUrl().equals(apiUrl);
+        rbBasicAuthentication.setEnabled(rbBasicAuthentication.isSelected() || "basic".equals(authMethod) || !defaultApi);
+    }
+
 }
Index: src/org/openstreetmap/josm/data/Preferences.java
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/src/org/openstreetmap/josm/data/Preferences.java	(revision 86e4d775139717e88166dc0245ad517a409cb322)
+++ b/src/org/openstreetmap/josm/data/Preferences.java	(date 1717426977537)
@@ -37,11 +37,13 @@
 
 import org.openstreetmap.josm.data.preferences.ColorInfo;
 import org.openstreetmap.josm.data.preferences.JosmBaseDirectories;
+import org.openstreetmap.josm.data.preferences.JosmUrls;
 import org.openstreetmap.josm.data.preferences.NamedColorProperty;
 import org.openstreetmap.josm.data.preferences.PreferencesReader;
 import org.openstreetmap.josm.data.preferences.PreferencesWriter;
 import org.openstreetmap.josm.gui.MainApplication;
 import org.openstreetmap.josm.io.NetworkManager;
+import org.openstreetmap.josm.io.OsmApi;
 import org.openstreetmap.josm.spi.preferences.AbstractPreferences;
 import org.openstreetmap.josm.spi.preferences.Config;
 import org.openstreetmap.josm.spi.preferences.DefaultPreferenceChangeEvent;
@@ -910,6 +912,12 @@
             }
             modifiedDefault = false;
         }
+        // As of June 1st, 2024, the OSM.org instance no longer allows basic authentication.
+        if (JosmUrls.getInstance().getDefaultOsmApiUrl().equals(OsmApi.getOsmApi().getServerUrl()) && "basic".equals(OsmApi.getAuthMethod())) {
+            put("osm-server.auth-method", null);
+            put("osm-server.username", null);
+            put("osm-server.password", null);
+        }
     }
 
     /**
