Search in sources :

Example 51 with HttpHandler

use of io.undertow.server.HttpHandler in project wildfly by wildfly.

the class ModClusterUndertowDeploymentProcessor method deploy.

@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    // Add mod_cluster-undertow integration service (jboss.modcluster.undertow) as a web deployment dependency
    deploymentUnit.addToAttachmentList(Attachments.WEB_DEPENDENCIES, UndertowEventHandlerAdapterBuilder.SERVICE_NAME);
    // Request count wrapping
    if (isMetricEnabled(RequestCountLoadMetric.class)) {
        deploymentUnit.addToAttachmentList(UndertowAttachments.UNDERTOW_INITIAL_HANDLER_CHAIN_WRAPPERS, new HandlerWrapper() {

            @Override
            public HttpHandler wrap(final HttpHandler handler) {
                return new RequestCountHttpHandler(handler);
            }
        });
    }
    // Bytes Sent wrapping
    if (isMetricEnabled(SendTrafficLoadMetric.class)) {
        deploymentUnit.addToAttachmentList(UndertowAttachments.UNDERTOW_INITIAL_HANDLER_CHAIN_WRAPPERS, new HandlerWrapper() {

            @Override
            public HttpHandler wrap(final HttpHandler handler) {
                return new BytesSentHttpHandler(handler);
            }
        });
    }
    // Bytes Received wrapping
    if (isMetricEnabled(ReceiveTrafficLoadMetric.class)) {
        deploymentUnit.addToAttachmentList(UndertowAttachments.UNDERTOW_INITIAL_HANDLER_CHAIN_WRAPPERS, new HandlerWrapper() {

            @Override
            public HttpHandler wrap(final HttpHandler handler) {
                return new BytesReceivedHttpHandler(handler);
            }
        });
    }
    // Busyness thread setup actions
    if (isMetricEnabled(BusyConnectorsLoadMetric.class)) {
        deploymentUnit.addToAttachmentList(UndertowAttachments.UNDERTOW_OUTER_HANDLER_CHAIN_WRAPPERS, new HandlerWrapper() {

            @Override
            public HttpHandler wrap(final HttpHandler handler) {
                return new RunningRequestsHttpHandler(handler);
            }
        });
    }
}
Also used : RequestCountHttpHandler(org.wildfly.mod_cluster.undertow.metric.RequestCountHttpHandler) HttpHandler(io.undertow.server.HttpHandler) BytesReceivedHttpHandler(org.wildfly.mod_cluster.undertow.metric.BytesReceivedHttpHandler) BytesSentHttpHandler(org.wildfly.mod_cluster.undertow.metric.BytesSentHttpHandler) RunningRequestsHttpHandler(org.wildfly.mod_cluster.undertow.metric.RunningRequestsHttpHandler) RequestCountHttpHandler(org.wildfly.mod_cluster.undertow.metric.RequestCountHttpHandler) BytesSentHttpHandler(org.wildfly.mod_cluster.undertow.metric.BytesSentHttpHandler) BytesReceivedHttpHandler(org.wildfly.mod_cluster.undertow.metric.BytesReceivedHttpHandler) RunningRequestsHttpHandler(org.wildfly.mod_cluster.undertow.metric.RunningRequestsHttpHandler) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) HandlerWrapper(io.undertow.server.HandlerWrapper)

Example 52 with HttpHandler

use of io.undertow.server.HttpHandler in project wildfly by wildfly.

the class UndertowHostTestCase method findContext.

@Test
public void findContext() {
    Deployment deployment = mock(Deployment.class);
    DeploymentInfo info = new DeploymentInfo();
    String expectedPath = "";
    info.setContextPath(expectedPath);
    HttpHandler handler = mock(HttpHandler.class);
    when(deployment.getDeploymentInfo()).thenReturn(info);
    this.undertowHost.registerDeployment(deployment, handler);
    Context result = this.host.findContext(expectedPath);
    assertSame(this.host, result.getHost());
    assertSame(expectedPath, result.getPath());
    result = this.host.findContext("unknown");
    assertNull(result);
}
Also used : Context(org.jboss.modcluster.container.Context) HttpHandler(io.undertow.server.HttpHandler) Deployment(io.undertow.servlet.api.Deployment) DeploymentInfo(io.undertow.servlet.api.DeploymentInfo) Test(org.junit.Test)

Example 53 with HttpHandler

use of io.undertow.server.HttpHandler in project wildfly by wildfly.

the class UndertowHostTestCase method getContexts.

@Test
public void getContexts() {
    Deployment deployment = mock(Deployment.class);
    DeploymentInfo info = new DeploymentInfo();
    String expectedPath = "";
    info.setContextPath(expectedPath);
    HttpHandler handler = mock(HttpHandler.class);
    when(deployment.getDeploymentInfo()).thenReturn(info);
    this.undertowHost.registerDeployment(deployment, handler);
    Iterator<Context> result = this.host.getContexts().iterator();
    assertTrue(result.hasNext());
    Context context = result.next();
    assertSame(this.host, context.getHost());
    assertSame(expectedPath, context.getPath());
    assertFalse(result.hasNext());
}
Also used : Context(org.jboss.modcluster.container.Context) HttpHandler(io.undertow.server.HttpHandler) Deployment(io.undertow.servlet.api.Deployment) DeploymentInfo(io.undertow.servlet.api.DeploymentInfo) Test(org.junit.Test)

Example 54 with HttpHandler

use of io.undertow.server.HttpHandler in project cxf by apache.

the class UndertowBasicAuthHandler method buildSecurityHandler.

private void buildSecurityHandler() {
    HttpHandler handler = this.next;
    handler = new AuthenticationCallHandler(handler);
    handler = new AuthenticationConstraintHandler(handler);
    final List<AuthenticationMechanism> mechanisms = Collections.<AuthenticationMechanism>singletonList(new BasicAuthenticationMechanism("My Realm"));
    handler = new AuthenticationMechanismsHandler(handler, mechanisms);
    this.securityHandler = new SecurityInitialHandler(AuthenticationMode.PRO_ACTIVE, identityManager, handler);
}
Also used : CXFUndertowHttpHandler(org.apache.cxf.transport.http_undertow.CXFUndertowHttpHandler) HttpHandler(io.undertow.server.HttpHandler) AuthenticationConstraintHandler(io.undertow.security.handlers.AuthenticationConstraintHandler) SecurityInitialHandler(io.undertow.security.handlers.SecurityInitialHandler) AuthenticationMechanismsHandler(io.undertow.security.handlers.AuthenticationMechanismsHandler) BasicAuthenticationMechanism(io.undertow.security.impl.BasicAuthenticationMechanism) AuthenticationMechanism(io.undertow.security.api.AuthenticationMechanism) AuthenticationCallHandler(io.undertow.security.handlers.AuthenticationCallHandler) BasicAuthenticationMechanism(io.undertow.security.impl.BasicAuthenticationMechanism)

Example 55 with HttpHandler

use of io.undertow.server.HttpHandler in project cxf by apache.

the class UndertowDigestAuthHandler method buildSecurityHandler.

private void buildSecurityHandler() {
    HttpHandler handler = this.next;
    handler = new AuthenticationCallHandler(handler);
    handler = new AuthenticationConstraintHandler(handler);
    final List<AuthenticationMechanism> mechanisms = Collections.<AuthenticationMechanism>singletonList(new DigestAuthenticationMechanism("WSRealm", "WSDomain", "DIGEST", this.identityManager));
    handler = new AuthenticationMechanismsHandler(handler, mechanisms);
    this.securityHandler = new SecurityInitialHandler(AuthenticationMode.PRO_ACTIVE, identityManager, handler);
}
Also used : CXFUndertowHttpHandler(org.apache.cxf.transport.http_undertow.CXFUndertowHttpHandler) HttpHandler(io.undertow.server.HttpHandler) AuthenticationConstraintHandler(io.undertow.security.handlers.AuthenticationConstraintHandler) DigestAuthenticationMechanism(io.undertow.security.impl.DigestAuthenticationMechanism) SecurityInitialHandler(io.undertow.security.handlers.SecurityInitialHandler) AuthenticationMechanismsHandler(io.undertow.security.handlers.AuthenticationMechanismsHandler) DigestAuthenticationMechanism(io.undertow.security.impl.DigestAuthenticationMechanism) AuthenticationMechanism(io.undertow.security.api.AuthenticationMechanism) AuthenticationCallHandler(io.undertow.security.handlers.AuthenticationCallHandler)

Aggregations

HttpHandler (io.undertow.server.HttpHandler)126 HttpServerExchange (io.undertow.server.HttpServerExchange)72 IOException (java.io.IOException)54 BeforeClass (org.junit.BeforeClass)35 Test (org.junit.Test)25 TestHttpClient (io.undertow.testutils.TestHttpClient)20 HttpResponse (org.apache.http.HttpResponse)20 HttpGet (org.apache.http.client.methods.HttpGet)19 PathHandler (io.undertow.server.handlers.PathHandler)17 HttpString (io.undertow.util.HttpString)15 DeploymentInfo (io.undertow.servlet.api.DeploymentInfo)13 Undertow (io.undertow.Undertow)12 ArrayList (java.util.ArrayList)11 HandlerWrapper (io.undertow.server.HandlerWrapper)9 InMemorySessionManager (io.undertow.server.session.InMemorySessionManager)9 SessionAttachmentHandler (io.undertow.server.session.SessionAttachmentHandler)9 Header (org.apache.http.Header)9 SessionCookieConfig (io.undertow.server.session.SessionCookieConfig)8 AuthenticationMechanism (io.undertow.security.api.AuthenticationMechanism)7 AuthenticationCallHandler (io.undertow.security.handlers.AuthenticationCallHandler)7