Index: trunk/src/org/openstreetmap/josm/io/auth/CredentialsManager.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/auth/CredentialsManager.java	(revision 15756)
+++ trunk/src/org/openstreetmap/josm/io/auth/CredentialsManager.java	(revision 15757)
@@ -132,4 +132,6 @@
             }
         }
+        // see #11914: clear cache before we store new value
+        purgeCredentialsCache(requestorType);
         delegate.store(requestorType, host, credentials);
     }
@@ -138,5 +140,17 @@
     public CredentialsAgentResponse getCredentials(RequestorType requestorType, String host, boolean noSuccessWithLastResponse)
             throws CredentialsAgentException {
-        return delegate.getCredentials(requestorType, host, noSuccessWithLastResponse);
+        CredentialsAgentResponse credentials = delegate.getCredentials(requestorType, host, noSuccessWithLastResponse);
+        if (requestorType == RequestorType.SERVER) {
+            // see #11914 : Keep UserIdentityManager up to date
+            String userName = credentials.getUsername();
+            userName = userName == null ? "" : userName.trim();
+            if (!Objects.equals(UserIdentityManager.getInstance().getUserName(), userName)) {
+                if (userName.isEmpty())
+                    UserIdentityManager.getInstance().setAnonymous();
+                else
+                    UserIdentityManager.getInstance().setPartiallyIdentified(userName);
+            }
+        }
+        return credentials;
     }
 
