JBoss Community

javax.ejb.EJBAccessException: Invalid User Jboss 5.1

created by Lokesh Kumar Padhanvis in EJB3 Development - View the full discussion

Hi

 

This might be the routine question I am posting here, but I dont know what where else to post.

 

My configuration

 

Jboss 5.1.0 GA app server, EJB3

 

And I am trying to call a secured method on a SLSB. And I am constantly getting this exception

 

javax.ejb.EJBAccessException: Invalid User

    at org.jboss.ejb3.security.Ejb3AuthenticationInterceptorv2.invoke(Ejb3AuthenticationInterceptorv2.java:165)

    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)

    at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:41)

    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)

    at org.jboss.ejb3.BlockContainerShutdownInterceptor.invoke(BlockContainerShutdownInterceptor.java:67)

    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)

    at org.jboss.aspects.currentinvocation.CurrentInvocationInterceptor.invoke(CurrentInvocationInterceptor.java:67)

    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)

    at org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:421)

    at org.jboss.ejb3.session.InvokableContextClassProxyHack._dynamicInvoke(InvokableContextClassProxyHack.java:53)

    at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:91)

    at org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(AOPRemotingInvocationHandler.java:82)

    at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:891)

    at org.jboss.remoting.transport.socket.ServerThread.completeInvocation(ServerThread.java:744)

    at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:697)

    at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:524)

    at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:232)

    at org.jboss.remoting.MicroRemoteClientInvoker.invoke(MicroRemoteClientInvoker.java:211)

    at org.jboss.remoting.Client.invoke(Client.java:1724)

    at org.jboss.remoting.Client.invoke(Client.java:629)

    at org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemoteInterceptor.java:60)

    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)

    at org.jboss.aspects.tx.ClientTxPropagationInterceptor.invoke(ClientTxPropagationInterceptor.java:61)

    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)

    at org.jboss.ejb3.security.client.SecurityClientInterceptor.invoke(SecurityClientInterceptor.java:65)

    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)

    at org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:74)

    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)

    at org.jboss.aspects.remoting.PojiProxy.invoke(PojiProxy.java:62)

    at $Proxy3.invoke(Unknown Source)

    at org.jboss.ejb3.proxy.impl.handler.session.SessionProxyInvocationHandlerBase.invoke(SessionProxyInvocationHandlerBase.java:207)

    at org.jboss.ejb3.proxy.impl.handler.session.SessionProxyInvocationHandlerBase.invoke(SessionProxyInvocationHandlerBase.java:164)

    at $Proxy2.getAllNetworkElements(Unknown Source)

    at tryouts.ejb3.Client.start(Client.java:49)

    at tryouts.ejb3.Client.main(Client.java:33)

    at org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemoteInterceptor.java:72)

    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)

    at org.jboss.aspects.tx.ClientTxPropagationInterceptor.invoke(ClientTxPropagationInterceptor.java:61)

    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)

    at org.jboss.ejb3.security.client.SecurityClientInterceptor.invoke(SecurityClientInterceptor.java:65)

    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)

    at org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:74)

    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)

    at org.jboss.aspects.remoting.PojiProxy.invoke(PojiProxy.java:62)

    at $Proxy3.invoke(Unknown Source)

    at org.jboss.ejb3.proxy.impl.handler.session.SessionProxyInvocationHandlerBase.invoke(SessionProxyInvocationHandlerBase.java:207)

    at org.jboss.ejb3.proxy.impl.handler.session.SessionProxyInvocationHandlerBase.invoke(SessionProxyInvocationHandlerBase.java:164)

    at $Proxy2.getAllNetworkElements(Unknown Source)

    at tryouts.ejb3.Client.start(Client.java:49)

    at tryouts.ejb3.Client.main(Client.java:33)

 

 

I have gone through the security FAQ "https://community.jboss.org/wiki/SecurityFAQ" and did the same thing in my client code.

 

Client.java

public class Client

{

    public static void main(String[] args)

    {

        new Client().start();

    }

   

    private void start()

    {

        try

        {

            System.setProperty( "java.security.auth.login.config","src/auth.conf" );

            SecurityClient client = SecurityClientFactory.getSecurityClient();

            client.setJAAS( "myDomain", new MyCallbackHandler("username","password"));

            client.login();

            InitialContext ctx = new InitialContext();

            System.out.println( "Got the initial context" );

            Object ref = ctx.lookup( "aserver/TopologySessionBean/remote" );

            TopologySessionRemote remote = (TopologySessionRemote) PortableRemoteObject.narrow( ref, TopologySessionRemote.class );

            System.out.println( "Got the remote bean: " + remote );

            List nes = remote.getAllNetworkElements();

            System.out.println( "Number of NEs: " + nes.size() );

        }

        catch ( Exception ex )

        {

            System.out.println( "~~~~~~~~~~~~~ ERROR ~~~~~~~~~~~~~~" );

            ex.printStackTrace();

        }

    }

   

    class MyCallbackHandler implements CallbackHandler

    {

       

        private String uid;

        private String pid;

       

        public MyCallbackHandler(String uid, String pid )

        {

            this.uid = uid;

            this.pid = pid;

        }

 

        @Override

        public void handle( Callback[] callbacks ) throws IOException, UnsupportedCallbackException

        {

            for ( Callback cb : callbacks )

            {

                if ( cb instanceof NameCallback )

                {

                    NameCallback ncb = (NameCallback) cb;

                    ncb.setName( uid );

                }

                else if ( cb instanceof PasswordCallback )

                {

                    PasswordCallback pcb = (PasswordCallback) cb;

                    pcb.setPassword( pid.toCharArray() );

                }

                else

                {

                    System.out.println( "Not handling Callback: " + cb.getClass() );

                }

            }

        }

       

    }

}

 

 

auth.conf in META-INF directory:

 

 

myDomain {

   org.jboss.security.ClientLoginModule required;

};

 

 

Can someone please help or point me to a working example in this forum or elsewhere in internet.

Reply to this message by going to Community

Start a new discussion in EJB3 Development at Community