Search in sources :

Example 76 with Connector

use of org.eclipse.jetty.server.Connector in project athenz by yahoo.

the class AthenzJettyContainerTest method initContainerInvalidHTTPSPort.

@Test
public void initContainerInvalidHTTPSPort() {
    System.setProperty(AthenzConsts.ATHENZ_PROP_HOME, "/tmp/ATHENZ_server");
    System.setProperty(AthenzConsts.ATHENZ_PROP_HTTP_PORT, "4080");
    System.setProperty(AthenzConsts.ATHENZ_PROP_HTTPS_PORT, "-10");
    AthenzJettyContainer container = AthenzJettyContainer.createJettyContainer();
    assertNotNull(container);
    Server server = container.getServer();
    Connector[] connectors = server.getConnectors();
    assertEquals(connectors.length, 2);
    assertTrue(connectors[0].getProtocols().contains("http/1.1"));
    assertTrue(connectors[1].getProtocols().contains("http/1.1"));
    assertTrue(connectors[1].getProtocols().contains("ssl"));
}
Also used : Connector(org.eclipse.jetty.server.Connector) Server(org.eclipse.jetty.server.Server) Test(org.testng.annotations.Test)

Example 77 with Connector

use of org.eclipse.jetty.server.Connector in project athenz by yahoo.

the class AthenzJettyContainerTest method testHttpConnectorsBoth.

@Test
public void testHttpConnectorsBoth() {
    System.setProperty(AthenzConsts.ATHENZ_PROP_KEYSTORE_PATH, "/tmp/keystore");
    System.setProperty(AthenzConsts.ATHENZ_PROP_KEYSTORE_TYPE, "PKCS12");
    System.setProperty(AthenzConsts.ATHENZ_PROP_KEYSTORE_PASSWORD, "pass123");
    System.setProperty(AthenzConsts.ATHENZ_PROP_TRUSTSTORE_PATH, "/tmp/truststore");
    System.setProperty(AthenzConsts.ATHENZ_PROP_TRUSTSTORE_TYPE, "PKCS12");
    System.setProperty(AthenzConsts.ATHENZ_PROP_TRUSTSTORE_PASSWORD, "pass123");
    System.setProperty(AthenzConsts.ATHENZ_PROP_KEYMANAGER_PASSWORD, "pass123");
    System.setProperty(AthenzConsts.ATHENZ_PROP_IDLE_TIMEOUT, "10001");
    AthenzJettyContainer container = new AthenzJettyContainer();
    container.createServer(100);
    HttpConfiguration httpConfig = container.newHttpConfiguration();
    container.addHTTPConnectors(httpConfig, 8081, 8082, 0);
    Server server = container.getServer();
    Connector[] connectors = server.getConnectors();
    assertEquals(connectors.length, 2);
    assertEquals(connectors[0].getIdleTimeout(), 10001);
    assertTrue(connectors[0].getProtocols().contains("http/1.1"));
    assertTrue(connectors[1].getProtocols().contains("http/1.1"));
    assertTrue(connectors[1].getProtocols().contains("ssl"));
}
Also used : Connector(org.eclipse.jetty.server.Connector) Server(org.eclipse.jetty.server.Server) HttpConfiguration(org.eclipse.jetty.server.HttpConfiguration) Test(org.testng.annotations.Test)

Example 78 with Connector

use of org.eclipse.jetty.server.Connector in project athenz by yahoo.

the class AthenzJettyContainerTest method testHttpConnectorsHttpOnly.

@Test
public void testHttpConnectorsHttpOnly() {
    System.setProperty(AthenzConsts.ATHENZ_PROP_KEYSTORE_PATH, "file:///tmp/keystore");
    System.setProperty(AthenzConsts.ATHENZ_PROP_KEYSTORE_TYPE, "PKCS12");
    System.setProperty(AthenzConsts.ATHENZ_PROP_KEYSTORE_PASSWORD, "pass123");
    System.setProperty(AthenzConsts.ATHENZ_PROP_TRUSTSTORE_PATH, "file:///tmp/truststore");
    System.setProperty(AthenzConsts.ATHENZ_PROP_TRUSTSTORE_TYPE, "PKCS12");
    System.setProperty(AthenzConsts.ATHENZ_PROP_TRUSTSTORE_PASSWORD, "pass123");
    System.setProperty(AthenzConsts.ATHENZ_PROP_KEYMANAGER_PASSWORD, "pass123");
    System.setProperty(AthenzConsts.ATHENZ_PROP_IDLE_TIMEOUT, "10001");
    AthenzJettyContainer container = new AthenzJettyContainer();
    container.createServer(100);
    HttpConfiguration httpConfig = container.newHttpConfiguration();
    container.addHTTPConnectors(httpConfig, 8081, 0, 0);
    Server server = container.getServer();
    Connector[] connectors = server.getConnectors();
    assertEquals(connectors.length, 1);
    assertEquals(connectors[0].getIdleTimeout(), 10001);
    assertTrue(connectors[0].getProtocols().contains("http/1.1"));
    assertFalse(connectors[0].getProtocols().contains("ssl"));
}
Also used : Connector(org.eclipse.jetty.server.Connector) Server(org.eclipse.jetty.server.Server) HttpConfiguration(org.eclipse.jetty.server.HttpConfiguration) Test(org.testng.annotations.Test)

Example 79 with Connector

use of org.eclipse.jetty.server.Connector in project athenz by yahoo.

the class AthenzJettyContainerTest method testHttpConnectorsHttpsOnly.

@Test
public void testHttpConnectorsHttpsOnly() {
    System.setProperty(AthenzConsts.ATHENZ_PROP_KEYSTORE_PATH, "file:///tmp/keystore");
    System.setProperty(AthenzConsts.ATHENZ_PROP_KEYSTORE_TYPE, "PKCS12");
    System.setProperty(AthenzConsts.ATHENZ_PROP_KEYSTORE_PASSWORD, "pass123");
    System.setProperty(AthenzConsts.ATHENZ_PROP_TRUSTSTORE_PATH, "file:///tmp/truststore");
    System.setProperty(AthenzConsts.ATHENZ_PROP_TRUSTSTORE_TYPE, "PKCS12");
    System.setProperty(AthenzConsts.ATHENZ_PROP_TRUSTSTORE_PASSWORD, "pass123");
    System.setProperty(AthenzConsts.ATHENZ_PROP_KEYMANAGER_PASSWORD, "pass123");
    System.setProperty(AthenzConsts.ATHENZ_PROP_IDLE_TIMEOUT, "10001");
    AthenzJettyContainer container = new AthenzJettyContainer();
    container.createServer(100);
    HttpConfiguration httpConfig = container.newHttpConfiguration();
    container.addHTTPConnectors(httpConfig, 0, 8082, 0);
    Server server = container.getServer();
    Connector[] connectors = server.getConnectors();
    assertEquals(connectors.length, 1);
    assertTrue(connectors[0].getProtocols().contains("http/1.1"));
    assertTrue(connectors[0].getProtocols().contains("ssl"));
}
Also used : Connector(org.eclipse.jetty.server.Connector) Server(org.eclipse.jetty.server.Server) HttpConfiguration(org.eclipse.jetty.server.HttpConfiguration) Test(org.testng.annotations.Test)

Aggregations

Connector (org.eclipse.jetty.server.Connector)79 Server (org.eclipse.jetty.server.Server)41 ServerConnector (org.eclipse.jetty.server.ServerConnector)25 ServletContextHandler (org.eclipse.jetty.servlet.ServletContextHandler)22 HttpConfiguration (org.eclipse.jetty.server.HttpConfiguration)17 HttpConnectionFactory (org.eclipse.jetty.server.HttpConnectionFactory)15 ServletHolder (org.eclipse.jetty.servlet.ServletHolder)13 IOException (java.io.IOException)12 NetworkConnector (org.eclipse.jetty.server.NetworkConnector)12 Test (org.junit.Test)11 SslContextFactory (org.eclipse.jetty.util.ssl.SslContextFactory)10 SelectChannelConnector (org.eclipse.jetty.server.nio.SelectChannelConnector)8 Test (org.testng.annotations.Test)8 Handler (org.eclipse.jetty.server.Handler)7 QueuedThreadPool (org.eclipse.jetty.util.thread.QueuedThreadPool)7 ArrayList (java.util.ArrayList)6 HashMap (java.util.HashMap)6 SecureRequestCustomizer (org.eclipse.jetty.server.SecureRequestCustomizer)6 SslConnectionFactory (org.eclipse.jetty.server.SslConnectionFactory)6 ServletException (javax.servlet.ServletException)5