/**
   * Connects to a particular instance of the domain adminstration server using the provided
   * connection information
   */
  public boolean connect(ServerConnectionIdentifier targetDAS) {
    try {
      TLSParams tlsParams = null;
      if (targetDAS.isSecure()) {
        X509TrustManager trustManager =
            (X509TrustManager)
                targetDAS
                    .getConnectionEnvironment()
                    .get(DefaultConfiguration.TRUST_MANAGER_PROPERTY_NAME);
        tlsParams = new TLSParams(trustManager, null);
      }

      dasConnection =
          new AppserverConnectionSource(
              AppserverConnectionSource.PROTOCOL_HTTP,
              targetDAS.getHostName(),
              targetDAS.getHostPort(),
              targetDAS.getUserName(),
              targetDAS.getPassword(),
              tlsParams,
              null);
    } catch (IllegalArgumentException illEx) {
      return false;
    }
    serverId = targetDAS;
    domain = new SunTarget(targetDAS);
    domain.setConnectionSource(dasConnection);
    domain.setTargetType(TargetType.DOMAIN);
    return true;
  }
  public Target[] createTargets(String[] targets) {
    if (!isConnected()) {
      throw new IllegalStateException(
          localStrings.getString("enterprise.deployment.client.disconnected_state"));
    }
    Target[] targetsArray = new Target[targets.length];
    Map serverProxies = null;
    Map clusterProxies = null;

    try {
      // parse through given targets
      for (int i = 0; i < targets.length; i++) {

        // if this is "domain" add a domain target
        if (TargetType.DOMAIN.equals(targets[i])) {
          // Add a domain target
          SunTarget dom = new SunTarget(serverId);
          dom.setAppServerInstance(TargetType.DOMAIN);
          dom.setConnectionSource(dasConnection);
          dom.setTargetType(TargetType.DOMAIN);
          targetsArray[i] = dom;
          continue;
        }
        // if this is "server" add a server target
        if (DAS.equals(targets[i])) {
          // Add a target for default server
          SunTarget serv = new SunTarget(serverId);
          serv.setAppServerInstance(DAS);
          serv.setConnectionSource(dasConnection);
          serv.setTargetType(TargetType.STAND_ALONE_SERVER);
          targetsArray[i] = serv;
          continue;
        }
        // for PE, it will not come here at all; go ahead and get proxies and server/cluster keysets
        // from the proxies
        if (serverProxies == null || clusterProxies == null) {
          DomainConfig domainCfg =
              ProxyFactory.getInstance(dasConnection).getDomainRoot().getDomainConfig();
          serverProxies = domainCfg.getStandaloneServerConfigMap();
          clusterProxies = domainCfg.getClusterConfigMap();
        }
        // check if ctarget is a stand alone server
        if (serverProxies.get(targets[i]) != null) {
          SunTarget aTarget = new SunTarget(serverId);
          aTarget.setAppServerInstance(targets[i]);
          aTarget.setConnectionSource(dasConnection);
          aTarget.setTargetType(TargetType.STAND_ALONE_SERVER);
          targetsArray[i] = aTarget;
          continue;
        }
        // check if ctarget is a cluster
        if (clusterProxies.get(targets[i]) != null) {
          SunTarget aTarget = new SunTarget(serverId);
          aTarget.setAppServerInstance(targets[i]);
          aTarget.setConnectionSource(dasConnection);
          aTarget.setTargetType(TargetType.CLUSTER);
          targetsArray[i] = aTarget;
          continue;
        }
        // if we are here, it means given target does not exist at all - return null
        return null;
      }
    } catch (Throwable ex) {
      // it's too late to change the DeploymentFacility.createTargets
      // interface to throw approriate exceptions as this point,
      // but let's at least re-throw the RuntimeException so
      // connection failure (for example, due to wrong user/password)
      // could be reported back to user.
      if (ex instanceof RuntimeException) {
        throw (RuntimeException) ex;
      }
      return null;
    }
    return targetsArray;
  }