Index: /trunk/src/org/openstreetmap/josm/io/auth/AbstractCredentialsAgent.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/io/auth/AbstractCredentialsAgent.java	(revision 5691)
+++ /trunk/src/org/openstreetmap/josm/io/auth/AbstractCredentialsAgent.java	(revision 5692)
@@ -8,4 +8,5 @@
 
 import org.openstreetmap.josm.gui.io.CredentialDialog;
+import org.openstreetmap.josm.gui.util.GuiHelper;
 
 abstract public class AbstractCredentialsAgent implements CredentialsAgent {
@@ -14,15 +15,15 @@
 
     /**
-     * @see CredentialsAgent#getCredentials(RequestorType, boolean)
+     * @see CredentialsAgent#getCredentials(RequestorType, String, boolean)
      */
     @Override
-    public CredentialsAgentResponse getCredentials(RequestorType requestorType, String host, boolean noSuccessWithLastResponse) throws CredentialsAgentException{
+    public CredentialsAgentResponse getCredentials(final RequestorType requestorType, final String host, boolean noSuccessWithLastResponse) throws CredentialsAgentException{
         if (requestorType == null)
             return null;
         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());
+        final String username = (credentials == null || credentials.getUserName() == null) ? "" : credentials.getUserName();
+        final String password = (credentials == null || credentials.getPassword() == null) ? "" : String.valueOf(credentials.getPassword());
 
-        CredentialsAgentResponse response = new CredentialsAgentResponse();
+        final CredentialsAgentResponse response = new CredentialsAgentResponse();
 
         /*
@@ -45,16 +46,25 @@
          */
         } else if (noSuccessWithLastResponse || username.equals("") || password.equals("")) {
-            CredentialDialog dialog = null;
-            switch(requestorType) {
-            case SERVER: dialog = CredentialDialog.getOsmApiCredentialDialog(username, password, host, getSaveUsernameAndPasswordCheckboxText()); break;
-            case PROXY: dialog = CredentialDialog.getHttpProxyCredentialDialog(username, password, host, getSaveUsernameAndPasswordCheckboxText()); break;
+            GuiHelper.runInEDTAndWait(new Runnable() {
+                @Override
+                public void run() {
+                    CredentialDialog dialog = null;
+                    switch(requestorType) {
+                    case SERVER: dialog = CredentialDialog.getOsmApiCredentialDialog(username, password, host, getSaveUsernameAndPasswordCheckboxText()); break;
+                    case PROXY: dialog = CredentialDialog.getHttpProxyCredentialDialog(username, password, host, getSaveUsernameAndPasswordCheckboxText()); break;
+                    }
+                    dialog.setVisible(true);
+                    response.setCanceled(dialog.isCanceled());
+                    if (dialog.isCanceled())
+                        return;
+                    response.setUsername(dialog.getUsername());
+                    response.setPassword(dialog.getPassword());
+                    response.setSaveCredentials(dialog.isSaveCredentials());
+                }
+            });
+            if (response.isCanceled()) {
+                return response;
             }
-            dialog.setVisible(true);
-            response.setCanceled(dialog.isCanceled());
-            if (dialog.isCanceled())
-                return response;
-            response.setUsername(dialog.getUsername());
-            response.setPassword(dialog.getPassword());
-            if (dialog.isSaveCredentials()) {
+            if (response.isSaveCredentials()) {
                 store(requestorType, host, new PasswordAuthentication(
                         response.getUsername(),
@@ -66,5 +76,5 @@
              */
             } else {
-                PasswordAuthentication pa = new PasswordAuthentication(dialog.getUsername(), dialog.getPassword());
+                PasswordAuthentication pa = new PasswordAuthentication(response.getUsername(), response.getPassword());
                 memoryCredentialsCache.put(requestorType, pa);
             }
Index: /trunk/src/org/openstreetmap/josm/io/auth/CredentialsAgentResponse.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/io/auth/CredentialsAgentResponse.java	(revision 5691)
+++ /trunk/src/org/openstreetmap/josm/io/auth/CredentialsAgentResponse.java	(revision 5692)
@@ -3,9 +3,10 @@
 
 /**
- * CredentialsAgentResponse represents the response from {@link CredentialsAgent#getCredentials(java.net.Authenticator.RequestorType, boolean)}.
+ * CredentialsAgentResponse represents the response from {@link CredentialsAgent#getCredentials(java.net.Authenticator.RequestorType, String, boolean)}.
  *
  * The response consists of the username and the password the requested credentials consists of.
  * In addition, it provides information whether authentication was canceled by the user, i.e.
  * because he or she canceled a username/password dialog (see {@link #isCanceled()}.
+ * It also provides information whether authentication should be saved.
  *
  */
@@ -14,21 +15,60 @@
     private char[] password;
     private boolean canceled;
+    private boolean saveCredentials;
+    /**
+     * Replies the user name
+     * @return The user name
+     */
     public String getUsername() {
         return username;
     }
+    /**
+     * Sets the user name
+     * @param username The user name
+     */
     public void setUsername(String username) {
         this.username = username;
     }
+    /**
+     * Replies the password
+     * @return The password in plain text
+     */
     public char[] getPassword() {
         return password;
     }
+    /**
+     * Sets the password
+     * @param password The password in plain text
+     */
     public void setPassword(char[] password) {
         this.password = password;
     }
+    /**
+     * Determines if authentication request has been canceled by user
+     * @return true if authentication request has been canceled by user, false otherwise
+     */
     public boolean isCanceled() {
         return canceled;
     }
+    /**
+     * Sets the cancelation status (authentication request canceled by user)
+     * @param canceled the cancelation status (authentication request canceled by user)
+     */
     public void setCanceled(boolean canceled) {
         this.canceled = canceled;
     }
+    /**
+     * Determines if authentication credentials should be saved
+     * @return true if authentication credentials should be saved, false otherwise
+     */
+    public boolean isSaveCredentials() {
+        return saveCredentials;
+    }
+    /**
+     * Sets the saving status (authentication credentials to save)
+     * @param saveCredentials the saving status (authentication credentials to save)
+     */
+    public void setSaveCredentials(boolean saveCredentials) {
+        this.saveCredentials = saveCredentials;
+    }
 }
