/** start the KERBEROS server */
  private void startKerberos(KdcServerBean kdcServerBean, DirectoryService directoryService)
      throws Exception {
    LOG.info("Starting the Kerberos server");
    long startTime = System.currentTimeMillis();

    kdcServer = ServiceBuilder.createKdcServer(kdcServerBean, directoryService);

    if (kdcServer == null) {
      LOG.info(
          "Cannot find any reference to the Kerberos Server in the configuration : the server won't be started");
      return;
    }

    getDirectoryService().startup();
    kdcServer.setDirectoryService(getDirectoryService());

    printBanner(BANNER_KERBEROS);

    kdcServer.start();

    if (LOG.isInfoEnabled()) {
      LOG.info(
          "Kerberos server: started in {} milliseconds",
          (System.currentTimeMillis() - startTime) + "");
    }
  }
  public void stop() throws Exception {
    // Stops the server
    if (ldapServer != null) {
      ldapServer.stop();
    }

    if (kdcServer != null) {
      kdcServer.stop();
    }

    /*if ( changePwdServer != null )
    {
        changePwdServer.stop();
    }*/

    if (ntpServer != null) {
      ntpServer.stop();
    }

    if (httpServer != null) {
      httpServer.stop();
    }

    // We now have to stop the underlaying DirectoryService
    ldapServer.getDirectoryService().shutdown();
  }
  /**
   * Stops LDAP server and KDCServer and shuts down the directory service.
   *
   * @param managementClient
   * @param containerId
   * @throws Exception
   * @see
   *     org.jboss.as.arquillian.api.ServerSetupTask#tearDown(org.jboss.as.arquillian.container.ManagementClient,
   *     java.lang.String)
   */
  public void tearDown(ManagementClient managementClient, String containerId) throws Exception {
    krbServer1.stop();
    ldapServer1.stop();
    directoryService1.shutdown();

    KEYSTORE_FILE.delete();

    FileUtils.deleteDirectory(directoryService1.getInstanceLayout().getInstanceDirectory());

    if (removeBouncyCastle) {
      try {
        Security.removeProvider(BouncyCastleProvider.PROVIDER_NAME);
      } catch (SecurityException ex) {
        LOGGER.warn("Cannot deregister BouncyCastleProvider", ex);
      }
    }
  }