cancel
Showing results for 
Search instead for 
Did you mean: 

SecureContext timeout in RMI accessing ?

leon
Champ in-the-making
Champ in-the-making
After some output ,I get the following exception.
Is there a setting about timeout of SecureContext in RMI?

(the code will be posted after exception )



Exception occured: net.sf.acegisecurity.AuthenticationCredentialsNotFoundException: A valid SecureContext was not provided in the RequestContext

   at net.sf.acegisecurity.intercept.AbstractSecurityInterceptor.credentialsNotFound(AbstractSecurityInterceptor.java:477)
   at net.sf.acegisecurity.intercept.AbstractSecurityInterceptor.beforeInvocation(AbstractSecurityInterceptor.java:355)
   at net.sf.acegisecurity.intercept.method.aopalliance.MethodSecurityInterceptor.invoke(MethodSecurityInterceptor.java:77)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)
   at org.alfresco.repo.security.permissions.impl.ExceptionTranslatorMethodInterceptor.invoke(ExceptionTranslatorMethodInterceptor.java:37)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)
   at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)
   at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:176)
   at $Proxy22.getCurrentUserName(Unknown Source)
   at org.alfresco.jcr.util.JCRProxyFactory$SessionContextInvocationHandler.invoke(JCRProxyFactory.java:116)
   at $Proxy64.getDefinition(Unknown Source)
   at org.apache.jackrabbit.rmi.server.ServerProperty.getDefinition(ServerProperty.java:118)
   at sun.reflect.GeneratedMethodAccessor168.invoke(Unknown Source)
   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)
   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.apache.jackrabbit.rmi.server.ServerProperty_Stub.getDefinition(Unknown Source)
   at org.alfresco.rmijcr.RemoteJcrTest.visitNode(RemoteJcrTest.java:46)
   at org.alfresco.rmijcr.RemoteJcrTest.visitNode(RemoteJcrTest.java:60)
   at org.alfresco.rmijcr.RemoteJcrTest.visitNode(RemoteJcrTest.java:60)
   at org.alfresco.rmijcr.RemoteJcrTest.main(RemoteJcrTest.java:29)


—accessing code—


public static void main(String[] argv) {
      try {
         // bind server object to object in client
         RemoteRepository r = (RemoteRepository) Naming
               .lookup("//leon:1099/javaContentRepository");

         // invoke method on server object
         Credentials c=new SimpleCredentials("admin","admin".toCharArray());
         RemoteSession session=r.login©;
         RemoteNode root=session.getRootNode();
         
         System.out.println("root of reposity is:" + root.getUUID());
         RemoteNode[] nodes=root.getNodes();
         if(nodes!=null) {
            for(RemoteNode node:nodes) {
               visitNode(node,0);
            }
         }
         
         System.out.println("done");
      } catch (Exception e) {
         System.out.println("Exception occured: ");
         e.printStackTrace();         
         System.exit(0);
      }
   }
   
   public static void visitNode(RemoteNode node,int n) throws Exception{
      System.out.println(node.getName() +"\t" + node.getUUID());
      RemoteProperty[] ps=node.getProperties();
      for(RemoteProperty p:ps) {
         RemotePropertyDefinition d= p.getDefinition();
         if(!d.isMultiple()) {
            System.out.println("\t– "+ p.getName()+"=\t"+p.getValue().getString());
         }else {
            Value[] vs=p.getValues();
            System.out.println("\t– "+ p.getName()+"=");
            for(Value v:vs) {
               System.out.println("\t\t\t"+ v.getString());
            }
         }
      }
      if(n<3) {
         RemoteNode[] children=node.getNodes();
         for(RemoteNode child:children) {
            visitNode(child,n++);
         }
      }
   }
7 REPLIES 7

davidc
Star Contributor
Star Contributor
I'm not sure this is a timeout issue.  At the moment, we haven't yet tested with Jackrabbit RMI (it's planned for v1.3).

leon
Champ in-the-making
Champ in-the-making
I'm not sure this is a timeout issue.  At the moment, we haven't yet tested with Jackrabbit RMI (it's planned for v1.3).

thx. I look forward to it.
when will v1.3 be released?  I can not find it in roadmap

timv
Champ in-the-making
Champ in-the-making
Hi,

I'm having the same problem.

In my portlet, when doing:

String vRmiRegistryLocation = "rmi://" + "localhost" + ":" + "1099" + "/" + "javaContentRepository";
Object vRemoteObjectReference;
vRemoteObjectReference = Naming.lookup(vRmiRegistryLocation);
LocalAdapterFactory vLocalAdapterFactory = new ClientAdapterFactory();
Repository vJcrRepository = vLocalAdapterFactory.getRepository((RemoteRepository)vRemoteObjectReference);
jcrSession = vJcrRepository.login(new SimpleCredentials("admin", "admin".toCharArray()));
QueryManager qm = jcrSession.getWorkspace().getQueryManager();

I get


X net.sf.acegisecurity.AuthenticationCredentialsNotFoundException: A valid SecureContext was not provided in the RequestContext
X    at net.sf.acegisecurity.intercept.AbstractSecurityInterceptor.credentialsNotFound(AbstractSecurityInterceptor.java:477)
X    at net.sf.acegisecurity.intercept.AbstractSecurityInterceptor.beforeInvocation(AbstractSecurityInterceptor.java:355)
X    at net.sf.acegisecurity.intercept.method.aopalliance.MethodSecurityInterceptor.invoke(MethodSecurityInterceptor.java:77)
X    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)
X    at org.alfresco.repo.security.permissions.impl.ExceptionTranslatorMethodInterceptor.invoke(ExceptionTranslatorMethodInterceptor.java:40)
X    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)
X    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
X    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)
X    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:176)
X    at $Proxy22.getCurrentUserName(Unknown Source)
X    at org.alfresco.jcr.util.JCRProxyFactory$SessionContextInvocationHandler.invoke(JCRProxyFactory.java:116)
X    at $Proxy68.getQueryManager(Unknown Source)
X    at org.apache.jackrabbit.rmi.server.ServerWorkspace.getQueryManager(ServerWorkspace.java:144)
X    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
X    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
X    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
X    at java.lang.reflect.Method.invoke(Method.java:585)
X    at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:294)
X    at sun.rmi.transport.Transport$1.run(Transport.java:153)
X    at java.security.AccessController.doPrivileged(Native Method)
X    at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
X    at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
X    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
X    at java.lang.Thread.run(Thread.java:595)
X    at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:247)
X    at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:223)
X    at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:126)
X    at org.apache.jackrabbit.rmi.server.ServerWorkspace_Stub.getQueryManager(Unknown Source)
X    at org.apache.jackrabbit.rmi.client.ClientWorkspace.getQueryManager(ClientWorkspace.java:133)
X    at be.acait.cms.alfresco.AlfrescoFaceletPortlet.doView(AlfrescoFaceletPortlet.java:91)
X    at javax.portlet.GenericPortlet.doDispatch(GenericPortlet.java:235)
X    at javax.portlet.GenericPortlet.render(GenericPortlet.java:163)
X    at com.sun.portal.portletappengine.PortletAppEngineServlet.service(PortletAppEngineServlet.java:271)
X    at javax.servlet.http.HttpServlet.service(HttpServlet.java:860)
X    at sun.reflect.GeneratedMethodAccessor382.invoke(Unknown Source)
X    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
X    at java.lang.reflect.Method.invoke(Method.java:585)
X    at org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:249)
X    at java.security.AccessController.doPrivileged(Native Method)
X    at javax.security.auth.Subject.doAsPrivileged(Subject.java:517)
X    at org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:282)
X    at org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:165)
X    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:257)
X    at org.apache.catalina.core.ApplicationFilterChain.access$000(ApplicationFilterChain.java:55)
X    at org.apache.catalina.core.ApplicationFilterChain$1.run(ApplicationFilterChain.java:161)
X    at java.security.AccessController.doPrivileged(Native Method)
X    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
X    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:723)
X    at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:599)
X    at org.apache.catalina.core.ApplicationDispatcher.access$100(ApplicationDispatcher.java:80)
X    at org.apache.catalina.core.ApplicationDispatcher$PrivilegedInclude.run(ApplicationDispatcher.java:111)
X    at java.security.AccessController.doPrivileged(Native Method)
X    at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:509)
X    at com.sun.portal.container.portlet.impl.PortletContainer.invokePAE(PortletContainer.java:409)
X    at com.sun.portal.container.portlet.impl.PortletContainer.getMarkup(PortletContainer.java:180)
X    at com.sun.portal.providers.window.WindowProvider.getPortletContent(WindowProvider.java:386)
X    at com.sun.portal.providers.window.WindowProvider.getContentInternal(WindowProvider.java:239)
X    at com.sun.portal.providers.window.WindowProvider.getContent(WindowProvider.java:204)
X    at com.sun.portal.desktop.context.ReusableProviderCaller.run(ReusableProviderCaller.java:160)

rdanner
Champ in-the-making
Champ in-the-making
After some output ,I get the following exception.
Is there a setting about timeout of SecureContext in RMI?

(the code will be posted after exception )



Exception occured: net.sf.acegisecurity.AuthenticationCredentialsNotFoundException: A valid SecureContext was not provided in the RequestContext

   at net.sf.acegisecurity.intercept.AbstractSecurityInterceptor.credentialsNotFound(AbstractSecurityInterceptor.java:477)
   at net.sf.acegisecurity.intercept.AbstractSecurityInterceptor.beforeInvocation(AbstractSecurityInterceptor.java:355)
   at net.sf.acegisecurity.intercept.method.aopalliance.MethodSecurityInterceptor.invoke(MethodSecurityInterceptor.java:77)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)
   at org.alfresco.repo.security.permissions.impl.ExceptionTranslatorMethodInterceptor.invoke(ExceptionTranslatorMethodInterceptor.java:37)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)
   at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)
   at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:176)
   at $Proxy22.getCurrentUserName(Unknown Source)
   at org.alfresco.jcr.util.JCRProxyFactory$SessionContextInvocationHandler.invoke(JCRProxyFactory.java:116)
   at $Proxy64.getDefinition(Unknown Source)
   at org.apache.jackrabbit.rmi.server.ServerProperty.getDefinition(ServerProperty.java:118)
   at sun.reflect.GeneratedMethodAccessor168.invoke(Unknown Source)
   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)
   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.apache.jackrabbit.rmi.server.ServerProperty_Stub.getDefinition(Unknown Source)
   at org.alfresco.rmijcr.RemoteJcrTest.visitNode(RemoteJcrTest.java:46)
   at org.alfresco.rmijcr.RemoteJcrTest.visitNode(RemoteJcrTest.java:60)
   at org.alfresco.rmijcr.RemoteJcrTest.visitNode(RemoteJcrTest.java:60)
   at org.alfresco.rmijcr.RemoteJcrTest.main(RemoteJcrTest.java:29)


—accessing code—


public static void main(String[] argv) {
      try {
         // bind server object to object in client
         RemoteRepository r = (RemoteRepository) Naming
               .lookup("//leon:1099/javaContentRepository");

         // invoke method on server object
         Credentials c=new SimpleCredentials("admin","admin".toCharArray());
         RemoteSession session=r.login©;
         RemoteNode root=session.getRootNode();
         
         System.out.println("root of reposity is:" + root.getUUID());
         RemoteNode[] nodes=root.getNodes();
         if(nodes!=null) {
            for(RemoteNode node:nodes) {
               visitNode(node,0);
            }
         }
         
         System.out.println("done");
      } catch (Exception e) {
         System.out.println("Exception occured: ");
         e.printStackTrace();         
         System.exit(0);
      }
   }
   
   public static void visitNode(RemoteNode node,int n) throws Exception{
      System.out.println(node.getName() +"\t" + node.getUUID());
      RemoteProperty[] ps=node.getProperties();
      for(RemoteProperty p:ps) {
         RemotePropertyDefinition d= p.getDefinition();
         if(!d.isMultiple()) {
            System.out.println("\t– "+ p.getName()+"=\t"+p.getValue().getString());
         }else {
            Value[] vs=p.getValues();
            System.out.println("\t– "+ p.getName()+"=");
            for(Value v:vs) {
               System.out.println("\t\t\t"+ v.getString());
            }
         }
      }
      if(n<3) {
         RemoteNode[] children=node.getNodes();
         for(RemoteNode child:children) {
            visitNode(child,n++);
         }
      }
   }

Your sample code looks fine.  I dont see evidence for a timeout in the stack trace. What leads you to think this is related to a timeout?

It looks like there are some bad interactions between afresco security and the jackrabbit RMI implementaion.

Unfortunately for me I've been spending all my time with Liferay portal these days and I dodnt get  much time for alfresco.  I used to play with the Jackrabbit RMI mechanism because it was the only standards based remoting for the alfresco repository available at the time.  If i get a minute this week I will try to install the RMI extension in 1.3.x and see if I can reproduce your error.

Sorry I cant be more helpful.

cchab
Champ in-the-making
Champ in-the-making
This is not a problem of Timeout but this is a problem with Spring RMI and Acegi.
Acegi keeps security context in a ThreadLocal (see net.sf.acegisecurity.context.ContextHolder).

But when you do multiple rmi requests using the same user, these requests will not be always be handled by the same thread.

timv
Champ in-the-making
Champ in-the-making
I think you're right cchab, which explains why sometimes we are and some other time we aren't having that problem.

Is there any workaround or any hope this issue will be resolved in the near future?

Regards,
Tim

This is not a problem of Timeout but this is a problem with Spring RMI and Acegi.
Acegi keeps security context in a ThreadLocal (see net.sf.acegisecurity.context.ContextHolder).

But when you do multiple rmi requests using the same user, these requests will not be always be handled by the same thread.

danul
Champ in-the-making
Champ in-the-making
I seem to be having much the same problem, which seems to occur sporadically (i'm assuming this is due to the threadlocal issue mentioned earlier).  Interestingly enough it seems to occur after a few actions have occurred (eg: adding a new node).

Has anyone found a solution?  Is there some way these security issues can be dealt with transparently?

Daniel