JBoss AS7, JSF, Get Logged in User

if you use JAAS to login to your application, you are able to get the active user(name) the following way:

final Principal principal = FacesContext.getCurrentInstance()
                    .getExternalContext().getUserPrincipal();
if (null == principal) {
    return null;
}
return principal.getName();

Leave a Reply