Skip to content
Discussion options

You must be logged in to vote

Hello,

ok, I did some further debugging and found one way which seems to work

SecurityManager securityManager = SecurityUtils.getSecurityManager();
Subject subject = SecurityUtils.getSubject();
Runnable task = () -> {
   try {
      ThreadContext.bind(securityManager);
      ThreadContext.bind(subject);
      // my code with access control check based on principal
    } finally {
      ThreadContext.remove();
    }
};

The problem was that subject.associateWith(task) did not ensure that the subject within the child thread is properly resolved as needed for obtaining the principal. Specifically, there was no session associated with the subject in the child thread.

Can you confirm that this…

Replies: 5 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@lprimak
Comment options

lprimak Dec 5, 2025
Collaborator

Answer selected by lprimak
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
2 participants
Converted from issue

This discussion was converted from issue #2405 on December 05, 2025 04:47.