How to handle dynamic role or username changes in JSF?

Posted by roadrunner on Stack Overflow See other posts from Stack Overflow or by roadrunner
Published on 2010-03-21T13:28:10Z Indexed on 2010/03/21 13:31 UTC
Read the original article Hit count: 286

Filed under:
|
|
|

I have a JSF application running on glassfish 2.1 with a EJB 3 backend. For authentication I use a custom realm. The user authenticates using the e-mail-address and password he specified on registration. Everything is working quite well.

Now I have two related problems:

1) The user can edit his profile and -- naturally -- he can also change his e-mail-address. Unfortunately when I perform operations based on the current user's identity using ExternalContext.getUserPrincipal().getName(), I will receive the previous e-mail-address the user used on login. At the moment I handle this by forcing the user to reauthenticate after he changed his e-mail-address, but is there another more graceful possibility?

2) Same for user roles. E.g. I have the user roles MEMBER and PREMIUM_MEMBER. A MEMBER may become a PREMIUM_MEMBER during his current session. Unfortunately the role seems to be only determined at login. Is there any possibility, that JSF and EJB recognize the new user role without the need for the user to re-authenticated?

© Stack Overflow or respective owner

Related posts about jsf

Related posts about ejb