I have the some problem. The IsUserInRole always returns false.
try {
SecurityAssociationHandler handler = new
SecurityAssociationHandler();
Principal user = new SimplePrincipal(userName);
handler.setSecurityInfo(user, password.toCharArray());
LoginContext loginContext = new LoginContext("MyRealm",
(CallbackHandler) handler);
loginContext.login();
subject = loginContext.getSubject();
Set principals = subject.getPrincipals();
principals.add(user);
} catch (LoginException e) {
System.out.println("Error LoginException: " + e);
}
if (request.isUserInRole("Admin")) {
System.out
.println("User with role admin is
forwarded to admin page");
return mapping.findForward("Admin");
} else if (request.isUserInRole("ViewBills")) {
System.out
.println("User with role ViewBills is
forwarded to ViewBills page");
return mapping.findForward("ViewBills");
} else {
System.out
.println("User has no role. He needs to
be forwarded to login page");
return mapping.findForward("failure");
}
}
View the original post :
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3865707#3865707
Reply to the post :
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3865707
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user