You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@shiro.apache.org by Dan Haywood <da...@haywood-associates.co.uk> on 2013/01/03 18:27:47 UTC
Newbie qn: how make ShiroFilter initialize ThreadContext ?
I'm sure this is an easy one...
I'm using Shiro 1.2.1 in a web context (integrating into Apache Isis [1])
with org.apache.shiro.web.env.EnvironmentLoaderListener and ShiroFilter.
I want my app/framework to pick up the SecurityManager and Subject from
SecurityUtils, by way of the ThreadContext.
Is there a way to have ShiroFilter populate the ThreadContext?
At the moment, I'm writing my own filter that grabs the WebEnvironment and
then calls ThreadContext.bind(...). Feels a bit overkill to do this,
though.
Many thanks!
Dan
committer, Apache Isis
[1] http://isis.apache.org
Re: Newbie qn: how make ShiroFilter initialize ThreadContext ?
Posted by Dan Haywood <da...@haywood-associates.co.uk>.
Hi Les,
thanks for this ... as you say, it does do it automatically. Not sure
exactly why I thought otherwise.
I have some further questions/issues, but will raise in another thread.
Cheers
Dan
On 3 January 2013 17:51, Les Hazlewood <lh...@apache.org> wrote:
> Hi Dan,
>
> The ShiroFilter already does this automatically - it is core to how
> Shiro's current web support functions. Here's the code:
>
>
> https://github.com/apache/shiro/blob/trunk/web/src/main/java/org/apache/shiro/web/servlet/AbstractShiroFilter.java#L362
>
> The subject.execute call on line 362 will automatically bind the current
> subject to the thread - via the ThreadContext - and then auto unbind from
> the thread after the filter chain executes.
>
> There is some more information about how this works here:
> http://shiro.apache.org/subject.html under "Thread Association".
>
> I hope that helps!
>
> Best,
>
> --
> Les Hazlewood | @lhazlewood
> CTO, Stormpath | http://stormpath.com | @goStormpath | 888.391.5282
> Stormpath wins GigaOM Structure Launchpad Award! http://bit.ly/MvZkMk
>
>
> On Thu, Jan 3, 2013 at 9:27 AM, Dan Haywood <da...@haywood-associates.co.uk>wrote:
>
>>
>> I'm sure this is an easy one...
>>
>> I'm using Shiro 1.2.1 in a web context (integrating into Apache Isis [1])
>> with org.apache.shiro.web.env.EnvironmentLoaderListener and ShiroFilter.
>>
>> I want my app/framework to pick up the SecurityManager and Subject from
>> SecurityUtils, by way of the ThreadContext.
>>
>> Is there a way to have ShiroFilter populate the ThreadContext?
>>
>> At the moment, I'm writing my own filter that grabs the WebEnvironment
>> and then calls ThreadContext.bind(...). Feels a bit overkill to do this,
>> though.
>>
>> Many thanks!
>> Dan
>>
>> committer, Apache Isis
>>
>> [1] http://isis.apache.org
>>
>>
>>
>
Re: Newbie qn: how make ShiroFilter initialize ThreadContext ?
Posted by Les Hazlewood <lh...@apache.org>.
Thanks for the notice! I'll update the site template as soon as I can get
to it.
Best,
--
Les Hazlewood | @lhazlewood
CTO, Stormpath | http://stormpath.com | @goStormpath | 888.391.5282
Stormpath wins GigaOM Structure Launchpad Award! http://bit.ly/MvZkMk
On Sat, Jan 5, 2013 at 3:16 AM, Dan Haywood <da...@haywood-associates.co.uk>wrote:
>
>
> On 3 January 2013 17:56, Les Hazlewood <lh...@apache.org> wrote:
>
>> P.S. Congrats on Isis' graduation! :)
>>
>> ta!
>
> By the way, was sorting out our website and came across some stuff on
> branding [1]. I notice that the shiro site is missing one or two of these
> things (specifically a TM mark and the links to the standard Apache pages).
> You might want to spend a minute fixing that?
>
> Dan
>
> [1] http://www.apache.org/foundation/marks/pmcs.html#attributions
> [2] http://www.apache.org/foundation/marks/pmcs.html#navigation
>
>
> Cheers,
>>
>>
Re: Newbie qn: how make ShiroFilter initialize ThreadContext ?
Posted by Dan Haywood <da...@haywood-associates.co.uk>.
On 3 January 2013 17:56, Les Hazlewood <lh...@apache.org> wrote:
> P.S. Congrats on Isis' graduation! :)
>
> ta!
By the way, was sorting out our website and came across some stuff on
branding [1]. I notice that the shiro site is missing one or two of these
things (specifically a TM mark and the links to the standard Apache pages).
You might want to spend a minute fixing that?
Dan
[1] http://www.apache.org/foundation/marks/pmcs.html#attributions
[2] http://www.apache.org/foundation/marks/pmcs.html#navigation
Cheers,
>
>
Re: Newbie qn: how make ShiroFilter initialize ThreadContext ?
Posted by Les Hazlewood <lh...@apache.org>.
P.S. Congrats on Isis' graduation! :)
Cheers,
--
Les Hazlewood | @lhazlewood
CTO, Stormpath | http://stormpath.com | @goStormpath | 888.391.5282
Stormpath wins GigaOM Structure Launchpad Award! http://bit.ly/MvZkMk
On Thu, Jan 3, 2013 at 9:51 AM, Les Hazlewood <lh...@apache.org> wrote:
> Hi Dan,
>
> The ShiroFilter already does this automatically - it is core to how
> Shiro's current web support functions. Here's the code:
>
>
> https://github.com/apache/shiro/blob/trunk/web/src/main/java/org/apache/shiro/web/servlet/AbstractShiroFilter.java#L362
>
> The subject.execute call on line 362 will automatically bind the current
> subject to the thread - via the ThreadContext - and then auto unbind from
> the thread after the filter chain executes.
>
> There is some more information about how this works here:
> http://shiro.apache.org/subject.html under "Thread Association".
>
> I hope that helps!
>
> Best,
>
> --
> Les Hazlewood | @lhazlewood
> CTO, Stormpath | http://stormpath.com | @goStormpath | 888.391.5282
> Stormpath wins GigaOM Structure Launchpad Award! http://bit.ly/MvZkMk
>
>
> On Thu, Jan 3, 2013 at 9:27 AM, Dan Haywood <da...@haywood-associates.co.uk>wrote:
>
>>
>> I'm sure this is an easy one...
>>
>> I'm using Shiro 1.2.1 in a web context (integrating into Apache Isis [1])
>> with org.apache.shiro.web.env.EnvironmentLoaderListener and ShiroFilter.
>>
>> I want my app/framework to pick up the SecurityManager and Subject from
>> SecurityUtils, by way of the ThreadContext.
>>
>> Is there a way to have ShiroFilter populate the ThreadContext?
>>
>> At the moment, I'm writing my own filter that grabs the WebEnvironment
>> and then calls ThreadContext.bind(...). Feels a bit overkill to do this,
>> though.
>>
>> Many thanks!
>> Dan
>>
>> committer, Apache Isis
>>
>> [1] http://isis.apache.org
>>
>>
>>
>
Re: Newbie qn: how make ShiroFilter initialize ThreadContext ?
Posted by Les Hazlewood <lh...@apache.org>.
Hi Dan,
The ShiroFilter already does this automatically - it is core to how Shiro's
current web support functions. Here's the code:
https://github.com/apache/shiro/blob/trunk/web/src/main/java/org/apache/shiro/web/servlet/AbstractShiroFilter.java#L362
The subject.execute call on line 362 will automatically bind the current
subject to the thread - via the ThreadContext - and then auto unbind from
the thread after the filter chain executes.
There is some more information about how this works here:
http://shiro.apache.org/subject.html under "Thread Association".
I hope that helps!
Best,
--
Les Hazlewood | @lhazlewood
CTO, Stormpath | http://stormpath.com | @goStormpath | 888.391.5282
Stormpath wins GigaOM Structure Launchpad Award! http://bit.ly/MvZkMk
On Thu, Jan 3, 2013 at 9:27 AM, Dan Haywood <da...@haywood-associates.co.uk>wrote:
>
> I'm sure this is an easy one...
>
> I'm using Shiro 1.2.1 in a web context (integrating into Apache Isis [1])
> with org.apache.shiro.web.env.EnvironmentLoaderListener and ShiroFilter.
>
> I want my app/framework to pick up the SecurityManager and Subject from
> SecurityUtils, by way of the ThreadContext.
>
> Is there a way to have ShiroFilter populate the ThreadContext?
>
> At the moment, I'm writing my own filter that grabs the WebEnvironment and
> then calls ThreadContext.bind(...). Feels a bit overkill to do this,
> though.
>
> Many thanks!
> Dan
>
> committer, Apache Isis
>
> [1] http://isis.apache.org
>
>
>