users@glassfish.java.net

Re: Pass Principal to EJB from external app

From: <glassfish_at_javadesktop.org>
Date: Wed, 17 Jun 2009 00:24:23 PDT

Hi, thank you for the hints. I've done my best doing all kind of stuff with programmatic login, but was not able to delegate that damn Principal.

As I understood, this programmatic login uses JAAS to authenticate user. This means that I must provide my own LoginModule, that would perform auth in login() and set the principal into Subject in commit(), right? I did just that with no success:

public boolean login() throws LoginException {
    return true;
}

public boolean commit() throws LoginException {
        PrincipalImpl p = new PrincipalImpl("user");
        if (!currentSubject.getPrincipals().contains(p))
                currentSubject.getPrincipals().add(p);
        PasswordCredential pc = new PasswordCredential("user", "pass", "default");
        if(!currentSubject.getPrivateCredentials().contains(pc)) {
                currentSubject.getPrivateCredentials().add(pc);
        }
        return true;
}

I use my custom cofiguration file to specify this module. Am I doing something wrong, or did I missed something? There is simply no damn information about this. =(

Anyone, please?
[Message sent by forum member 'sadaka' (sadaka)]

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