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/21 17:05:58 UTC

Re[2]: Must Realm#onInit be called when SecurityManager is created manually?

Could you explain the lifecycle of what? Of SecurityManager? Is there something like Shiro container?
I am asking because either I don’t understand something, or it is a little strange that sometimes Realm onInit method
is called and sometimes not? We are talking about one object in SecurityManager. So, it is SM that must control Realm,
isn’t it. But if it is the duty of SM why does SM behave differently? I don’t understand...
 
 
--
Best regards, Alex Orlov
 
  
>Суббота, 21 ноября 2020, 19:12 +03:00 от Brian Demers <br...@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