When I try to use a secure bean with this method in a servlet a
javax.servlet.ServletException: EJBException:; nested exception is: 
javax.ejb.EJBException: checkSecurityAssociation; CausedByException is:
Authentication exception, principal=null
was thrown.

public void doGet(HttpServletRequest request, HttpServletResponse response) throws 
ServletException, IOException {
    response.setContentType("text/html");
    PrintWriter out = response.getWriter();
    System.setProperty("java.security.auth.login.config", "file://d:/wudo/auth.conf");
    try {
      org.jboss.security.auth.callback.UsernamePasswordHandler handler = new 
org.jboss.security.auth.callback.UsernamePasswordHandler("weidig", 
"wunden".toCharArray());
      javax.security.auth.login.LoginContext loginContext = new 
javax.security.auth.login.LoginContext("handlerName", handler);
      loginContext.login();
      java.util.Hashtable JNDIParm = new java.util.Hashtable();
      JNDIParm.put(Context.PROVIDER_URL, "localhost");
      JNDIParm.put(Context.INITIAL_CONTEXT_FACTORY, 
"org.jnp.interfaces.NamingContextFactory");
      javax.naming.InitialContext ejbContext = new 
javax.naming.InitialContext(JNDIParm);

      AnyBeanHome bh = (AnyBeanHome)ejbContext.lookup("AnyBean");
      AnyBean b = bh.create();
      b.doAnything();
      out.println("ok!");
    } catch (Exception ex) {
      throw new ServletException(ex);
    }
  }

This code works perfect when I use it in an application!
What is my mistake?

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

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


-------------------------------------------------------
This SF.net email is sponsored by: The Robotic Monkeys at ThinkGeek
For a limited time only, get FREE Ground shipping on all orders of $35
or more. Hurry up and shop folks, this offer expires April 30th!
http://www.thinkgeek.com/freeshipping/?cpg=12297
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to