0 Replies Latest reply on Jan 19, 2004 4:41 PM by meera13

    Please Help needed! [SecurityInterceptor] Authentication exc

    meera13 Newbie

       

      "learnJB" wrote:
      Hi!

      Need some help ! I am trying to use both ssl and srp to login and authenticate my user ans send message via JMS to the server which in turn invokes an ejb.

      My code for login :

      Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
      System.setProperty("java.security.auth.login.config","C:\...auth.conf");
      UsernamePasswordHandler handler = new UsernamePasswordHandler("jduke", "theduke".toCharArray());
      LoginContext lc = null;
      try {
      lc = new LoginContext("srp",handler);
      System.out.println("lc " +lc);

      lc.login();
      }
      catch (LoginException ex) {
      System.out.println("LoginException " +ex);
      }

      I send a message by setting up a connection and sending a message: (via JMS)

      setUpConnection();
      sendMessage(msg); // Basically does sender.send(msg);


      But I am able to login as well as am able to get the credentials at the client end.

      My ejb-jar.xml

      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
      <ejb-jar>
      <enterprise-beans>
      <session>
      <display-name>MDType</display-name>
      <ejb-name>MDType</ejb-name>
      <local-home>distributor.MDTypeLocalHome</local-home>
      <local>distributor.MDTypeLocal</local>
      <ejb-class>distributor.MDTypeBean</ejb-class>
      <session-type>Stateless</session-type>
      <transaction-type>Container</transaction-type>
      <security-role-ref>
      <role-name>test</role-name>
      <role-link>testrole</role-link>
      </security-role-ref>
      </session>
      <message-driven>
      <display-name>MessageReceiver</display-name>
      <ejb-name>MessageReceiver</ejb-name>
      <ejb-class>communication.MessageReceiverBean</ejb-class>
      <transaction-type>Container</transaction-type>
      <message-driven-destination>
      <destination-type>javax.jms.Queue</destination-type>
      </message-driven-destination>
      <ejb-local-ref>
      <description>EJB Reference CompareConfig</description>
      <ejb-ref-name>CompareConfigBean</ejb-ref-name>
      <ejb-ref-type>Session</ejb-ref-type>
      <local-home>configBean.CompareConfigLocalHome</local-home>
      <local>configBean.CompareConfigLocal</local>
      <ejb-link>CompareConfigBeanLocal</ejb-link>
      </ejb-local-ref>
      <security-role-ref>
      <role-name>test</role-name>
      <role-link>testrole</role-link>
      </security-role-ref>
      </message-driven>
      </enterprise-beans>
      <assembly-descriptor>
      <security-role>
      <role-name>testrole</role-name>
      </security-role>
      <method-permission>
      <description>Users of Testrole type can only</description>
      <unchecked/>
      <method>
      <ejb-name>MessageReceiver</ejb-name>
      <method-name>*</method-name>
      </method>

      <method>
      <ejb-name>MDType</ejb-name>
      <method-name>*</method-name>
      </method>
      </method-permission>
      </assembly-descriptor>
      </ejb-jar>


      On the server side I receive the message in onMessage() in MDB but when it does a lookUp for another seesionBean to pass the Message it errors: (Authentication exception, principal=null)

      15:41:08,439 ERROR [SecurityInterceptor] Authentication exception, principal=null
      15:41:08,449 ERROR [LogInterceptor] EJBException, causedBy:
      java.lang.SecurityException: Authentication exception, principal=null
      at org.jboss.ejb.plugins.SecurityInterceptor.checkSecurityAssociation(SecurityIntercep
      tor.java:164)
      at org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityInterceptor.java:81)
      at org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:120)
      at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invokeHome(ProxyFactoryFinderIn
      terceptor.java:93)
      at org.jboss.ejb.StatelessSessionContainer.internalInvokeHome(StatelessSessionContaine
      r.java:319)
      at org.jboss.ejb.Container.invoke(Container.java:720)
      at org.jboss.ejb.plugins.local.BaseLocalProxyFactory.invokeHome(BaseLocalProxyFactory.
      java:272)
      at org.jboss.ejb.plugins.local.LocalHomeProxy.invoke(LocalHomeProxy.java:110)
      at $Proxy45.create(Unknown Source)
      at kbrepository.server.communication.MessageReceiverBean.sendMessageHandlingBean(Messa
      geReceiverBean.java:79)
      at kbrepository.server.communication.MessageReceiverBean.onMessage(MessageReceiverBean
      .java:60)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:2
      5)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at org.jboss.ejb.MessageDrivenContainer$ContainerInterceptor.invoke(MessageDrivenConta
      iner.java:460)
      at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConne
      ctionInterceptor.java:186)
      at org.jboss.ejb.plugins.MessageDrivenInstanceInterceptor.invoke(MessageDrivenInstance
      Interceptor.java:62)
      at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:8
      4)
      at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:24
      0)
      at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:128)
      at org.jboss.ejb.plugins.RunAsSecurityInterceptor.invoke(RunAsSecurityInterceptor.java
      :90)
      at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:191)
      at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterc
      eptor.java:122)
      at org.jboss.ejb.MessageDrivenContainer.internalInvoke(MessageDrivenContainer.java:374
      )
      at org.jboss.ejb.Container.invoke(Container.java:700)
      at org.jboss.ejb.plugins.jms.JMSContainerInvoker.invoke(JMSContainerInvoker.java:827)
      at org.jboss.ejb.plugins.jms.JMSContainerInvoker$MessageListenerImpl.onMessage(JMSCont
      ainerInvoker.java:1117)
      at org.jboss.jms.asf.StdServerSession.onMessage(StdServerSession.java:256)
      at org.jboss.mq.SpyMessageConsumer.sessionConsumerProcessMessage(SpyMessageConsumer.ja
      va:633)
      at org.jboss.mq.SpyMessageConsumer.addMessage(SpyMessageConsumer.java:433)
      at org.jboss.mq.SpySession.run(SpySession.java:298)
      at org.jboss.jms.asf.StdServerSession.run(StdServerSession.java:180)
      at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:727)

      at java.lang.Thread.run(Thread.java:536)
      15:41:08,469 ERROR [LogInterceptor] EJBException, causedBy:
      java.lang.SecurityException: Authentication exception, principal=null
      at org.jboss.ejb.plugins.SecurityInterceptor.checkSecurityAssociation(SecurityIntercep
      tor.java:164)
      at org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityInterceptor.java:81)
      at org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:120)
      at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invokeHome(ProxyFactoryFinderIn
      terceptor.java:93)
      at org.jboss.ejb.StatelessSessionContainer.internalInvokeHome(StatelessSessionContaine
      r.java:319)
      at org.jboss.ejb.Container.invoke(Container.java:720)
      at org.jboss.ejb.plugins.local.BaseLocalProxyFactory.invokeHome(BaseLocalProxyFactory.
      java:272)
      at org.jboss.ejb.plugins.local.LocalHomeProxy.invoke(LocalHomeProxy.java:110)
      at $Proxy45.create(Unknown Source)
      at kbrepository.server.communication.MessageReceiverBean.sendMessageHandlingBean(Messa
      geReceiverBean.java:79)
      at kbrepository.server.communication.MessageReceiverBean.onMessage(MessageReceiverBean
      .java:60)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:2
      5)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at org.jboss.ejb.MessageDrivenContainer$ContainerInterceptor.invoke(MessageDrivenConta
      iner.java:460)
      at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConne
      ctionInterceptor.java:186)
      at org.jboss.ejb.plugins.MessageDrivenInstanceInterceptor.invoke(MessageDrivenInstance
      Interceptor.java:62)
      at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:8
      4)
      at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:24
      0)
      at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:128)
      at org.jboss.ejb.plugins.RunAsSecurityInterceptor.invoke(RunAsSecurityInterceptor.java
      :90)
      at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:191)
      at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterc
      eptor.java:122)
      at org.jboss.ejb.MessageDrivenContainer.internalInvoke(MessageDrivenContainer.java:374
      )
      at org.jboss.ejb.Container.invoke(Container.java:700)


      ........
      .....