I'm writing a Swing application client (it's runs over webstart, and I'm using glassfish). In the application class I have:
@EJB private static MyBean myBean;
and in MyBean
I have:
@Remote
public interface MyBean {
public int getRand();
}
@DeclareRoles(("admin"))
@Stateful(name="MyBean")
public class MyBeanImpl implements MyBean {
@RolesAllowed(("admin"))
public int getRand() {
return 9; // Guaranteed to be random
}
}
So far so good. I start the app using javaws http://server/app/app-client
, it asks for user/pass and authenticates properly (using the fileRealm from glassfish).
I have two problems:
- It seems to try to authenticate right away (when the bean is referenced) rather than when I try to call the method. I can live with this.
- I want to use my own login dialog. Partly for aesthetic reasons, but also for graceful error handling, retries, etc
So I need to specify a callback. Using new LoginContext("fileRealm", myCallback)
I get an error about no login modules for fileRealm. I've tried various mixtures of examples from the net, but very few are designed to application clients.