users@glassfish.java.net

Re: glassfish and custom login module

From: <glassfish_at_javadesktop.org>
Date: Fri, 25 Jan 2008 12:04:05 PST

Had the same problem. The only solution that worked for my standalone client was the following:

1. Java - Client

String username = ... // get from own login dialog
String password = ...
String realm = "myRealm";

ProgrammaticLogin pm = new ProgrammaticLogin();
pm.login(username, password, realm, true);

2. Commandline:
java -cp ... -Djava.security.auth.login.config=login.conf MyMainClass

3. JAAS-Configuration login.conf

myRealm {
        com.sun.enterprise.security.auth.login.ClientPasswordLoginModule required debug=true;
};

4. Realm on the server-side

The realm (here: "myRealm") must be specified in sun-application.xml (for an EAR-application at the server side) or in sun-ejb.xml (for a single EJB module), and the realm has to be configured on GF (e.g. using the Admin-GUI).


Perhaps there is a clean solution, but I did not find one (half a day of googling and reading GF docs).

I also had a look the sources of ProgrammaticLogin.java, ClientPasswordLoginModule.java etc. Weird stuff. GF claims to use standard JAAS, but this does not seem to be a clean solution. The ClientPasswordLoginModule should accept a standard CallbackHandler, fetch username/password, and off we go. Then there would be absolutely no need for a non-standard ProgrammaticLogin class in my build classpath...
[Message sent by forum member 'scotty69' (scotty69)]

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