You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@shiro.apache.org by jewelk80 <je...@yahoo.com> on 2015/03/05 00:03:10 UTC
Issue using runAs: SessionContext must be an HTTP compatible
implementation
Hi,
I'm using Shiro 1.2.3 for authorization only (no authentication) in a web
application. I created a class that extends PermissionsAuthorizationFilter
which checks if the user is known, and if so, builds the Subject and binds
it to the ThreadContext. So far, everything has run beautifully.
Now I want to add user delegate capability by using Shiro's "run as"
functionality. I'm getting an error, "SessionContext must be an HTTP
compatible implementation" (stack trace below).
I've tried a bunch of different approaches based on other posts for this
error (though not with the "run as" use case), but here's the simplest that
I started with:
SimplePrincipalCollection principals = new SimplePrincipalCollection();
principals.add(userNameToRunAs, realmName);
subject.runAs(principals);
What am I missing or doing incorrectly?
Stack trace:
java.lang.IllegalArgumentException: SessionContext must be an HTTP
compatible implementation.
org.apache.shiro.web.session.mgt.ServletContainerSessionManager.createSession(ServletContainerSessionManager.java:103)
org.apache.shiro.web.session.mgt.ServletContainerSessionManager.start(ServletContainerSessionManager.java:64)
org.apache.shiro.mgt.SessionsSecurityManager.start(SessionsSecurityManager.java:121)
org.apache.shiro.subject.support.DelegatingSubject.getSession(DelegatingSubject.java:336)
org.apache.shiro.subject.support.DelegatingSubject.getSession(DelegatingSubject.java:312)
org.apache.shiro.subject.support.DelegatingSubject.pushIdentity(DelegatingSubject.java:491)
org.apache.shiro.subject.support.DelegatingSubject.runAs(DelegatingSubject.java:437)
com.hp.it.scv.controllers.RoleController.index(RoleController.java:66)
com.hp.it.scv.controllers.RoleController$$FastClassByCGLIB$$c8405c1b.invoke(<generated>)
org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:698)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
org.apache.shiro.spring.security.interceptor.AopAllianceAnnotationsAuthorizingMethodInterceptor$1.proceed(AopAllianceAnnotationsAuthorizingMethodInterceptor.java:82)
org.apache.shiro.authz.aop.AuthorizingMethodInterceptor.invoke(AuthorizingMethodInterceptor.java:39)
org.apache.shiro.spring.security.interceptor.AopAllianceAnnotationsAuthorizingMethodInterceptor.invoke(AopAllianceAnnotationsAuthorizingMethodInterceptor.java:115)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:631)
com.hp.it.scv.controllers.RoleController$$EnhancerByCGLIB$$a4c24f0f.index(<generated>)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:219)
org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132)
org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:745)
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:686)
org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:936)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:827)
javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:812)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
com.hp.it.scv.authorization.PermissionFilter.doFilterInternal(PermissionFilter.java:43)
org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:343)
org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:260)
--
View this message in context: http://shiro-developer.582600.n2.nabble.com/Issue-using-runAs-SessionContext-must-be-an-HTTP-compatible-implementation-tp7578520.html
Sent from the Shiro Developer mailing list archive at Nabble.com.
Re: Issue using runAs: SessionContext must be an HTTP compatible
implementation
Posted by jewelk80 <je...@yahoo.com>.
It never fails :*) Shortly after I posted, I found a post that showed me the
error of my ways. I've been using Subject.Builder (with no issues), but if
I switch to WebSubject.Builder - problem solved (at least so far).
--
View this message in context: http://shiro-developer.582600.n2.nabble.com/Issue-using-runAs-SessionContext-must-be-an-HTTP-compatible-implementation-tp7578520p7578521.html
Sent from the Shiro Developer mailing list archive at Nabble.com.