Class HttpServerChannelHandler

java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
io.netty.channel.SimpleChannelInboundHandler<Object>
org.apache.camel.component.netty.handlers.ServerChannelHandler
org.apache.camel.component.netty.http.handlers.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
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    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.
     
    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 class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface io.netty.channel.ChannelHandler

    handlerAdded, handlerRemoved
  • Constructor Details

    • HttpServerChannelHandler

      public HttpServerChannelHandler(NettyHttpConsumer consumer)
  • Method Details

    • getConsumer

      public NettyHttpConsumer getConsumer()
    • 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