Shiro and Spring with ShiroFilterFactoryBean

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Shiro and Spring with ShiroFilterFactoryBean

Minas Manthos
short: Initializable.init() from AuthorizingRealm is not called by LifecycleBeanPostProcessor when using ShiroFilterFactoryBean

long: ShiroFilterFactoryBean itself is a BeanPostProcessor, like LifecycleBeanPostProcessor too. So during AbstractApplicationContext.registerBeanPostProcessors() these two beans are created and added to nonOrderedPostProcessors, after then they get registered. At this execution point ShiroFilterFactoryBean is already created with its SecurityManager and defined Realms. So LifecycleBeanPostProcessor will not effect anymore on Realms init.

Can anyone confirm before I create an issue.

Thanks.

shiro 1.1, spring 3.0

PS.
to reproduce just replace in shiro samples the JdbcRealm (wich does not need a init) with a PropertiesRealm. Init method is never called so definitions never created from properties file...

as workaround I just implement the Ordered (org.springframework.core) interface to LifecycleBeanPostProcessor with LOWEST_PRECEDENCE. Ordered PostProcessors are processed and registered before non-ordered. So LifecycleBeanPostProcessor gets registered before ShiroFilterFactoryBean is created.
Reply | Threaded
Open this post in threaded view
|

Re: Shiro and Spring with ShiroFilterFactoryBean

Les Hazlewood-2
Hi Minas,

I think this is a valid issue - please open it in Jira.  Any patches
would be welcome!

Best regards,

Les

On Tue, Dec 7, 2010 at 2:39 AM, Minas Manthos <[hidden email]> wrote:

>
> short: Initializable.init() from AuthorizingRealm is not called by
> LifecycleBeanPostProcessor when using ShiroFilterFactoryBean
>
> long: ShiroFilterFactoryBean itself is a BeanPostProcessor, like
> LifecycleBeanPostProcessor too. So during
> AbstractApplicationContext.registerBeanPostProcessors() these two beans are
> created and added to nonOrderedPostProcessors, after then they get
> registered. At this execution point ShiroFilterFactoryBean is already
> created with its SecurityManager and defined Realms. So
> LifecycleBeanPostProcessor will not effect anymore on Realms init.
>
> Can anyone confirm before I create an issue.
>
> Thanks.
>
> shiro 1.1, spring 3.0
>
> PS.
> to reproduce just replace in shiro samples the JdbcRealm (wich does not need
> a init) with a PropertiesRealm. Init method is never called so definitions
> never created from properties file...
>
> as workaround I just implement the Ordered (org.springframework.core)
> interface to LifecycleBeanPostProcessor with LOWEST_PRECEDENCE. Ordered
> PostProcessors are processed and registered before non-ordered. So
> LifecycleBeanPostProcessor gets registered before ShiroFilterFactoryBean is
> created.
> --
> View this message in context: http://shiro-user.582556.n2.nabble.com/Shiro-and-Spring-with-ShiroFilterFactoryBean-tp5811127p5811127.html
> Sent from the Shiro User mailing list archive at Nabble.com.
Reply | Threaded
Open this post in threaded view
|

Re: Shiro and Spring with ShiroFilterFactoryBean

Minas Manthos
Hi Les

Created Issue https://issues.apache.org/jira/browse/SHIRO-222

and in a similar scope https://issues.apache.org/jira/browse/SHIRO-223

Patch included.

Thanks
Minas.
Reply | Threaded
Open this post in threaded view
|

Re: Shiro and Spring with ShiroFilterFactoryBean

Les Hazlewood-2
This is great - thanks!

On Thu, Dec 9, 2010 at 12:16 PM, Minas Manthos <[hidden email]> wrote:

>
> Hi Les
>
> Created Issue https://issues.apache.org/jira/browse/SHIRO-222
>
> and in a similar scope https://issues.apache.org/jira/browse/SHIRO-223
>
> Patch included.
>
> Thanks
> Minas.
> --
> View this message in context: http://shiro-user.582556.n2.nabble.com/Shiro-and-Spring-with-ShiroFilterFactoryBean-tp5811127p5820499.html
> Sent from the Shiro User mailing list archive at Nabble.com.