I currently have a web service running some basic authentication through Tomcat. I get the login box to pop up fine, and I can log in with accounts I have defined in the tomcat-users.xml file. However, when it comes to defining permissions based on roles, I'm having some issues.
Currently, I have three roles: manager, admin, and user. I have a few methods which should be only accessible by, say, an admin role. I can log in as my manager/admin/user super account and see everything just fine- but I can do the same as a normal user as well.
The methods are defined like so:
@Path("/Test")
@RolesAllowed("admin")
public class Test
{
@GET
@RolesAllowed("user")
public methodThatMyUsersCanAcess{}
@GET
@Path("/Secure")
@RolesAllowed("admin")
public methodThatOnlyAdminsCanAcess{}
}
I'm really not sure how a 'user' role would be able to access the second method, but somehow it still happens.
/Test
resource maps tomethodTheMyUsersCanAccess
and should only be accessible by theuser
role and/Test/Secure
maps tomethodThatOnlyAdminsCanAccess
and is only accessible by theadmin
role. The@RolesAllowed
annotation is from JSR 250 which states that its use in a method should override its use at the class level. What happens when you remove the@RolesAllowed
annotation from the class level? – stand