Full reauthentication after server-side session expiration
diff --git a/org.eclipse.userstorage/src/org/eclipse/userstorage/internal/Session.java b/org.eclipse.userstorage/src/org/eclipse/userstorage/internal/Session.java
index 1dc50ff..7032a65 100644
--- a/org.eclipse.userstorage/src/org/eclipse/userstorage/internal/Session.java
+++ b/org.eclipse.userstorage/src/org/eclipse/userstorage/internal/Session.java
@@ -404,18 +404,21 @@
           if (ex instanceof ProtocolException)
           {
             ProtocolException protocolException = (ProtocolException)ex;
-            if (protocolException.getStatusCode() == AUTHORIZATION_REQUIRED && --authenticationAttempts > 0)
+            if (protocolException.getStatusCode() == AUTHORIZATION_REQUIRED)
             {
-              reauthentication = true;
-
               if (authenticated)
               {
                 // This means that the initial authenticate() call was skipped because we already have a session,
                 // but this session is no longer valid on the server. So reset() to force a full reauthentication.
                 reset();
+                continue;
               }
 
-              continue;
+              if (--authenticationAttempts > 0)
+              {
+                reauthentication = true;
+                continue;
+              }
             }
           }