2012-05-29 19 views
0

我想用JSF創建一個登錄表單,該表單還在外部上下文中創建一個新的UserPrincipal。如何創建新的UserPrincipal?

當我想在External FacesContext中創建一個新的UserPrincipal時,我該怎麼辦?

我使用WebSphere Application Server 8 JSF 2

我想要像這樣的工作:

FacesContext context = FacesContext.getCurrentInstance(); 
Principal principal = context.getExternalContext().getUserPrincipal(); 

問候 Veote

+0

UserPrincipal是託管bean還是模型bean?另外,你使用的是什麼JSF版本? –

+0

我編輯了我的帖子 – veote

+0

@Luiggi:它是容器管理安全的一部分http://docs.oracle.com/javaee/6/tutorial/doc/gkbaa.html – BalusC

回答

3

據我所知,我不認爲我們必須明確創建UserPrincipal。您必須使用某種機制(如JAAS/NTLM/SPNEGO)對用戶進行身份驗證,以便容器爲您創建我i n其javax.servlet.http.HttpServletRequest實現