[
https://issues.apache.org/jira/browse/GEODE-3941?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16236952#comment-16236952
]
ASF GitHub Bot commented on GEODE-3941:
---------------------------------------
jdeppe-pivotal closed pull request #1007: GEODE-3941: Pulse issues when
SecurityManager is enabled
URL: https://github.com/apache/geode/pull/1007
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git
a/geode-assembly/src/test/java/org/apache/geode/tools/pulse/PulseSecurityIntegrationTest.java
b/geode-assembly/src/test/java/org/apache/geode/tools/pulse/PulseSecurityIntegrationTest.java
new file mode 100644
index 0000000000..7e331d7f27
--- /dev/null
+++
b/geode-assembly/src/test/java/org/apache/geode/tools/pulse/PulseSecurityIntegrationTest.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
contributor license
+ * agreements. See the NOTICE file distributed with this work for additional
information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache
License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express
+ * or implied. See the License for the specific language governing permissions
and limitations under
+ * the License.
+ */
+
+package org.apache.geode.tools.pulse;
+
+import static java.util.concurrent.TimeUnit.MINUTES;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.awaitility.Awaitility.await;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import org.apache.geode.examples.SimpleSecurityManager;
+import org.apache.geode.management.ManagementService;
+import org.apache.geode.test.junit.categories.IntegrationTest;
+import org.apache.geode.test.junit.rules.EmbeddedPulseRule;
+import org.apache.geode.test.junit.rules.LocatorStarterRule;
+import org.apache.geode.tools.pulse.internal.data.Cluster;
+
+@Category(IntegrationTest.class)
+public class PulseSecurityIntegrationTest {
+
+ @Rule
+ public LocatorStarterRule locator =
+ new
LocatorStarterRule().withSecurityManager(SimpleSecurityManager.class).withAutoStart();
+
+ @Rule
+ public EmbeddedPulseRule pulse = new EmbeddedPulseRule();
+
+ @Test
+ public void getAttributesWithSecurityManager() throws Exception {
+ pulse.useJmxPort(locator.getJmxPort());
+
+ ManagementService service =
+
ManagementService.getExistingManagementService(locator.getLocator().getCache());
+
+ await().atMost(2, MINUTES).until(() ->
assertThat(service.getMemberMXBean()).isNotNull());
+
+ Cluster cluster = pulse.getRepository().getCluster("cluster", "cluster");
+ Cluster.Member[] members = cluster.getMembers();
+ assertThat(members.length).isEqualTo(1);
+ assertThat(members[0].getName()).isEqualTo("locator");
+ }
+}
diff --git
a/geode-core/src/main/java/org/apache/geode/management/internal/beans/LocatorMBeanBridge.java
b/geode-core/src/main/java/org/apache/geode/management/internal/beans/LocatorMBeanBridge.java
index 1597f9f851..bb86ac07f6 100644
---
a/geode-core/src/main/java/org/apache/geode/management/internal/beans/LocatorMBeanBridge.java
+++
b/geode-core/src/main/java/org/apache/geode/management/internal/beans/LocatorMBeanBridge.java
@@ -16,6 +16,7 @@
import java.io.File;
import java.io.IOException;
+import java.net.InetAddress;
import java.util.List;
import org.apache.logging.log4j.Logger;
@@ -44,7 +45,8 @@ public LocatorMBeanBridge(Locator loc) {
}
public String getBindAddress() {
- return loc.getBindAddress().getCanonicalHostName();
+ InetAddress bindAddress = loc.getBindAddress();
+ return bindAddress != null ? bindAddress.getCanonicalHostName() : null;
}
public String getHostnameForClients() {
diff --git
a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/data/JMXDataUpdater.java
b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/data/JMXDataUpdater.java
index 2da74f178c..f9b6825a0b 100644
---
a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/data/JMXDataUpdater.java
+++
b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/data/JMXDataUpdater.java
@@ -17,16 +17,10 @@
package org.apache.geode.tools.pulse.internal.data;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import org.apache.commons.lang.StringUtils;
-import
org.apache.geode.tools.pulse.internal.data.JmxManagerFinder.JmxManagerInfo;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
+import java.lang.reflect.Array;
import java.math.BigDecimal;
import java.net.Inet4Address;
import java.net.Inet6Address;
@@ -43,11 +37,14 @@
import java.util.Map.Entry;
import java.util.ResourceBundle;
import java.util.Set;
+import java.util.stream.Collectors;
+
import javax.management.Attribute;
import javax.management.AttributeList;
import javax.management.AttributeNotFoundException;
import javax.management.InstanceNotFoundException;
import javax.management.IntrospectionException;
+import javax.management.MBeanAttributeInfo;
import javax.management.MBeanException;
import javax.management.MBeanServerConnection;
import javax.management.MalformedObjectNameException;
@@ -62,6 +59,14 @@
import javax.management.remote.JMXServiceURL;
import javax.rmi.ssl.SslRMIClientSocketFactory;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import org.apache.commons.lang.StringUtils;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+import
org.apache.geode.tools.pulse.internal.data.JmxManagerFinder.JmxManagerInfo;
+
/**
* Class JMXDataUpdater Class used for creating JMX connection and getting all
the required MBeans
*
@@ -1256,15 +1261,20 @@ private void updateClusterStatement(ObjectName
mbeanName) throws IOException {
* function used to iterate through all member attributes and return the
updated member
*/
private Cluster.Member initializeMember(ObjectName mbeanName, Cluster.Member
member)
- throws InstanceNotFoundException, ReflectionException, IOException {
+ throws InstanceNotFoundException, ReflectionException, IOException,
IntrospectionException {
+
+ MBeanAttributeInfo[] mbeanAttributes =
this.mbs.getMBeanInfo(mbeanName).getAttributes();
+ Set<String> mbeanAttributeNames =
+
Arrays.stream(mbeanAttributes).map(MBeanAttributeInfo::getName).collect(Collectors.toSet());
AttributeList attributeList =
- this.mbs.getAttributes(mbeanName,
PulseConstants.MEMBER_MBEAN_ATTRIBUTES);
+ this.mbs.getAttributes(mbeanName, mbeanAttributeNames.toArray(new
String[0]));
for (int i = 0; i < attributeList.size(); i++) {
Attribute attribute = (Attribute) attributeList.get(i);
String name = attribute.getName();
+
switch (name) {
case PulseConstants.MBEAN_ATTRIBUTE_GEMFIREVERSION:
if (member.getGemfireVersion() == null) {
@@ -1424,7 +1434,7 @@ private void updateClusterMember(ObjectName mbeanName)
throws IOException {
memberList.add(clusterMember);
cluster.getPhysicalToMember().put(clusterMember.getHost(), memberList);
}
- } catch (InstanceNotFoundException | ReflectionException infe) {
+ } catch (InstanceNotFoundException | ReflectionException |
IntrospectionException infe) {
logger.warn(infe);
}
}
diff --git a/geode-pulse/src/main/webapp/WEB-INF/spring-security.xml
b/geode-pulse/src/main/webapp/WEB-INF/spring-security.xml
index b8055f1362..8cc035dd56 100644
--- a/geode-pulse/src/main/webapp/WEB-INF/spring-security.xml
+++ b/geode-pulse/src/main/webapp/WEB-INF/spring-security.xml
@@ -29,6 +29,7 @@
<!-- Can be invoked w/o auth -->
<intercept-url pattern="/login.html" access="permitAll" />
<intercept-url pattern="/authenticateUser" access="permitAll" />
+ <intercept-url pattern="/pulseVersion" access="permitAll" />
<!-- Can be invoked w/o auth -->
<!-- Restricted urls -->
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> Pulse throws NPE when SecurityManager is enabled
> ------------------------------------------------
>
> Key: GEODE-3941
> URL: https://issues.apache.org/jira/browse/GEODE-3941
> Project: Geode
> Issue Type: Bug
> Components: pulse
> Reporter: Jens Deppe
> Assignee: Jens Deppe
>
> When `SecurityManager` is enabled, Pulse produces the following errors in
> `pulse.log`.
> {noformat}
> 2017-10-26 13:54:51,590 INFO o.a.g.t.p.i.d.Cluster
> [PULSE-localhost:11099:gfadmin] Exception Occurred while updating cluster
> data :
> java.lang.NullPointerException: null
> at
> org.apache.geode.tools.pulse.internal.data.JMXDataUpdater.initializeMember(JMXDataUpdater.java:1374)
> ~[classes/:?]
> at
> org.apache.geode.tools.pulse.internal.data.JMXDataUpdater.updateClusterMember(JMXDataUpdater.java:1415)
> ~[classes/:?]
> at
> org.apache.geode.tools.pulse.internal.data.JMXDataUpdater.updateData(JMXDataUpdater.java:323)
> ~[classes/:?]
> at
> org.apache.geode.tools.pulse.internal.data.Cluster.updateData(Cluster.java:2336)
> ~[classes/:?]
> at
> org.apache.geode.tools.pulse.internal.data.Cluster.run(Cluster.java:2300)
> [classes/:?]
> {noformat}
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)