I am in a Jboss AS 7 environment. My application’s /admIn/* path is protected by a security-constraint which requires form based authentication. Security domain is database backed.
It’s ok but now I want to display a “good morning ” in each page’s header.
I’m looking for some sort of getLoggedUsername() or getPrincipal() function but I can’t find it.
Please post a reference to the official docs if any.
Thank you.
You should be able to use JAAS. Which is what JBoss 7 ought to be using.
The calling principal will be stored in a
SessionContextwhich you can obtain by telling JBoss it’s a resource.If for some reason the Injection doesn’t work on a Stateless bean, you can look up the EJBContext direct.
This snippet was obtained from 4 ways to obtain EJBContext.