I am trying to get declarative security working in JBoss 4.0.1 using Hibernate 3.0 final. In hibernate.cfg.xml I configured
Code:
<session-factory
name="java:/ews/hibernate/SessionFactory">
...
<listener type="pre-insert" class="org.hibernate.secure.JACCPreInsertEventListener"/>
</session-factory>
<security context="ldap-easynet">
<grant role="ewssales" entity-name="net.easynet.de.ews.salesact.model.SalesAct" actions="*"/>
</security>
where "ldap-easynet" is the name of a realm configured in JBoss' login-config.xml. When trying to insert a new net....SalesAct instance, JBoss' security subsystem tells me
Code:
2005-04-03 15:49:55,545 TRACE [org.jboss.security.plugins.JaasSecurityManager.ldap-easynet] updateCache, subject=Betreff:
Principal: obergner
Principal: Roles(members:ewsdefault,ewssales),
i.e. I am logged in as user 'obergner' with the required role 'ewssales' assigned to me, just as the doctor ordered. Then
Code:
2005-04-03 15:49:57,228 TRACE [org.jboss.security.jacc.JBossPolicyConfiguration] ctor, contextID=ldap-easynet
2005-04-03 15:49:57,228 TRACE [org.jboss.security.jacc.JBossPolicyConfiguration] addToRole, roleName=ewssales, p=HibernatePermission(net.easynet.de.ews.salesact.model.SalesAct:*)
which seems to tell me that a PolicyConfiguration wit the contextId "ldap-easynet" has been created and in it the role "ewssales" has been granted the permission to do anything with entities of type "net....SalesAct".
Meanwhile, in Hibernate land:
Code:
2005-04-03 15:49:57,208 DEBUG [org.hibernate.cfg.Configuration] Encountered configured listener : pre-insert=org.hibernate.secure.JACCPreInsertEventListener
2005-04-03 15:49:57,228 INFO [org.hibernate.cfg.Configuration] JACC contextID: ldap-easynet
2005-04-03 15:49:57,228 DEBUG [org.hibernate.secure.JACCConfiguration] adding permission to role ewssales: HibernatePermission(net.easynet.de.ews.salesact.model.SalesAct:*)
which seems to mirror what is happening inside JBoss.
Still I get an exception when trying to insert a SalesAct instance:
Code:
java.security.AccessControlException: access denied HibernatePermission(net.easynet.de.ews.salesact.model.SalesAct:insert)
(full stack trace below).
Could someone tell me what I am doing wrong here? I have been trying to figure this out by myself for the last three days, but every time I look into the logs everything seems just fine, and then all of a sudden an exception is thrown.
Thx,
Olaf
Hibernate version: 3.0
Mapping documents: n/a
Code between sessionFactory.openSession() and session.close(): n/a
Full stack trace of any exception that occurs:
java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
java.rmi.AccessException: SecurityException; nested exception is:
java.security.AccessControlException: access denied HibernatePermission(net.easynet.de.ews.salesact.model.SalesAct:insert)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:325)
at sun.rmi.transport.Transport$1.run(Transport.java:153)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
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:595)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:247)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:223)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:126)
at org.jboss.invocation.jrmp.server.JRMPInvoker_Stub.invoke(Unknown Source)
at org.jboss.invocation.jrmp.interfaces.JRMPInvokerProxy.invoke(JRMPInvokerProxy.java:118)
at org.jboss.invocation.InvokerInterceptor.invokeInvoker(InvokerInterceptor.java:163)
at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:103)
at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:46)
at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:55)
at org.jboss.proxy.ejb.StatelessSessionInterceptor.invoke(StatelessSessionInterceptor.java:97)
at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:91)
at $Proxy1.createSalesAct(Unknown Source)
at net.easynet.de.ews.salesact.ejb.SalesActServiceSBTest.testCreateSalesActSucceeds(SalesActServiceSBTest.java:80)
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:585)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:474)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:342)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:194)
Caused by: java.rmi.AccessException: SecurityException; nested exception is:
java.security.AccessControlException: access denied HibernatePermission(net.easynet.de.ews.salesact.model.SalesAct:insert)
at org.jboss.ejb.plugins.LogInterceptor.handleException(LogInterceptor.java:370)
at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:196)
at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
at org.jboss.ejb.SessionContainer.internalInvoke(SessionContainer.java:624)
at org.jboss.ejb.Container.invoke(Container.java:870)
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:585)
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:144)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:249)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:642)
at org.jboss.invocation.jrmp.server.JRMPInvoker$MBeanServerAction.invoke(JRMPInvoker.java:805)
at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:406)
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:585)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:294)
at sun.rmi.transport.Transport$1.run(Transport.java:153)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
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:595)
Caused by: java.security.AccessControlException: access denied HibernatePermission(net.easynet.de.ews.salesact.model.SalesAct:insert)
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:264)
at java.security.AccessController.checkPermission(AccessController.java:427)
at org.hibernate.secure.JACCPreInsertEventListener.onPreInsert(JACCPreInsertEventListener.java:24)
at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:41)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:239)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:223)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:136)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:274)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:675)
at org.springframework.orm.hibernate3.SessionFactoryUtils$SpringSessionSynchronization.beforeCommit(SessionFactoryUtils.java:827)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.triggerBeforeCommit(AbstractPlatformTransactionManager.java:530)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:390)
at org.springframework.transaction.interceptor.TransactionAspectSupport.doCommitTransactionAfterReturning(TransactionAspectSupport.java:256)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:67)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:144)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:174)
at $Proxy56.createSalesAct(Unknown Source)
at net.easynet.de.ews.salesact.ejb.SalesActServiceSB.createSalesAct(SalesActServiceSB.java:82)
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:585)
at org.jboss.invocation.Invocation.performCall(Invocation.java:345)
at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:214)
at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:185)
at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:113)
at org.jboss.ejb.plugins.CallValidationInterceptor.invoke(CallValidationInterceptor.java:48)
at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:105)
at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:313)
at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:146)
at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:123)
at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:192)
... 25 more
Name and version of the database you are using: Firebird 1.5
The generated SQL (show_sql=true): n/a
Debug level Hibernate log excerpt: see above