8 Replies Latest reply on Apr 1, 2009 10:36 AM by bugoff

    Basic app client to app server authentication in J2EE

    bugoff

      I have DB with users. I also have a basic swing app with username/password fields. I want client to be able connect and authorize itself with those credentials.

      Currently I have:

      Client:



      //global
      @EJB(name="DemoServer/MyBean/remote") private MyBeanRemote ejb;
      
      //login
      Properties p = new Properties();
      p.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.security.jndi.LoginInitialContextFactory");
      p.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
      p.put(Context.PROVIDER_URL, "localhost");
      p.put(Context.SECURITY_PRINCIPAL, tName.getText());
      p.put(Context.SECURITY_CREDENTIALS, tPass.getText());
      p.put(Context.SECURITY_PROTOCOL, "MyLogin");
      
      
      InitialContext ctx;
      ctx = new InitialContext(p);
      ejb = (MyBeanRemote) ctx.lookup("DemoServer/MyBean/remote");
      


      Server is local Jboss5 and EJB3. I have jaas.conf on server and I want to authenticate through it. Am I on the right path and what do I do? Thank you very much.