示例#1
0
  @Override
  public boolean isConfigurationAcceptable(
      ConnectionHandlerCfg configuration, List<LocalizableMessage> unacceptableReasons) {
    HTTPConnectionHandlerCfg config = (HTTPConnectionHandlerCfg) configuration;

    if (currentConfig == null || (!this.enabled && config.isEnabled())) {
      // Attempt to bind to the listen port on all configured addresses to
      // verify whether the connection handler will be able to start.
      LocalizableMessage errorMessage =
          checkAnyListenAddressInUse(
              config.getListenAddress(),
              config.getListenPort(),
              config.isAllowTCPReuseAddress(),
              config.dn());
      if (errorMessage != null) {
        unacceptableReasons.add(errorMessage);
        return false;
      }
    }

    if (config.isEnabled() && config.isUseSSL()) {
      try {
        createSSLEngineConfigurator(config);
      } catch (DirectoryException e) {
        logger.traceException(e);
        unacceptableReasons.add(e.getMessageObject());
        return false;
      }
    }

    return true;
  }
  private ConnectionHandlerDescriptor getConnectionHandler(
      ConnectionHandlerCfg connHandler, String name) throws OpenDsException {
    SortedSet<InetAddress> addresses = new TreeSet<InetAddress>(getInetAddressComparator());
    int port;

    ConnectionHandlerDescriptor.Protocol protocol;

    ConnectionHandlerDescriptor.State state =
        connHandler.isEnabled()
            ? ConnectionHandlerDescriptor.State.ENABLED
            : ConnectionHandlerDescriptor.State.DISABLED;

    if (connHandler instanceof LDAPConnectionHandlerCfg) {
      LDAPConnectionHandlerCfg ldap = (LDAPConnectionHandlerCfg) connHandler;
      if (ldap.isUseSSL()) {
        protocol = ConnectionHandlerDescriptor.Protocol.LDAPS;
      } else if (ldap.isAllowStartTLS()) {
        protocol = ConnectionHandlerDescriptor.Protocol.LDAP_STARTTLS;
      } else {
        protocol = ConnectionHandlerDescriptor.Protocol.LDAP;
      }
      addAll(addresses, ldap.getListenAddress());
      port = ldap.getListenPort();
    } else if (connHandler instanceof HTTPConnectionHandlerCfg) {
      HTTPConnectionHandlerCfg http = (HTTPConnectionHandlerCfg) connHandler;
      if (http.isUseSSL()) {
        protocol = ConnectionHandlerDescriptor.Protocol.HTTPS;
      } else {
        protocol = ConnectionHandlerDescriptor.Protocol.HTTP;
      }
      addAll(addresses, http.getListenAddress());
      port = http.getListenPort();
    } else if (connHandler instanceof JMXConnectionHandlerCfg) {
      JMXConnectionHandlerCfg jmx = (JMXConnectionHandlerCfg) connHandler;
      if (jmx.isUseSSL()) {
        protocol = ConnectionHandlerDescriptor.Protocol.JMXS;
      } else {
        protocol = ConnectionHandlerDescriptor.Protocol.JMX;
      }
      addAll(addresses, jmx.getListenAddress());
      port = jmx.getListenPort();
    } else if (connHandler instanceof LDIFConnectionHandlerCfg) {
      protocol = ConnectionHandlerDescriptor.Protocol.LDIF;
      port = -1;
    } else if (connHandler instanceof SNMPConnectionHandlerCfg) {
      protocol = ConnectionHandlerDescriptor.Protocol.SNMP;
      SNMPConnectionHandlerCfg snmp = (SNMPConnectionHandlerCfg) connHandler;
      addAll(addresses, snmp.getListenAddress());
      port = snmp.getListenPort();
    } else {
      protocol = ConnectionHandlerDescriptor.Protocol.OTHER;
      port = -1;
    }
    Set<CustomSearchResult> emptySet = Collections.emptySet();
    return new ConnectionHandlerDescriptor(addresses, port, protocol, state, name, emptySet);
  }
示例#3
0
 private String getHandlerName(HTTPConnectionHandlerCfg config) {
   StringBuilder nameBuffer = new StringBuilder();
   nameBuffer.append(friendlyName);
   for (InetAddress a : config.getListenAddress()) {
     nameBuffer.append(" ");
     nameBuffer.append(a.getHostAddress());
   }
   nameBuffer.append(" port ");
   nameBuffer.append(config.getListenPort());
   return nameBuffer.toString();
 }
示例#4
0
 private boolean anyChangeRequiresRestart(HTTPConnectionHandlerCfg newCfg) {
   return !equals(newCfg.getListenPort(), initConfig.getListenPort())
       || !Objects.equals(newCfg.getListenAddress(), initConfig.getListenAddress())
       || !equals(newCfg.getMaxRequestSize(), currentConfig.getMaxRequestSize())
       || !equals(newCfg.isAllowTCPReuseAddress(), currentConfig.isAllowTCPReuseAddress())
       || !equals(newCfg.isUseTCPKeepAlive(), currentConfig.isUseTCPKeepAlive())
       || !equals(newCfg.isUseTCPNoDelay(), currentConfig.isUseTCPNoDelay())
       || !equals(
           newCfg.getMaxBlockedWriteTimeLimit(), currentConfig.getMaxBlockedWriteTimeLimit())
       || !equals(newCfg.getBufferSize(), currentConfig.getBufferSize())
       || !equals(newCfg.getAcceptBacklog(), currentConfig.getAcceptBacklog())
       || !equals(newCfg.isUseSSL(), currentConfig.isUseSSL())
       || !Objects.equals(
           newCfg.getKeyManagerProviderDN(), currentConfig.getKeyManagerProviderDN())
       || !Objects.equals(newCfg.getSSLCertNickname(), currentConfig.getSSLCertNickname())
       || !Objects.equals(
           newCfg.getTrustManagerProviderDN(), currentConfig.getTrustManagerProviderDN())
       || !Objects.equals(newCfg.getSSLProtocol(), currentConfig.getSSLProtocol())
       || !Objects.equals(newCfg.getSSLCipherSuite(), currentConfig.getSSLCipherSuite())
       || !Objects.equals(newCfg.getSSLClientAuthPolicy(), currentConfig.getSSLClientAuthPolicy());
 }
示例#5
0
  @Override
  public void initializeConnectionHandler(HTTPConnectionHandlerCfg config)
      throws ConfigException, InitializationException {
    this.enabled = config.isEnabled();

    if (friendlyName == null) {
      friendlyName = config.dn().rdn().getAttributeValue(0).toString();
    }

    int listenPort = config.getListenPort();
    for (InetAddress a : config.getListenAddress()) {
      listeners.add(new HostPort(a.getHostAddress(), listenPort));
    }

    handlerName = getHandlerName(config);

    // Configure SSL if needed.
    try {
      // This call may disable the connector if wrong SSL settings
      configureSSL(config);
    } catch (DirectoryException e) {
      logger.traceException(e);
      throw new InitializationException(e.getMessageObject());
    }

    // Create and register monitors.
    statTracker = new HTTPStatistics(handlerName + " Statistics");
    DirectoryServer.registerMonitorProvider(statTracker);

    connMonitor = new ClientConnectionMonitorProvider(this);
    DirectoryServer.registerMonitorProvider(connMonitor);

    // Register this as a change listener.
    config.addHTTPChangeListener(this);

    this.initConfig = config;
    this.currentConfig = config;
  }