I have a lot of EJBs with my business methods. These methods use the @RolesAllowed annotation to check if the user can execute this method.
So, I have an EJB scheduler that calls these EJB methods. EJB schedulers work with an anonymous user, so authorization is not performed.
How can I run my schedulers with a different role? To test the sentences, I run the @RunAs ("SYSTEM") annotation, but I don't know if this is correct.
My planner class
@RunAs("SYSTEM")
public class InboxScheduler {
protected void inboxFileScan(Timer t) {
receiptFilesService.receiptFiles();
}
}
My EJB class
@RolesAllowed("SYSTEM")
public void receiptFiles() {
}
source
share