You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Andreas Bulling <sp...@phoenix.hadiko.de> on 2006/04/18 10:39:18 UTC
ICallback/Session problem
Hi folks,
I have a problem with the user login session in Tapestry
and my custom ICallback and I would like to hear about
your best-practice solutions again ;-)
The problem is that if the user session gets invalidated due
to a timeout for example and the user logs in again I get
an exception on the previously visited page because my custom
ICallback doesn't work with pages where for example a database
record needs to be read before the page gets displayed.
Does someone know how to fix this? Storing the record id
in the visit object (I'm not using ASOs so far, perhaps I
should instead of the "old" visit object) should work
but is that the best-practice solution?
Thanks,
Andreas
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
RE: ICallback/Session problem
Posted by James Carman <ja...@carmanconsulting.com>.
Well, as for the SecurityContext:
1. Set up a session-scoped ASO which can hold the current user's id.
2. Set up a SecurityContext service in HiveMind (threaded service lifecycle
model of course). Inject the ApplicationStateManager into it (just provide
a setter) so that it can look up the ASO you created in step 1.
3. Create a lazy-loaded getter for the actual user object (which contains a
way to ask what permissions/privileges/roles they have). This usually
involves checking that a property is null and then calling a DAO to go get
the user object from the database.
-----Original Message-----
From: Andreas Bulling [mailto:andreas@phoenix.hadiko.de] On Behalf Of
Andreas Bulling
Sent: Tuesday, April 18, 2006 7:03 AM
To: Tapestry users
Subject: Re: ICallback/Session problem
Hi James,
On 18. Apr 2006 - 06:55:12, James Carman wrote:
| That's how I do it. I store the user-id in the session inside one of my
| ASOs. Then, I have a threaded service called SecurityContext which
actually
| will lazily load the actual user object during the request cycle if it's
| asked for by someone (like a security interceptor or something).
in only this four lines you mention two things I'm highly interested in:
The SecurityContext and the SecurtyInterceptor. As I wrote in one of
my former posts I'm in search of a security concept for my application
and those two things at least sound as if they are what I also
thought of ;) Would you mind to provide further information about
how you implemented them or even some example/the code?
Kind regards,
Andreas
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: ICallback/Session problem
Posted by Andreas Bulling <sp...@phoenix.hadiko.de>.
Hi James,
On 18. Apr 2006 - 06:55:12, James Carman wrote:
| That's how I do it. I store the user-id in the session inside one of my
| ASOs. Then, I have a threaded service called SecurityContext which actually
| will lazily load the actual user object during the request cycle if it's
| asked for by someone (like a security interceptor or something).
in only this four lines you mention two things I'm highly interested in:
The SecurityContext and the SecurtyInterceptor. As I wrote in one of
my former posts I'm in search of a security concept for my application
and those two things at least sound as if they are what I also
thought of ;) Would you mind to provide further information about
how you implemented them or even some example/the code?
Kind regards,
Andreas
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: ICallback/Session problem
Posted by Andreas Bulling <sp...@phoenix.hadiko.de>.
| IMO this design can be improved: Try changing to external page instead
| of direct link. then use a callback for the external page. The external
| parameters should contain the "state" - thus the id of the db object you
| need. creating the callback may be tricky: for that I use callbacks
| which throw RedirectException to a given URL -
Thanks for this! I will try and hopefully this fixes my problem ;)
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: ICallback/Session problem
Posted by Ron Piterman <rp...@gmx.net>.
Andreas Bulling wrote:
> Hi Ron,
>
> thanks for your answer!
>
> | I don't fully understand what your ICallback does and where in the work
> | flow it is activated -
>
> Well, actually as a first version I just took the one from the vlib example...
> When the user has been idle for some period of time the login page is shown
> again and he is able to re-login. After that the page he had visited
> before the session became invalid is shown. But this only works for pages
> where no database record has to be read in pageBeginRender() because the
> database id (which is normally passed for example as a parameter with a
> DirectLink) is unknown and an exception is thrown :(
IMO this design can be improved: Try changing to external page instead
of direct link. then use a callback for the external page. The external
parameters should contain the "state" - thus the id of the db object you
need. creating the callback may be tricky: for that I use callbacks
which throw RedirectException to a given URL -
>
> | My solution is to design pages that always work, thus, keep the minimum
> | necessary in the Visit (eg current logged in user-id) - the rest on the
> | client -
>
> And in your page classes (probably in a page superclass) you reload the
> user object from the id every time a page gets loaded?
yes - if this causes performance problems one can save the whole User
object in the session - but I preffer letting hibernate / ehcache do its
own the performance optimisation (if needed) and keep the session
(Visit?) small...
>
> Sincerly,
> Andreas
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
RE: ICallback/Session problem
Posted by James Carman <ja...@carmanconsulting.com>.
That's how I do it. I store the user-id in the session inside one of my
ASOs. Then, I have a threaded service called SecurityContext which actually
will lazily load the actual user object during the request cycle if it's
asked for by someone (like a security interceptor or something).
-----Original Message-----
From: Andreas Bulling [mailto:andreas@phoenix.hadiko.de] On Behalf Of
Andreas Bulling
Sent: Tuesday, April 18, 2006 5:50 AM
To: Tapestry users
Subject: Re: ICallback/Session problem
Hi Ron,
thanks for your answer!
| I don't fully understand what your ICallback does and where in the work
| flow it is activated -
Well, actually as a first version I just took the one from the vlib
example...
When the user has been idle for some period of time the login page is shown
again and he is able to re-login. After that the page he had visited
before the session became invalid is shown. But this only works for pages
where no database record has to be read in pageBeginRender() because the
database id (which is normally passed for example as a parameter with a
DirectLink) is unknown and an exception is thrown :(
| My solution is to design pages that always work, thus, keep the minimum
| necessary in the Visit (eg current logged in user-id) - the rest on the
| client -
And in your page classes (probably in a page superclass) you reload the
user object from the id every time a page gets loaded?
Sincerly,
Andreas
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: ICallback/Session problem
Posted by Andreas Bulling <sp...@phoenix.hadiko.de>.
Hi Ron,
thanks for your answer!
| I don't fully understand what your ICallback does and where in the work
| flow it is activated -
Well, actually as a first version I just took the one from the vlib example...
When the user has been idle for some period of time the login page is shown
again and he is able to re-login. After that the page he had visited
before the session became invalid is shown. But this only works for pages
where no database record has to be read in pageBeginRender() because the
database id (which is normally passed for example as a parameter with a
DirectLink) is unknown and an exception is thrown :(
| My solution is to design pages that always work, thus, keep the minimum
| necessary in the Visit (eg current logged in user-id) - the rest on the
| client -
And in your page classes (probably in a page superclass) you reload the
user object from the id every time a page gets loaded?
Sincerly,
Andreas
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: ICallback/Session problem
Posted by Ron Piterman <rp...@gmx.net>.
I don't fully understand what your ICallback does and where in the work
flow it is activated -
My solution is to design pages that always work, thus, keep the minimum
necessary in the Visit (eg current logged in user-id) - the rest on the
client -
some examples:
- a direct link should use parameters which indicate the whole state it
leeds to -
- a form contains hidden fields which contain the current application
state ( from a user's view-point).
and so on...
Hope that helps,
Ron
Andreas Bulling wrote:
> Hi folks,
>
> I have a problem with the user login session in Tapestry
> and my custom ICallback and I would like to hear about
> your best-practice solutions again ;-)
>
> The problem is that if the user session gets invalidated due
> to a timeout for example and the user logs in again I get
> an exception on the previously visited page because my custom
> ICallback doesn't work with pages where for example a database
> record needs to be read before the page gets displayed.
>
> Does someone know how to fix this? Storing the record id
> in the visit object (I'm not using ASOs so far, perhaps I
> should instead of the "old" visit object) should work
> but is that the best-practice solution?
>
> Thanks,
> Andreas
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org