-
1. Re: How to add filter in a portal extension
nscavell Jul 25, 2013 2:05 PM (in response to tim.drisdelle)1 of 1 people found this helpful/google "gatein filter" -> results[0] = https://community.jboss.org/thread/172870
-
2. Re: How to add filter in a portal extension
tim.drisdelle Jul 25, 2013 2:07 PM (in response to nscavell)Wow - I guess my Google chops are in need of tuning (too verbose!)
Thanks for the thread, I'll go check it out!
-
3. Re: How to add filter in a portal extension
tim.drisdelle Jul 25, 2013 6:44 PM (in response to nscavell)Alright...
I've followed the direction on the referenced thread and I think I've got everything working.
However, I'm not able to read in my init-params from the configuration in web-inf-extension-configuration.xml
These params used to be in my web.xml file, and now I've got them like this:
<init-params>
<properties-param>
<name>authfilter.properties</name>
<property name="APP_ID" value="1234"/>
<property name="APP_ID_KEY" value="aaabbbcccddd111222333444"/>
<property name="APP_ADMIN_PASSWORD" value="abcde12345"/>
</properties-param>
<object-param>
<name>Auth Filter Definition</name>
<object type="org.exoplatform.web.filter.FilterDefinition">
<!-- The filter instance -->
<field name="filter">
<object type="com.mycompany.authfilter.AuthFilter"/>
</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>
I'm not sure I've done this correctly, and when my filter tries filterConfig.getInitParameter("APP_ID") it throws NPE.
Am I supposed to use a different <name> in the <properties-param> ?
I just noticed that the interface org.exoplatform.web.filter.Filter does not include methods for init and destroy, which I was using to populate my FilterConfig (and contained the properties).
-
4. Re: How to add filter in a portal extension
mposolda Jul 26, 2013 3:17 AM (in response to tim.drisdelle)Hi,
I think that you need to create constructor of your filter, which will just accept InitParams as the argument and read parameters here. Something like
{code}
public MyFilter implements Filter
{
public MyFilter(InitParams params)
{
params.getPropertiesParam('APP_ID');
// Read other parameters here
}
...
}
{code}