I've used the following with a rich client with success:
ProgrammaticLogin login = new ProgrammaticLogin();
login.login(username, password);
Properties props = new Properties();
props.setProperty(Context.INITIAL_CONTEXT_FACTORY, "com.sun.enterprise.naming.SerialInitContextFactory");
props.setProperty(Context.PROVIDER_URL,"iiop://" + host + ":" + port);
props.setProperty("org.omg.CORBA.ORBInitialHost", host);
props.setProperty("org.omg.CORBA.ORBServerHost", host);
props.setProperty("org.omg.CORBA.ORBInitialPort", port);
InitialContext ctx = new InitialContext(props);
return ctx;
Then using the initial context to get references to your beans. There are problems with linux, but that's a whole different kettle of fish :)
--- On Tue, 14/4/09, glassfish_at_javadesktop.org <glassfish_at_javadesktop.org> wrote:
From: glassfish_at_javadesktop.org <glassfish_at_javadesktop.org>
Subject: ProgrammaticLogin for stand-alone application
To: users_at_glassfish.dev.java.net
Received: Tuesday, 14 April, 2009, 9:03 PM
Hello,
I am fairly new to GF, so please forgive me if this is a stupid question - but I can't seem to find any answer... The situation is as follows:
I have a stand-alone application (RCP based rich client) which needs to authenticate different users using GF. Based on that, programmatic authorisation is used to grant permissions on the server. I want to address all of this using JAAS. So I wrote a custom realm and login module, which seem to work as expected. Authentication is done via a stateful ejb3 session bean (over RMI/IIOP). So far so good, but the problem I encounter is that the login state (security context) doesn't seem to be cached anywhere, it simply gets lost after the login call returns. Subsequent calls to ctx.isCallerInRole() (from within other bean methods) thus fail, and ctx.getCallerPrincipal().getName() only returns 'ANONYMOUS' (I use "@Resource SessionContext ctx).
What am I doing wrong, and what's the common way of addressing this issue?
Thanks
[Message sent by forum member 'gnorph' (gnorph)]
http://forums.java.net/jive/thread.jspa?messageID=341945
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
For additional commands, e-mail: users-help_at_glassfish.dev.java.net