I'm willing to work on this problem, since I've already spent some 
time studying the relevant code. However, my first attempt was not spec 
compliant. So I though it might be a good idea to bounce a couple of 
solutions off the general dev group.

The general problem is that passivated stateful session beans are 
activated in the StatefulSessionInstanceInterceptor. The instance 
interceptor sits before the security interceptor in the interceptor 
chain. If the passivated bean has any references to other beans, the 
handles to those beans call the bean's remote method (create or 
findByPrimaryKey). Since the caller's principal hasn't been associated 
with the current context yet, the remote method fails due to an 
authentication exception.

Simply changing the order of the interceptors is not spec compliant 
because legitimate security exceptions will not dispose of the session 
bean. I can think of two solutions.

1. Split the security interceptor into two. The first would check the 
caller's credentials. If verifiable, associate the principal with the 
current context. Otherwise, do nothing before calling the next 
interceptor. The second security interceptor would check the method 
permissions.

2. Add support for a special principal like the anybody principal to the 
security interceptor. Any call with this principal will always succeed. 
Then the StatefulSessionPersistenceManager can temporarily associate 
this principal during activateSession.

I think the first solution is cleaner, and only marginally violates the 
EJB spec. The spec is concerned with checking the callers roles against 
the declared method permissions. It really isn't concerned with 
verifying the caller's credentials. Any thoughts before I attempt 
another patch?

--Victor Langelo

>Bugs item #552157, was opened at 2002-05-03 21:54
>You can respond by visiting: 
>http://sourceforge.net/tracker/?func=detail&atid=376685&aid=552157&group_id=22866
>
>Category: JBossServer
>Group: v2.4 (stable)
>Status: Open
>Resolution: None
>Priority: 5
>Submitted By: Victor Langelo (vlangelo)
>Assigned to: Nobody/Anonymous (nobody)
>Summary: Stateful session activation fails
>
>Initial Comment:
>JDK 1.3.1_03
>Windows NT and RedHat Linux 7.0
>JBoss version 2.4.5RC3+ (branch_2_4 checkout 5/3/02)
>and in JBoss 2.4.4
>
>This is really the same as bug 441165. When a stateful
>session bean with referenced entity bean is
>reactivated, there is no security context associated
>with the thread. Hence an Authenication exception is
>thrown by an attempt to call the entity bean's
>findBy
>PrimaryKey method.
>
>As shown in the following log excerpt,
>AbstractInstanceCache.get is called before the security
>interceptor has associated the caller principal with
>the current context.
>
>[ClientEditBean,2002-05-03 22:29:45,672] ejbPassivate
>called for
>com.eclipseservices.adpro.customer.ClientEditBean@2b436d
>[DBConnectionProvider,2002-05-03 22:29:58,711] Getting
>data source from environment.
>[DBConnectionProvider,2002-05-03 22:29:58,721]
>getDBConnection: creating connection spec.
>[SecurityInterceptor,2002-05-03 22:30:29,435]
>Authentication exception, principal=null
>[ClientEdit,2002-05-03 22:30:29,465] TRANSACTION
>ROLLBACK EXCEPTION:
>javax.transaction.TransactionRolledbackException: Could
>not activate; nested exception is: 
>       java.rmi.ServerException: Could not get EJBObject;
>nested exception is: 
>       java.lang.reflect.InvocationTargetException; nested
>exception is: 
>       java.rmi.NoSuchObjectException: Could no
>t activate;
>nested exception is: 
>       java.rmi.ServerException: Could not get EJBObject;
>nested exception is: 
>       java.lang.reflect.InvocationTargetException
>java.rmi.NoSuchObjectException: Could not activate;
>nested exception is: 
>       java.rmi.ServerException: Could not get EJBObject;
>nested exception is: 
>       java.lang.reflect.InvocationTargetException
>       at
>org.jboss.ejb.plugins.AbstractInstanceCache.get(AbstractInstanceCache.java:182)
>       at
>org.jboss.ejb.plugins.StatefulSessionInstanceInterceptor.invoke(StatefulSessionInstanceInterceptor.java:194)
>       at
>org.jboss.ejb.plugins.TxInterceptorCMT.invokeNext(TxInterceptorCMT.java:138)
>       at
>org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:347)
>       at
>org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:100)
>       at
>org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:170)
>       at
>org.jboss.ejb.StatefulSessionContainer.invoke(Statefu
>lSessionContainer.java:347)
>       at
>org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoker.invoke(JRMPContainerInvoker.java:412)
>       at java.lang.reflect.Method.invoke(Native Method)
>       at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)
>       at sun.rmi.transport.Transport$1.run(Unknown Source)
>       at java.security.AccessController.doPrivileged(Native
>Method)
>       at sun.rmi.transport.Transport.serviceCall(Unknown Source)
>       at
>sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown
>Source)
>       at
>sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown
>Source)
>       at java.lang.Thread.run(Unknown Source)
>
>
>




_______________________________________________________________

Have big pipes? SourceForge.net is looking for download mirrors. We supply
the hardware. You get the recognition. Email Us: [EMAIL PROTECTED]
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to