demery-pivotal commented on a change in pull request #4977:
URL: https://github.com/apache/geode/pull/4977#discussion_r413431474



##########
File path: 
geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/data/Repository.java
##########
@@ -80,8 +88,95 @@ public Repository(OAuth2AuthorizedClientService 
authorizedClientService,
     this.clusterFactory = clusterFactory;
   }
 
+  /**
+   * this will return a cluster already connected to the geode jmx manager for 
the user in the
+   * request
+   * <p>
+   * But for multi-user connections to gemfireJMX, i.e pulse that uses gemfire 
integrated security,
+   * we will need to get the username from the context
+   */
+  public Cluster getCluster() {
+    Authentication authentication = 
SecurityContextHolder.getContext().getAuthentication();
+    if (authentication == null) {
+      return null;
+    }
+
+    if (authentication instanceof OAuth2AuthenticationToken) {
+      return getClusterWithAuthenticationToken((OAuth2AuthenticationToken) 
authentication);
+    }
+
+    return getClusterWithUserNameAndPassword(authentication.getName(), null);
+  }
+
+  public Cluster getClusterWithUserNameAndPassword(String userName, String 
password) {
+    String[] credentials = {userName, password};
+    return getClusterWithCredentials(userName, credentials);
+  }
+
+  public Cluster getClusterWithCredentials(String userName, Object 
credentials) {

Review comment:
       Done.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to