-
1. Re: Retriving principals after authentication.
tcherel Dec 27, 2004 10:26 AM (in response to infectedrhythms)See http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3859817
The isCallerInRole on the EJBContext object can be used to test user roles, and the isUserInRole on the HttpServletRequest can be used to do the same in a servlet context.
There is no standard J2EE way to get the list of role of a user.
Thomas -
2. Re: Retriving principals after authentication.
infectedrhythms Dec 27, 2004 11:32 PM (in response to infectedrhythms)Am trying this as I need it in my web container not ejb...
request.getPrincipal.getName()
But i get...
An error occurred at line: 10 in the jsp file: /artists/profile_form.jsp
Generated servlet error:
D:\jboss-4.0.0\server\default\work\jboss.web\localhost\mamoth\org\apache\jsp\artists\profile_005fform_jsp.java:52: cannot resolve symbol
symbol : variable getPrincipal
location: interface javax.servlet.http.HttpServletRequest
out.print(request.getPrincipal.getName());
^
1 error -
3. Re: Retriving principals after authentication.
infectedrhythms Dec 27, 2004 11:51 PM (in response to infectedrhythms)Sorry more specifically, I would like to know the username (PrincipalID) that is loged in to my web site, so i can use that PrincipalID to query the DB for additional information.
As sugested in the other post, request.getPrincipal.getName(), throws an exception as shown in the previous post.
I also wanted to do this through filter so I can create a bean and pass it along through a session, so i wont have to query the DB for the extra info again.
Thanks -
4. Re: Retriving principals after authentication.
tcherel Dec 28, 2004 4:06 AM (in response to infectedrhythms)Agree, it was typed a little too quickly, but you should, at least, check the javadoc of the javax.servlet.http.HttpServletRequest class.
getPrincipal is a method, not a public instance variable (Java 101 ...).
Try request.getPrincipal().getName() instead.
Thomas -
5. Re: Retriving principals after authentication.
infectedrhythms Dec 28, 2004 11:50 AM (in response to infectedrhythms)in fact i looked at it through the eclipse code completion! and i didnt get the methodname getPrincipal!
But i will try this! -
6. Re: Retriving principals after authentication.
infectedrhythms Dec 28, 2004 11:55 AM (in response to infectedrhythms)Still no go!
Same error
request.getPrincipal().getName()
Unresolved symbol -
7. Re: Retriving principals after authentication.
infectedrhythms Dec 28, 2004 12:01 PM (in response to infectedrhythms)According to...
http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/http/HttpServletRequest.html
There is no getPrincipal() -
8. Re: Retriving principals after authentication.
infectedrhythms Dec 28, 2004 12:09 PM (in response to infectedrhythms)it's request.getUserPrincipal().getName()
Thanks