org.jboss.netty.handler.ipfilter

## Class IpFilteringHandlerImpl

- java.lang.Object
- - org.jboss.netty.handler.ipfilter.IpFilteringHandlerImpl

- All Implemented Interfaces:
    ChannelHandler, ChannelUpstreamHandler, IpFilteringHandler
  Direct Known Subclasses:
    IpFilterRuleHandler, OneIpFilterHandler

      public abstract class IpFilteringHandlerImpl
      extends Object
      implements ChannelUpstreamHandler, IpFilteringHandler

  General class that handle Ip Filtering.

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface org.jboss.netty.channel.ChannelHandler

      `ChannelHandler.Sharable`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `IpFilteringHandlerImpl()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected abstract boolean` | `accept(ChannelHandlerContext ctx, ChannelEvent e, InetSocketAddress inetSocketAddress)` Called when the channel is connected.
    `protected boolean` | `continues(ChannelHandlerContext ctx, ChannelEvent e)` Called in handleUpstream, if this channel was previously blocked, to check if whatever the event, it should be passed to the next entry in the pipeline.
    `protected ChannelFuture` | `handleAllowedChannel(ChannelHandlerContext ctx, ChannelEvent e, InetSocketAddress inetSocketAddress)`
    `protected ChannelFuture` | `handleRefusedChannel(ChannelHandlerContext ctx, ChannelEvent e, InetSocketAddress inetSocketAddress)` Called when the channel has the CONNECTED status and the channel was refused by a previous call to accept().
    `void` | `handleUpstream(ChannelHandlerContext ctx, ChannelEvent e)` Handles the specified upstream event.
    `protected boolean` | `isBlocked(ChannelHandlerContext ctx)` Internal method to test if the current channel is blocked.
    `void` | `removeIpFilterListener()` Remove the filter listener.
    `void` | `setIpFilterListener(IpFilterListener listener)` Sets the filter listener.

    - ### Methods inherited from class java.lang.Object

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

- - ### Constructor Detail

    - #### IpFilteringHandlerImpl

          public IpFilteringHandlerImpl()

  - ### Method Detail

    - #### accept

          protected abstract boolean accept(ChannelHandlerContext ctx,
                       ChannelEvent e,
                       InetSocketAddress inetSocketAddress)
                                     throws Exception

      Called when the channel is connected. It returns True if the corresponding connection is to be allowed. Else it returns False.
      Parameters:
        `inetSocketAddress` - the remote `InetSocketAddress` from client
      Returns:
        True if the corresponding connection is allowed, else False.
      Throws:
        `Exception`

    - #### handleRefusedChannel

          protected ChannelFuture handleRefusedChannel(ChannelHandlerContext ctx,
                                           ChannelEvent e,
                                           InetSocketAddress inetSocketAddress)
                                                throws Exception

      Called when the channel has the CONNECTED status and the channel was refused by a previous call to accept(). This method enables your implementation to send a message back to the client before closing or whatever you need. This method returns a ChannelFuture on which the implementation will wait uninterruptibly before closing the channel.
      For instance, If a message is sent back, the corresponding ChannelFuture has to be returned.
      Parameters:
        `inetSocketAddress` - the remote `InetSocketAddress` from client
      Returns:
        the associated ChannelFuture to be waited for before closing the channel. Null is allowed.
      Throws:
        `Exception`

    - #### handleAllowedChannel

          protected ChannelFuture handleAllowedChannel(ChannelHandlerContext ctx,
                                           ChannelEvent e,
                                           InetSocketAddress inetSocketAddress)
                                                throws Exception

      Throws:
        `Exception`

    - #### isBlocked

          protected boolean isBlocked(ChannelHandlerContext ctx)

      Internal method to test if the current channel is blocked. Should not be overridden.
      Returns:
        True if the current channel is blocked, else False

    - #### continues

          protected boolean continues(ChannelHandlerContext ctx,
                          ChannelEvent e)
                               throws Exception

      Called in handleUpstream, if this channel was previously blocked, to check if whatever the event, it should be passed to the next entry in the pipeline.
      If one wants to not block events, just overridden this method by returning always true.
      Note that OPENED and BOUND events are still passed to the next entry in the pipeline since those events come out before the CONNECTED event and so the possibility to filter the connection.
      Returns:
        True if the event should continue, False if the event should not continue since this channel was blocked by this filter
      Throws:
        `Exception`

    - #### handleUpstream

          public void handleUpstream(ChannelHandlerContext ctx,
                            ChannelEvent e)
                              throws Exception

      Description copied from interface: `ChannelUpstreamHandler`
      Handles the specified upstream event.
      Specified by:
        `handleUpstream` in interface `ChannelUpstreamHandler`
      Parameters:
        `ctx` - the context object for this handler
        `e` - the upstream event to process or intercept
      Throws:
        `Exception`

    - #### setIpFilterListener

          public void setIpFilterListener(IpFilterListener listener)

      Description copied from interface: `IpFilteringHandler`
      Sets the filter listener.
      Specified by:
        `setIpFilterListener` in interface `IpFilteringHandler`
      Parameters:
        `listener` - the new ip filter listener

    - #### removeIpFilterListener

          public void removeIpFilterListener()

      Description copied from interface: `IpFilteringHandler`
      Remove the filter listener.
      Specified by:
        `removeIpFilterListener` in interface `IpFilteringHandler`

Copyright © 2008-2012 The Netty Project. All Rights Reserved.