users@glassfish.java.net

authenticating a standalone client to the EJB container

From: <glassfish_at_javadesktop.org>
Date: Thu, 25 Oct 2007 19:37:58 PDT

Following the instructions here

http://java.sun.com/developer/EJTechTips/2006/tt0225.html#2

I have the following code:


ProgrammaticLogin programmaticLogin = new ProgrammaticLogin();
try {
boolean login = programmaticLogin.login("robot", "test","myldap", true);
System.out.println("State:" + login);
} catch (Exception e) {
e.printStackTrace();
}

InitialContext ctx;
try {
ctx = new InitialContext(props);
serviceBean = (PermitServiceRemote) ctx.lookup("ejb/permit/stateless/PermitServiceBean");
} catch (NamingException e1) {
e1.printStackTrace();
}

The programmaticLogin,login() returns true irrespective of whether I pass a valid or invalid crendential for the specified realm. And further on the code where I have the ctx.lookup() bean, I get a SecurityException. On looking in the glassfish server log, when the bean lookup is executed the user name is being checked against the default file realm and as expected fails.

Why is glassfish using the default file realm instead of the "myldap" realm I specified in the login method. Also why does the login return true even when I pass incorrect credentials?

Here is my appclientlogin.conf file:

default {
        com.sun.enterprise.security.auth.login.ClientPasswordLoginModule required debug=false;
};

certificate {
        com.sun.enterprise.security.auth.login.ClientCertificateLoginModule required debug=false;
};

myldap {
        com.sun.enterprise.security.auth.login.ClientPasswordLoginModule required debug=true;
};
[Message sent by forum member 'r_sudh' (r_sudh)]

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