File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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 REST with Spring (video course) this week in the Spring 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: 14688

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( )
It's not a secret anymore!