如何处理JSF动态角色或用户名的变化? [英] How to handle dynamic role or username changes in JSF?

查看:162
本文介绍了如何处理JSF动态角色或用户名的变化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在GlassFish 2.1上运行一个EJB 3后端JSF应用程序。为了验证我使用自定义的境界。用户认证使用他上注册指定的电子邮件地址和密码。一切都合作得非常好。

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),用户可以编辑自己的个人资料, - 自然 - 他也可以改变他的电子邮件地址。不幸的是,当我执行基于使用ExternalContext.getUserPrincipal当前用户的身份()的getName()操作,我将获得previous电子邮件地址登录时使用的用户。此刻,我通过强制用户重新进行身份验证后,他改变了他的电子邮件地址解决这个问题,但有另一种更优雅的可能性?

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),同样为用户角色。例如。我有用户角色和会员preMIUM_MEMBER。一成员可成为他当前会话期间preMIUM_MEMBER。不幸的是,作用似乎在登录时只确定。有没有可能,那JSF和EJB认识到新的用户角色,而无需用户重新进行身份验证?

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?

推荐答案

考虑使用与JSF。在那里,你可以更改用户凭据登录,而无需重新登录。

Consider using Seam with JSF. There you can change the logged in users credentials without needing to re-login.

这篇关于如何处理JSF动态角色或用户名的变化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆