Hello,
I'm building an application on JBoss AS 5.1 and ICEFaces. The application runs in a single JBoss instance currently. I'm doing authentication via JAAS, using the DatabaseServerLoginModule, and I'm able to login successfully via ICEFaces as follows:
CallbackHandler cb = new Handler("someuser", password);
LoginContext lc = new LoginContext("foo", cb);
lc.login();
Once logged in, I can see clearly that "someuser" has the "admin" role. Now, I have an EJB set up as follows:
@Service
@Local
@SecurityDomain("foo") // corresponds to the security domain above
public class MyService implements MyServiceLocal {
@RolesAllowed("admin")
public void doSomething() {
// do something
}
}
I am trying to call MyBean.doSomething() from my ICEFaces client code as follows:
InitialContext ctx = new InitialContext();
final String name = "MyService/local";
service = (MyServiceLocal) ctx.lookup(name);
service.doSomething(); // causes EJBAccessException: Caller unauthorized
Somehow, the callee doesn't recognize that I am authenticated. I did a bit of debugging, and the caller thinks my principal is "anonymous".
How do I get EJB to recognize my credentials which were established outside of EJB? Do I need to pass some extra information to the InitialContext? (I tried setting Context.SECURITY_PRINCIPAL, with no luck...). Any help would be appreciated!
Thanks,
Dave Bredesen