users@glassfish.java.net

ProgrammaticLogin - get Subject on client side - how?

From: <glassfish_at_javadesktop.org>
Date: Thu, 17 Jul 2008 09:04:42 PDT

The code below is from http://java.sun.com/javase/6/docs/technotes/guides/security/jaas/JAASRefGuide.html

I understand that you can log in a Java client to the appserver using ProgrammaticLogin, afterwards an EJB is called using the login user.
(http://docs.sun.com/source/819-0079/dgsecure.html#wp22278)

But how can you access the authenticated subject to use it for Subject.doAs as in the code below?

Or do you have to use a JAAS CallbackHandler? Is there a suitable on in Glassfish jars?

[code]
public class Example1 {
        public static void main(String[] args) {

            // Authenticate the subject, "BOB".
            // This process is described in the
            // LoginContext section.
            
            Subject bob;
            // Set bob to the Subject created during the
            // authentication process

            // perform "ExampleAction" as "BOB"
            Subject.doAs(bob, new ExampleAction());
        }
    }

[/code]
[Message sent by forum member 'weberjn' (weberjn)]

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