We added a GenericFilter that allows you to define new Http Filters thanks to an external plugin. Your filter will need to implement the interface org.exoplatform.web.filter.Filter.
See an example of configuration below:
<?xml version="1.0" encoding="UTF-8"?>
<configuration
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.exoplatform.org/xml/ns/kernel_1_2.xsd http://www.exoplatform.org/xml/ns/kernel_1_2.xsd"
xmlns="http://www.exoplatform.org/xml/ns/kernel_1_2.xsd">
<external-component-plugins>
<!-- The full qualified name of the ExtensibleFilter -->
<target-component>org.exoplatform.web.filter.ExtensibleFilter</target-component>
<component-plugin>
<!-- The name of the plugin -->
<name>Sample Filter Definition Plugin</name>
<!-- The name of the method to call on the ExtensibleFilter in order to register the FilterDefinitions -->
<set-method>addFilterDefinitions</set-method>
<!-- The full qualified name of the FilterDefinitionPlugin -->
<type>org.exoplatform.web.filter.FilterDefinitionPlugin</type>
<init-params>
<object-param>
<name>Sample Filter Definition</name>
<object type="org.exoplatform.web.filter.FilterDefinition">
<!-- The filter instance -->
<field name="filter"><object type="org.exoplatform.sample.ext.web.SampleFilter"/></field>
<!-- The mapping to use -->
<!-- WARNING: the mapping is expressed with regular expressions -->
<field name="patterns">
<collection type="java.util.ArrayList" item-type="java.lang.String">
<value>
<string>/.*</string>
</value>
</collection>
</field>
</object>
</object-param>
</init-params>
</component-plugin>
</external-component-plugins>
</configuration>
See an example of Filter below:
...
import org.exoplatform.web.filter.Filter;
import java.io.IOException;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
public class SampleFilter implements Filter
{
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException,
ServletException
{
System.out.println("SampleFilter start");
try
{
chain.doFilter(request, response);
}
finally
{
System.out.println("SampleFilter end");
}
}
}