Class HttpServerChannelHandler

  • All Implemented Interfaces:
    io.netty.channel.ChannelHandler, io.netty.channel.ChannelInboundHandler

    public class HttpServerChannelHandler
    extends org.apache.camel.component.netty.handlers.ServerChannelHandler
    Netty HTTP ServerChannelHandler that handles the incoming HTTP requests and routes the received message in Camel.
    • Nested Class Summary

      • Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler

        io.netty.channel.ChannelHandler.Sharable
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected Subject authenticate​(SecurityAuthenticator authenticator, org.apache.camel.LoggingLevel deniedLoggingLevel, HttpPrincipal principal)
      Authenticates the http basic auth subject.
      protected void beforeProcess​(org.apache.camel.Exchange exchange, io.netty.channel.ChannelHandlerContext ctx, Object message)  
      protected void channelRead0​(io.netty.channel.ChannelHandlerContext ctx, Object msg)  
      protected org.apache.camel.Exchange createExchange​(io.netty.channel.ChannelHandlerContext ctx, Object message)  
      void exceptionCaught​(io.netty.channel.ChannelHandlerContext ctx, Throwable cause)  
      protected static HttpPrincipal extractBasicAuthSubject​(io.netty.handler.codec.http.HttpRequest request)
      Extracts the username and password details from the HTTP basic header Authorization.
      NettyHttpConsumer getConsumer()  
      protected Object getResponseBody​(org.apache.camel.Exchange exchange)  
      protected boolean matchesRoles​(String roles, String userRoles)  
      • Methods inherited from class org.apache.camel.component.netty.handlers.ServerChannelHandler

        channelActive, channelInactive, createResponseFutureListener
      • Methods inherited from class io.netty.channel.SimpleChannelInboundHandler

        acceptInboundMessage, channelRead
      • Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter

        channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, userEventTriggered
      • Methods inherited from class io.netty.channel.ChannelHandlerAdapter

        ensureNotSharable, handlerAdded, handlerRemoved, isSharable
      • Methods inherited from interface io.netty.channel.ChannelHandler

        handlerAdded, handlerRemoved
    • Constructor Detail

      • HttpServerChannelHandler

        public HttpServerChannelHandler​(NettyHttpConsumer consumer)
    • Method Detail

      • channelRead0

        protected void channelRead0​(io.netty.channel.ChannelHandlerContext ctx,
                                    Object msg)
                             throws Exception
        Overrides:
        channelRead0 in class org.apache.camel.component.netty.handlers.ServerChannelHandler
        Throws:
        Exception
      • matchesRoles

        protected boolean matchesRoles​(String roles,
                                       String userRoles)
      • extractBasicAuthSubject

        protected static HttpPrincipal extractBasicAuthSubject​(io.netty.handler.codec.http.HttpRequest request)
        Extracts the username and password details from the HTTP basic header Authorization.

        This requires that the Authorization HTTP header is provided, and its using Basic. Currently Digest is not supported.

        Returns:
        HttpPrincipal with username and password details, or null if not possible to extract
      • authenticate

        protected Subject authenticate​(SecurityAuthenticator authenticator,
                                       org.apache.camel.LoggingLevel deniedLoggingLevel,
                                       HttpPrincipal principal)
        Authenticates the http basic auth subject.
        Parameters:
        authenticator - the authenticator
        principal - the principal
        Returns:
        true if username and password is valid, false if not
      • beforeProcess

        protected void beforeProcess​(org.apache.camel.Exchange exchange,
                                     io.netty.channel.ChannelHandlerContext ctx,
                                     Object message)
        Overrides:
        beforeProcess in class org.apache.camel.component.netty.handlers.ServerChannelHandler
      • exceptionCaught

        public void exceptionCaught​(io.netty.channel.ChannelHandlerContext ctx,
                                    Throwable cause)
        Specified by:
        exceptionCaught in interface io.netty.channel.ChannelHandler
        Specified by:
        exceptionCaught in interface io.netty.channel.ChannelInboundHandler
        Overrides:
        exceptionCaught in class org.apache.camel.component.netty.handlers.ServerChannelHandler
      • getResponseBody

        protected Object getResponseBody​(org.apache.camel.Exchange exchange)
                                  throws Exception
        Overrides:
        getResponseBody in class org.apache.camel.component.netty.handlers.ServerChannelHandler
        Throws:
        Exception
      • createExchange

        protected org.apache.camel.Exchange createExchange​(io.netty.channel.ChannelHandlerContext ctx,
                                                           Object message)
                                                    throws Exception
        Overrides:
        createExchange in class org.apache.camel.component.netty.handlers.ServerChannelHandler
        Throws:
        Exception