@Override public SslHandler create(ByteBufAllocator bufferAllocator) { SslHandler handler = super.create(bufferAllocator); handler.engine().setNeedClientAuth(clientAuthEnabled); return handler; } }
@Override protected void initChannel(SocketChannel ch) { channelGroup.add(ch); ChannelPipeline pipeline = ch.pipeline(); if (sslEnabled) { pipeline.addLast("ssl", sslHandlerFactory.create(ch.alloc())); } pipeline.addLast("http-codec", new HttpServerCodec()); pipeline.addLast("http-status-request-handler", new HttpStatusRequestHandler()); if (securityEnabled) { pipeline.addLast("access-token-authenticator", new AuthenticationHandler(cConf, tokenValidator, discoveryServiceClient, accessTokenTransformer)); } if (cConf.getBoolean(Constants.Router.ROUTER_AUDIT_LOG_ENABLED)) { pipeline.addLast("audit-log", new AuditLogHandler()); } // Always let the client to continue sending the request body after the authentication passed pipeline.addLast("expect-continue", new HttpServerExpectContinueHandler()); // for now there's only one hardcoded rule, but if there will be more, we may want it generic and configurable pipeline.addLast("http-request-handler", new HttpRequestRouter(cConf, serviceLookup)); } });
@Override protected void initChannel(SocketChannel ch) throws Exception { channelGroup.add(ch); ChannelPipeline pipeline = ch.pipeline(); if (sslHandlerFactory != null) { // Add SSLHandler if SSL is enabled pipeline.addLast("ssl", sslHandlerFactory.create(ch.alloc())); } pipeline.addLast("codec", new HttpServerCodec()); pipeline.addLast("compressor", new HttpContentCompressor()); pipeline.addLast("chunkedWriter", new ChunkedWriteHandler()); pipeline.addLast("keepAlive", new HttpServerKeepAliveHandler()); pipeline.addLast("router", new RequestRouter(resourceHandler, httpChunkLimit, sslHandlerFactory != null)); if (eventExecutorGroup == null) { pipeline.addLast("dispatcher", new HttpDispatcher()); } else { pipeline.addLast(eventExecutorGroup, "dispatcher", new HttpDispatcher()); } if (pipelineModifier != null) { pipelineModifier.modify(pipeline); } } });