You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by dj...@apache.org on 2008/03/14 21:04:14 UTC
svn commit: r637237 - in /db/derby/code/branches/10.4/java:
drda/org/apache/derby/impl/drda/ engine/org/apache/derby/iapi/services/info/
engine/org/apache/derby/impl/services/jmx/
testing/org/apache/derbyTesting/functionTests/tests/management/
Author: djd
Date: Fri Mar 14 13:04:13 2008
New Revision: 637237
URL: http://svn.apache.org/viewvc?rev=637237&view=rev
Log:
Merge revisions 635723 635766 636029 636319 from trunk.
DERBY-3462 DERBY-3506 related changes.
JMX changes to add permission checks to attributes and to allow the JMX tests to run with a security manager.
Modified:
db/derby/code/branches/10.4/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java
db/derby/code/branches/10.4/java/drda/org/apache/derby/impl/drda/NetworkServerMBeanImpl.java
db/derby/code/branches/10.4/java/engine/org/apache/derby/iapi/services/info/Version.java
db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/services/jmx/JMXManagementService.java
db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/management/JMXConnectionGetter.java
db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/management/JMXTest.java
db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/management/MBeanTest.java
db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/management/PlatformConnectionGetter.java
db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/management/RemoteConnectionGetter.java
Modified: db/derby/code/branches/10.4/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.4/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java?rev=637237&r1=637236&r2=637237&view=diff
==============================================================================
--- db/derby/code/branches/10.4/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java (original)
+++ db/derby/code/branches/10.4/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java Fri Mar 14 13:04:13 2008
@@ -777,7 +777,9 @@
Monitor.getSystemModule(Module.JMX));
Object versionMBean = mgmtService.registerMBean(
- new Version(getNetProductVersionHolder()),
+ new Version(
+ getNetProductVersionHolder(),
+ null /*SystemPermission.SERVER*/),
VersionMBean.class,
"type=Version,jar=derbynet.jar");
Object networkServerMBean = mgmtService.registerMBean(
Modified: db/derby/code/branches/10.4/java/drda/org/apache/derby/impl/drda/NetworkServerMBeanImpl.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.4/java/drda/org/apache/derby/impl/drda/NetworkServerMBeanImpl.java?rev=637237&r1=637236&r2=637237&view=diff
==============================================================================
--- db/derby/code/branches/10.4/java/drda/org/apache/derby/impl/drda/NetworkServerMBeanImpl.java (original)
+++ db/derby/code/branches/10.4/java/drda/org/apache/derby/impl/drda/NetworkServerMBeanImpl.java Fri Mar 14 13:04:13 2008
@@ -51,6 +51,20 @@
this.server = nsc;
startTime = System.currentTimeMillis();
}
+
+ /**
+ * Ensure the caller has permission to control the network server.
+ */
+ private void checkControl() {
+ // TODO: implement check
+ }
+
+ /**
+ * Ensure the caller has permission to monitor the network server.
+ */
+ private void checkMonitor() {
+// TODO: implement check
+ }
// Some of the code is disabled (commented out) due to security concerns,
// see DERBY-1387 for details.
@@ -60,6 +74,9 @@
//
public String getDrdaHost() {
+ // Since this is sensitive information require control permission.
+ checkControl();
+
String host = getServerProperty(Property.DRDA_PROP_HOSTNAME);
return host;
}
@@ -70,6 +87,8 @@
}
public int getDrdaMaxThreads() {
+ checkMonitor();
+
int maxThreads = 0; // default
String maxThreadsStr = getServerProperty(Property.DRDA_PROP_MAXTHREADS);
if (maxThreadsStr != null) {
@@ -95,6 +114,9 @@
}*/
public int getDrdaPortNumber() {
+ // Since this is sensitive information require control permission.
+ checkControl();
+
int portNumber = NetworkServerControl.DEFAULT_PORTNUMBER; // the default
String portString = getServerProperty(Property.DRDA_PROP_PORTNUMBER);
try {
@@ -106,6 +128,9 @@
}
public String getDrdaSecurityMechanism() {
+ // Since this is sensitive information require control permission.
+ checkControl();
+
String secmec = getServerProperty(Property.DRDA_PROP_SECURITYMECHANISM);
if (secmec == null) {
// default is none (represented by the empty string)
@@ -115,6 +140,9 @@
}
public String getDrdaSslMode() {
+ // Since this is sensitive information require control permission.
+ checkControl();
+
// may be null if not set (?)
String SSLMode = getServerProperty(Property.DRDA_PROP_SSL_MODE);
return SSLMode;
@@ -122,6 +150,8 @@
public String getDrdaStreamOutBufferSize() {
+ checkMonitor();
+
// TODO - Fix NetworkServerControlImpl so that this setting is included
// in the property values returned by getPropertyValues()?
//String size = getServerProperty(Property.DRDA_PROP_STREAMOUTBUFFERSIZE);
@@ -132,6 +162,8 @@
public int getDrdaTimeSlice() {
+ checkMonitor();
+
// relying on server to return the default if not set
return server.getTimeSlice();
}
@@ -149,6 +181,8 @@
}*/
public boolean getDrdaTraceAll() {
+ checkMonitor();
+
String on = getServerProperty(Property.DRDA_PROP_TRACEALL);
return ("true".equals(on) ? true : false );
}
@@ -166,6 +200,10 @@
}*/
public String getDrdaTraceDirectory() {
+ // Since this is sensitive information require control
+ // (gives away information about the file system).
+ checkControl();
+
String traceDirectory = null;
traceDirectory = getServerProperty(Property.DRDA_PROP_TRACEDIRECTORY);
if(traceDirectory == null){
@@ -209,30 +247,44 @@
**/
public int getConnectionCount() {
+ checkMonitor();
+
return getActiveConnectionCount() + getWaitingConnectionCount();
}
public int getActiveConnectionCount() {
+ checkMonitor();
+
return server.getActiveSessions();
}
public int getWaitingConnectionCount() {
+ checkMonitor();
+
return server.getRunQueueSize();
}
public int getConnectionThreadPoolSize() {
+ checkMonitor();
+
return server.getThreadListSize();
}
public int getAccumulatedConnectionCount() {
+ checkMonitor();
+
return server.getConnectionNumber();
}
public long getBytesReceived() {
+ checkMonitor();
+
return server.getBytesRead();
}
public long getBytesSent() {
+ checkMonitor();
+
return server.getBytesWritten();
}
@@ -241,6 +293,8 @@
private int receiveResult = 0;
synchronized public int getBytesReceivedPerSecond(){
+ checkMonitor();
+
long now = System.currentTimeMillis();
if (now - lastReceiveTime >= 1000) {
long count = getBytesReceived();
@@ -256,6 +310,8 @@
private int sentResult = 0;
synchronized public int getBytesSentPerSecond(){
+ checkMonitor();
+
long now = System.currentTimeMillis();
if (now - lastSentTime >= 1000) {
long count = getBytesSent();
@@ -270,6 +326,8 @@
* Return start time.
*/
public long getStartTime() {
+ checkMonitor();
+
return startTime;
}
@@ -277,8 +335,9 @@
* Return time server has been running.
*/
public long getUptime() {
- return System.currentTimeMillis() - startTime;
+ checkMonitor();
+ return System.currentTimeMillis() - startTime;
}
// ------------------------- MBEAN OPERATIONS ----------------------------
@@ -290,6 +349,8 @@
* @throws Exception if the ping fails.
*/
public void ping() throws Exception {
+ checkMonitor();
+
//String feedback = "Server pinged successfully.";
//boolean success = true;
try {
Modified: db/derby/code/branches/10.4/java/engine/org/apache/derby/iapi/services/info/Version.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.4/java/engine/org/apache/derby/iapi/services/info/Version.java?rev=637237&r1=637236&r2=637237&view=diff
==============================================================================
--- db/derby/code/branches/10.4/java/engine/org/apache/derby/iapi/services/info/Version.java (original)
+++ db/derby/code/branches/10.4/java/engine/org/apache/derby/iapi/services/info/Version.java Fri Mar 14 13:04:13 2008
@@ -34,48 +34,74 @@
private final ProductVersionHolder versionInfo;
- public Version(ProductVersionHolder pvh) {
+ /**
+ * Permission name for the object the version
+ * information applies to.
+ */
+ private final String permissionName;
+
+ public Version(ProductVersionHolder pvh, String permissionName) {
versionInfo = pvh;
+ this.permissionName = permissionName;
+ }
+
+ /*
+ ** Security checks(non-Javadoc)
+ */
+
+ private void checkMonitor() {
+ // TODO: Add actual check
+ //new SystemPermission(permissionName, SystemPermission.MONITOR);
}
// ------------------------- MBEAN ATTRIBUTES ----------------------------
public String getProductName(){
+ checkMonitor();
return versionInfo.getProductName();
}
public String getProductTechnologyName(){
+ checkMonitor();
return versionInfo.getProductTechnologyName();
}
public String getProductVendorName(){
+ checkMonitor();
return versionInfo.getProductVendorName();
}
public String getVersionString() {
+ checkMonitor();
return versionInfo.getVersionBuildString(true);
}
public int getMajorVersion(){
+ checkMonitor();
return versionInfo.getMajorVersion();
}
public int getMinorVersion(){
+ checkMonitor();
return versionInfo.getMinorVersion();
}
public int getMaintenanceVersion(){
+ checkMonitor();
return versionInfo.getMaintVersion();
}
public String getBuildNumber(){
+ checkMonitor();
return versionInfo.getBuildNumber();
}
public boolean isBeta(){
+ checkMonitor();
return versionInfo.isBeta();
}
public boolean isAlpha(){
+ checkMonitor();
return versionInfo.isAlpha();
}
Modified: db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/services/jmx/JMXManagementService.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/services/jmx/JMXManagementService.java?rev=637237&r1=637236&r2=637237&view=diff
==============================================================================
--- db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/services/jmx/JMXManagementService.java (original)
+++ db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/services/jmx/JMXManagementService.java Fri Mar 14 13:04:13 2008
@@ -118,7 +118,10 @@
"type=Management");
myManagementServer = mbeanServer;
- registerMBean(new Version(Monitor.getMonitor().getEngineVersion()),
+ registerMBean(
+ new Version(
+ Monitor.getMonitor().getEngineVersion(),
+ null /* SystemPermission.ENGINE */),
VersionMBean.class,
"type=Version,jar=derby.jar");
}
Modified: db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/management/JMXConnectionGetter.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/management/JMXConnectionGetter.java?rev=637237&r1=637236&r2=637237&view=diff
==============================================================================
--- db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/management/JMXConnectionGetter.java (original)
+++ db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/management/JMXConnectionGetter.java Fri Mar 14 13:04:13 2008
@@ -40,7 +40,8 @@
/**
* Get a connection to the platform MBean Server.
*/
- MBeanServerConnection getMBeanServerConnection() throws Exception;
+ MBeanServerConnection getMBeanServerConnection(String user,
+ String password) throws Exception;
void close(MBeanServerConnection jmxConnection) throws Exception;
}
Modified: db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/management/JMXTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/management/JMXTest.java?rev=637237&r1=637236&r2=637237&view=diff
==============================================================================
--- db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/management/JMXTest.java (original)
+++ db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/management/JMXTest.java Fri Mar 14 13:04:13 2008
@@ -21,11 +21,17 @@
package org.apache.derbyTesting.functionTests.tests.management;
+import java.io.IOException;
+import java.security.AccessController;
+import java.security.PrivilegedExceptionAction;
import java.util.Set;
+import javax.management.InstanceNotFoundException;
+import javax.management.IntrospectionException;
import javax.management.MBeanInfo;
import javax.management.MBeanServerConnection;
import javax.management.ObjectName;
+import javax.management.ReflectionException;
import junit.framework.Test;
@@ -64,14 +70,20 @@
assertTrue("Derby MBEan count:" + derbyMBeans.size(),
derbyMBeans.size() >= 2);
- MBeanServerConnection jmx = getMBeanServerConnection();
- for (ObjectName name : derbyMBeans)
+ final MBeanServerConnection jmx = getMBeanServerConnection();
+ for (final ObjectName name : derbyMBeans)
{
String type = name.getKeyProperty("type");
// Every Derby MBean has a type.
assertNotNull(type);
- MBeanInfo mbeanInfo = jmx.getMBeanInfo(name);
+ MBeanInfo mbeanInfo = AccessController.doPrivileged(
+ new PrivilegedExceptionAction<MBeanInfo>() {
+ public MBeanInfo run() throws InstanceNotFoundException, IntrospectionException, ReflectionException, IOException {
+ return jmx.getMBeanInfo(name);
+ }
+ }
+ );
String mbeanClassName = mbeanInfo.getClassName();
// Is the class name in the public api
Modified: db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/management/MBeanTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/management/MBeanTest.java?rev=637237&r1=637236&r2=637237&view=diff
==============================================================================
--- db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/management/MBeanTest.java (original)
+++ db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/management/MBeanTest.java Fri Mar 14 13:04:13 2008
@@ -24,15 +24,25 @@
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
+import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StringReader;
+import java.security.AccessController;
+import java.security.PrivilegedExceptionAction;
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.Set;
+import javax.management.AttributeNotFoundException;
+import javax.management.InstanceAlreadyExistsException;
+import javax.management.InstanceNotFoundException;
+import javax.management.MBeanException;
+import javax.management.MBeanRegistrationException;
import javax.management.MBeanServerConnection;
+import javax.management.NotCompliantMBeanException;
import javax.management.ObjectName;
+import javax.management.ReflectionException;
import junit.framework.Test;
import junit.framework.TestSuite;
@@ -51,7 +61,7 @@
* BaseTestCase.
*/
abstract class MBeanTest extends BaseJDBCTestCase {
-
+
/**
* JMX connection to use throughout the instance.
*/
@@ -61,7 +71,7 @@
super(name);
}
- protected static Test suite(Class testClass, String suiteName) {
+ protected static Test suite(Class<? extends MBeanTest> testClass, String suiteName) {
// TODO -
// Check for J2SE 5.0 or better? Or java.lang.management.ManagementFactory?
@@ -75,11 +85,11 @@
// all the MBeans are running.
platform = TestConfiguration.clientServerDecorator(platform);
platform = JMXConnectionDecorator.platformMBeanServer(platform);
-
+
// TODO: Run with no security for the moment, requires changes in the
// test policy files that may clash with a couple of outstanding patches.
platform = SecurityManagerSetup.noSecurityManager(platform);
-
+
// Set of tests that run within the same virtual machine using
// the platform MBeanServer directly.
outerSuite.addTest(platform);
@@ -106,7 +116,7 @@
NetworkServerTestSetup networkServerTestSetup =
new NetworkServerTestSetup (
suite, // run all tests in this class in the same setup
- getCommandLineProperties(), // need to set up JMX in JVM
+ getCommandLineProperties(false), // need to set up JMX in JVM
new String[0], // no server arguments needed
true // wait for the server to start properly
);
@@ -117,13 +127,15 @@
* JMX specific policy file later. Or use the property trick reported
* on derby-dev 2008-02-26 and add the permission to the generic
* policy.
+ * Note that the remote server will be running with a security
+ * manager (by default) if testing with jars.
*/
Test testSetup =
SecurityManagerSetup.noSecurityManager(networkServerTestSetup);
// this decorator makes sure the suite is empty if this configration
// does not support the network server:
outerSuite.addTest(TestConfiguration.defaultServerDecorator(testSetup));
-
+
return outerSuite;
}
@@ -138,13 +150,21 @@
* @return a set of Java system properties to be set on the command line
* when starting a new JVM in order to enable remote JMX.
*/
- private static String[] getCommandLineProperties()
+ protected static String[] getCommandLineProperties(boolean authentication)
{
ArrayList<String> list = new ArrayList<String>();
list.add("com.sun.management.jmxremote.port="
+ TestConfiguration.getCurrent().getJmxPort());
- list.add("com.sun.management.jmxremote.authenticate=false");
+ list.add("com.sun.management.jmxremote.authenticate=" +
+ Boolean.toString(authentication));
list.add("com.sun.management.jmxremote.ssl=false");
+
+ if (authentication) {
+ list.add("com.sun.management.jmxremote.password.file=" +
+ "extin/jmx.password");
+ list.add("com.sun.management.jmxremote.access.file=" +
+ "extin/jmx.access");
+ }
String[] result = new String[list.size()];
list.toArray(result);
return result;
@@ -175,7 +195,10 @@
}
/**
- * Obtains a connection to an MBean server. Assumes th
+ * Obtains a connection to an MBean server with
+ * no user name or password,
+ * opens a single connection for the lifetime
+ * of the fixture
*
* @return a plain connection to an MBean server
*/
@@ -184,11 +207,24 @@
if (jmxConnection == null)
jmxConnection =
- JMXConnectionGetter.mbeanServerConnector.get().getMBeanServerConnection();
+ JMXConnectionGetter.mbeanServerConnector.get()
+ .getMBeanServerConnection(null, null);
return jmxConnection;
}
/**
+ * Obtains a connection to an MBean server with
+ * a user name or password. A new connection is
+ * returned for each call.
+ */
+ protected MBeanServerConnection getMBeanServerConnection(
+ String user, String password) throws Exception {
+
+ return JMXConnectionGetter.mbeanServerConnector.get()
+ .getMBeanServerConnection(user, password);
+ }
+
+ /**
* Is the JMX connecting using platform JMX.
* @return True jmx connections via the platform server, false remote connections.
*/
@@ -213,7 +249,7 @@
// check the status of the management service
Boolean active = (Boolean)
- serverConn.getAttribute(mgmtObjName, "ManagementActive");
+ getAttribute(mgmtObjName, "ManagementActive");
if (!active.booleanValue()) {
// JMX management is not active, so activate it by invoking the
@@ -223,7 +259,7 @@
"startManagement",
new Object[0], new String[0]); // no arguments
active = (Boolean)
- serverConn.getAttribute(mgmtObjName, "ManagementActive");
+ getAttribute(mgmtObjName, "ManagementActive");
}
assertTrue("Failed to activate Derby's JMX management", active);
@@ -237,9 +273,16 @@
@SuppressWarnings("unchecked")
protected Set<ObjectName> getDerbyDomainMBeans() throws Exception
{
- ObjectName derbyDomain = new ObjectName("org.apache.derby:*");
- return (Set<ObjectName>)
- getMBeanServerConnection().queryNames(derbyDomain, null);
+ final ObjectName derbyDomain = new ObjectName("org.apache.derby:*");
+ final MBeanServerConnection serverConn = getMBeanServerConnection();
+
+ return (Set<ObjectName>) AccessController.doPrivileged(
+ new PrivilegedExceptionAction<Object>() {
+ public Object run() throws IOException {
+ return serverConn.queryNames(derbyDomain, null);
+ }
+ }
+ );
}
/**
@@ -253,19 +296,25 @@
/* prepare the Management mbean, which is (so far) the only MBean that
* can be created/registered from a JMX client, and without knowing the
* system identifier */
- ObjectName mgmtObjName
+ final ObjectName mgmtObjName
= new ObjectName("org.apache.derby", "type", "Management");
// create/register the MBean. If the same MBean has already been
// registered with the MBeanServer, that MBean will be referenced.
//ObjectInstance mgmtObj =
- MBeanServerConnection serverConn = getMBeanServerConnection();
+ final MBeanServerConnection serverConn = getMBeanServerConnection();
if (!serverConn.isRegistered(mgmtObjName))
- {
-
- serverConn.createMBean(
- "org.apache.derby.mbeans.Management",
- mgmtObjName);
+ {
+ AccessController.doPrivileged(
+ new PrivilegedExceptionAction<Object>() {
+ public Object run() throws InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException, ReflectionException, MBeanException, IOException {
+ serverConn.createMBean(
+ "org.apache.derby.mbeans.Management",
+ mgmtObjName);
+ return null;
+ }
+ }
+ );
}
return mgmtObjName;
@@ -314,16 +363,22 @@
* @return the value returned by the operation being invoked, or
* <code>null</code> if there is no return value.
*/
- protected Object invokeOperation(ObjectName objName,
- String name,
- Object[] params,
- String[] sign)
+ protected Object invokeOperation(final ObjectName objName,
+ final String name,
+ final Object[] params,
+ final String[] sign)
throws Exception
{
- return getMBeanServerConnection().invoke(
- objName,
- name,
- params, sign);
+ final MBeanServerConnection jmxConn = getMBeanServerConnection();
+
+ return AccessController.doPrivileged(
+ new PrivilegedExceptionAction<Object>() {
+ public Object run() throws InstanceNotFoundException, MBeanException, ReflectionException, IOException {
+ return jmxConn.invoke(objName, name,
+ params, sign);
+ }
+ }
+ );
}
/**
@@ -334,10 +389,18 @@
* @return the value of the attribute
* @throws java.lang.Exception if an unexpected error occurs
*/
- protected Object getAttribute(ObjectName objName, String name)
+ protected Object getAttribute(final ObjectName objName, final String name)
throws Exception {
- return getMBeanServerConnection().getAttribute(objName, name);
+ final MBeanServerConnection jmxConn = getMBeanServerConnection();
+
+ return AccessController.doPrivileged(
+ new PrivilegedExceptionAction<Object>() {
+ public Object run() throws AttributeNotFoundException, InstanceNotFoundException, MBeanException, ReflectionException, IOException {
+ return jmxConn.getAttribute(objName, name);
+ }
+ }
+ );
}
protected void assertBooleanAttribute(boolean expected,
@@ -434,6 +497,7 @@
String value = (String)getAttribute(objName, name);
println(name + " = " + value); // for debugging
}
+
/**
* Calls the public method <code>getInfo</code> of the sysinfo tool within
Modified: db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/management/PlatformConnectionGetter.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/management/PlatformConnectionGetter.java?rev=637237&r1=637236&r2=637237&view=diff
==============================================================================
--- db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/management/PlatformConnectionGetter.java (original)
+++ db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/management/PlatformConnectionGetter.java Fri Mar 14 13:04:13 2008
@@ -35,7 +35,11 @@
PlatformConnectionGetter() {
}
- public MBeanServerConnection getMBeanServerConnection() throws Exception {
+ /**
+ * User name ignored, only applicable for remote connections.
+ */
+ public MBeanServerConnection getMBeanServerConnection(String user,
+ String password) throws Exception {
return AccessController.doPrivileged(new PrivilegedAction<MBeanServerConnection>() {
Modified: db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/management/RemoteConnectionGetter.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/management/RemoteConnectionGetter.java?rev=637237&r1=637236&r2=637237&view=diff
==============================================================================
--- db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/management/RemoteConnectionGetter.java (original)
+++ db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/management/RemoteConnectionGetter.java Fri Mar 14 13:04:13 2008
@@ -44,9 +44,17 @@
this.url = url;
}
- public MBeanServerConnection getMBeanServerConnection() throws Exception {
- // assumes that JMX authentication and SSL is not required (hence null)
- JMXConnector jmxc = JMXConnectorFactory.connect(url, null);
+ public MBeanServerConnection getMBeanServerConnection(String user,
+ String password) throws Exception {
+
+ HashMap<String,String[]> env = new HashMap<String,String[]>();
+ if (user != null) {
+ String[] credentials = new String[] {
+ user, password };
+ env.put("jmx.remote.credentials", credentials);
+ }
+
+ JMXConnector jmxc = JMXConnectorFactory.connect(url, env);
MBeanServerConnection jmxConn = jmxc.getMBeanServerConnection();
Map<MBeanServerConnection,JMXConnector> conns = connections.get();