-
1. Re: Getting the logged on user info
starksm64 Jan 4, 2005 8:53 PM (in response to scotttam)Use the standard HttpServletRequest.getUserPrincipal call.
-
2. Re: Getting the logged on user info
scotttam Jan 5, 2005 8:02 AM (in response to scotttam)Thanks Scott.
I tried that originally but request.getUserPrincipal() was returning null, even though my security-constraint contained the path to the jsp page. I figured out that the problem was the struts action path was not in the security-constraint. Once I added that in, request.getUserPrincipal returned what I expected. -
3. Re: Getting the logged on user info
didi Jan 8, 2005 6:47 AM (in response to scotttam)I am having the same problem: request.getUserPrincipal() is null in my jsp even when I am authenticated sucessfully. I am using a simple jsp to understand the whole JAAS stuff but where do I have to change the "security-constraint" you mentioned?
-
4. Re: Getting the logged on user info
scotttam Jan 8, 2005 1:11 PM (in response to scotttam)You need to add something like this to your web.xml. Make sure the jsp page you wish to use request.getUserPrincipal() is in the url-pattern.
<security-constraint> <web-resource-collection> <web-resource-name>Protected Area</web-resource-name> <url-pattern>/jsp/secure/*</url-pattern> <url-pattern>/secure/*</url-pattern> </web-resource-collection> <auth-constraint> <role-name>admin</role-name> </auth-constraint> </security-constraint>