/** {@inheritDoc} */
  @Override
  protected Object doExecute() throws Exception {
    new CloudifyLicenseVerifier().verifyLicense();

    if (getTimeoutInMinutes() < 0) {
      throw new CLIException("-timeout cannot be negative");
    }

    if (SPRING_SECURITY_CONFIG_FILE == null) {
      throw new IllegalStateException(
          "Environment variable "
              + CloudifyConstants.SPRING_SECURITY_CONFIG_FILE_ENV_VAR
              + " cannot be null");
    }
    if (securityProfile == null) {
      throw new IllegalStateException(
          "Environment variable "
              + CloudifyConstants.SPRING_ACTIVE_PROFILE_ENV_VAR
              + " cannot be null");
    }
    if (CloudifyConstants.SPRING_PROFILE_SECURE.equals(securityProfile)) {
      if (KEYSTORE_FILE == null) {
        throw new IllegalStateException(
            "Environment variable " + CloudifyConstants.KEYSTORE_FILE_ENV_VAR + " cannot be null");
      }
      if (KEYSTORE_PASSWORD == null) {
        throw new IllegalStateException(
            "Environment variable "
                + CloudifyConstants.KEYSTORE_PASSWORD_ENV_VAR
                + " cannot be null");
      }
    }

    setSecurityMode();

    final LocalhostGridAgentBootstrapper installer = new LocalhostGridAgentBootstrapper();
    installer.setVerbose(verbose);
    installer.setLookupGroups(lookupGroups);
    installer.setLookupLocators(lookupLocators);
    installer.setNicAddress(nicAddress);
    installer.setProgressInSeconds(DEFAULT_PROGRESS_INTERVAL_SECONDS);
    installer.setAdminFacade((AdminFacade) session.get(Constants.ADMIN_FACADE));
    installer.setNoWebServices(noWebServices);
    installer.setNoManagementSpace(noManagementSpace);
    installer.setNotHighlyAvailableManagementSpace(isNotHAManagementSpace());
    installer.setAutoShutdown(autoShutdown);
    installer.setWaitForWebui(true);
    installer.setCloudFilePath(cloudFileName);

    installer.startManagementOnLocalhostAndWait(
        securityProfile,
        SPRING_SECURITY_CONFIG_FILE,
        username,
        password,
        KEYSTORE_FILE,
        KEYSTORE_PASSWORD,
        getTimeoutInMinutes(),
        TimeUnit.MINUTES);
    return "Management started successfully. Use the shutdown-management command to shutdown"
        + " management processes running on local machine.";
  }
 /**
  * Checks if the passed security profile uses a secure connection (SSL).
  *
  * @param springSecurityProfile The name of the security profile
  * @return true - if the profile indicates SSL is used, false otherwise.
  */
 public static boolean isSecureConnection(final String springSecurityProfile) {
   List<String> existingProfiles = Arrays.asList(springSecurityProfile.toLowerCase().split(","));
   return existingProfiles.contains(CloudifyConstants.SPRING_PROFILE_SECURE.toLowerCase());
 }