Index: trunk/src/org/openstreetmap/josm/gui/io/CredentialDialog.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/io/CredentialDialog.java	(revision 4689)
+++ trunk/src/org/openstreetmap/josm/gui/io/CredentialDialog.java	(revision 4690)
@@ -42,12 +42,16 @@
 public class CredentialDialog extends JDialog {
 
-    static public CredentialDialog getOsmApiCredentialDialog(String username, String password, String saveUsernameAndPasswordCheckboxText) {
+    static public CredentialDialog getOsmApiCredentialDialog(String username, String password, String host, String saveUsernameAndPasswordCheckboxText) {
         CredentialDialog dialog = new CredentialDialog(saveUsernameAndPasswordCheckboxText);
-        dialog.prepareForOsmApiCredentials(username, password);
+        if(OsmApi.getOsmApi().getHost().equals(host)) {
+            dialog.prepareForOsmApiCredentials(username, password);
+        } else {
+            dialog.prepareForOtherHostCredentials(username, password, host);
+        }
         dialog.pack();
         return dialog;
     }
 
-    static public CredentialDialog getHttpProxyCredentialDialog(String username, String password, String saveUsernameAndPasswordCheckboxText) {
+    static public CredentialDialog getHttpProxyCredentialDialog(String username, String password, String host, String saveUsernameAndPasswordCheckboxText) {
         CredentialDialog dialog = new CredentialDialog(saveUsernameAndPasswordCheckboxText);
         dialog.prepareForProxyCredentials(username, password);
@@ -109,4 +113,11 @@
         setTitle(tr("Enter credentials for OSM API"));
         getContentPane().add(pnlCredentials = new OsmApiCredentialsPanel(this), BorderLayout.CENTER);
+        pnlCredentials.init(username, password);
+        validate();
+    }
+
+    public void prepareForOtherHostCredentials(String username, String password, String host) {
+        setTitle(tr("Enter credentials for host"));
+        getContentPane().add(pnlCredentials = new OtherHostCredentialsPanel(this, host), BorderLayout.CENTER);
         pnlCredentials.init(username, password);
         validate();
@@ -257,4 +268,26 @@
     }
 
+    private static class OtherHostCredentialsPanel extends CredentialPanel {
+
+        String host;
+
+        @Override
+        protected void build() {
+            super.build();
+            tfUserName.setToolTipText(tr("Please enter the user name of your account"));
+            tfPassword.setToolTipText(tr("Please enter the password of your account"));
+            lblHeading.setText(
+                    "<html>" + tr("Authenticating at the host ''{0}'' failed. Please enter a valid username and a valid password.",
+                            host) + "</html>");
+            lblWarning.setText(tr("Warning: The password is transferred unencrypted."));
+        }
+
+        public OtherHostCredentialsPanel(CredentialDialog owner, String host) {
+            super(owner);
+            this.host = host;
+            build();
+        }
+    }
+
     private static class HttpProxyCredentialsPanel extends CredentialPanel {
         @Override
Index: trunk/src/org/openstreetmap/josm/gui/oauth/FullyAutomaticAuthorizationUI.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/oauth/FullyAutomaticAuthorizationUI.java	(revision 4689)
+++ trunk/src/org/openstreetmap/josm/gui/oauth/FullyAutomaticAuthorizationUI.java	(revision 4690)
@@ -42,4 +42,5 @@
 import org.openstreetmap.josm.gui.widgets.SelectAllOnFocusGainedDecorator;
 import org.openstreetmap.josm.gui.widgets.VerticallyScrollablePanel;
+import org.openstreetmap.josm.io.OsmApi;
 import org.openstreetmap.josm.io.OsmTransferException;
 import org.openstreetmap.josm.io.auth.CredentialsAgent;
@@ -184,5 +185,5 @@
         CredentialsAgent cm = CredentialsManager.getInstance();
         try {
-            PasswordAuthentication pa = cm.lookup(RequestorType.SERVER);
+            PasswordAuthentication pa = cm.lookup(RequestorType.SERVER, OsmApi.getOsmApi().getHost());
             if (pa == null) {
                 tfUserName.setText("");
Index: trunk/src/org/openstreetmap/josm/gui/preferences/server/BasicAuthenticationPreferencesPanel.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/preferences/server/BasicAuthenticationPreferencesPanel.java	(revision 4689)
+++ trunk/src/org/openstreetmap/josm/gui/preferences/server/BasicAuthenticationPreferencesPanel.java	(revision 4690)
@@ -23,4 +23,5 @@
 import org.openstreetmap.josm.io.auth.CredentialsManager;
 import org.openstreetmap.josm.io.auth.JosmPreferencesCredentialAgent;
+import org.openstreetmap.josm.io.OsmApi;
 
 /**
@@ -94,5 +95,5 @@
             decorationPanel.removeAll();
             decorationPanel.add(cm.getPreferencesDecorationPanel(), BorderLayout.CENTER);
-            PasswordAuthentication pa = cm.lookup(RequestorType.SERVER);
+            PasswordAuthentication pa = cm.lookup(RequestorType.SERVER, OsmApi.getOsmApi().getHost());
             if (pa == null) {
                 tfOsmUserName.setText("");
@@ -118,5 +119,5 @@
                     tfOsmPassword.getPassword()
             );
-            cm.store(RequestorType.SERVER, pa);
+            cm.store(RequestorType.SERVER, OsmApi.getOsmApi().getHost(), pa);
         } catch(CredentialsAgentException e) {
             e.printStackTrace();
Index: trunk/src/org/openstreetmap/josm/gui/preferences/server/ProxyPreferencesPanel.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/preferences/server/ProxyPreferencesPanel.java	(revision 4689)
+++ trunk/src/org/openstreetmap/josm/gui/preferences/server/ProxyPreferencesPanel.java	(revision 4690)
@@ -325,5 +325,5 @@
         CredentialsAgent cm = CredentialsManager.getInstance();
         try {
-            PasswordAuthentication pa = cm.lookup(RequestorType.PROXY);
+            PasswordAuthentication pa = cm.lookup(RequestorType.PROXY, tfProxyHttpHost.getText());
             if (pa == null) {
                 tfProxyHttpUser.setText("");
@@ -404,5 +404,5 @@
                     tfProxyHttpPassword.getPassword()
             );
-            cm.store(RequestorType.PROXY, pa);
+            cm.store(RequestorType.PROXY, tfProxyHttpHost.getText(), pa);
         } catch(CredentialsAgentException e) {
             e.printStackTrace();
Index: trunk/src/org/openstreetmap/josm/io/OsmApi.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/OsmApi.java	(revision 4689)
+++ trunk/src/org/openstreetmap/josm/io/OsmApi.java	(revision 4690)
@@ -17,4 +17,5 @@
 import java.net.ConnectException;
 import java.net.HttpURLConnection;
+import java.net.MalformedURLException;
 import java.net.SocketTimeoutException;
 import java.net.URL;
@@ -141,4 +142,13 @@
     public String getVersion() {
         return version;
+    }
+
+    public String getHost() {
+        String host = null;
+        try {
+            host = (new URL(serverUrl)).getHost();
+        } catch (MalformedURLException e) {
+        }
+        return host;
     }
 
Index: trunk/src/org/openstreetmap/josm/io/OsmConnection.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/OsmConnection.java	(revision 4689)
+++ trunk/src/org/openstreetmap/josm/io/OsmConnection.java	(revision 4690)
@@ -77,5 +77,6 @@
         try {
             synchronized (CredentialsManager.getInstance()) {
-                response = CredentialsManager.getInstance().getCredentials(RequestorType.SERVER, false /* don't know yet whether the credentials will succeed */);
+                response = CredentialsManager.getInstance().getCredentials(RequestorType.SERVER,
+                con.getURL().getHost(), false /* don't know yet whether the credentials will succeed */);
             }
         } catch (CredentialsAgentException e) {
Index: trunk/src/org/openstreetmap/josm/io/auth/AbstractCredentialsAgent.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/auth/AbstractCredentialsAgent.java	(revision 4689)
+++ trunk/src/org/openstreetmap/josm/io/auth/AbstractCredentialsAgent.java	(revision 4690)
@@ -17,8 +17,8 @@
      */
     @Override
-    public CredentialsAgentResponse getCredentials(RequestorType requestorType, boolean noSuccessWithLastResponse) throws CredentialsAgentException{
+    public CredentialsAgentResponse getCredentials(RequestorType requestorType, String host, boolean noSuccessWithLastResponse) throws CredentialsAgentException{
         if (requestorType == null)
             return null;
-        PasswordAuthentication credentials =  lookup(requestorType);
+        PasswordAuthentication credentials =  lookup(requestorType, host);
         String username = (credentials == null || credentials.getUserName() == null) ? "" : credentials.getUserName();
         String password = (credentials == null || credentials.getPassword() == null) ? "" : String.valueOf(credentials.getPassword());
@@ -47,6 +47,6 @@
             CredentialDialog dialog = null;
             switch(requestorType) {
-            case SERVER: dialog = CredentialDialog.getOsmApiCredentialDialog(username, password, getSaveUsernameAndPasswordCheckboxText()); break;
-            case PROXY: dialog = CredentialDialog.getHttpProxyCredentialDialog(username, password, getSaveUsernameAndPasswordCheckboxText()); break;
+            case SERVER: dialog = CredentialDialog.getOsmApiCredentialDialog(username, password, host, getSaveUsernameAndPasswordCheckboxText()); break;
+            case PROXY: dialog = CredentialDialog.getHttpProxyCredentialDialog(username, password, host, getSaveUsernameAndPasswordCheckboxText()); break;
             }
             dialog.setVisible(true);
@@ -57,5 +57,5 @@
             response.setPassword(dialog.getPassword());
             if (dialog.isSaveCredentials()) {
-                store(requestorType, new PasswordAuthentication(
+                store(requestorType, host, new PasswordAuthentication(
                         response.getUsername(),
                         response.getPassword()
Index: trunk/src/org/openstreetmap/josm/io/auth/CredentialsAgent.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/auth/CredentialsAgent.java	(revision 4689)
+++ trunk/src/org/openstreetmap/josm/io/auth/CredentialsAgent.java	(revision 4690)
@@ -29,5 +29,5 @@
      * @throws CredentialsAgentException thrown if a problem occurs in a implementation of this interface
      */
-    PasswordAuthentication lookup(RequestorType requestorType) throws CredentialsAgentException;
+    PasswordAuthentication lookup(RequestorType requestorType, String host) throws CredentialsAgentException;
 
     /**
@@ -39,5 +39,5 @@
      * @throws CredentialsManagerException thrown if a problem occurs in a implementation of this interface
      */
-    void store(RequestorType requestorType, PasswordAuthentication credentials) throws CredentialsAgentException;
+    void store(RequestorType requestorType, String host, PasswordAuthentication credentials) throws CredentialsAgentException;
 
     /**
@@ -50,5 +50,5 @@
 
      */
-    CredentialsAgentResponse getCredentials(RequestorType requestorType, boolean noSuccessWithLastResponse) throws CredentialsAgentException;
+    CredentialsAgentResponse getCredentials(RequestorType requestorType, String host, boolean noSuccessWithLastResponse) throws CredentialsAgentException;
 
     /**
Index: trunk/src/org/openstreetmap/josm/io/auth/CredentialsManager.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/auth/CredentialsManager.java	(revision 4689)
+++ trunk/src/org/openstreetmap/josm/io/auth/CredentialsManager.java	(revision 4690)
@@ -8,4 +8,5 @@
 import org.openstreetmap.josm.data.oauth.OAuthToken;
 import org.openstreetmap.josm.gui.JosmUserIdentityManager;
+import org.openstreetmap.josm.io.OsmApi;
 import org.openstreetmap.josm.tools.Utils;
 
@@ -66,7 +67,11 @@
 
     public String getUsername() {
+        return getUsername(OsmApi.getOsmApi().getHost());
+    }
+
+    public String getUsername(String host) {
         String username = null;
         try {
-            PasswordAuthentication auth = lookup(RequestorType.SERVER);
+            PasswordAuthentication auth = lookup(RequestorType.SERVER, host);
             if (auth != null) {
                 username = auth.getUserName();
@@ -81,19 +86,22 @@
 
     @Override
-    public PasswordAuthentication lookup(RequestorType requestorType) throws CredentialsAgentException {
-        return delegate.lookup(requestorType);
+    public PasswordAuthentication lookup(RequestorType requestorType, String host) throws CredentialsAgentException {
+        return delegate.lookup(requestorType, host);
     }
 
     @Override
-    public void store(RequestorType requestorType, PasswordAuthentication credentials) throws CredentialsAgentException {
-        if (requestorType == RequestorType.SERVER && credentials.getUserName() != null && !credentials.getUserName().trim().isEmpty()) {
-            JosmUserIdentityManager.getInstance().setPartiallyIdentified(credentials.getUserName());
+    public void store(RequestorType requestorType, String host, PasswordAuthentication credentials) throws CredentialsAgentException {
+        if (requestorType == RequestorType.SERVER && OsmApi.getOsmApi().getHost().equals(host)) {
+            String username = credentials.getUserName();
+            if(username != null && !username.trim().isEmpty()) {
+                JosmUserIdentityManager.getInstance().setPartiallyIdentified(username);
+            }
         }
-        delegate.store(requestorType, credentials);
+        delegate.store(requestorType, host, credentials);
     }
 
     @Override
-    public CredentialsAgentResponse getCredentials(RequestorType requestorType, boolean noSuccessWithLastResponse) throws CredentialsAgentException {
-        return delegate.getCredentials(requestorType, noSuccessWithLastResponse);
+    public CredentialsAgentResponse getCredentials(RequestorType requestorType, String host, boolean noSuccessWithLastResponse) throws CredentialsAgentException {
+        return delegate.getCredentials(requestorType, host, noSuccessWithLastResponse);
     }
 
Index: trunk/src/org/openstreetmap/josm/io/auth/DefaultAuthenticator.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/auth/DefaultAuthenticator.java	(revision 4689)
+++ trunk/src/org/openstreetmap/josm/io/auth/DefaultAuthenticator.java	(revision 4690)
@@ -49,5 +49,5 @@
             }
             boolean tried = credentialsTried.get(getRequestorType()) != null;
-            CredentialsAgentResponse response = CredentialsManager.getInstance().getCredentials(getRequestorType(), tried);
+            CredentialsAgentResponse response = CredentialsManager.getInstance().getCredentials(getRequestorType(), getRequestingHost(), tried);
             if (response == null || response.isCanceled())
                 return null;
Index: trunk/src/org/openstreetmap/josm/io/auth/JosmPreferencesCredentialAgent.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/auth/JosmPreferencesCredentialAgent.java	(revision 4689)
+++ trunk/src/org/openstreetmap/josm/io/auth/JosmPreferencesCredentialAgent.java	(revision 4690)
@@ -14,4 +14,5 @@
 import org.openstreetmap.josm.gui.preferences.server.ProxyPreferencesPanel;
 import org.openstreetmap.josm.gui.widgets.HtmlPanel;
+import org.openstreetmap.josm.io.OsmApi;
 
 /**
@@ -26,5 +27,5 @@
      */
     @Override
-    public PasswordAuthentication lookup(RequestorType requestorType) throws CredentialsAgentException{
+    public PasswordAuthentication lookup(RequestorType requestorType, String host) throws CredentialsAgentException{
         if (requestorType == null)
             return null;
@@ -33,6 +34,11 @@
         switch(requestorType) {
         case SERVER:
-            user = Main.pref.get("osm-server.username", null);
-            password = Main.pref.get("osm-server.password", null);
+            if(OsmApi.getOsmApi().getHost().equals(host)) {
+                user = Main.pref.get("osm-server.username", null);
+                password = Main.pref.get("osm-server.password", null);
+            } else {
+                user = null;
+                password = null;
+            }
             if (user == null)
                 return null;
@@ -52,14 +58,16 @@
      */
     @Override
-    public void store(RequestorType requestorType, PasswordAuthentication credentials) throws CredentialsAgentException {
+    public void store(RequestorType requestorType, String host, PasswordAuthentication credentials) throws CredentialsAgentException {
         if (requestorType == null)
             return;
         switch(requestorType) {
         case SERVER:
-            Main.pref.put("osm-server.username", credentials.getUserName());
-            if (credentials.getPassword() == null) {
-                Main.pref.put("osm-server.password", null);
-            } else {
-                Main.pref.put("osm-server.password", String.valueOf(credentials.getPassword()));
+            if(OsmApi.getOsmApi().getHost().equals(host)) {
+                Main.pref.put("osm-server.username", credentials.getUserName());
+                if (credentials.getPassword() == null) {
+                    Main.pref.put("osm-server.password", null);
+                } else {
+                    Main.pref.put("osm-server.password", String.valueOf(credentials.getPassword()));
+                }
             }
             break;
