Ok, seems logical. Now, I'm probably totally stupid and stuck at a different
edge:
The ApplicationStateManager throws
java.lang.ClassCastException: stb.admin2.base.SessionStoredUser cannot be cast
to stb.admin2.base.SessionStoredUser
This is the code in my component:
@SessionState(create=false)
private SessionStoredUser userData;
And this is in the Realm:
SessionStoredUser userData = new SessionStoredUser();
userData.setNachname(userDAO.getUserName());
asm.set(SessionStoredUser.class, userData);
The ApplicationStateManager asm is injected with the constructor.
I've been using the ApplicationStateManager before without complaints.
Thanks for any help
Jens
--
Jens Reufsteck
-----Original Message-----
From: Kalle Korhonen [mailto:[email protected]]
Sent: Monday, November 21, 2011 5:47 PM
To: Tapestry users
Subject: Re: Tynamo: Store additional user data during authentication
On Mon, Nov 21, 2011 at 4:44 AM, Jens Reufsteck <
[email protected]> wrote:
> Hi, sorry if this has been asked before, though I couldn’t find
> anything about it.****
>
> I’ve just started to use Tapestry security instead of our own light
> weigth authentication system. Works fine so far – thanks to the
> developers!****
>
> Now, I want to display the real name for logged in users. It’s not the
> same as their login or username, so I can’t get it with
> securityService.getSubject().getPrincipal().****
>
> I’d expect to store it in the session – and I’m wondering, how to
> accomplish this during authentication.****
>
> As recommended, I’m contributing an implementation of a realm.
> Probably, I could inject the Session into the realm, store the user
> name into the session and hope, that getSubject().getSession() will
> afterwards retrieve exactly this session. Isn’t there a more elegant solution?
>
There's no reason to strongly tie this to your security logic. You should use
an ApplicationStateObject for session-bound user data. Often, I have a
lightweight CurrentUser ApplicationStateObject for authenticated (or
remembered) users that holds the user's name among other things. For example,
you could have a custom ApplicationStateCreator to create a CurrentUser on the
fly and inject a UserService into it to populate your CurrentUser with the
required data.
Kalle
** **
>
> We’re using Tapestry 5.1.0.5 with Tapestry security 0.2.2.****
>
> ** **
>
> Many thanks****
>
> Jens****
>
> ** **
>
> --
> Jens Reufsteck
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]