1 Reply Latest reply on Jul 10, 2004 10:50 AM by Scott Stark

    Can't get it working

    David Linsin Newbie

      Hey guys,

      I read the tutorial posted here in this forum and I also red the administrations and development document, but I just can't it working. I use 3.2.4.

      I have to beans, a session and an entity bean. The client application calls the session bean to obtain data of the entity bean. I want only authenticated clients to call the session bean. So I put this into my ejb-jar.xml:

      <security-role>
       <role-name>extern</role-name>
       </security-role>
       <security-role>
       <description>internal mBuddy component</description>
       <role-name>intern</role-name>
       </security-role>
      
       <method-permission>
       <role-name>extern</role-name>
       <method>
       <ejb-name>UserDataAccess</ejb-name>
       <method-name>*</method-name>
       </method>
       </method-permission>
       <method-permission>
       <role-name>intern</role-name>
       <method>
       <ejb-name>Profile</ejb-name>
       <method-name>*</method-name>
       </method>
       </method-permission>


      Next thing I did was I put this to my client application:

      LoginContext auth = new LoginContext("mBuddy", new MyCallbackHandler());
       auth.login();


      MyCallbackHandler shows a username and passwort prompt to enter both.

      I created a auth.conf which contains this:

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


      On server side I added this to the login-config.xml in my default\conf path:

      <application-policy name = "mBuddy">
      <authentication>
      <login-module code = "org.jboss.security.auth.spi.UsersRolesLoginModule"
      flag = "required">
      </login-module>
      </authentication>
      </application-policy>


      To map the username / password I enter on client side I created users.properties and roles.properties and put them into the same directory as the login-config.xml which is default\conf:

      username = password


      username = extern, intern


      When I run the client application I get this exception:

      java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
       java.rmi.ServerException: EJBException:; nested exception is:
       javax.ejb.EJBException: checkSecurityAssociation; CausedByException is:
       Authentication exception, principal=dlinsin
       at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:292)
       at sun.rmi.transport.Transport$1.run(Transport.java:148)
       at java.security.AccessController.doPrivileged(Native Method)
       at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
       at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
       at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
       at java.lang.Thread.run(Thread.java:534)
       at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(Unknown Source)
       at sun.rmi.transport.StreamRemoteCall.executeCall(Unknown Source)
       at sun.rmi.server.UnicastRef.invoke(Unknown Source)
       at org.jboss.invocation.jrmp.server.JRMPInvoker_Stub.invoke(Unknown Source)
       at org.jboss.invocation.jrmp.interfaces.JRMPInvokerProxy.invoke(JRMPInvokerProxy.java:135)
       at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:96)
       at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:46)
       at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:53)
       at org.jboss.proxy.ejb.HomeInterceptor.invoke(HomeInterceptor.java:173)
       at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:85)
       at $Proxy0.findByPrimaryKey(Unknown Source)
       at com.mbuddy.application.StartUp.main(StartUp.java:40)
      Caused by: java.rmi.ServerException: EJBException:; nested exception is:
       javax.ejb.EJBException: checkSecurityAssociation; CausedByException is:
       Authentication exception, principal=dlinsin
       at org.jboss.ejb.plugins.LogInterceptor.handleException(LogInterceptor.java:347)
       at org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:124)
       at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invokeHome(ProxyFactoryFinderInterceptor.java:93)
       at org.jboss.ejb.EntityContainer.internalInvokeHome(EntityContainer.java:478)
       at org.jboss.ejb.Container.invoke(Container.java:743)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:324)
       at org.jboss.mx.server.ReflectedDispatcher.dispatch(ReflectedDispatcher.java:60)
       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:61)
       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:53)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
       at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:185)
       at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:473)
       at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:360)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:324)
       at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
       at sun.rmi.transport.Transport$1.run(Transport.java:148)
       at java.security.AccessController.doPrivileged(Native Method)
       at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
       at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
       at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
       at java.lang.Thread.run(Thread.java:534)
      Caused by: javax.ejb.EJBException: checkSecurityAssociation; CausedByException is:
       Authentication exception, principal=usernameRemoteException occurred in server thread; nested exception is:
       java.rmi.ServerException: EJBException:; nested exception is:
       javax.ejb.EJBException: checkSecurityAssociation; CausedByException is:
       Authentication exception, principal=username
      
       at org.jboss.ejb.plugins.SecurityInterceptor.checkSecurityAssociation(SecurityInterceptor.java:166)
       at org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityInterceptor.java:83)
       at org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:120)
       ... 25 more


      I hope you can give me a hint what's wrong and how I can get it working!

      Thanks

      David