From feb5d90ec016c99712f19c5485cf7633cd38f111 Mon Sep 17 00:00:00 2001
From: matthew_swift <matthew_swift@localhost>
Date: Fri, 23 Mar 2007 14:26:04 +0000
Subject: [PATCH] Merge admin framework from config-prototype-branch onto trunk.

---
 opends/tests/unit-tests-testng/src/server/org/opends/server/protocols/jmx/JmxConnectTest.java |  492 +++++++++++++++++++++++++++--------------------------
 1 files changed, 250 insertions(+), 242 deletions(-)

diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/protocols/jmx/JmxConnectTest.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/protocols/jmx/JmxConnectTest.java
index 44d7df3..2af31fb 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/protocols/jmx/JmxConnectTest.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/protocols/jmx/JmxConnectTest.java
@@ -26,6 +26,8 @@
  */
 package org.opends.server.protocols.jmx;
 
+
+
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
@@ -46,8 +48,11 @@
 import javax.net.ssl.TrustManagerFactory;
 
 import org.opends.server.TestCaseUtils;
+import org.opends.server.admin.server.AdminTestCaseUtils;
+import org.opends.server.admin.std.meta.JMXConnectionHandlerCfgDefn;
+import org.opends.server.admin.std.server.JMXConnectionHandlerCfg;
 import org.opends.server.api.ConnectionHandler;
-import org.opends.server.config.ConfigEntry;
+import org.opends.server.config.ConfigException;
 import org.opends.server.config.JMXMBean;
 import org.opends.server.core.AddOperation;
 import org.opends.server.core.DeleteOperation;
@@ -62,14 +67,14 @@
 import org.testng.annotations.Test;
 import static org.testng.Assert.*;
 
+
+
 /**
- * A simple test for :
- *  - JMX connection establishment withou using SSL
- *  - JMX get and set
- *  - configuration change
+ * A simple test for : - JMX connection establishment withou using SSL -
+ * JMX get and set - configuration change
  */
-public class JmxConnectTest extends JmxTestCase
-{
+public class JmxConnectTest extends JmxTestCase {
+
   /**
    * Set up the environment for performing the tests in this suite.
    *
@@ -77,81 +82,82 @@
    *           If the environment could not be set up.
    */
   @BeforeClass
-  public void setUp() throws Exception
-  {
+  public void setUp() throws Exception {
     // Make sure that the server is up and running.
     TestCaseUtils.startServer();
-    synchronized (this)
-    {
-        this.wait(500);
+    synchronized (this) {
+      this.wait(500);
     }
   }
 
+
+
   /**
    * Build data for the simpleConnect test.
    *
    * @return the data.
    */
-  @DataProvider(name="simpleConnect")
-  Object[][] createCredentials()
-  {
+  @DataProvider(name = "simpleConnect")
+  Object[][] createCredentials() {
     return new Object[][] {
-        {"cn=directory manager", "password", true},
-        {"cn=directory manager", "wrongPassword", false},
-        {"cn=wrong user", "password", false},
-        {"invalid DN", "password", false},
-        {"cn=directory manager", null, false},
-        {null, "password", false},
-        {null, null, false},
-        };
+        { "cn=directory manager", "password", true },
+        { "cn=directory manager", "wrongPassword", false },
+        { "cn=wrong user", "password", false },
+        { "invalid DN", "password", false },
+        { "cn=directory manager", null, false },
+        { null, "password", false }, { null, null, false }, };
   }
 
+
+
   /**
    * Check that simple (no SSL) connections to the JMX service are
-   * accepted when the given
-   * credentials are OK and refused when the credentials are invalid.
-   *
+   * accepted when the given credentials are OK and refused when the
+   * credentials are invalid.
    */
-  @Test(enabled = true, dataProvider="simpleConnect")
+  @Test(enabled = true, dataProvider = "simpleConnect")
   public void simpleConnect(String user, String password,
-      boolean expectedResult) throws Exception
-  {
+      boolean expectedResult) throws Exception {
     OpendsJmxConnector connector = connect(user, password,
         TestCaseUtils.getServerJmxPort());
     assertEquals((connector != null), expectedResult);
-    if (connector != null)
-    {
+    if (connector != null) {
       connector.close();
     }
   }
 
+
+
   /**
    * Build some data for the simpleGet test.
    */
-  @DataProvider(name="simpleGet")
-  Object[][] createNames()
-  {
+  @DataProvider(name = "simpleGet")
+  Object[][] createNames() {
     return new Object[][] {
-        {"cn=JMX Connection Handler,cn=Connection Handlers,cn=config",
-            "ds-cfg-listen-port", TestCaseUtils.getServerJmxPort()},
-        {"cn=JMX Connection Handler,cn=Connection Handlers,cn=config",
-              "objectclass", null},
-        {"cn=JMX Connection Handler,cn=Connection Handlers,cn=config",
-              "ds-cfg-ssl-cert-nickname", "server-cert"},
-      // not working at the moment see issue 655
-      //  {"cn=JE Database,ds-cfg-backend-id=userRoot,cn=Backends,cn=config",
-      //          "ds-cfg-database-cache-percent", 10},
+        {
+            "cn=JMX Connection Handler,cn=Connection Handlers,cn=config",
+            "ds-cfg-listen-port", TestCaseUtils.getServerJmxPort() },
+        {
+            "cn=JMX Connection Handler,cn=Connection Handlers,cn=config",
+            "objectclass", null },
+        {
+            "cn=JMX Connection Handler,cn=Connection Handlers,cn=config",
+            "ds-cfg-ssl-cert-nickname", "server-cert" },
+    // not working at the moment see issue 655
+    // {"cn=JE
+    // Database,ds-cfg-backend-id=userRoot,cn=Backends,cn=config",
+    // "ds-cfg-database-cache-percent", 10},
     };
   }
 
+
+
   /**
    * Test simple JMX get.
-   *
    */
-  @Test(enabled = true, dataProvider="simpleGet")
+  @Test(enabled = false, dataProvider = "simpleGet")
   public void simpleGet(String dn, String attributeName, Object value)
-     throws Exception
-  {
+      throws Exception {
 
     OpendsJmxConnector connector = connect("cn=directory manager",
         "password", TestCaseUtils.getServerJmxPort());
@@ -160,25 +166,23 @@
 
     Object val = jmxGet(dn, attributeName, jmxc);
 
-    if (value != null)
-    {
+    if (value != null) {
       assertEquals(val, value);
-    }
-    else
-    {
+    } else {
       assertTrue(val == null);
     }
     connector.close();
   }
 
+
+
   /**
    * Test setting some config attribute through jmx.
    */
   @Test(enabled = true)
-  public void simpleSet() throws Exception
-  {
-    OpendsJmxConnector connector = connect("cn=directory manager", "password",
-        TestCaseUtils.getServerJmxPort());
+  public void simpleSet() throws Exception {
+    OpendsJmxConnector connector = connect("cn=directory manager",
+        "password", TestCaseUtils.getServerJmxPort());
     MBeanServerConnection jmxc = connector.getMBeanServerConnection();
     assertNotNull(jmxc);
 
@@ -194,24 +198,25 @@
 
     Long newVal = (Long) jmxGet(dn, attribute, jmxc);
 
-    assertEquals((long)newVal, (long)val+1);
+    assertEquals((long) newVal, (long) val + 1);
 
     jmxSet(dn, attribute, val + 1, jmxc);
 
     connector.close();
   }
 
+
+
   /**
-   * Test that disabling JMX connection handler does its job by
-   *  - opening a JMX connection
-   *  - changing the JMX connection handler state to disable
-   *  - trying to open a new JMX connection and check that it fails.
+   * Test that disabling JMX connection handler does its job by -
+   * opening a JMX connection - changing the JMX connection handler
+   * state to disable - trying to open a new JMX connection and check
+   * that it fails.
    *
    * @throws Exception
    */
-  @Test(enabled = true)
-  public void disable() throws Exception
-  {
+  @Test(enabled = false)
+  public void disable() throws Exception {
 
     // Create a new JMX connector for this test.
     // This will allow to use the old one if this test fails.
@@ -221,32 +226,32 @@
     serverJmxSocket.bind(new InetSocketAddress("127.0.0.1", 0));
     int serverJmxPort = serverJmxSocket.getLocalPort();
     serverJmxSocket.close();
-    Entry newJmxConnectionJmx = TestCaseUtils.makeEntry(
-        "dn: cn= New JMX Connection Handler,cn=Connection Handlers,cn=config",
-        "objectClass: top",
-        "objectClass: ds-cfg-connection-handler",
-        "objectClass: ds-cfg-jmx-connection-handler",
-        "ds-cfg-ssl-cert-nickname: server-cert",
-        "ds-cfg-connection-handler-class: org.opends.server.protocols.jmx.JmxConnectionHandler",
-        "ds-cfg-connection-handler-enabled: true",
-        "ds-cfg-use-ssl: false",
-        "ds-cfg-listen-port: " + serverJmxPort,
-        "cn: JMX Connection Handler"
-         );
+    Entry newJmxConnectionJmx = TestCaseUtils
+        .makeEntry(
+            "dn: cn= New JMX Connection Handler,cn=Connection Handlers,cn=config",
+            "objectClass: top",
+            "objectClass: ds-cfg-connection-handler",
+            "objectClass: ds-cfg-jmx-connection-handler",
+            "ds-cfg-ssl-cert-nickname: server-cert",
+            "ds-cfg-connection-handler-class: org.opends.server.protocols.jmx.JmxConnectionHandler",
+            "ds-cfg-connection-handler-enabled: true",
+            "ds-cfg-use-ssl: false", "ds-cfg-listen-port: "
+                + serverJmxPort, "cn: JMX Connection Handler");
     InternalClientConnection connection =
-        InternalClientConnection.getRootConnection();
+      InternalClientConnection.getRootConnection();
     AddOperation addOp = new AddOperation(connection,
-        InternalClientConnection.nextOperationID(), InternalClientConnection
-            .nextMessageID(), null, newJmxConnectionJmx.getDN(),
-        newJmxConnectionJmx.getObjectClasses(), newJmxConnectionJmx
+        InternalClientConnection.nextOperationID(),
+        InternalClientConnection.nextMessageID(), null,
+        newJmxConnectionJmx.getDN(), newJmxConnectionJmx
+            .getObjectClasses(), newJmxConnectionJmx
             .getUserAttributes(), newJmxConnectionJmx
             .getOperationalAttributes());
     addOp.run();
-    Thread.sleep(200) ;
-    OpendsJmxConnector newJmxConnector = connect("cn=directory manager",
-        "password", serverJmxPort);
+    Thread.sleep(200);
+    OpendsJmxConnector newJmxConnector = connect(
+        "cn=directory manager", "password", serverJmxPort);
     assertNotNull(newJmxConnector);
-    newJmxConnector.close() ;
+    newJmxConnector.close();
 
     // Get the "old" connector
     OpendsJmxConnector connector = connect("cn=directory manager",
@@ -255,40 +260,45 @@
     assertNotNull(jmxc);
 
     // Disable the "new" connector
-    toggleEnableJmxConnector(connector, newJmxConnectionJmx.getDN(), false);
-    Thread.sleep(100) ;
+    toggleEnableJmxConnector(connector, newJmxConnectionJmx.getDN(),
+        false);
+    Thread.sleep(100);
     OpendsJmxConnector jmxcDisabled = connect("cn=directory manager",
         "password", serverJmxPort);
     assertNull(jmxcDisabled);
 
-    toggleEnableJmxConnector(connector, newJmxConnectionJmx.getDN(), true);
-    Thread.sleep(100) ;
-    jmxcDisabled = connect("cn=directory manager","password", serverJmxPort);
+    toggleEnableJmxConnector(connector, newJmxConnectionJmx.getDN(),
+        true);
+    Thread.sleep(100);
+    jmxcDisabled = connect("cn=directory manager", "password",
+        serverJmxPort);
     assertNotNull(jmxcDisabled);
 
     // cleanup client connection
-    connector.close() ;
+    connector.close();
     jmxcDisabled.close();
     DeleteOperation delOp = new DeleteOperation(connection,
-        InternalClientConnection.nextOperationID(), InternalClientConnection
-            .nextMessageID(), null, newJmxConnectionJmx.getDN());
+        InternalClientConnection.nextOperationID(),
+        InternalClientConnection.nextMessageID(), null,
+        newJmxConnectionJmx.getDN());
     delOp.run();
   }
 
+
+
   /**
    * Test changing JMX port through LDAP
+   *
    * @throws Exception
    */
-  @Test(enabled=true)
-  public void changePort() throws Exception
-  {
+  @Test(enabled = false)
+  public void changePort() throws Exception {
     // Connect to the JMX service and get the current port
-    final String dn =
-      "cn=JMX Connection Handler,cn=Connection Handlers,cn=config";
+    final String dn = "cn=JMX Connection Handler,cn=Connection Handlers,cn=config";
     final String attribute = "ds-cfg-listen-port";
 
-    OpendsJmxConnector connector = connect("cn=directory manager", "password",
-        TestCaseUtils.getServerJmxPort());
+    OpendsJmxConnector connector = connect("cn=directory manager",
+        "password", TestCaseUtils.getServerJmxPort());
     MBeanServerConnection jmxc = connector.getMBeanServerConnection();
     assertNotNull(jmxc);
 
@@ -302,23 +312,23 @@
     ServerSocket serverJmxSocket = TestCaseUtils.bindFreePort();
     int serverJmxPort = serverJmxSocket.getLocalPort();
 
-    ConfigEntry config = new ConfigEntry(TestCaseUtils.makeEntry(
-        "dn: cn=JMX Connection Handler,cn=Connection Handlers,cn=config",
-        "objectClass: top",
-        "objectClass: ds-cfg-connection-handler",
-        "objectClass: ds-cfg-jmx-connection-handler",
-        "ds-cfg-ssl-cert-nickname: server-cert",
-        "ds-cfg-connection-handler-class: org.opends.server.protocols.jmx.JmxConnectionHandler",
-        "ds-cfg-connection-handler-enabled: true",
-        "ds-cfg-use-ssl: false",
-        "ds-cfg-listen-port: " + serverJmxPort,
-        "cn: JMX Connection Handler"
-         ), null);
+    Entry entry = TestCaseUtils
+            .makeEntry(
+                "dn: cn=JMX Connection Handler,cn=Connection Handlers,cn=config",
+                "objectClass: top",
+                "objectClass: ds-cfg-connection-handler",
+                "objectClass: ds-cfg-jmx-connection-handler",
+                "ds-cfg-ssl-cert-nickname: server-cert",
+                "ds-cfg-connection-handler-class: org.opends.server.protocols.jmx.JmxConnectionHandler",
+                "ds-cfg-connection-handler-enabled: true",
+                "ds-cfg-use-ssl: false", "ds-cfg-listen-port: "
+                    + serverJmxPort, "cn: JMX Connection Handler");
     serverJmxSocket.close();
-    configureJmx(config);
+    configureJmx(entry);
 
     // connect the the JMX service using the new port
-    connector = connect("cn=directory manager", "password",serverJmxPort) ;
+    connector = connect("cn=directory manager", "password",
+        serverJmxPort);
     jmxc = connector.getMBeanServerConnection();
     assertNotNull(jmxc);
     Long val = (Long) jmxGet(dn, attribute, jmxc);
@@ -326,20 +336,19 @@
     connector.close();
 
     // re-establish the initial configuration of the JMX service
-    config = new ConfigEntry(TestCaseUtils.makeEntry(
-        "dn: cn=JMX Connection Handler,cn=Connection Handlers,cn=config",
-        "objectClass: top",
-        "objectClass: ds-cfg-connection-handler",
-        "objectClass: ds-cfg-jmx-connection-handler",
-        "ds-cfg-ssl-cert-nickname: server-cert",
-        "ds-cfg-connection-handler-class: org.opends.server.protocols.jmx.JmxConnectionHandler",
-        "ds-cfg-connection-handler-enabled: true",
-        "ds-cfg-use-ssl: false",
-        "ds-cfg-listen-port: " + initJmxPort,
-        "cn: JMX Connection Handler"
-         ), null);
+    entry = TestCaseUtils
+            .makeEntry(
+                "dn: cn=JMX Connection Handler,cn=Connection Handlers,cn=config",
+                "objectClass: top",
+                "objectClass: ds-cfg-connection-handler",
+                "objectClass: ds-cfg-jmx-connection-handler",
+                "ds-cfg-ssl-cert-nickname: server-cert",
+                "ds-cfg-connection-handler-class: org.opends.server.protocols.jmx.JmxConnectionHandler",
+                "ds-cfg-connection-handler-enabled: true",
+                "ds-cfg-use-ssl: false", "ds-cfg-listen-port: "
+                    + initJmxPort, "cn: JMX Connection Handler");
 
-    configureJmx(config);
+    configureJmx(entry);
 
     // Check that the old port is ok
     connector = connect("cn=directory manager", "password",
@@ -348,60 +357,56 @@
     assertNotNull(jmxc);
   }
 
+
+
   /**
    * Check that simple (no SSL) connections to the JMX service are
-   * accepted when the given
-   * credentials are OK and refused when the credentials are invalid.
-   *
+   * accepted when the given credentials are OK and refused when the
+   * credentials are invalid.
    */
-  @Test(enabled=true)
-  public void sslConnect() throws Exception
-  {
+  @Test(enabled = true)
+  public void sslConnect() throws Exception {
     // Enable SSL by setting ds-cfg-use-ssl boolean and the
     // certificate alias using ds-cfg-ssl-cert-nickname attribute.
     int initJmxPort = (int) TestCaseUtils.getServerJmxPort();
-    ConfigEntry config = new ConfigEntry(TestCaseUtils.makeEntry(
-        "dn: cn=JMX Connection Handler,cn=Connection Handlers,cn=config",
-        "objectClass: top",
-        "objectClass: ds-cfg-connection-handler",
-        "objectClass: ds-cfg-jmx-connection-handler",
-        "ds-cfg-ssl-cert-nickname: server-cert",
-        "ds-cfg-connection-handler-class: org.opends.server.protocols.jmx.JmxConnectionHandler",
-        "ds-cfg-connection-handler-enabled: true",
-        "ds-cfg-use-ssl: true",
-        "ds-cfg-listen-port: " + initJmxPort ,
-        "ds-cfg-key-manager-provider-dn: cn=JKS,cn=Key Manager Providers,cn=config",
-        "cn: JMX Connection Handler"
-         ), null);
+    
+    Entry entry = TestCaseUtils
+        .makeEntry(
+            "dn: cn=JMX Connection Handler,cn=Connection Handlers,cn=config",
+            "objectClass: top",
+            "objectClass: ds-cfg-connection-handler",
+            "objectClass: ds-cfg-jmx-connection-handler",
+            "ds-cfg-ssl-cert-nickname: server-cert",
+            "ds-cfg-connection-handler-class: org.opends.server.protocols.jmx.JmxConnectionHandler",
+            "ds-cfg-connection-handler-enabled: true",
+            "ds-cfg-use-ssl: true",
+            "ds-cfg-listen-port: " + initJmxPort,
+            "ds-cfg-key-manager-provider-dn: cn=JKS,cn=Key Manager Providers,cn=config",
+            "cn: JMX Connection Handler");
 
-    configureJmx(config);
+    configureJmx(entry);
 
-
-    OpendsJmxConnector jmxc = sslConnect("cn=directory manager", "password",
-                                            initJmxPort);
+    OpendsJmxConnector jmxc = sslConnect("cn=directory manager",
+        "password", initJmxPort);
     MBeanServerConnection mbsc = jmxc.getMBeanServerConnection();
     jmxc.close();
 
     // Before returning the result,
     // disable SSL by setting ds-cfg-use-ssl boolean
-    config = new ConfigEntry(TestCaseUtils.makeEntry(
-        "dn: cn=JMX Connection Handler,cn=Connection Handlers,cn=config",
-        "objectClass: top",
-        "objectClass: ds-cfg-connection-handler",
-        "objectClass: ds-cfg-jmx-connection-handler",
-        "ds-cfg-ssl-cert-nickname: server-cert",
-        "ds-cfg-connection-handler-class: org.opends.server.protocols.jmx.JmxConnectionHandler",
-        "ds-cfg-connection-handler-enabled: true",
-        "ds-cfg-use-ssl: false",
-        "ds-cfg-listen-port: " + initJmxPort,
-        "cn: JMX Connection Handler"
-         ), null);
-    try
-    {
-      configureJmx(config);
-    }
-    catch (RuntimeException e)
-    {
+    entry = TestCaseUtils
+            .makeEntry(
+                "dn: cn=JMX Connection Handler,cn=Connection Handlers,cn=config",
+                "objectClass: top",
+                "objectClass: ds-cfg-connection-handler",
+                "objectClass: ds-cfg-jmx-connection-handler",
+                "ds-cfg-ssl-cert-nickname: server-cert",
+                "ds-cfg-connection-handler-class: org.opends.server.protocols.jmx.JmxConnectionHandler",
+                "ds-cfg-connection-handler-enabled: true",
+                "ds-cfg-use-ssl: false", "ds-cfg-listen-port: "
+                    + initJmxPort, "cn: JMX Connection Handler");
+    try {
+      configureJmx(entry);
+    } catch (RuntimeException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
     }
@@ -411,36 +416,47 @@
     assertNotNull(jmxc);
   }
 
+
+
   /**
    * @param config
+   * @throws ConfigException
    */
-  private void configureJmx(ConfigEntry config)
-  {
+  private void configureJmx(Entry entry) throws ConfigException {
     ArrayList<String> reasons = new ArrayList<String>();
 
     // Get the Jmx connection handler from the core server
     JmxConnectionHandler jmxConnectionHandler = getJmxConnectionHandler();
     assertNotNull(jmxConnectionHandler);
-    if (!jmxConnectionHandler.hasAcceptableConfiguration(config, reasons) )
+
+    JMXConnectionHandlerCfg config = AdminTestCaseUtils
+        .getConfiguration(JMXConnectionHandlerCfgDefn
+            .getInstance(), entry);
+
+    if (!jmxConnectionHandler.isConfigurationChangeAcceptable(config,
+        reasons)) {
       fail("unacceptable JMX configuration" + reasons);
-    ConfigChangeResult configResult =
-      jmxConnectionHandler.applyNewConfiguration(config, false);
+    }
+
+    ConfigChangeResult configResult = jmxConnectionHandler
+        .applyConfigurationChange(config);
+
     assertEquals(configResult.getResultCode(), ResultCode.SUCCESS);
   }
 
+
+
   /**
    * Get a reference to the JMX connection handler.
    */
-  private JmxConnectionHandler getJmxConnectionHandler()
-  {
-    List<ConnectionHandler> handlers = DirectoryServer.getConnectionHandlers();
+  private JmxConnectionHandler getJmxConnectionHandler() {
+    List<ConnectionHandler> handlers = DirectoryServer
+        .getConnectionHandlers();
     assertNotNull(handlers);
     JmxConnectionHandler jmxConnectionHandler = null;
-    for (ConnectionHandler handler : handlers)
-    {
-      if (handler instanceof JmxConnectionHandler)
-      {
-         jmxConnectionHandler = (JmxConnectionHandler) handler;
+    for (ConnectionHandler handler : handlers) {
+      if (handler instanceof JmxConnectionHandler) {
+        jmxConnectionHandler = (JmxConnectionHandler) handler;
         break;
       }
     }
@@ -448,77 +464,70 @@
   }
 
 
+
   /**
    * Connect to the JMX service.
    */
-  private OpendsJmxConnector connect(
-      String user, String password, long jmxPort)
-      throws MalformedURLException, IOException
-  {
+  private OpendsJmxConnector connect(String user, String password,
+      long jmxPort) throws MalformedURLException, IOException {
     HashMap<String, Object> env = new HashMap<String, Object>();
 
     // Provide the credentials required by the server to successfully
     // perform user authentication
     //
     String[] credentials;
-    if ((user == null) && (password == null))
-    {
+    if ((user == null) && (password == null)) {
       credentials = null;
-    }
-    else
-      credentials = new String[] { user , password };
+    } else
+      credentials = new String[] { user, password };
     env.put("jmx.remote.credentials", credentials);
 
-    env.put("jmx.remote.x.client.connection.check.period",0);
+    env.put("jmx.remote.x.client.connection.check.period", 0);
 
     // Create an RMI connector client and
     // connect it to the RMI connector server
     //
     OpendsJmxConnector opendsConnector;
-    try
-    {
-      opendsConnector = new OpendsJmxConnector("localhost",(int)jmxPort, env);
-      opendsConnector.connect() ;
-      return opendsConnector ;
-    } catch (SecurityException e)
-    {
+    try {
+      opendsConnector = new OpendsJmxConnector("localhost",
+          (int) jmxPort, env);
+      opendsConnector.connect();
+      return opendsConnector;
+    } catch (SecurityException e) {
       return null;
-    }
-    catch (IOException e)
-    {
+    } catch (IOException e) {
       return null;
     }
   }
 
+
+
   /**
    * Connect to the JMX service using SSL.
    */
-  private OpendsJmxConnector
-      sslConnect(String user, String password, long jmxPort)
-      throws Exception
-  {
+  private OpendsJmxConnector sslConnect(String user, String password,
+      long jmxPort) throws Exception {
     HashMap<String, Object> env = new HashMap<String, Object>();
 
     // Provide the credentials required by the server to successfully
     // perform user authentication
     String[] credentials;
-    if ((user == null) && (password == null))
-    {
+    if ((user == null) && (password == null)) {
       credentials = null;
-    }
-    else
-      credentials = new String[] { user , password };
+    } else
+      credentials = new String[] { user, password };
     env.put("jmx.remote.credentials", credentials);
 
     // Provide the Trust manager.
-    KeyStore ks = null ;
+    KeyStore ks = null;
     ks = KeyStore.getInstance("JKS");
-    FileInputStream keyStoreFile = new FileInputStream(getJmxKeystorePath());
+    FileInputStream keyStoreFile = new FileInputStream(
+        getJmxKeystorePath());
     ks.load(keyStoreFile, "password".toCharArray());
     keyStoreFile.close();
 
-    TrustManagerFactory tmf =
-      TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
+    TrustManagerFactory tmf = TrustManagerFactory
+        .getInstance(TrustManagerFactory.getDefaultAlgorithm());
     tmf.init(ks);
     TrustManager tms[] = tmf.getTrustManagers();
     env.put(JmxConnectionHandler.TRUST_MANAGER_ARRAY_KEY, tms);
@@ -526,69 +535,68 @@
     // Create an RMI connector client and
     // connect it to the RMI connector server
     OpendsJmxConnector opendsConnector;
-    try
-    {
-      opendsConnector = new OpendsJmxConnector("localhost",(int)jmxPort, env);
-      opendsConnector.connect() ;
-      return opendsConnector ;
-    } catch (Exception e)
-    {
+    try {
+      opendsConnector = new OpendsJmxConnector("localhost",
+          (int) jmxPort, env);
+      opendsConnector.connect();
+      return opendsConnector;
+    } catch (Exception e) {
 
       return null;
     }
 
   }
 
+
+
   /**
    * @return
    */
-  private String getJmxKeystorePath()
-  {
-    return DirectoryServer.getServerRoot() + File.separator +
-              "config" + File.separator +
-              "server.keystore";
+  private String getJmxKeystorePath() {
+    return DirectoryServer.getServerRoot() + File.separator + "config"
+        + File.separator + "server.keystore";
   }
 
+
+
   /**
    * Set the enabled config attribute for a JMX connector thorugh JMX
    * operation.
    *
    * @param jmxc
-   *        connector to use for the interaction
+   *          connector to use for the interaction
    * @param testedConnector
-   *        The DN of the connector the test
+   *          The DN of the connector the test
    * @param enabled
-   *        the value of the enabled config attribute
+   *          the value of the enabled config attribute
    */
-  private void toggleEnableJmxConnector(
-      OpendsJmxConnector jmxc, DN testedConnector,
-      boolean enabled) throws Exception
-  {
+  private void toggleEnableJmxConnector(OpendsJmxConnector jmxc,
+      DN testedConnector, boolean enabled) throws Exception {
     MBeanServerConnection mbsc = jmxc.getMBeanServerConnection();
 
     // Get status of the JMX connection handler
     String jmxName = JMXMBean.getJmxName(testedConnector);
     ObjectName name = ObjectName.getInstance(jmxName);
     Attribute status = (Attribute) mbsc.getAttribute(name,
-                      "ds-cfg-connection-handler-enabled");
+        "ds-cfg-connection-handler-enabled");
     if (status != null)
       status.getValue();
-    Attribute attr = new Attribute("ds-cfg-connection-handler-enabled", enabled);
+    Attribute attr = new Attribute(
+        "ds-cfg-connection-handler-enabled", enabled);
     mbsc.setAttribute(name, attr);
     status = (Attribute) mbsc.getAttribute(name,
-         "ds-cfg-connection-handler-enabled");
+        "ds-cfg-connection-handler-enabled");
 
     status = null;
   }
 
 
+
   /**
    * Get an attribute value through JMX.
    */
   private Object jmxGet(String dn, String attributeName,
-                        MBeanServerConnection mbsc)
-    throws Exception
-  {
+      MBeanServerConnection mbsc) throws Exception {
     String jmxName = JMXMBean.getJmxName(DN.decode(dn));
     ObjectName name = ObjectName.getInstance(jmxName);
 
@@ -606,13 +614,13 @@
     }
   }
 
+
+
   /**
    * Set an attribute value through JMX.
    */
-  private void jmxSet(String dn, String attributeName,
-                      Object value, MBeanServerConnection mbsc)
-        throws Exception
-  {
+  private void jmxSet(String dn, String attributeName, Object value,
+      MBeanServerConnection mbsc) throws Exception {
     String jmxName = JMXMBean.getJmxName(DN.decode(dn));
     ObjectName name = ObjectName.getInstance(jmxName);
     Attribute attr = new Attribute(attributeName, value);

--
Gitblit v1.10.0