shiro-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Les Hazlewood <...@hazlewood.com>
Subject Re: Is There a Way to Manually Unbind Thread After Login
Date Wed, 18 May 2011 23:44:19 GMT
The ThreadContext is really an internal support class for Shiro and
not really intended to be used by end-users.

The ideal scenario is I think this:

1.  Based on the incoming message/request/whatever, use the
Subject.Builder to build your subject instance.
2.  Call subject.execute and call whatever method is at the 'root' of
your chain., e.g.

subject.execute(new Runnable() {
    public void run() {
        myRootMethod();
    }
});

from myRootMethod() and anywhere below it in the call stack,
SecurityUtils.getSubject() will work correctly.  When subject.execute
returns, the thread's state will be as it was before calling execute -
it performs automatic cleanup.

This is exactly what the ShiroFilter and the
SecureRemoteInvocationExecutor do to ensure thread association and
automatic cleanup.

Is this not possible in your scenario Jack?

Cheers,

Les

Mime
View raw message