I define a session bean like so:
@Stateless @SecurityDomain("MySecDomain") public class EchoBean implements EchoRemote { // lots of stuff }
Properties env = new Properties(); env.setProperty(Context.SECURITY_PRINCIPAL, "peter"); env.setProperty(Context.SECURITY_CREDENTIALS, "spiderman"); env.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.security.jndi.JndiLoginInitialContextFactory"); InitialContext ctx = new InitialContext(env); EchoRemote echo = (EchoRemote) ctx.lookup(EchoRemote.class.getName()); // do funky things with the bean
InitialContext ctx = new InitialContext(); EchoRemote echo = (EchoRemote) ctx.lookup(EchoRemote.class.getName()); // do funky things with the bean