Announcement Announcement Module
Collapse
No announcement yet.
biz api call from threads Page Title Module
Move Remove Collapse
This topic is closed
X
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • biz api call from threads

    I have biz api permissions associated with all methods in the biz interface. Alls well when the logged in users are calling them.
    There are a few threads/pollers in the application that need to access these apis periodically. But since there is not user context associated here in the threadlocal acegi security prevents these thread from calling the api.

    Are there any standard solutions to this problem?? One solution I have in mind is to create a seperate unsecured interface by extending the currently secured biz interface by not defining security metadata on top of the method signatures.

    thanks

  • #2
    There are a few threads/pollers in the application that need to access these apis periodically. But since there is not user context associated here in the threadlocal acegi security prevents these thread from calling the api.
    You could provide these jobs with credentials and do something like:
    Code:
    Authentication authentication = new UsernamePasswordAuthenticationToken(systemUser, systemPassword);
    SecurityContextHolder.getContext().setAuthentication(authentication);
    ...
    SecurityContextHolder.clearContext();

    Comment


    • #3
      i thought about doing this except it looks cumbersome, setting context in the thread and clearing it later. this method leaves a lot for the developer of the thread to get right. is there a more convenient work around?? dont mean to apply hacks. i just thought this was a popular problem with documented solutions.

      thanks

      Comment

      Working...
      X