I have many EJBs with my business methods. These methods use @RolesAllowed annotation to check if user can execute this method.
So I have an EJB Scheduler that calls these EJB methods. EJB schedulers runs with anonymous user, so authorization fails.
How I can run my schedulers with other role? For testing proposes, I run with @RunAs("SYSTEM") annotation, but I don't know if this is right.
My scheduler class
@RunAs("SYSTEM")
public class InboxScheduler {
protected void inboxFileScan(Timer t) {
receiptFilesService.receiptFiles();
}
}
My EJB class
@RolesAllowed("SYSTEM")
public void receiptFiles() {
// do anything
}