You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@shiro.apache.org by Alex Orlov <oo...@mail.ru> on 2020/11/24 06:56:31 UTC
Re[4]: Must Realm#onInit be called when SecurityManager is created manually?
Hello Brian,
Thank you for clarifying this moment. I think, it would be fine to add information about
LifecycleUtils here https://shiro.apache.org/configuration.html#programmatic-configuration
--
Best regards, Alex Orlov
>Вторник, 24 ноября 2020, 1:55 +03:00 от Brian Demers <br...@gmail.com>:
>
>Correct,
>
>Most of the time these methods would be transparently called via (Shiro's INI feature, Spring, Guice, or potentially CDI),
>On Sat, Nov 21, 2020 at 3:12 PM Alex Orlov < ooo_saturn7@mail.ru > wrote:
>>Do I understand it correctly if we control realm and security manager manually we need to use:
>>
>>to init Realm → LifecycleUtils.init(realm);
>>to destroy SecurityManager → LifecycleUtils.destroy(securityManager);
>>
>>
>>--
>>Best regards, Alex Orlov
>>
>>
>>>Суббота, 21 ноября 2020, 19:12 +03:00 от Brian Demers < brian.demers@gmail.com >:
>>>
>>>Shiro has "lifecycle" methods that can be plugged into a DI container. If you are not using a Shiro integration, you can just need to call the `onInit` method directly.
>>>On Sat, Nov 21, 2020 at 6:11 AM Alex Orlov < ooo_saturn7@mail.ru > wrote:
>>>>Hello all,
>>>>
>>>>I have two security managers — web and default. When shiro filter creates web manager
>>>>the method onInit( https://shiro.apache.org/static/1.2.2/apidocs/org/apache/shiro/realm/AuthorizingRealm.html#onInit( ) )
>>>>of my Realm is called.
>>>>
>>>>However, when I create SM manually
>>>> var realm = new SecurityRealm();
>>>> ...
>>>> DefaultSecurityManager sm = new DefaultSecurityManager(realm);
>>>> sm.setCacheManager(new MemoryConstrainedCacheManager());
>>>> this.securityManager = sm;
>>>>
>>>>this method (onInit) is not called.
>>>>
>>>>Could anyone say if it is a bug or I miss something (I use shiro 1.7.0)?
>>>>
>>>>
>>>>--
>>>>Best regards, Alex Orlov
>>
Re[6]: Must Realm#onInit be called when SecurityManager is created manually?
Posted by Alex Orlov <oo...@mail.ru>.
Let’s make a deal — I open an issue, you make a pull request, all right?
--
Best regards, Alex Orlov
>Вторник, 24 ноября 2020, 18:23 +03:00 от Brian Demers <bd...@apache.org>:
>
>I agree, pull requests are always welcome :D
>On Tue, Nov 24, 2020 at 1:56 AM Alex Orlov < ooo_saturn7@mail.ru > wrote:
>>Hello Brian,
>>
>>Thank you for clarifying this moment. I think, it would be fine to add information about
>>LifecycleUtils here https://shiro.apache.org/configuration.html#programmatic-configuration
>>
>>
>>--
>>Best regards, Alex Orlov
>>
>>
>>>Вторник, 24 ноября 2020, 1:55 +03:00 от Brian Demers < brian.demers@gmail.com >:
>>>
>>>Correct,
>>>
>>>Most of the time these methods would be transparently called via (Shiro's INI feature, Spring, Guice, or potentially CDI),
>>>On Sat, Nov 21, 2020 at 3:12 PM Alex Orlov < ooo_saturn7@mail.ru > wrote:
>>>>Do I understand it correctly if we control realm and security manager manually we need to use:
>>>>
>>>>to init Realm → LifecycleUtils.init(realm);
>>>>to destroy SecurityManager → LifecycleUtils.destroy(securityManager);
>>>>
>>>>
>>>>--
>>>>Best regards, Alex Orlov
>>>>
>>>>
>>>>>Суббота, 21 ноября 2020, 19:12 +03:00 от Brian Demers < brian.demers@gmail.com >:
>>>>>
>>>>>Shiro has "lifecycle" methods that can be plugged into a DI container. If you are not using a Shiro integration, you can just need to call the `onInit` method directly.
>>>>>On Sat, Nov 21, 2020 at 6:11 AM Alex Orlov < ooo_saturn7@mail.ru > wrote:
>>>>>>Hello all,
>>>>>>
>>>>>>I have two security managers — web and default. When shiro filter creates web manager
>>>>>>the method onInit( https://shiro.apache.org/static/1.2.2/apidocs/org/apache/shiro/realm/AuthorizingRealm.html#onInit( ) )
>>>>>>of my Realm is called.
>>>>>>
>>>>>>However, when I create SM manually
>>>>>> var realm = new SecurityRealm();
>>>>>> ...
>>>>>> DefaultSecurityManager sm = new DefaultSecurityManager(realm);
>>>>>> sm.setCacheManager(new MemoryConstrainedCacheManager());
>>>>>> this.securityManager = sm;
>>>>>>
>>>>>>this method (onInit) is not called.
>>>>>>
>>>>>>Could anyone say if it is a bug or I miss something (I use shiro 1.7.0)?
>>>>>>
>>>>>>
>>>>>>--
>>>>>>Best regards, Alex Orlov
>>>>
>>
Re: Re[4]: Must Realm#onInit be called when SecurityManager is
created manually?
Posted by Brian Demers <bd...@apache.org>.
I agree, pull requests are always welcome :D
On Tue, Nov 24, 2020 at 1:56 AM Alex Orlov <oo...@mail.ru> wrote:
> Hello Brian,
>
> Thank you for clarifying this moment. I think, it would be fine to add
> information about
> LifecycleUtils here
> https://shiro.apache.org/configuration.html#programmatic-configuration
>
>
> --
> Best regards, Alex Orlov
>
>
>
> Вторник, 24 ноября 2020, 1:55 +03:00 от Brian Demers <
> brian.demers@gmail.com>:
>
> Correct,
>
> Most of the time these methods would be transparently called via (Shiro's
> INI feature, Spring, Guice, or potentially CDI),
>
> On Sat, Nov 21, 2020 at 3:12 PM Alex Orlov <ooo_saturn7@mail.ru
> <//...@mail.ru>> wrote:
>
> Do I understand it correctly if we control realm and security manager
> manually we need to use:
>
> to init Realm → LifecycleUtils.init(realm);
> to destroy SecurityManager → LifecycleUtils.destroy(securityManager);
>
>
> --
> Best regards, Alex Orlov
>
>
>
> Суббота, 21 ноября 2020, 19:12 +03:00 от Brian Demers <
> brian.demers@gmail.com
> <//...@gmail.com>>:
>
> Shiro has "lifecycle" methods that can be plugged into a DI container. If
> you are not using a Shiro integration, you can just need to call the
> `onInit` method directly.
>
> On Sat, Nov 21, 2020 at 6:11 AM Alex Orlov <ooo_saturn7@mail.ru
> <ht...@mail.ru>> wrote:
>
> Hello all,
>
> I have two security managers — web and default. When shiro filter creates
> web manager
> the method onInit(
> https://shiro.apache.org/static/1.2.2/apidocs/org/apache/shiro/realm/AuthorizingRealm.html#onInit()
> )
> of my Realm is called.
>
> However, when I create SM manually
> var realm = new SecurityRealm();
> ...
> DefaultSecurityManager sm = new DefaultSecurityManager(realm);
> sm.setCacheManager(new MemoryConstrainedCacheManager());
> this.securityManager = sm;
>
> this method (onInit) is not called.
>
> Could anyone say if it is a bug or I miss something (I use shiro 1.7.0)?
>
>
> --
> Best regards, Alex Orlov
>
>
>
>
>