Jaas authentication

M

Michele Milidoni

Hello,
I'm trying to create a client-server authentication with JAAS (and
LDAP).
My problem is that authentication with LDAP it's ok but JavaEE Server
don't recognize logged user.

This is client fragment code:
System.setProperty("java.security.auth.login.config", "src/
conf/jaas.conf");
LoginCallbackHandler("user.0","secret"));
lc.login();

Context ic = new InitialContext();
AutoreRemote foo = (AutoreRemote) ic.lookup("AutoreBean");
System.out.println("Return Message: "+foo.getAutore());


This is server fragment code:
@Stateless
public class AutoreBean implements AutoreRemote {
@Resource SessionContext sc;
public String getAutore() {
Principal caller = sc.getCallerPrincipal();
return caller.getName();
}
}

This is the system output
[LdapLoginModule] authentication-only mode; SSL
disabled
[LdapLoginModule] user provider: ldap://localhost:1389/
[LdapLoginModule] attempting to authenticate user:
user.0
[LdapLoginModule] authentication succeeded
[LdapLoginModule] added LdapPrincipal "uid=user.
0,ou=People,dc=example,dc=com" to Subject
[LdapLoginModule] added UserPrincipal "user.0" to
Subject
Return Message: ANONYMOUS

Why it reply with Principal ANONYMOUS?

Thank you in advice.
Michele
 
D

Donkey Hottie

Hello,
I'm trying to create a client-server authentication with JAAS (and
LDAP).
My problem is that authentication with LDAP it's ok but JavaEE Server
don't recognize logged user.

This is client fragment code:
System.setProperty("java.security.auth.login.config", "src/
conf/jaas.conf");
LoginCallbackHandler("user.0","secret"));
lc.login();

Context ic = new InitialContext();
AutoreRemote foo = (AutoreRemote) ic.lookup("AutoreBean");
System.out.println("Return Message: "+foo.getAutore());


This is server fragment code:
@Stateless
public class AutoreBean implements AutoreRemote {
@Resource SessionContext sc;
public String getAutore() {
Principal caller = sc.getCallerPrincipal();
return caller.getName();
}
}

This is the system output
[LdapLoginModule] authentication-only mode; SSL
disabled
[LdapLoginModule] user provider: ldap://localhost:1389/
[LdapLoginModule] attempting to authenticate user:
user.0
[LdapLoginModule] authentication succeeded
[LdapLoginModule] added LdapPrincipal "uid=user.
0,ou=People,dc=example,dc=com" to Subject
[LdapLoginModule] added UserPrincipal "user.0" to
Subject
Return Message: ANONYMOUS

Why it reply with Principal ANONYMOUS?

Maybe you need to run getAutore() via

Subject.runAs()
 
M

Michele Milidoni

(e-mail address removed):


Hello,
I'm trying to create a client-server authentication with JAAS (and
LDAP).
My problem is that authentication with LDAP it's ok but JavaEE Server
don't recognize logged user.
This is client fragment code:
            System.setProperty("java.security.auth.login.config", "src/
conf/jaas.conf");
            LoginCallbackHandler("user.0","secret"));
            lc.login();
            Context ic = new InitialContext();
            AutoreRemote foo = (AutoreRemote) ic.lookup("AutoreBean");
            System.out.println("Return Message: "+foo.getAutore());
This is server fragment code:
@Stateless
public class AutoreBean implements AutoreRemote {
    @Resource SessionContext sc;
    public String getAutore() {
            Principal caller = sc.getCallerPrincipal();
            return caller.getName();
    }
}
This is the system output
                [LdapLoginModule] authentication-only mode; SSL
disabled
                [LdapLoginModule] user provider: ldap://localhost:1389/
                [LdapLoginModule] attempting to authenticate user:
user.0
                [LdapLoginModule] authentication succeeded
                [LdapLoginModule] added LdapPrincipal "uid=user.
0,ou=People,dc=example,dc=com" to Subject
                [LdapLoginModule] added UserPrincipal "user.0" to
Subject
Return Message: ANONYMOUS
Why it reply with Principal ANONYMOUS?

Maybe you need to run getAutore() via

Subject.runAs()


I cannot run Subject.doAs() because it don't require a EJB but a class
witch implements PrivilegedAction.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,740
Latest member
JudsonFrie

Latest Threads

Top