mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

jvergara
20.22.2008 03e2f3ec702df46c01c9a370a1072104c179e228
opendj-sdk/opends/src/ads/org/opends/admin/ads/ServerDescriptor.java
@@ -84,6 +84,10 @@
     */
    LDAPS_ENABLED,
    /**
     * The associated value is an ArrayList of Boolean.
     */
    STARTTLS_ENABLED,
    /**
     * The associated value is an ArrayList of Integer.
     */
    JMX_PORT,
@@ -297,6 +301,80 @@
  }
  /**
   * Returns the URL to access this server using LDAP.  Returns
   * <CODE>null</CODE> if the server is not configured to listen on an LDAP
   * port.
   * @return the URL to access this server using LDAP.
   */
  public String getLDAPURL()
  {
    String ldapUrl = null;
    String host = getHostName();
    int port = -1;
    if (!serverProperties.isEmpty())
    {
      ArrayList s = (ArrayList)serverProperties.get(
          ServerProperty.LDAP_ENABLED);
      ArrayList p = (ArrayList)serverProperties.get(
          ServerProperty.LDAP_PORT);
      if (s != null)
      {
        for (int i=0; i<s.size(); i++)
        {
          if (Boolean.TRUE.equals(s.get(i)))
          {
            port = (Integer)p.get(i);
            break;
          }
        }
      }
    }
    if (port != -1)
    {
      ldapUrl = ConnectionUtils.getLDAPUrl(host, port, false);
    }
    return ldapUrl;
  }
  /**
   * Returns the URL to access this server using LDAPS.  Returns
   * <CODE>null</CODE> if the server is not configured to listen on an LDAPS
   * port.
   * @return the URL to access this server using LDAP.
   */
  public String getLDAPsURL()
  {
    String ldapsUrl = null;
    String host = getHostName();
    int port = -1;
    if (!serverProperties.isEmpty())
    {
      ArrayList s = (ArrayList)serverProperties.get(
          ServerProperty.LDAPS_ENABLED);
      ArrayList p = (ArrayList)serverProperties.get(
          ServerProperty.LDAPS_PORT);
      if (s != null)
      {
        for (int i=0; i<s.size(); i++)
        {
          if (Boolean.TRUE.equals(s.get(i)))
          {
            port = (Integer)p.get(i);
            break;
          }
        }
      }
    }
    if (port != -1)
    {
      ldapsUrl = ConnectionUtils.getLDAPUrl(host, port, true);
    }
    return ldapsUrl;
  }
  /**
   * Returns a String of type host-name:port-number for the server.  If
   * the provided securePreferred is set to true the port that will be used
   * (if LDAPS is enabled) will be the LDAPS port.
@@ -517,6 +595,16 @@
        adsProperties.put(adsProps[i][1], String.valueOf(port));
      }
    }
    ArrayList array = (ArrayList)serverProperties.get(
        ServerProperty.STARTTLS_ENABLED);
    boolean startTLSEnabled = false;
    if ((array != null) && !array.isEmpty())
    {
      startTLSEnabled = Boolean.TRUE.equals(array.get(array.size() -1));
    }
    adsProperties.put(ADSContext.ServerProperty.STARTTLS_ENABLED,
        startTLSEnabled ? "true" : "false");
    adsProperties.put(ADSContext.ServerProperty.ID, getHostPort(true));
    adsProperties.put(ADSContext.ServerProperty.INSTANCE_PUBLIC_KEY_CERTIFICATE,
                      getInstancePublicKeyCertificate());
@@ -576,6 +664,7 @@
            "ds-cfg-listen-address",
            "ds-cfg-listen-port",
            "ds-cfg-use-ssl",
            "ds-cfg-allow-start-tls",
            "objectclass"
        });
    String filter = "(objectclass=ds-cfg-ldap-connection-handler)";
@@ -587,11 +676,13 @@
    ArrayList<Integer> ldapsPorts = new ArrayList<Integer>();
    ArrayList<Boolean> ldapEnabled = new ArrayList<Boolean>();
    ArrayList<Boolean> ldapsEnabled = new ArrayList<Boolean>();
    ArrayList<Boolean> startTLSEnabled = new ArrayList<Boolean>();
    desc.serverProperties.put(ServerProperty.LDAP_PORT, ldapPorts);
    desc.serverProperties.put(ServerProperty.LDAPS_PORT, ldapsPorts);
    desc.serverProperties.put(ServerProperty.LDAP_ENABLED, ldapEnabled);
    desc.serverProperties.put(ServerProperty.LDAPS_ENABLED, ldapsEnabled);
    desc.serverProperties.put(ServerProperty.STARTTLS_ENABLED, startTLSEnabled);
    while(listeners.hasMore())
    {
@@ -613,6 +704,9 @@
      {
        ldapPorts.add(new Integer(port));
        ldapEnabled.add(enabled);
        enabled = "true".equalsIgnoreCase(
            getFirstValue(sr, "ds-cfg-allow-start-tls"));
        startTLSEnabled.add(enabled);
      }
    }
  }