Exec login and get security context from cuba middleware

I created a service in my cuba application middleware, this service uses AWS IOT to receive messages over mqtt.
With a @PostCostruct method I established the persistent connection with AWS iot and declared an handler method for the incoming mqtt messages.
When a message arrives I need to store it in a persistent entity to save informations on DB, but when I try to persist the entity using
I get a SecurityException:"No security context bound to the current thread"

**Is it possibile to exec login and get security context from a middleware service bean? **
I need to store entities from the middleware without using API Rest / UI


Hi Massimo,

Yes you can store entities from middleware outside of user requests: use System Authentication.

Thankyou Konstantin!
It works!!!