users@glassfish.java.net

isUserInRole not working

From: <glassfish_at_javadesktop.org>
Date: Tue, 10 Mar 2009 01:29:31 PDT

Hi

I am using metro 1.4 and glassfish 2.1 final. I have found that isUserInRole always returns false in both a servlet webservice and an EJB webservice. The code snippet below always prints "not noone" after the user has been validated using @RolesAllowed.

@Resource
    private WebServiceContext context;

    @WebMethod(operationName = "sayHello")
    @RolesAllowed("noone")
    public String sayHello(@WebParam(name = "name") String name) {
        if(context.isUserInRole("noone"))
            System.out.println("I'm here");
        else
            System.out.println("not noone");
return "done"
}

At the moment I am using
             clientSubject = com.sun.xml.wss.SubjectAccessor.getRequesterSubject(context);
             Set principals = clientSubject.getPrincipals();
etc as a work around but I'd its dirty.

Any ideas?
[Message sent by forum member 'waynetg' (waynetg)]

http://forums.java.net/jive/thread.jspa?messageID=335994