I am writing an application using JSF 2.0, java ee and glassfish.
My user interface is simple xhtml containing jsf.
I want my user to login and depending their right have different element displayed on the same pages.
is it possible usi开发者_如何学JAVAng jaas ?
Thanks in advance loic
If you don't want to write framework type code to do this "behind the scenes" you could bind the rendered attribute of the component to a method which checks the user's access rights e.g.
public boolean isUserAllowedAccess() {
return FacesContext.getCurrentInstance().getExternalContext().
isUserInRole("ROLE_ADMIN");
// or whatever authorization code you want
}
and then refer to it in the 'rendered' attribute of your JSF-tags e.g.
rendered="#{authBean.userAllowedAccess}"
You can wrap multiple components using panels e.g.
<h:panelGroup rendered="#{authBean.userAllowedAccess}">
精彩评论