Search in sources :

Example 96 with Connector

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

the class AthenzJettyContainerTest method testInitContainerOnlyHTTPSPort.

@Test
public void testInitContainerOnlyHTTPSPort() {
    System.setProperty(AthenzConsts.ATHENZ_PROP_HTTP_PORT, "0");
    System.setProperty(AthenzConsts.ATHENZ_PROP_HTTPS_PORT, "4443");
    System.setProperty("yahoo.zms.debug.user_authority", "true");
    AthenzJettyContainer container = AthenzJettyContainer.createJettyContainer();
    assertNotNull(container);
    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) Test(org.testng.annotations.Test)

Example 97 with Connector

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

the class AthenzJettyContainerTest method testInitContainerOnlyHTTPPort.

@Test
public void testInitContainerOnlyHTTPPort() {
    System.setProperty(AthenzConsts.ATHENZ_PROP_HTTP_PORT, "4080");
    System.setProperty(AthenzConsts.ATHENZ_PROP_HTTPS_PORT, "0");
    AthenzJettyContainer container = AthenzJettyContainer.createJettyContainer();
    assertNotNull(container);
    Server server = container.getServer();
    Connector[] connectors = server.getConnectors();
    assertEquals(connectors.length, 1);
    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) Test(org.testng.annotations.Test)

Example 98 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, "src/test/resources/keystore.pkcs12");
    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_KEYSTORE_RELOAD_SEC, "3600");
    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 99 with Connector

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

the class AthenzJettyContainerTest method testInitContainerInvalidHTTPPort.

@Test
public void testInitContainerInvalidHTTPPort() {
    System.setProperty(AthenzConsts.ATHENZ_PROP_HTTP_PORT, "-10");
    System.setProperty(AthenzConsts.ATHENZ_PROP_HTTPS_PORT, "4443");
    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 100 with Connector

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

the class AthenzJettyContainerTest method testInitContainerInvalidHTTPSPort.

@Test
public void testInitContainerInvalidHTTPSPort() {
    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)

Aggregations

Connector (org.eclipse.jetty.server.Connector)131 Server (org.eclipse.jetty.server.Server)66 ServerConnector (org.eclipse.jetty.server.ServerConnector)51 ServletContextHandler (org.eclipse.jetty.servlet.ServletContextHandler)31 HttpConfiguration (org.eclipse.jetty.server.HttpConfiguration)26 HttpConnectionFactory (org.eclipse.jetty.server.HttpConnectionFactory)23 IOException (java.io.IOException)22 ServletHolder (org.eclipse.jetty.servlet.ServletHolder)20 ArrayList (java.util.ArrayList)18 SslContextFactory (org.eclipse.jetty.util.ssl.SslContextFactory)16 QueuedThreadPool (org.eclipse.jetty.util.thread.QueuedThreadPool)15 SelectChannelConnector (org.eclipse.jetty.server.nio.SelectChannelConnector)14 Test (org.testng.annotations.Test)14 Handler (org.eclipse.jetty.server.Handler)11 NetworkConnector (org.eclipse.jetty.server.NetworkConnector)11 SecureRequestCustomizer (org.eclipse.jetty.server.SecureRequestCustomizer)11 File (java.io.File)10 SslConnectionFactory (org.eclipse.jetty.server.SslConnectionFactory)10 ContextHandler (org.eclipse.jetty.server.handler.ContextHandler)10 ContextHandlerCollection (org.eclipse.jetty.server.handler.ContextHandlerCollection)10