Security context exception for 3rd party RPC

Hi team,

I know the solution described in manual to handle security context for thread and background task, but not work for my case.

I’m using the service grid of Apache Ignite as our RPC framework.

The consumer side, we just need to deploy/register a service bean.
services.deployNodeSingleton(“myIgniteRpcService”, igniteRpcServiceBean());

Then from the caller side, which holds same Interface, could obtain a proxy object.

For an invocation, the new thread at the consumer side will get security context error, as there’s no way I can set secrutiy context manually.

I believe the usual spring way will solve the case which changes strategy globally.

So my question is, how to set strategy in a Cuba project, or there’s better solution?

thank you


If InheritableThreadLocal works for you, you can use it in your CUBA application:

  • Create a subclass of java.lang.InheritableThreadLocal and implement SecurityContextHolder as done in ThreadLocalSecurityContextHolder. If you need it in the web module, override get/set methods like in WebVaadinCompatibleSecurityContextHolder.
  • In a AppContextInitializedEvent listener, instantiate your class and set to AppContext:
    AppContext.Internals.setSecurityContextHolder(new MySecurityContextHolder());


1 Like

Thank you, Konstantin, this works for my case