Overview | Package | Class | Tree | Deprecated | Index | Help
| Openfire 3.4.3 Javadoc
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.jivesoftware.openfire.interceptor
Class InterceptorManager

    java.lang.Object
      org.jivesoftware.openfire.interceptor.InterceptorManager

    public class InterceptorManager

extends Object

An InterceptorManager manages the list of global interceptors and per-user interceptors that are invoked before and after packets are read and sent. If an interceptor is installed for a user then it will receive all packets sent or received for any connection of that user.

PacketInterceptors that are invoked before the packet is sent or processed (when read) may change the original packet or reject the packet by throwing a `PacketRejectedException`. If the interceptor rejects a received packet then the sender of the packet receive a `not_allowed` error.

Author:
  Gaston Dombiak
See Also:
  `PacketInterceptor`

Constructor Summary
`InterceptorManager()`

Method Summary
`void` | `addInterceptor(int index, PacketInterceptor interceptor)` Inserts a new interceptor at specified index in the list of currently configured interceptors.
`void` | `addInterceptor(PacketInterceptor interceptor)` Inserts a new interceptor at the end of the list of currently configured interceptors.
`void` | `addUserInterceptor(String username, int index, PacketInterceptor interceptor)` Inserts a new interceptor at specified index in the list of currently configured interceptors for a specific username.
`static InterceptorManager` | `getInstance()` Returns a singleton instance of InterceptorManager.
`List<PacketInterceptor>` | `getInterceptors()` Returns an unmodifiable list of global packet interceptors.
`List<PacketInterceptor>` | `getUserInterceptors(String username)` Returns an unmodifable list of packet interceptors that are related to the specified username.
`void` | `invokeInterceptors(Packet packet, Session session, boolean read, boolean processed)` Invokes all currently-installed interceptors on the specified packet.
`boolean` | `removeInterceptor(PacketInterceptor interceptor)` Removes the global interceptor from the list.
`boolean` | `removeUserInterceptor(String username, PacketInterceptor interceptor)` Removes the interceptor from the list of interceptors that are related to a specific username.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### InterceptorManager

    public InterceptorManager()

Method Detail

### getInstance

    public static InterceptorManager getInstance()

  Returns a singleton instance of InterceptorManager.

  Returns:
    an instance of InterceptorManager.

### getInterceptors

    public List<PacketInterceptor> getInterceptors()

  Returns an unmodifiable list of global packet interceptors. Global interceptors are applied to all packets read and sent by the server.

  Returns:
    an unmodifiable list of the global packet interceptors.

### addInterceptor

    public void addInterceptor(PacketInterceptor interceptor)

  Inserts a new interceptor at the end of the list of currently configured interceptors. This interceptor will be used for all the sent and received packets.

  Parameters:
    `interceptor` - the interceptor to add.

### addInterceptor

    public void addInterceptor(int index,
                               PacketInterceptor interceptor)

  Inserts a new interceptor at specified index in the list of currently configured interceptors. This interceptor will be used for all the sent and received packets.

  Parameters:
    `index` - the index in the list to insert the new interceptor at.
    `interceptor` - the interceptor to add.

### removeInterceptor

    public boolean removeInterceptor(PacketInterceptor interceptor)

  Removes the global interceptor from the list.

  Parameters:
    `interceptor` - the interceptor to remove.
  Returns:
    true if the item was present in the list

### getUserInterceptors

    public List<PacketInterceptor> getUserInterceptors(String username)

  Returns an unmodifable list of packet interceptors that are related to the specified username.

  Parameters:
    `username` - the name of the user.
  Returns:
    an unmodifiable list of packet interceptors that are related to the specified username.

### addUserInterceptor

    public void addUserInterceptor(String username,
                                   int index,
                                   PacketInterceptor interceptor)

  Inserts a new interceptor at specified index in the list of currently configured interceptors for a specific username. This interceptor will be used only when a packet was sent or received by the specified username.

  Parameters:
    `username` - the name of the user.
    `index` - the index in the list to insert the new interceptor at.
    `interceptor` - the interceptor to add.

### removeUserInterceptor

    public boolean removeUserInterceptor(String username,
                                         PacketInterceptor interceptor)

  Removes the interceptor from the list of interceptors that are related to a specific username.

  Parameters:
    `username` - the name of the user.
    `interceptor` - the interceptor to remove.
  Returns:
    true if the item was present in the list

### invokeInterceptors

    public void invokeInterceptors(Packet packet,
                                   Session session,
                                   boolean read,
                                   boolean processed)
                            throws PacketRejectedException

  Invokes all currently-installed interceptors on the specified packet. All global interceptors will be invoked as well as interceptors that are related to the address of the session that received or is sending the packet.

  Interceptors are executed before and after processing an incoming packet and sending a packet to a user. This means that interceptors are able to alter or reject packets before they are processed further. If possible, interceptors should perform their work in a short time so that overall performance is not compromised.

  Parameters:
    `packet` - the packet that has been read or is about to be sent.
    `session` - the session that received the packet or that the packet will be sent to.
    `read` - true indicates that the packet was read. When false, the packet is being sent to a user.
    `processed` - true if the packet has already processed (incoming or outgoing). If the packet hasn't already been processed, this flag will be false.
  Throws:
    `PacketRejectedException` - if the packet should be prevented from being processed.

Overview | Package | Class | Tree | Deprecated | Index | Help
| Openfire 3.4.3 Javadoc
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2003-2007 Jive Software.