Package org.eclipse.jetty.server

Examples of org.eclipse.jetty.server.ServerConnector


      // Chrome.
      sslContextFactory.setWantClientAuth(true);
    }

    for (InetSocketAddress address : httpAddresses) {
      ServerConnector connector;
      if (sslEnabled) {
        connector = new ServerConnector(httpServer, sslContextFactory);
      } else {
        connector = new ServerConnector(httpServer);
      }
      connector.setHost(address.getAddress().getHostAddress());
      connector.setPort(address.getPort());
      connector.setIdleTimeout(0);
      list.add(connector);
    }

    return list;
  }
View Full Code Here


   */
  public SocketAddress getWebSocketAddress() {
    if (httpServer == null) {
      return null;
    } else {
      ServerConnector c = (ServerConnector)httpServer.getConnectors()[0];
      return new InetSocketAddress(c.getHost(), c.getLocalPort());
    }
  }
View Full Code Here

    private void build() {
        if (server != null)
            return;
        this.server = new Server(new QueuedThreadPool(nThreads, nThreads));
        this.http = new ServerConnector(server);
        http.setPort(port);
        http.setAcceptQueueSize(maxConn);
        server.addConnector(http);
        this.context = new ServletContextHandler(ServletContextHandler.SESSIONS);
    }
View Full Code Here

                this.configurationClasses = JETTY_CONFIGURATION_CLASSES;
            }
         }

         server = new Server();
         ServerConnector connector = new ServerConnector(server);
         connector.setHost(containerConfig.getBindAddress());
         connector.setPort(containerConfig.getBindHttpPort());
         server.setConnectors(new Connector[] { connector });
         server.setHandler(new HandlerCollection(true));
         log.info("Starting Jetty Embedded Server " + Server.getVersion() + " [id:" + server.hashCode() + "]");
         server.start();
      }
View Full Code Here

public class Start
{
  public static void main(String[] args)
  {
    Server server = new Server();
    ServerConnector connector = new ServerConnector(server, new HttpConnectionFactory());
    // Set some timeout options to make debugging easier.
    connector.setIdleTimeout(1000 * 60 * 60);
    connector.setSoLingerTime(-1);
    connector.setPort(8080);
    server.setConnectors(new Connector[] {connector});

    WebAppContext bb = new WebAppContext();
    bb.setServer(server);
    bb.setContextPath("/");
View Full Code Here

    http_config.setResponseHeaderSize(8192);
    http_config.setSendServerVersion(true);
    http_config.setSendDateHeader(false);

    Server server = new Server();
    ServerConnector connector = new ServerConnector(server, new HttpConnectionFactory(http_config));

    // Set some timeout options to make debugging easier.
//        connector.setMaxIdleTime(timeout);
    connector.setSoLingerTime(-1);
    connector.setPort(8080);
    server.addConnector(connector);

    Resource keystore = Resource.newClassPathResource("/keystore");
    if (keystore != null && keystore.exists()) {
      // if a keystore for a SSL certificate is available, start a SSL
      // connector on port 8443.
      // By default, the quickstart comes with a Apache Wicket Quickstart
      // Certificate that expires about half way september 2021. Do not
      // use this certificate anywhere important as the passwords are
      // available in the source.

      SslContextFactory factory = new SslContextFactory();
      factory.setKeyStoreResource(keystore);
      factory.setKeyStorePassword("wicket");
      factory.setTrustStoreResource(keystore);
      factory.setKeyManagerPassword("wicket");

      // SSL HTTP Configuration
      HttpConfiguration https_config = new HttpConfiguration(http_config);
      https_config.addCustomizer(new SecureRequestCustomizer());

      // SSL Connector
      ServerConnector sslConnector = new ServerConnector(server,
          new SslConnectionFactory(factory,"http/1.1"),
          new HttpConnectionFactory(https_config));
      sslConnector.setPort(8443);
      server.addConnector(sslConnector);

      System.out.println("SSL access to the quickstart has been enabled on port 8443");
      System.out.println("You can access the application using SSL on https://localhost:8443");
      System.out.println();
View Full Code Here

        // set redirect port for those pages requiring confidential
        // (SSL) access
        httpConfig.setSecurePort(this.httpsPort);
      }
      httpConfig.setOutputBufferSize(32768);
      ServerConnector http = new ServerConnector(server,
          new HttpConnectionFactory(httpConfig));
      http.setPort(this.httpPort);

      server.addConnector(http);
    }

    // set up HTTPS connector with SSL key store (and optionally a trust
    // store)
    if (this.httpsPort != null) {
      checkArgument(this.sslKeyStoreType != null,
          "https configuration missing key store type is null");
      checkArgument(this.sslKeyStorePath != null,
          "https configuration missing SSL key store path");
      checkArgument(this.sslKeyStorePassword != null,
          "https configuration missing SSL key store password");

      SslContextFactory sslContextFactory = new SslContextFactory();
      sslContextFactory.setKeyStoreType(this.sslKeyStoreType.name());
      sslContextFactory.setKeyStorePath(this.sslKeyStorePath);
      sslContextFactory.setKeyStorePassword(this.sslKeyStorePassword);
      if (this.sslKeyPassword != null) {
        sslContextFactory.setKeyManagerPassword(this.sslKeyPassword);
      } else {
        sslContextFactory
            .setKeyManagerPassword(this.sslKeyStorePassword);
      }

      if (this.sslTrustStorePath != null) {
        checkArgument(this.sslTrustStoreType != null,
            "missing trust store type for trust store");
        checkArgument(this.sslTrustStorePassword != null,
            "missing password for trust store");

        sslContextFactory.setTrustStoreType(this.sslTrustStoreType
            .name());
        sslContextFactory.setTrustStorePath(this.sslTrustStorePath);
        sslContextFactory
            .setTrustStorePassword(this.sslTrustStorePassword);
      }
      if (this.sslRequireClientCert) {
        checkArgument(this.sslTrustStorePath != null,
            "Client certificate authentication specified without "
                + "specifying a trust store");
        checkArgument(this.sslTrustStorePassword != null,
            "Client certificate authentication specified without "
                + "specifying a trust store password");
      }
      // if true: requires client to authenticate with certificate
      sslContextFactory.setNeedClientAuth(this.sslRequireClientCert);
      // if true: authenticates client certificate if provided
      sslContextFactory.setWantClientAuth(false);

      // HTTPS config
      HttpConfiguration httpsConfig = new HttpConfiguration();
      httpsConfig.addCustomizer(new SecureRequestCustomizer());
      httpsConfig.setOutputBufferSize(32768);
      // HTTPS connector
      ServerConnector https = new ServerConnector(server,
          new SslConnectionFactory(sslContextFactory, "http/1.1"),
          new HttpConnectionFactory(httpsConfig));
      https.setPort(this.httpsPort);

      server.addConnector(https);
    }

    return server;
View Full Code Here

        server.setHandler(web);
  }

  private static void initConnnector(Server server, Configs configObj) {
    ServerConnector connector = new ServerConnector(server);

    //Don't set any host , or the port detection will failed. -_-#
    //connector.setHost("127.0.0.1");
    connector.setPort(configObj.getPort());

    server.addConnector(connector);

    if (configObj.getEnablessl() && configObj.getSslport() != null){
      initSSL(server, configObj.getSslport(), configObj.getKeystore(),
View Full Code Here

      System.err.println("Enable NeedClientAuth.");
      sslcontextfactory.setNeedClientAuth(needClientAuth);
    }

   
    ServerConnector sslConnector = new ServerConnector(server,sslcontextfactory);
        sslConnector.setPort(sslport);
        server.addConnector(sslConnector);
        try{
          sslConnector.open();
        }catch(Exception ex){
          ex.printStackTrace();
        }
  }
View Full Code Here

          factory.setNeedClientAuth(true);
        } else {
          factory.setWantClientAuth(true);
        }

        ServerConnector connector = new ServerConnector(server, factory);
        connector.setSoLingerTime(-1);
        connector.setIdleTimeout(30000);
        connector.setPort(params.securePort);
        String bindInterface = settings.getString(Keys.server.httpsBindInterface, null);
        if (!StringUtils.isEmpty(bindInterface)) {
          logger.warn(MessageFormat.format(
              "Binding HTTPS transport on port {0,number,0} to {1}", params.securePort,
              bindInterface));
          connector.setHost(bindInterface);
        }
        if (params.securePort < 1024 && !isWindows()) {
          logger.warn("Gitblit needs to run with ROOT permissions for ports < 1024!");
        }

        server.addConnector(connector);
      } else {
        logger.warn("Failed to find or load Keystore?");
        logger.warn("HTTPS transport DISABLED.");
      }
    }

    // conditionally configure the http transport
    if (params.port > 0) {
      /*
       * HTTP
       */
      logger.info("Setting up HTTP transport on port " + params.port);

      HttpConfiguration httpConfig = new HttpConfiguration();
      if (params.port > 0 && params.securePort > 0 && settings.getBoolean(Keys.server.redirectToHttpsPort, true)) {
        httpConfig.setSecureScheme("https");
        httpConfig.setSecurePort(params.securePort);
      }
          httpConfig.setSendServerVersion(false);
          httpConfig.setSendDateHeader(false);

      ServerConnector connector = new ServerConnector(server, new HttpConnectionFactory(httpConfig));
      connector.setSoLingerTime(-1);
      connector.setIdleTimeout(30000);
      connector.setPort(params.port);
      String bindInterface = settings.getString(Keys.server.httpBindInterface, null);
      if (!StringUtils.isEmpty(bindInterface)) {
        logger.warn(MessageFormat.format("Binding HTTP transport on port {0,number,0} to {1}",
            params.port, bindInterface));
        connector.setHost(bindInterface);
      }
      if (params.port < 1024 && !isWindows()) {
        logger.warn("Gitblit needs to run with ROOT permissions for ports < 1024!");
      }

View Full Code Here

TOP

Related Classes of org.eclipse.jetty.server.ServerConnector

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.