Impersonate a User From a Backend Custom Service
We have a custom service which is supposed to send emails to the end users (user data is saved in AEM) whenever a file stored in DAM is modified or a new file is uploaded under a certain DAM location. So, we are using event handler for catching the add/edit event, however, the email should be sent to the end users ONLY if the user has access to that file as per their assigned permissions through groups. So, in our even handler we need to first impersonate the user and then get the session of the impersonated user in order to check if that user has permissions to the file or not.
We are looking for any ideas on how to impersonate a user using code in an AEM service.