Using @RunAs in my EJ schedulers

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() {
    // do anything
}
+3
source share
1 answer

Yes, this is the right use.

12.3.4.1 EJB 3.2 , bean ( ) , run-as.

: bean , -, bean / -; bean; bean; bean, .

+2

Source: https://habr.com/ru/post/1790322/


All Articles