You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@shiro.apache.org by Kevin Minder <ke...@hortonworks.com> on 2013/10/25 17:14:20 UTC
Filter init() method not being called?
Hi,
I'm trying to integrate a 3rd party filter into a Shiro filter chain.
I'm surprised by two things and I hope I'm just missing something.
1) The init() method of a filter configured in a chain never seems to be
called.
2) If the init() method was called it seems like you can't set filter
init-params via the typical JEE filter mechanism.
For the example below the init method of TestFilter is never called and
even if it were I'm not sure the filter could use
filterConfig.getInitParameter( "testParam" )
to retrieve the test-value.
[main]
test-filter = test.TestFilter
test-file.testParam = test-value
[urls]
/** = test-filter
Is this a bug, feature or user error?
I do understand that the pseudo-DI in Shiro in most cases is probably
nicer but:
A) If the javax.servlet.Filter is being used the contract associated
with that interface should be honored.
B) Not support init() or init-params really limits the ability to use
"off the shelf" filters.
Hoping I'm wrong...
Kevin.
--
CONFIDENTIALITY NOTICE
NOTICE: This message is intended for the use of the individual or entity to
which it is addressed and may contain information that is confidential,
privileged and exempt from disclosure under applicable law. If the reader
of this message is not the intended recipient, you are hereby notified that
any printing, copying, dissemination, distribution, disclosure or
forwarding of this communication is strictly prohibited. If you have
received this communication in error, please contact the sender immediately
and delete it from your system. Thank You.
Re: Filter init() method not being called?
Posted by Kevin Minder <ke...@hortonworks.com>.
Unfortunately, after more searching I see this is a known issue.
http://shiro-user.582556.n2.nabble.com/Can-t-get-ServletContext-from-Filter-td7468957.html
However, just to make this concrete, here is what I was trying to do.
[main]
jersey = com.sun.jersey.spi.container.servlet.ServletContainer
jersey.com.sun.jersey.config.property.packages = test
[urls]
/** = jersey
Now I know there are 100 other ways to do what this seems to suggest but
I have valid reasons for wanting to attempt this.
And before anyone asks, yes
com.sun.jersey.spi.container.servlet.ServletContainer is actually a
javax.servlet.Filter.
On 10/25/13 11:14 AM, Kevin Minder wrote:
> Hi,
>
> I'm trying to integrate a 3rd party filter into a Shiro filter chain.
> I'm surprised by two things and I hope I'm just missing something.
>
> 1) The init() method of a filter configured in a chain never seems to
> be called.
> 2) If the init() method was called it seems like you can't set filter
> init-params via the typical JEE filter mechanism.
>
> For the example below the init method of TestFilter is never called
> and even if it were I'm not sure the filter could use
> filterConfig.getInitParameter( "testParam" )
> to retrieve the test-value.
>
> [main]
> test-filter = test.TestFilter
> test-file.testParam = test-value
>
> [urls]
> /** = test-filter
>
> Is this a bug, feature or user error?
> I do understand that the pseudo-DI in Shiro in most cases is probably
> nicer but:
>
> A) If the javax.servlet.Filter is being used the contract associated
> with that interface should be honored.
> B) Not support init() or init-params really limits the ability to use
> "off the shelf" filters.
>
> Hoping I'm wrong...
> Kevin.
--
CONFIDENTIALITY NOTICE
NOTICE: This message is intended for the use of the individual or entity to
which it is addressed and may contain information that is confidential,
privileged and exempt from disclosure under applicable law. If the reader
of this message is not the intended recipient, you are hereby notified that
any printing, copying, dissemination, distribution, disclosure or
forwarding of this communication is strictly prohibited. If you have
received this communication in error, please contact the sender immediately
and delete it from your system. Thank You.