geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jensde...@apache.org
Subject [geode] branch develop updated: GEODE-3857: Pulse login fails after second login (#939)
Date Wed, 18 Oct 2017 22:28:51 GMT
This is an automated email from the ASF dual-hosted git repository.

jensdeppe pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git


The following commit(s) were added to refs/heads/develop by this push:
     new bfdaeba  GEODE-3857: Pulse login fails after second login (#939)
bfdaeba is described below

commit bfdaebafb63419efb4f71420bf36a3ef2ae68c34
Author: Jens Deppe <jdeppe@pivotal.io>
AuthorDate: Wed Oct 18 15:28:49 2017 -0700

    GEODE-3857: Pulse login fails after second login (#939)
    
    * GEODE-3857: Pulse login fails after second login
    
    * GEODE-3857: Consolidate actions for logging out
    
    - Close the JMX connection and remove the reference from the cluster map in one
      place.
---
 .../java/org/apache/geode/test/junit/rules/HttpClientRule.java |  4 ++++
 .../java/org/apache/geode/tools/pulse/PulseSecurityTest.java   |  7 +++++++
 .../org/apache/geode/tools/pulse/internal/data/Repository.java | 10 ++++++++++
 .../tools/pulse/internal/security/GemFireAuthentication.java   |  4 ----
 .../pulse/internal/security/GemFireAuthenticationProvider.java |  3 +--
 .../geode/tools/pulse/internal/security/LogoutHandler.java     |  3 ++-
 6 files changed, 24 insertions(+), 7 deletions(-)

diff --git a/geode-assembly/src/test/java/org/apache/geode/test/junit/rules/HttpClientRule.java
b/geode-assembly/src/test/java/org/apache/geode/test/junit/rules/HttpClientRule.java
index cfff7c1..8434136 100644
--- a/geode-assembly/src/test/java/org/apache/geode/test/junit/rules/HttpClientRule.java
+++ b/geode-assembly/src/test/java/org/apache/geode/test/junit/rules/HttpClientRule.java
@@ -73,6 +73,10 @@ public class HttpClientRule extends ExternalResource {
         .contains("/pulse/clusterDetail.html");
   }
 
+  public HttpResponse logoutFromPulse() throws Exception {
+    return get("/pulse/clusterLogout");
+  }
+
   public HttpResponse get(String uri, String... params) throws Exception {
     return httpClient.execute(host, buildHttpGet(uri, params));
   }
diff --git a/geode-assembly/src/test/java/org/apache/geode/tools/pulse/PulseSecurityTest.java
b/geode-assembly/src/test/java/org/apache/geode/tools/pulse/PulseSecurityTest.java
index a28ae59..42d8411 100644
--- a/geode-assembly/src/test/java/org/apache/geode/tools/pulse/PulseSecurityTest.java
+++ b/geode-assembly/src/test/java/org/apache/geode/tools/pulse/PulseSecurityTest.java
@@ -108,4 +108,11 @@ public class PulseSecurityTest {
     assertThat(result.toString()).contains("No Data Found");
   }
 
+  @Test
+  public void loginAfterLogout() throws Exception {
+    client.loginToPulseAndVerify("data", "data");
+    client.logoutFromPulse();
+    client.loginToPulseAndVerify("data", "data");
+    client.logoutFromPulse();
+  }
 }
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/data/Repository.java
b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/data/Repository.java
index c3a33fd..9a03349 100644
--- a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/data/Repository.java
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/data/Repository.java
@@ -136,6 +136,16 @@ public class Repository {
     }
   }
 
+  public void logoutUser(String username) {
+    Cluster data = clusterMap.remove(username);
+    if (data != null) {
+      try {
+        data.getJMXConnector().close();
+      } catch (Exception e) {
+        // We're logging out so this can be ignored
+      }
+    }
+  }
 
   // This method is used to remove all cluster threads
   public void removeAllClusters() {
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/security/GemFireAuthentication.java
b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/security/GemFireAuthentication.java
index dc75735..62de395 100644
--- a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/security/GemFireAuthentication.java
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/security/GemFireAuthentication.java
@@ -81,8 +81,4 @@ public class GemFireAuthentication extends UsernamePasswordAuthenticationToken
{
 
   }
 
-  public JMXConnector getJmxc() {
-    return jmxc;
-  }
-
 }
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/security/GemFireAuthenticationProvider.java
b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/security/GemFireAuthenticationProvider.java
index 2b110bc..2d3f0b1 100644
--- a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/security/GemFireAuthenticationProvider.java
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/security/GemFireAuthenticationProvider.java
@@ -44,8 +44,7 @@ public class GemFireAuthenticationProvider implements AuthenticationProvider
{
   public Authentication authenticate(Authentication authentication) throws AuthenticationException
{
     if (authentication instanceof GemFireAuthentication) {
       GemFireAuthentication gemAuth = (GemFireAuthentication) authentication;
-      logger.debug("GemAuthentication is connected? = {}", gemAuth.getJmxc());
-      if (gemAuth.getJmxc() != null && gemAuth.isAuthenticated())
+      if (gemAuth.isAuthenticated())
         return gemAuth;
     }
 
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/security/LogoutHandler.java
b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/security/LogoutHandler.java
index d685964..16200c8 100644
--- a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/security/LogoutHandler.java
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/security/LogoutHandler.java
@@ -14,6 +14,7 @@
  */
 package org.apache.geode.tools.pulse.internal.security;
 
+import org.apache.geode.tools.pulse.internal.data.Repository;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 import org.springframework.security.core.Authentication;
@@ -41,7 +42,7 @@ public class LogoutHandler extends SimpleUrlLogoutSuccessHandler implements
Logo
     logger.debug("Invoked #LogoutHandler ...");
     GemFireAuthentication gemauthentication = (GemFireAuthentication) authentication;
     if (gemauthentication != null) {
-      gemauthentication.getJmxc().close();
+      Repository.get().logoutUser(gemauthentication.getName());
       logger.info("#LogoutHandler : Closing GemFireAuthentication JMX Connection...");
     }
     super.onLogoutSuccess(request, response, authentication);

-- 
To stop receiving notification emails like this one, please contact
['"commits@geode.apache.org" <commits@geode.apache.org>'].

Mime
View raw message