405535 implement Request.isUserInRole(role) check security-role-refs defaulting to security-role if no matching ref
This commit is contained in:
parent
0aa2a5b6bb
commit
f19421112a
|
@ -54,13 +54,19 @@ public class DefaultUserIdentity implements UserIdentity
|
|||
}
|
||||
|
||||
public boolean isUserInRole(String role, Scope scope)
|
||||
{
|
||||
{
|
||||
if (scope!=null && scope.getRoleRefMap()!=null)
|
||||
role=scope.getRoleRefMap().get(role);
|
||||
|
||||
{
|
||||
String mappedRole = scope.getRoleRefMap().get(role);
|
||||
if (mappedRole != null)
|
||||
role = mappedRole;
|
||||
}
|
||||
|
||||
for (String r :_roles)
|
||||
{
|
||||
if (r.equals(role))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ public class RoleAnnotationTest extends HttpServlet
|
|||
result = request.isUserInRole("manager");
|
||||
out.println("<br/><b>Result: isUserInRole(\"manager\")="+result+":"+ (result?" <span class=\"pass\">PASS":" <span class=\"fail\">FAIL")+"</span></b>");
|
||||
result = request.isUserInRole("user");
|
||||
out.println("<br/><b>Result: isUserInRole(\"user\")="+result+":"+ (result==false?" <span class=\"pass\">PASS":" <span class=\"fail\">FAIL")+"</span></b>");
|
||||
out.println("<br/><b>Result: isUserInRole(\"user\")="+result+":"+ (result?" <span class=\"pass\">PASS":" <span class=\"fail\">FAIL")+"</span></b>");
|
||||
String context = _config.getServletContext().getContextPath();
|
||||
if (!context.endsWith("/"))
|
||||
context += "/";
|
||||
|
|
Loading…
Reference in New Issue