View the original post : 
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3821833#3821833

Reply to the post : 
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3821833

Using something like this:





import org.jboss.security.auth.callback.UsernamePasswordHandler;

...



    protected void processRequest(HttpServletRequest request, HttpServletResponse 
response)

        throws ServletException, IOException

    {

        LoginContext lc = null;

        String echoMsg = null;

        try

        {

            lc = doLogin("jduke", "theduke");

...

        }

        catch(LoginException e)

        {

            throw new ServletException("Failed to login to client-login domain as 
jduke", e);

        }

        catch(Exception e)

        {

            throw new ServletException("Failed to access SecuredEJB", e);

        }

        finally

        {

            if( lc != null )

            {

                try

                {

                    lc.logout();

                }

                catch(LoginException e)

                {

                }

            }

        }



        response.setContentType("text/html");

        PrintWriter out = response.getWriter();

        out.println("");

        out.println("ClientLoginServlet");

        out.println("<h1>ClientLoginServlet Accessed</h1>");

        out.println("Login as user=jduke succeeded.SecuredEJB.echo 
returned:"+echoMsg+"");

        out.println("");

        out.close();

    }



    private LoginContext doLogin(String username, String password) throws 
LoginException

    {

        UsernamePasswordHandler handler = new UsernamePasswordHandler(username, 
password.toCharArray());

        LoginContext lc = new LoginContext("client-login", handler);

        lc.login();

        return lc;

    }








-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to