2 Replies Latest reply on Mar 14, 2003 11:14 AM by Alan

    lookup secured EJBs

    LG Newbie

      i try to lookup secured EJB from a console-Application.
      the JBoss runs on a different machine as my application.
      the lookup on an unsecured EJB works fine.

      does someone have a small working example for me?

        • 1. Re: lookup secured EJBs
          Peter Doornbosch Apprentice

          You should do a JAAS login, using jboss' ClientLoginModule.
          See http://www.jboss.org/modules/bb/index.html?module=bb&op=viewtopic&t=forums/ for more info.


          • 2. Re: lookup secured EJBs
            Alan Newbie

            The easiest way is to use the ClientLoginModule to login to JBoss before you do JNDI lookups.

            Here's the code that needs to be in your app before you lookup the home interface and create off it:

            CallbackHandler handler = new JBossUsernamePasswordCallbackHandler();
            LoginContext lc = new LoginContext("other", handler);

            JBossUsernamePasswordCallbackHandler is a class I made. You can write your own, but here's mine:

            package com.cft.Simple;
            import java.io.IOException;

            import javax.security.auth.callback.Callback;
            import javax.security.auth.callback.CallbackHandler;
            import javax.security.auth.callback.*;
            import javax.security.auth.callback.UnsupportedCallbackException;

            public class JBossUsernamePasswordCallbackHandler implements CallbackHandler {

            * @see javax.security.auth.callback.CallbackHandler#handle(Callback[])
            public void handle(Callback[] callbacks)
            throws IOException, UnsupportedCallbackException {

            for(int i=0;i<callbacks.length;i++) {
            if(callbacks instanceof NameCallback) {
            NameCallback nc = (NameCallback) callbacks
            else if(callbacks instanceof PasswordCallback) {
            PasswordCallback pc = (PasswordCallback) callbacks
            else throw new UnsupportedCallbackException(callbacks, "Unrecognized Callback");



            You will also need to point your client to an auth.conf on your file system that tells your client code how to login. Mine looks like this:

            other{org.jboss.security.ClientLoginModule required;};

            The easiest way to point to it is using the -D JVM option, something like:


            See the docs for more info.