Class PluginFilter

  • All Implemented Interfaces:
    javax.servlet.Filter

    public class PluginFilter
    extends Object
    implements javax.servlet.Filter
    A servlet filter that plugin classes can use to dynamically register and un-register filter logic. This implementation assumes, but does not enforce, that filters installed by plugins are applied to URL patterns that match the plugin. When filters installed by different plugins are applied to the same URL, the behavior of this implementation is undetermined.
    Author:
    Matt Tucker, Guus der Kinderen, guus.der.kinderen@gmail.com
    • Constructor Detail

      • PluginFilter

        public PluginFilter()
    • Method Detail

      • addPluginFilter

        public static void addPluginFilter​(String filterUrl,
                                           javax.servlet.Filter filter)
        Adds a filter to the list of filters that will be run on every request of which the URL matches the URL that is registered with this filter. More specifically, the request URL should be equal to, or start with, the filter URL. Multiple filters can be registered on the same URL, in which case they will be executed in the order in which they were added. Adding a filter does not initialize the plugin instance.
        Parameters:
        filterUrl - The URL pattern to which the filter is to be applied. Cannot be null nor an empty string.
        filter - The filter. Cannot be null.
      • removePluginFilter

        public static javax.servlet.Filter removePluginFilter​(String filterUrl,
                                                              String filterClassName)
        Removes a filter that is applied to a certain URL. Removing a filter does not destroy the plugin instance.
        Parameters:
        filterUrl - The URL pattern to which the filter is applied. Cannot be null nor an empty string.
        filterClassName - The filter class name. Cannot be null or empty string.
        Returns:
        The filter instance that was removed, or null if the URL and name combination did not match a filter.
      • init

        public void init​(javax.servlet.FilterConfig filterConfig)
                  throws javax.servlet.ServletException
        Specified by:
        init in interface javax.servlet.Filter
        Throws:
        javax.servlet.ServletException
      • doFilter

        public void doFilter​(javax.servlet.ServletRequest servletRequest,
                             javax.servlet.ServletResponse servletResponse,
                             javax.servlet.FilterChain filterChain)
                      throws IOException,
                             javax.servlet.ServletException
        This class is a Filter implementation itself. It acts as a dynamic proxy to filters that are registered by Openfire plugins.
        Specified by:
        doFilter in interface javax.servlet.Filter
        Throws:
        IOException
        javax.servlet.ServletException
      • destroy

        public void destroy()
        Specified by:
        destroy in interface javax.servlet.Filter