This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes security-role-ref and isUserInRole( ) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "security-role-ref and isUserInRole( )" Watch "security-role-ref and isUserInRole( )" New topic

security-role-ref and isUserInRole( )

Grace Yang
Ranch Hand

Joined: Apr 01, 2007
Posts: 58
I am studying how <security-role-ref> maps role name, below are my web.xml and snippet of BasicServlet class, I expected to isUserInRole("Manger") returns true, but it returns false, I don't know why?
System.out.println("Manger isUserInRole? " + req.isUserInRole("Manger") );
res.getWriter().println("Manger isUserInRole? " + req.isUserInRole("Manger"));
------ web.xml

<web-resource-name>declarative security test</web-resource-name>

anybody knows?

Christophe Verré

Joined: Nov 24, 2005
Posts: 14687

The pseudo role is declared "Manager" in your descriptor, so replace "Manger" with "Manager" in your code

[My Blog]
All roads lead to JavaRanch
Grace Yang
Ranch Hand

Joined: Apr 01, 2007
Posts: 58
Thanks Satou !!

It works.It's the typo caused trouble.

subject: security-role-ref and isUserInRole( )
Similar Threads
Security tags
Declarative security in web.xml?? is this secure??
req.isUserInRole("admin"); return false??
need help,2 questions
Is auth-constraint related to security-role?