Something needs to set-up and bind the Subject to the current thread before the portlet is invoked.
In a normal webapp, the ShiroFilter does this via the Subject.Builder and then calls builtSubject.execute(...filterChain...), which guarantees that the built Subject (and the corresponding SecurityManager) is bound and then unbound to/from the thread before and after the 'execute' method call, respectively. You'll need to use a similar 'filter' mechanism for the portlet environment to ensure the setup/teardown occurs for any request that the container services. Here is the ShiroFilter implementation that performs this setup/teardown, if it helps: http://svn.apache.org/repos/asf/shiro/trunk/web/src/main/java/org/apache/shiro/web/servlet/AbstractShiroFilter.java Does this help/make sense? Cheers, -- Les Hazlewood Founder, Katasoft, Inc. Application Security Products & Professional Apache Shiro Support and Training: http://www.katasoft.com On Thu, May 5, 2011 at 7:43 AM, tkofford <[email protected]> wrote: > I'm using a combination of shiro & struts2 and have no problems when this is > a standalone web application. > > However, when I try and make that same web application into a JSR 168 > portlet via the struts2 portlet plug-in (as I've done successfully many > times before), I always get a "UnavailableSecurityManagerException" with the > message: > > "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." > > When I traced into the shiro code, the following sequence occurred: > SecurityUtils->getSubject() > -ThreadContext.getSubject() returned null > -(new Subject.Builder()).buildSubject(); > -ThreadContext.getSecurityManager(); returned null > -SecurityUtils.securityManager is also null > -throws UnavailableSecurityManagerException > > I'm not even sure if shiro supports this type of implementation, or if this > is the correct forum to post this, but I'd love to use shiro in my portlet > if possible. > > I'm using shiro 1.1.0 and struts 2.2.1.1 > > Any suggestions? > > Thanks in advance, > > Todd Kofford > [email protected] > > > -- > View this message in context: > http://shiro-user.582556.n2.nabble.com/Shiro-enabled-Portlet-UnavailableSecurityManagerException-tp6334470p6334470.html > Sent from the Shiro User mailing list archive at Nabble.com.
