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.
Tomcat configuration files are found in the directory: CATALINA_HOME/conf (where CATALINA_HOME environment variable is the Tomcat installation directory). The main configuration file is server. xml .
After restarting Tomcat, you should be able to access the Manager app (http://localhost:8080/manager/html) using username = admin and password = admin.
The available roles are: manager-gui — Access to the HTML interface. manager-status — Access to the "Server Status" page only. manager-script — Access to the tools-friendly plain text interface that is described in this document, and to the "Server Status" page.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With