Managed to get session scope bean by gettign portlet app context as:

ApplicationContext ctx =
WebApplicationContextUtils.getWebApplicationContext(session.getServletContext().getContext("/MyPortletApp"));

However I just found session scoped beans are not accessible to any
other bean as well. Probably Spring filter is not catching the request
and beans are not autowired. I have added RequestContextFilter mapping
as well as u suggested couple of days back in this email thread but
nothing seems to work.

Attaching my context file and web.xml if i'm making some silly mistake.

Thanks


On 3/15/11, anyz <[email protected]> wrote:
> Session scope bean uses AOP Proxy as:
> <bean id=*"userInfo"* class=*"com.xxx.xxxx.UserInfo"*
> scope=*"globalSession"
> *><aop:scoped-proxy/></bean>
>
> You are right it can not be autowired in Filter class since at that time no
> session is created. So i tried to access it manually as:
>
> RequestContext rc = (RequestContext)req.getAttribute(RequestContext.*
> REQUEST_PORTALENV*);
> HttpSession session = rc.getRequest().getSession();
> ApplicationContext ctx = WebApplicationContextUtils.*
> getWebApplicationContext*(session.getServletContext());
> *UseInfo ui *= (UserInfo) ctx.getBean("userInfo");
>
> it gives folowing error:
>
>  Context attribute is not of type WebApplicationContext:
> org.apache.jetspeed.components.FilteringXmlWebApplicationContext@602b6b:
> display name [Root WebApplicationContext]; startup date [Tue Mar 15
> 01:17:46
> VET 2011]; parent:
> org.apache.jetspeed.components.FilteringXmlWebApplicationContext@d67067
> Seems the session.getServletContext() is returning context from JetSpeed
> portal application. Need to provide Servlet context of my portlet
> application instead. But not able to get servlet context from portlet
> context sor far.
>
>
>
>
> On Mon, Mar 14, 2011 at 11:13 PM, Woonsan Ko <[email protected]> wrote:
>
>> Did you use 'globalSession' scope and inject AOP proxy? See [1].
>> Because your session scoped bean is retrieved from http session, you
>> should
>> either retrieve the bean manually from BeanFactory in request/session
>> context, or you can leverage AOP proxy instead.
>>
>> [1]
>> http://static.springsource.org/spring/docs/2.5.6/reference/beans.html#beans-factory-scopes-other-injection
>>
>>
>> --- On Mon, 3/14/11, anyz <[email protected]> wrote:
>>
>> > From: anyz <[email protected]>
>> > Subject: Re: Storing Custom Object in Session on User Login
>> > To: "Jetspeed Users List" <[email protected]>
>> > Date: Monday, March 14, 2011, 8:25 AM
>>  > Issue is described here in more
>> > detail.
>> >
>> > http://forum.springsource.org/archive/index.php/t-39087.html
>> > http://forum.springsource.org/archive/index.php/t-29765.html
>> >
>> >
>> >
>> > On Mon, Mar 14, 2011 at 11:00 AM, anyz <[email protected]>
>> > wrote:
>> >
>> > > Unfortunately it didn't work. I have web.xml as:
>> > >
>> > > <listener>
>> > >
>> > >
>> >
>> <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
>> > >    </listener>
>> > >    <context-param>
>> > >
>> > <param-name>log4jConfigLocation</param-name>
>> > >
>> > <param-value>/WEB-INF/classes/log4j-myapp.properties</param-value>
>> > >    </context-param>
>> > >
>> > >
>> > > <filter>
>> > >
>> > <filter-name>RequestContextFilter</filter-name>
>> > >
>> > >
>> >
>> <filter-class>org.springframework.web.filter.RequestContextFilter</filter-class>
>> > >  </filter>
>> > >   <filter-mapping>
>> > >
>> > <filter-name>RequestContextFilter</filter-name>
>> > >
>> > <url-pattern>/*</url-pattern>
>> > >
>> > <dispatcher>REQUEST</dispatcher>
>> > >
>> > <dispatcher>INCLUDE</dispatcher>
>> > >  </filter-mapping>
>> > >  <listener>
>> > >
>> >
>> >
>> > <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
>> > >  </listener>
>> > >  <context-param>
>> > >   <param-name>contextConfigLocation</param-name>
>> > >   <param-value>/WEB-INF/applicationContext*.xml</param-value>
>> > >  </context-param>
>> > >  <context-param>
>> > >   <param-name>webAppRootKey</param-name>
>> > >   <param-value>myApp-root</param-value>
>> > >  </context-param>
>> > >
>> > >
>> > >
>> > > On Sat, Mar 12, 2011 at 5:56 AM, Woonsan Ko <[email protected]>
>> > wrote:
>> > >
>> > >>
>> > >> --- On Fri, 3/11/11, anyz <[email protected]>
>> > wrote:
>> > >>
>> > >> > From: anyz <[email protected]>
>> > >> > Subject: Re: Storing Custom Object in Session
>> > on User Login
>> > >> > To: "Jetspeed Users List" <[email protected]>
>> > >> > Date: Friday, March 11, 2011, 10:44 AM
>> > >>  > Thanx Woonsan,
>> > >> > I worked as you suggested. A object set into
>> > session in
>> > >> > Filter Class is
>> > >> > accessible to rest of portlets. However i am
>> > not able to
>> > >> > get and set the
>> > >> > stuff into the session-scoped spring bean
>> > defined in my
>> > >> > application. Its
>> > >> > seems to be problem with my spring related
>> > logic. This bean
>> > >> > is later wired
>> > >> > into business delegate classes. Without this
>> > i have to pass
>> > >> > session object
>> > >> > to every method of delegate where needed.
>> > >> >
>> > >> > It throws errors when i try to set a value
>> > in
>> > >> > session-scoped spring bean.
>> > >> >
>> > >> > "java.lang.IllegalStateException: No
>> > thread-bound request
>> > >> > found: Are you
>> > >> > referring to request attributes outside of an
>> > actual web
>> > >> > request, or
>> > >> > processing a request outside of the
>> > originally receiving
>> > >> > thread? If you are
>> > >> > actually operating within a web request and
>> > still receive
>> > >> > this message, your
>> > >> > code is probably running outside of
>> > >> > DispatcherServlet/DispatcherPortlet: In
>> > >> > this case, use RequestContextListener or
>> > >> > RequestContextFilter to expose the
>> > >> > current request."
>> > >>
>> > >> I'm afraid it's because your portlet filter is
>> > executed before the
>> > >> dispatcher portlet is executed. So, the error
>> > message seems reasonable.
>> > >> It could be fixed just by adding a filter
>> > configuration with
>> > >>
>> > org.springframework.web.filter.RequestContextFilter in the
>> > web.xml of your
>> > >> portlet application.
>> > >> For example,
>> > >>
>> > >>  <filter>
>> > >>
>> > <filter-name>RequestContextFilter</filter-name>
>> > >>
>> > >>
>> >
>> <filter-class>org.springframework.web.filter.RequestContextFilter</filter-class>
>> > >>  </filter>
>> > >>
>> > >>  <filter-mapping>
>> > >>
>> > <filter-name>RequestContextFilter</filter-name>
>> > >>
>> > <url-pattern>/*</url-pattern>
>> > >>
>> > <dispatcher>REQUEST</dispatcher>
>> > >>
>> > <dispatcher>INCLUDE</dispatcher>
>> > >>  </filter-mapping>
>> > >>
>> > >> Be sure that the filter-mapping should have
>> > 'INCLUDE' dispatcher option
>> > >> because the portlet is invoked by
>> > including-dispatch from the portal.
>> > >>
>> > >>
>> > >> HTH,
>> > >>
>> > >> Woonsan
>> > >>
>> > >>
>> > >>
>> > >> >
>> > >> > I am going t post a question at Spring Forum
>> > about this.
>> > >> >
>> > >> > Thanks once again.
>> > >> >
>> > >> >
>> > >> >
>> > >> > On Thu, Mar 10, 2011 at 8:53 PM, Woonsan Ko
>> > <[email protected]>
>> > >> > wrote:
>> > >> >
>> > >> > > You may consider using a JSR 286 Portlet
>> > Filter, which
>> > >> > can intercept
>> > >> > > portlet request, so you can access
>> > portal session
>> > >> > through the portlet
>> > >> > > request. It seems possible to set an
>> > application-scope
>> > >> > session attribute
>> > >> > > there for your spring application
>> > through the portlet
>> > >> > request.
>> > >> > >
>> > >> > > Woonsan
>> > >> > >
>> > >> > > --- On Thu, 3/10/11, anyz <[email protected]>
>> > >> > wrote:
>> > >> > >
>> > >> > > > From: anyz <[email protected]>
>> > >> > > > Subject: Re: Storing Custom Object
>> > in Session on
>> > >> > User Login
>> > >> > > > To: "Jetspeed Users List" <[email protected]>
>> > >> > > > Date: Thursday, March 10, 2011,
>> > 12:22 PM
>> > >> > >  > It could be some thing like a
>> > session
>> > >> > > > listner in portlet application. We
>> > can
>> > >> > > > capture event in this listener,
>> > when session is
>> > >> > created
>> > >> > > > (i.e. first request
>> > >> > > > to any of portlet in portlet
>> > application).
>> > >> > However at this
>> > >> > > > point we do not
>> > >> > > > have access to Portal session.
>> > >> > > >
>> > >> > > > On Thu, Mar 10, 2011 at 4:02 PM,
>> > anyz <[email protected]>
>> > >> > > > wrote:
>> > >> > > >
>> > >> > > > > Woonsan,
>> > >> > > > >
>> > >> > > > > I have successfully get the
>> > session object
>> > >> > in Portlet
>> > >> > > > applicaton that was
>> > >> > > > > set by Portal application in
>> > custom security
>> > >> > valve.
>> > >> > > > There is one more step
>> > >> > > > > left in process. Actually
>> > portlet
>> > >> > application has a
>> > >> > > > session-scoped spring
>> > >> > > > > bean. The values from session
>> > object (set by
>> > >> > portal
>> > >> > > > app) should be extracted
>> > >> > > > > and set into spring bean.This
>> > spring bean is
>> > >> > then
>> > >> > > > accessible to other
>> > >> > > > > classes through dependency
>> > injection
>> > >> > performed by
>> > >> > > > Spring.
>> > >> > > > >
>> > >> > > > > What could be point where i
>> > can set the
>> > >> > values in
>> > >> > > > portlet application
>> > >> > > > > session-scoped spring bean.
>> > For example
>> > >> > writing
>> > >> > > > listner kind of thing. Is
>> > >> > > > > jet speed providing some
>> > thing...a entry
>> > >> > point to
>> > >> > > > Portlet application?
>> > >> > > > >
>> > >> > > > > Thanks
>> > >> > > > >
>> > >> > > > >
>> > >> > > > > On Fri, Mar 4, 2011 at 11:14
>> > AM, anyz <[email protected]>
>> > >> > > > wrote:
>> > >> > > > >
>> > >> > > > >> Thats right. Woonsan thank
>> > you very much
>> > >> > for your
>> > >> > > > time and effort. It
>> > >> > > > >> helped me a lot to come
>> > out of this
>> > >> > hard
>> > >> > > > situation.
>> > >> > > > >>
>> > >> > > > >> Thanks
>> > >> > > > >>
>> > >> > > > >>
>> > >> > > > >> On Thu, Mar 3, 2011 at
>> > 11:46 PM, Woonsan
>> > >> > Ko <[email protected]>
>> > >> > > > wrote:
>> > >> > > > >>
>> > >> > > > >>> As you already know,
>> > Jetspeed uses
>> > >> > shared
>> > >> > > > interfaces/classes if anything
>> > >> > > > >>> should be shared among
>> > applications.
>> > >> > For this
>> > >> > > > reason, jetspeed-api and
>> > >> > > > >>> jetspeed-commons jar
>> > files are
>> > >> > deployed into
>> > >> > > > the shared class path (e.g.
>> > >> > > > >>> $CATALINA_HOME/lib)
>> > >> > > > >>>
>> > >> > > > >>> Woonsan
>> > >> > > > >>>
>> > >> > > > >>>
>> > >> > > > >>> --- On Thu, 3/3/11,
>> > anyz <[email protected]>
>> > >> > > > wrote:
>> > >> > > > >>>
>> > >> > > > >>> > From: anyz <[email protected]>
>> > >> > > > >>> > Subject: Re:
>> > Storing Custom
>> > >> > Object in
>> > >> > > > Session on User Login
>> > >> > > > >>> > To: "Jetspeed
>> > Users List"
>> > >> > <[email protected]>
>> > >> > > > >>> > Date: Thursday,
>> > March 3, 2011,
>> > >> > 11:35 AM
>> > >> > > > >>>  > Since the
>> > authenticated
>> > >> > Subject
>> > >> > > > that
>> > >> > > > >>> > was set in
>> > session by Portal
>> > >> > > > >>> > Application
>> > (jetspeed.war) is
>> > >> > availabel
>> > >> > > > in all portlet
>> > >> > > > >>> > applications. How
>> > did
>> > >> > > > >>> > it work and can't
>> > i make my
>> > >> > custom calass
>> > >> > > > behave
>> > >> > > > >>> > similarly.
>> > >> > > > >>> >
>> > >> > > > >>> > Thanks
>> > >> > > > >>> >
>> > >> > > > >>> > On Thu, Mar 3,
>> > 2011 at 3:21 PM,
>> > >> > anyz
>> > >> > > > <[email protected]>
>> > >> > > > >>> > wrote:
>> > >> > > > >>> >
>> > >> > > > >>> > > Now portlet
>> > development
>> > >> > contain lots
>> > >> > > > of
>> > >> > > > >>> > challenges...As i
>> > stated
>> > >> > actually i
>> > >> > > > >>> > > want to set
>> > a custom class
>> > >> > (say
>> > >> > > > MySessionClass) into
>> > >> > > > >>> > session. With
>> > security
>> > >> > > > >>> > > valve i have
>> > to have that
>> > >> > class in
>> > >> > > > jar file that
>> > >> > > > >>> > contains custom
>> > security
>> > >> > > > >>> > > valve and
>> > placed in
>> > >> > portal
>> > >> > > > application jetspeed.
>> > >> > > > >>> > >
>> > >> > > > >>> > > While
>> > getting this
>> > >> > attribute from my
>> > >> > > > portlet
>> > >> > > > >>> > application i
>> > have that
>> > >> > > > >>> > >
>> > MySessionClass in portlet
>> > >> > > > application classpath. Now
>> > >> > > > >>> > casting the
>> > session
>> > >> > > > >>> > > attribute to
>> > this causes
>> > >> > > > ClassCastException becuase
>> > >> > > > >>> > two classes are
>> > loaded
>> > >> > > > >>> > > by JVM from
>> > differnt
>> > >> > locations.
>> > >> > > > >>> > >
>> > >> > > > >>> > > One possible
>> > way could be
>> > >> > to place
>> > >> > > > the MySessionClass
>> > >> > > > >>> > in soem common
>> > lib or
>> > >> > > > >>> > > application
>> > server
>> > >> > (Tomcat) where
>> > >> > > > both portal and
>> > >> > > > >>> > portlet
>> > application can
>> > >> > > > >>> > > access it.
>> > But i wonder
>> > >> > how people
>> > >> > > > achieve this
>> > >> > > > >>> >
>> > behaviour...ins'nt there
>> > >> > > > >>> > > some more
>> > simple way.
>> > >> > > > >>> > >
>> > >> > > > >>> >
>> > >   On Thu,
>> > >> > Mar 3, 2011
>> > >> > > > at 12:12 PM, anyz
>> > >> > > > >>> > <[email protected]>
>> > >> > > > >>> > wrote:
>> > >> > > > >>> > >
>> > >> > > > >>> > >> Thank
>> > you woonsan, it
>> > >> > worked
>> > >> > > > like a charm.
>> > >> > > > >>> > >>
>> > >> > > > >>> > >>
>> > >> > > > >>> > >> On Thu,
>> > Mar 3, 2011 at
>> > >> > 4:36 AM,
>> > >> > > > Woonsan Ko <[email protected]>
>> > >> > > > >>> > wrote:
>> > >> > > > >>> > >>
>> > >> > > > >>> > >>> In
>> > your custom
>> > >> > valve, you
>> > >> > > > may have set an
>> > >> > > > >>> > attribute in an
>> > http session
>> > >> > of
>> > >> > > > >>> > >>> the
>> > portal
>> > >> > application.
>> > >> > > > >>> > >>> Now,
>> > you're trying
>> > >> > to get
>> > >> > > > the attribute in an
>> > >> > > > >>> > http session of a
>> > portlet
>> > >> > > > >>> > >>>
>> > application. Http
>> > >> > sessions
>> > >> > > > are not shared
>> > >> > > > >>> > between web
>> > applications.
>> > >> > > > >>> > >>> So,
>> > you can try
>> > >> > this from
>> > >> > > > your portlet code
>> > >> > > > >>> > with Jetspeed API
>> > to get
>> > >> > > > >>> > >>>
>> > accesses to the
>> > >> > portal
>> > >> > > > session attributes:
>> > >> > > > >>> > >>>
>> > >> > > > >>> > >>>
>> > import
>> > >> > > > >>> >
>> > >> > > >
>> > org.apache.jetspeed.request.RequestContext;
>> > >> > > > >>> > >>>
>> > >> > > > >>> > >>>
>> > RequestContext rc
>> > >> > =
>> > >> > > > (RequestContext)
>> > >> > > > >>> > >>>
>> > >> > > > >>> >
>> > >> > > >
>> > >> >
>> > portletRequest.getAttribute(RequestContext.REQUEST_PORTALENV);
>> > >> > > > >>> > >>>
>> > Object attr =
>> > >> > > > >>> >
>> > >> > > >
>> > rc.getSessionAttribute("some-attribute-name");
>> > >> > > > >>> > >>>
>> > >> > > > >>> > >>>
>> > >> > > > >>> > >>>
>> > Woonsan
>> > >> > > > >>> > >>>
>> > >> > > > >>> > >>> ---
>> > On Wed,
>> > >> > 3/2/11, anyz
>> > >> > > > <[email protected]>
>> > >> > > > >>> > wrote:
>> > >> > > > >>> > >>>
>> > >> > > > >>> > >>> >
>> > From: anyz
>> > >> > <[email protected]>
>> > >> > > > >>> > >>> >
>> > Subject: Re:
>> > >> > Storing
>> > >> > > > Custom Object in
>> > >> > > > >>> > Session on User
>> > Login
>> > >> > > > >>> > >>> >
>> > To: "Jetspeed
>> > >> > Users
>> > >> > > > List" <[email protected]>
>> > >> > > > >>> > >>> >
>> > Date:
>> > >> > Wednesday, March
>> > >> > > > 2, 2011, 2:59 PM
>> > >> > > > >>> >
>> > >>>  > I used
>> > >> > to get
>> > >> > > > session in valve as
>> > >> > > > >>> > >>>
>> > >
>> > >> > > >
>> > requestContext.getRequest().getSession()
>> > >> > > > >>> > >>> >
>> > and then set
>> > >> > attribute
>> > >> > > > in session.
>> > >> > > > >>> > However i am not
>> > able to
>> > >> > > > >>> > >>> >
>> > get this
>> > >> > > > >>> > >>> >
>> > attribute in
>> > >> > portlet
>> > >> > > > JSP page from
>> > >> > > > >>> > HttpSession or
>> > >> > > > >>> > >>>
>> > >
>> > >> > PortletSession. This
>> > >> > > > seems
>> > >> > > > >>> > >>> >
>> > to be same
>> > >> > problem as
>> > >> > > > given in another
>> > >> > > > >>> > thread at
>> > >> > > > >>> > >>>
>> > >
>> > >> > > > >>>
>> > >> http://permalink.gmane.org/gmane.comp.jakarta.jetspeed.user/23626
>> > >> > > > >>> > >>>
>> > >
>> > >> > > > >>> > >>> >
>> > Probably if i
>> > >> > could set
>> > >> > > > the attribute in
>> > >> > > > >>> > portletsession
>> > and
>> > >> > > > >>> > >>> >
>> > with
>> > >> > > > >>> > >>>
>> > >
>> > >> > APPLICATION_SCOPE that
>> > >> > > > may be available.
>> > >> > > > >>> > But its not
>> > >> > > > >>> > >>> >
>> > possibel to
>> > >> > get
>> > >> > > > portlet
>> > >> > > > >>> > >>> >
>> > session in
>> > >> > valve.
>> > >> > > > >>> > >>>
>> > >
>> > >> > > > >>> > >>>
>> > >
>> > >> > > > >>> > >>>
>> > >
>> > >> > > > >>> > >>>
>> > >
>> > >> > > > >>> > >>>
>> > >
>> > >> > > > >>> > >>> >
>> > On Wed, Mar
>> > >> > 2, 2011 at
>> > >> > > > 5:54 PM, anyz
>> > >> > > > >>> > <[email protected]>
>> > >> > > > >>> > >>> >
>> > wrote:
>> > >> > > > >>> > >>>
>> > >
>> > >> > > > >>> > >>> >
>> > > In
>> > >> > custom security
>> > >> > > > valve if i set an
>> > >> > > > >>> > attribute in
>> > >> > > > >>> > >>> >
>> > session.
>> > >> > Later i 'm
>> > >> > > > not
>> > >> > > > >>> > >>> >
>> > > able to
>> > >> > get this
>> > >> > > > attribute in
>> > >> > > > >>> > portlet JSP page.
>> > It is
>> > >> > > > >>> > >>> >
>> > always
>> > >> > > > >>> > >>> >
>> > > NULL.
>> > >> > Application
>> > >> > > > is deployed on
>> > >> > > > >>> > Tomcat and
>> > already
>> > >> > > > >>> > >>> >
>> > have set
>> > >> > > > >>> > >>> >
>> > >
>> > >> > > > crossContext="true". Does the
>> > >> > > > >>> > session get
>> > overridden
>> > >> > > > >>> > >>> >
>> > somewhere?
>> > >> > > > >>> > >>> >
>> > >
>> > >> > > > >>> > >>> >
>> > > Thanks
>> > >> > > > >>> > >>> >
>> > >
>> > >> > > > >>> > >>>
>> > >
>> > >> > > > >   On Wed, Mar
>> > 2, 2011
>> > >> > > > >>> > at 3:59 PM, anyz
>> > >> > > > >>> > >>> >
>> > <[email protected]>
>> > >> > > > >>> > >>> >
>> > wrote:
>> > >> > > > >>> > >>> >
>> > >
>> > >> > > > >>> > >>> >
>> > >> I
>> > >> > think i got
>> > >> > > > it...added the
>> > >> > > > >>> > custom valve in
>> > >> > > > >>> > >>> >
>> > default
>> > >> > jetspeed
>> > >> > > > pipeline
>> > >> > > > >>> > >>> >
>> > >> that
>> > >> > is in the
>> > >> > > > following bean:
>> > >> > > > >>> > >>> >
>> > >>
>> > >> > > > >>> > >>> >
>> > >>
>> > >> > <bean
>> > >> > > > >>> >
>> > >> > id="jetspeed-pipeline"......../>
>> > >> > > > >>> > >>> >
>> > >>
>> > >> > > > >>> > >>> >
>> > >> It
>> > >> > is added
>> > >> > > > after <ref
>> > >> > > > >>> > >>>
>> > >
>> > >> > > > bean="loginValidationValve" />
>> > in
>> > >> > > > >>> > constructor
>> > >> > > > >>> > >>> >
>> > >>
>> > >> > argument list.
>> > >> > > > Now subject and
>> > >> > > > >>> > everything is
>> > >> > > > >>> > >>> >
>> > available.]
>> > >> > > > >>> > >>> >
>> > >>
>> > >> > > > >>> > >>> >
>> > >> Is
>> > >> > this
>> > >> > > > correct way to do
>> > >> > > > >>> > things?
>> > >> > > > >>> > >>> >
>> > >>
>> > >> > > > >>> > >>> >
>> > >>
>> > >> > > > >>> > >>> >
>> > >>
>> > >> > > > >>> > >>> >
>> > >>
>> > >> > > > >>> > >>> >
>> > >> On
>> > >> > Wed, Mar 2,
>> > >> > > > 2011 at 3:37 PM,
>> > >> > > > >>> > anyz <[email protected]>
>> > >> > > > >>> > >>> >
>> > wrote:
>> > >> > > > >>> > >>> >
>> > >>
>> > >> > > > >>> > >>> >
>> > >>>
>> > >> > I added
>> > >> > > > custom valve in
>> > >> > > > >>> > "login-pipeline"
>> > bean
>> > >> > > > >>> > >>> >
>> > defined in
>> > >> > > > pipelines.xml
>> > >> > > > >>> > >>> >
>> > >>>
>> > >> > that is
>> > >> > > > probably not right
>> > >> > > > >>> > place to do.
>> > >> > > > >>> > >>> >
>> > >>>
>> > >> > > > >>> > >>> >
>> > >>>
>> > >> > > > >>> > >>> >
>> > >>>
>> > >> > > > >>> > >>> >
>> > >>>
>> > >> > On Wed,
>> > >> > > > Mar 2, 2011 at 3:10
>> > >> > > > >>> > PM, anyz <[email protected]>
>> > >> > > > >>> > >>> >
>> > wrote:
>> > >> > > > >>> > >>> >
>> > >>>
>> > >> > > > >>> > >>>
>> > >
>> > >> > >>>> I
>> > >> > > > implemented my custom
>> > >> > > > >>> > valve by
>> > extending
>> > >> > > > >>> > >>>
>> > >
>> > >> > AbstractSecurityValve.
>> > >> > > > The
>> > >> > > > >>> > >>>
>> > >
>> > >> > >>>>
>> > >> > > > documentation says this
>> > >> > > > >>> > valve
>> > >> > > > >>> > >>>
>> > >
>> > >> > "Authenticates the user
>> > >> > > > or redirects to
>> > >> > > > >>> > Login
>> > >> > > > >>> > >>>
>> > >
>> > >> > >>>> if
>> > >> > > > necessary, adds the
>> > >> > > > >>> > authenticated
>> > >> > > > >>> > >>> >
>> > Subject to
>> > >> > the
>> > >> > > > RequestContext."
>> > >> > > > >>> > >>>
>> > >
>> > >> > >>>>
>> > >> > > > However in the invoke()
>> > >> > > > >>> > method as i try
>> > to
>> > >> > > > >>> > >>> >
>> > get subject
>> > >> > from
>> > >> > > > request
>> > >> > > > >>> > >>>
>> > >
>> > >> > >>>>
>> > >> > > > context its always
>> > >> > > > >>> > NULL.
>> > >> > > > >>> > >>>
>> > >
>> > >> > >>>>
>> > >> > > > >>> > >>>
>> > >
>> > >> > >>>> My
>> > >> > > > understanding is this
>> > >> > > > >>> > valve invokes
>> > >> > > > >>> > >>> >
>> > login module
>> > >> > to
>> > >> > > > authenticate user
>> > >> > > > >>> > >>>
>> > >
>> > >> > >>>> and
>> > >> > > > once authentication
>> > >> > > > >>> > done it sets teh
>> > >> > > > >>> > >>> >
>> > subject in
>> > >> > request
>> > >> > > > context. I have
>> > >> > > > >>> > >>>
>> > >
>> > >> > >>>> called
>> > >> > > > the
>> > >> > > > >>> >
>> > super.invoke(rc,vc) in my
>> > >> > > > >>> > >>> >
>> > custom valve
>> > >> > but
>> > >> > > > subject is always
>> > >> > > > >>> > >>>
>> > >
>> > >> > >>>> NULL.
>> > >> > > > >>> > >>>
>> > >
>> > >> > >>>>
>> > >> > > > >>> > >>>
>> > >
>> > >> > >>>> Could
>> > >> > > > you please guide
>> > >> > > > >>> > what am i
>> > missing?
>> > >> > > > >>> > >>>
>> > >
>> > >> > >>>>
>> > >> > > > >>> > >>>
>> > >
>> > >> > >>>>
>> > >> > > > Thanks
>> > >> > > > >>> > >>>
>> > >
>> > >> > >>>>
>> > >> > > > >>> > >>>
>> > >
>> > >> > >>>>
>> > >> > > > >>> > >>>
>> > >
>> > >> > >>>>
>> > >> > > > >>> > >>>
>> > >
>> > >> > >>>> On
>> > >> > > > Wed, Mar 2, 2011 at
>> > >> > > > >>> > 4:17 AM, Woonsan
>> > Ko
>> > >> > > > >>> > >>> >
>> > <[email protected]>
>> > >> > > > >>> > >>> >
>> > wrote:
>> > >> > > > >>> > >>>
>> > >
>> > >> > >>>>
>> > >> > > > >>> > >>>
>> > >
>> > >> > >>>>>
>> > >> > > > >>> > >>>
>> > >
>> > >> > >>>>>
>> > >> > > > --- On Tue, 3/1/11,
>> > >> > > > >>> > anyz <[email protected]>
>> > >> > > > >>> > >>> >
>> > wrote:
>> > >> > > > >>> > >>>
>> > >
>> > >> > >>>>>
>> > >> > > > >>> > >>>
>> > >
>> > >> > >>>>>
>> > >> > > > > From: anyz
>> > >> > > > >>> > <[email protected]>
>> > >> > > > >>> > >>>
>> > >
>> > >> > >>>>>
>> > >> > > > > Subject:
>> > >> > > > >>> > Storing Custom
>> > Object in
>> > >> > > > >>> > >>> >
>> > Session on
>> > >> > User Login
>> > >> > > > >>> > >>>
>> > >
>> > >> > >>>>>
>> > >> > > > > To: "Jetspeed
>> > >> > > > >>> > Users List"
>> > <[email protected]>
>> > >> > > > >>> > >>>
>> > >
>> > >> > >>>>>
>> > >> > > > > Date: Tuesday,
>> > >> > > > >>> > March 1, 2011,
>> > >> > > > >>> > >>> >
>> > 6:49 AM
>> > >> > > > >>> > >>>
>> > >
>> > >> > >>>>>
>> > >> > > > > I need to set a
>> > >> > > > >>> > custom class
>> > >> > > > >>> > >>> >
>> > object
>> > >> > > > >>> > >>>
>> > >
>> > >> > >>>>>
>> > >> > > > > into session
>> > >> > > > >>> > once user logged
>> > >> > > > >>> > >>> >
>> > into
>> > >> > > > >>> > >>>
>> > >
>> > >> > >>>>>
>> > >> > > > > Jetspeed. This
>> > >> > > > >>> > object will be
>> > >> > > > >>> > >>> >
>> > accessed and
>> > >> > used later
>> > >> > > > by
>> > >> > > > >>> > >>>
>> > >
>> > >> > >>>>>
>> > >> > > > > portlets.
>> > >> > > > >>> > After
>> > >> > > > >>> > >>>
>> > >
>> > >> > >>>>>
>> > >> > > > > searching into
>> > >> > > > >>> > email list and
>> > >> > > > >>> > >>> >
>> > forum i found
>> > >> > two ways
>> > >> > > > of
>> > >> > > > >>> > >>>
>> > >
>> > >> > >>>>>
>> > >> > > > > intercepting
>> > >> > > > >>> > J2
>> > >> > > > >>> > >>>
>> > >
>> > >> > >>>>>
>> > >> > > > > login process:
>> > >> > > > >>> > >>>
>> > >
>> > >> > >>>>>
>> > >> > > > >
>> > >> > > > >>> > >>>
>> > >
>> > >> > >>>>>
>> > >> > > > > 1- Custom Login
>> > >> > > > >>> > Module
>> > >> > > > >>> > >>>
>> > >
>> > >> > >>>>>
>> > >> > > > > 2- Custom
>> > >> > > > >>> > Security Valve
>> > and
>> > >> > > > >>> > >>> >
>> > possibly
>> > >> > Filter (not
>> > >> > > > sure if
>> > >> > > > >>> > >>>
>> > >
>> > >> > >>>>>
>> > >> > > > > Filter works
>> > >> > > > >>> > in
>> > >> > > > >>> > >>>
>> > >
>> > >> > >>>>>
>> > >> > > > > Jetspeed 2.2.1
>> > >> > > > >>> > or its for old
>> > >> > > > >>> > >>> >
>> > version)
>> > >> > > > >>> > >>>
>> > >
>> > >> > >>>>>
>> > >> > > > >
>> > >> > > > >>> > >>>
>> > >
>> > >> > >>>>>
>> > >> > > > > I manged to
>> > >> > > > >>> > plug my custom
>> > login
>> > >> > > > >>> > >>> >
>> > module
>> > >> > however i could
>> > >> > > > not
>> > >> > > > >>> > >>>
>> > >
>> > >> > >>>>>
>> > >> > > > > find a way to
>> > >> > > > >>> > >>>
>> > >
>> > >> > >>>>>
>> > >> > > > > get session in
>> > >> > > > >>> > login() method
>> > and
>> > >> > > > >>> > >>> >
>> > set my custom
>> > >> > class
>> > >> > > > >>> > >>>
>> > >
>> > >> > >>>>>
>> > >> > > > > object into
>> > >> > > > >>> > session.
>> > >> > > > >>> > >>>
>> > >
>> > >> > >>>>>
>> > >> > > > > Is it possible
>> > >> > > > >>> > to get
>> > HttpSession
>> > >> > > > >>> > >>> >
>> > in custom
>> > >> > login
>> > >> > > > module?
>> > >> > > > >>> > >>>
>> > >
>> > >> > >>>>>
>> > >> > > > >>> > >>>
>> > >
>> > >> > >>>>> It
>> > >> > > > is not possible
>> > >> > > > >>> > to access
>> > >> > > > >>> > >>> >
>> > HttpSession
>> > >> > in a JAAS
>> > >> > > > LoginModule.
>> > >> > > > >>> > >>>
>> > >
>> > >> > >>>>>
>> > >> > > > >>> > >>>
>> > >
>> > >> > >>>>>
>> > >> > > > >
>> > >> > > > >>> > >>>
>> > >
>> > >> > >>>>>
>> > >> > > > > If i have write
>> > >> > > > >>> > security valve,
>> > >> > > > >>> > >>> >
>> > do i also
>> > >> > need some
>> > >> > > > sort of
>> > >> > > > >>> > >>>
>> > >
>> > >> > >>>>>
>> > >> > > > > Serverlt
>> > >> > > > >>> > filter
>> > >> > > > >>> > >>>
>> > >
>> > >> > >>>>>
>> > >> > > > > where i can set
>> > >> > > > >>> > custom object
>> > >> > > > >>> > >>> >
>> > into
>> > >> > session.
>> > >> > > > >>> > >>>
>> > >
>> > >> > >>>>>
>> > >> > > > >>> > >>>
>> > >
>> > >> > >>>>>
>> > >> > > > You don't need a
>> > >> > > > >>> > servlet filter if
>> > you
>> > >> > > > >>> > >>> >
>> > use a custom
>> > >> > security
>> > >> > > > valve.
>> > >> > > > >>> > >>>
>> > >
>> > >> > >>>>>
>> > >> > > > Servlet filter such
>> > >> > > > >>> > as
>> > >> > > > >>> > >>>
>> > >
>> > >> > PoralLoginFilter is
>> > >> > > > enabled/used only for
>> > >> > > > >>> > some
>> > >> > > > >>> > >>>
>> > >
>> > >> > >>>>>
>> > >> > > > environment like WAS
>> > >> > > > >>> > instead of
>> > >> > > > >>> > >>> >
>> > Jetspeed
>> > >> > JAAS
>> > >> > > > LoginModule.
>> > >> > > > >>> > >>>
>> > >
>> > >> > >>>>>
>> > >> > > > >>> > >>>
>> > >
>> > >> > >>>>>
>> > >> > > > >>> > >>>
>> > >
>> > >> > >>>>>
>> > >> > > > Woonsan
>> > >> > > > >>> > >>>
>> > >
>> > >> > >>>>>
>> > >> > > > >>> > >>>
>> > >
>> > >> > >>>>>
>> > >> > > > >
>> > >> > > > >>> > >>>
>> > >
>> > >> > >>>>>
>> > >> > > > >
>> > >> > > > >>> > >>>
>> > >
>> > >> > >>>>>
>> > >> > > > > Thanks
>> > >> > > > >>> > >>>
>> > >
>> > >> > >>>>>
>> > >> > > > >
>> > >> > > > >>> > >>>
>> > >
>> > >> > >>>>>
>> > >> > > > >>> > >>>
>> > >
>> > >> > >>>>>
>> > >> > > > >>> > >>>
>> > >
>> > >> > >>>>>
>> > >> > > > >>> > >>>
>> > >
>> > >> > >>>>>
>> > >> > > > >>> > >>>
>> > >
>> > >> > >>>>>
>> > >> > > > >>> > >>>
>> > >
>> > >> > > > >>> >
>> > >> > > >
>> > >> >
>> > ---------------------------------------------------------------------
>> > >> > > > >>> > >>>
>> > >
>> > >> > >>>>> To
>> > >> > > > unsubscribe,
>> > >> > > > >>> > e-mail:
>> > >> > > > >>> > >>> [email protected]
>> > >> > > > >>> > >>>
>> > >
>> > >> > >>>>>
>> > >> > > > For additional
>> > >> > > > >>> > commands,
>> > e-mail:
>> > >> > > > >>> > >>> [email protected]
>> > >> > > > >>> > >>>
>> > >
>> > >> > >>>>>
>> > >> > > > >>> > >>>
>> > >
>> > >> > >>>>>
>> > >> > > > >>> > >>>
>> > >
>> > >> > >>>>
>> > >> > > > >>> > >>> >
>> > >>>
>> > >> > > > >>> > >>> >
>> > >>
>> > >> > > > >>> > >>> >
>> > >
>> > >> > > > >>> > >>>
>> > >
>> > >> > > > >>> > >>>
>> > >> > > > >>> > >>>
>> > >> > > > >>> > >>>
>> > >> > > > >>> > >>>
>> > >> > > > >>> > >>>
>> > >> > > > >>> >
>> > >> > > >
>> > >> >
>> > ---------------------------------------------------------------------
>> > >> > > > >>> > >>> To
>> > unsubscribe,
>> > >> > e-mail:
>> > >> > > > >>> [email protected]
>> > >> > > > >>> > >>> For
>> > additional
>> > >> > commands,
>> > >> > > > e-mail:
>> > >> > > > >>> [email protected]
>> > >> > > > >>> > >>>
>> > >> > > > >>> > >>>
>> > >> > > > >>> > >>
>> > >> > > > >>> > >
>> > >> > > > >>> >
>> > >> > > > >>>
>> > >> > > > >>>
>> > >> > > > >>>
>> > >> > > > >>>
>> > >> > > > >>>
>> > >> > > >
>> > >> >
>> > ---------------------------------------------------------------------
>> > >> > > > >>> To unsubscribe,
>> > e-mail:
>> > >> [email protected]
>> > >> > > > >>> For additional
>> > commands, e-mail:
>> > >> > > [email protected]
>> > >> > > > >>>
>> > >> > > > >>>
>> > >> > > > >>
>> > >> > > > >
>> > >> > > >
>> > >> > >
>> > >> > >
>> > >> > >
>> > >> > >
>> > >> > >
>> > >> >
>> > ---------------------------------------------------------------------
>> > >> > > To unsubscribe, e-mail:
>> [email protected]
>> > >> > > For additional commands, e-mail:
>> > >> [email protected]
>> > >> > >
>> > >> > >
>> > >> >
>> > >>
>> > >>
>> > >>
>> > >>
>> > >>
>> > ---------------------------------------------------------------------
>> > >> To unsubscribe, e-mail: [email protected]
>> > >> For additional commands, e-mail:
>> [email protected]
>> > >>
>> > >>
>> > >
>> >
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>>
>>
>
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans";
    xmlns:aop="http://www.springframework.org/schema/aop";
    xmlns:context="http://www.springframework.org/schema/context";
    xmlns:p="http://www.springframework.org/schema/p";
    xmlns:tx="http://www.springframework.org/schema/tx";
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
    xsi:schemaLocation="
       http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
       http://www.springframework.org/schema/tx
       http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
       http://www.springframework.org/schema/aop
       http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
       http://www.springframework.org/schema/context
       http://www.springframework.org/schema/context/spring-context-3.0.xsd";>

    <tx:annotation-driven />
    
	<bean id="loggerListener" class="org.springframework.security.event.authentication.LoggerListener" />

	<!-- ======================================== Session Scoped beans  ======================================== -->
	<bean id="userInfo" class="com.xx.xx.xx.SessionUserInfo" scope="session">
          <aop:scoped-proxy/>
    </bean>

    <!-- needed is for @Configurable -->
    <context:component-scan base-package="com.lwsi"/>

	
    <import resource="applicationContext-persistence.xml" />
	    
</beans>


<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.5"
	xmlns="http://java.sun.com/xml/ns/javaee"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee             http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd";>
	<display-name>myapp</display-name>
	
<listener>
<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>
	<listener>
		<listener-class>com.xxx.xxx.AppContextListener</listener-class>
	</listener>
	
	<listener>
    	<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
  	</listener>
  	<context-param>
    	<param-name>log4jConfigLocation</param-name>
    	<param-value>/WEB-INF/classes/log4j-myapp.properties</param-value>
  	</context-param>
  	
  	<listener>
		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
	</listener>
	<context-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>/WEB-INF/applicationContext*.xml</param-value>
	</context-param>
	<context-param>
		<param-name>webAppRootKey</param-name>
		<param-value>myapp-root</param-value>
	</context-param>
<filter>
   <filter-name>RequestContextFilter</filter-name>
   <filter-class>org.springframework.web.filter.RequestContextFilter</filter-class>
 </filter>

 <filter-mapping>
   <filter-name>RequestContextFilter</filter-name>
   <url-pattern>/*</url-pattern>
   <dispatcher>REQUEST</dispatcher>
   <dispatcher>INCLUDE</dispatcher>
   <dispatcher>FORWARD</dispatcher>
 </filter-mapping>

 <!-- Misc -->
	<session-config>
		<session-timeout>30</session-timeout>
	</session-config>
	<welcome-file-list>
		<welcome-file>index.jsp</welcome-file>
	</welcome-file-list>

</web-app>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to