I'm not sure, but I'm guessing you will run into classloader issues with a static instance.
Do you have an example project (something simple that can be used to illustrate the point)? Maybe that will help others as well. -Brian On Fri, Dec 9, 2016 at 4:58 PM, Harinath Mallepally <[email protected]> wrote: > Hi Brian, > I know it is not directly related with shiro, but trying to see how do I > configure this property in karaf? > staticSecurityManagerEnabled > > > Thanks > Hari > > On Fri, Oct 28, 2016 at 2:41 PM, Brian Demers <[email protected]> > wrote: > >> I'd need to see a bit more of the stacktrace. But i'm guessing your call >> is not in the context of a request. If that is the case you would need to >> enable the static instance of the SecurityManager. >> >> See the note about 'staticSecurityManagerEnabled' in: >> https://shiro.apache.org/static/current/apidocs/org/apache/ >> shiro/web/servlet/AbstractShiroFilter.html >> >> On Fri, Oct 28, 2016 at 4:56 PM, Harinath Mallepally <[email protected]> >> wrote: >> >>> Hi Brian, >>> >>> it is same error , looks like something is wrong. >>> >>> org.apache.shiro.UnavailableSecurityManagerException: No >>> SecurityManager accessible to the calling code, either bound to the >>> org.apache.shiro.util.ThreadContext or as a vm static singleton. This >>> is an invalid application configuration. >>> at org.apache.shiro.SecurityUtils.getSecurityManager(SecurityUt >>> ils.java:123) >>> at org.apache.shiro.subject.Subject$Builder.<init>(Subject.java:627) >>> at org.apache.shiro.SecurityUtils.getSubject(SecurityUtils.java:56) >>> >>> >>> couldn't figure it out. any thoughts? >>> >>> >>> >>> On Fri, Oct 28, 2016 at 10:37 AM, Harinath Mallepally <[email protected]> >>> wrote: >>> >>>> in both cases. I understand that it needs a user context and during >>>> application start, this error makes sense. >>>> >>>> it failed in RPC requests, i expected it to work. >>>> i saw this working fine earlier, might be something got messed up. will >>>> do clean build and try again. >>>> >>>> >>>> On Thu, Oct 27, 2016 at 5:54 PM, Brian Demers <[email protected]> >>>> wrote: >>>> >>>>> Where is that method getting called from? Is it from the context of a >>>>> request or while your application is starting ? >>>>> >>>>> >>>>> On Thu, Oct 27, 2016 at 7:02 PM, Harinath Mallepally <[email protected] >>>>> > wrote: >>>>> >>>>>> Thanks for the response. >>>>>> >>>>>> I tried this way, but results in with error. any thoughts on how do I >>>>>> get handle on this? It looks like something is wrong with configuration >>>>>> or >>>>>> so. >>>>>> >>>>>> private void setListener(){ >>>>>> >>>>>> try { >>>>>> //TODO temp code, remove it >>>>>> AuthenticatingSecurityManager securityMgr = >>>>>> (AuthenticatingSecurityManager) SecurityUtils.getSecurityManager(); >>>>>> >>>>>> System.out.println(securityMgr); >>>>>> >>>>>> AbstractAuthenticator authentication = >>>>>> (AbstractAuthenticator) securityMgr.getAuthenticator(); >>>>>> >>>>>> authentication.getAuthenticationListeners().add(new >>>>>> CustomAuthenticationListener()); >>>>>> }catch(Exception e){ >>>>>> LOG.error("error {}", e); >>>>>> } >>>>>> } >>>>>> but resulted in with this >>>>>> >>>>>> error {} >>>>>> org.apache.shiro.UnavailableSecurityManagerException: No >>>>>> SecurityManager accessible to the calling code, either bound to the >>>>>> org.apache.shiro.util.ThreadContext or as a vm static singleton. >>>>>> This is an invalid application configuration. >>>>>> at org.apache.shiro.SecurityUtils.getSecurityManager(SecurityUt >>>>>> ils.java:123) >>>>>> >>>>>> ......... >>>>>> >>>>>> On Thu, Oct 27, 2016 at 12:55 PM, Brian Demers < >>>>>> [email protected]> wrote: >>>>>> >>>>>>> I'm not sure, but if I had to guess, I would say you need to export >>>>>>> your package in your bundles config >>>>>>> >>>>>>> On Thu, Oct 27, 2016 at 2:10 PM, Harinath Mallepally < >>>>>>> [email protected]> wrote: >>>>>>> >>>>>>>> yes, I am using shiro.ini, my problem is my class is not being >>>>>>>> identified in karaf (doing it with opendaylight), didn't know how to >>>>>>>> add my >>>>>>>> class into classpath without modifying ODL feature. >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> On Thu, Oct 27, 2016 at 8:13 AM, Brian Demers < >>>>>>>> [email protected]> wrote: >>>>>>>> >>>>>>>>> I you are using a shiro.ini just stick your filter in the [main] >>>>>>>>> section. >>>>>>>>> >>>>>>>>> For example: >>>>>>>>> >>>>>>>>> [main] >>>>>>>>> ... >>>>>>>>> myFilter = com.foo.bar.MyWickedCoolFilter >>>>>>>>> >>>>>>>>> [urls] >>>>>>>>> /path/* = myFilter >>>>>>>>> # or possibly >>>>>>>>> /another/path/* = myFitler[anOption] >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> On Wed, Oct 26, 2016 at 7:50 PM, Allan C. <[email protected]> >>>>>>>>> wrote: >>>>>>>>> >>>>>>>>>> There's a SecurityUtils class that can access the static >>>>>>>>>> SecurityManager object. >>>>>>>>>> >>>>>>>>>> Regards, >>>>>>>>>> Allan C. >>>>>>>>>> >>>>>>>>>> On Thu, Oct 27, 2016 at 6:15 AM, Harinath Mallepally < >>>>>>>>>> [email protected]> wrote: >>>>>>>>>> >>>>>>>>>>> Hi, >>>>>>>>>>> >>>>>>>>>>> is it possible to get reference of SecurityManager so that a >>>>>>>>>>> custom AuthenticationFilter can be added? >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> Please let me know >>>>>>>>>>> >>>>>>>>>>> Thanks >>>>>>>>>>> Hari >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>> >>>>>>>>> >>>>>>>> >>>>>>> >>>>>> >>>>> >>>> >>> >> >
