Reputation: 91
is there a way to get the logged in user name (and group) from a Tomcat system. I read something about configuring Tomcat, so it is getting the user information out of a database. But I found now information about getting the name of the user (in my GWT Project), which is logged in.
I'm trying to write a little GWT project and would like to publish the user name to the front page.
Thx for your help.
Upvotes: 7
Views: 10188
Reputation: 10687
You can try these two methods from the HttpServletRequest interface.
getUserPrincipal()
returns a Principal from which you can get the logged used as getUserPrincipal().getName()
.
isUserInRole("Administrators")
returns true if the current Principal is in the provided role.
Of course this only works if you are using tomcat realm authentication found here.
Upvotes: 9