You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@shiro.apache.org by tarka <in...@tarka.tv> on 2012/05/16 21:09:38 UTC
Making Security manager accessible in Filter
Hi, My question is pretty much in the title! I am trying to implement a
filter that redirects users based on their role but not surprisingly I am
getting an error message stating that No SecurityManager is accessible to
the calling code when I try to retrive the current users role.
How would I go about making the SecurityManager available?
--
View this message in context: http://shiro-user.582556.n2.nabble.com/Making-Security-manager-accessible-in-Filter-tp7562478.html
Sent from the Shiro User mailing list archive at Nabble.com.
Re: Making Security manager accessible in Filter
Posted by Jared Bunting <ja...@peachjean.com>.
1. You either just implement a standard filter, or you can extend one
of Shiro's filters. There are a number that may prove useful depending
on what exactly you're trying to accomplish. Have a look at the
org.apache.shiro.web.filter package and its subpackages.
2. I'm not entirely sure what you're asking. What I think you're
asking is covered fairly comprehensively in the docs, but just to
clarify: Assuming that you're using ini setup, define your filter in
the [main] section. This means something like:
redirect = com.example.MyRedirectFilter
Then, add the filter to the filter chain in the [urls] section:
/redirectTarget/** = authc, redirect
If you have it setup this way, and it's still not working, I'd request
that you share your web.xml and shiro.ini, or at least portions of
them. Then maybe we can help you troubleshoot.
-Jared
On Wed 16 May 2012 02:55:22 PM CDT, tarka wrote:
> Thanks Jared, I have read that doc once before and have my application
> setup in a very similar way. Two questions:
>
> 1. Do I just create a standard filter class or do I have to extend or
> implement ShiroFilter in my custom filter?
> 2. Where do I declare the filter and specify the filter mapping?
> Presumably it needs to be in the ini file, anywhere in particular?
>
> Thanks for your help
>
>
> On 16/05/2012 21:44, Jared Bunting-2 [via Shiro User] wrote:
>> I would start here:
>>
>> http://shiro.apache.org/web.html#Web-Shiro1.2andlater
>>
>> The gist of it is that you will use a EnvironmentLoaderListener and a
>> ShiroFilter to bootstrap shiro in your web.xml.
>>
>> On Wed 16 May 2012 02:22:36 PM CDT, tarka wrote:
>>
>>> Aha, I actually wasn't using ShiroFilter I was just using a standard
>>> Filter. Is there some doc on implementing a ShiroFilter?
>>>
>>> On 16/05/2012 21:19, Jared Bunting-2 [via Shiro User] wrote:
>>>> If you're using ShiroFilter, the SecurityManager should always be
>>>> available within that filter, any filters registered in shiro, and any
>>>> subsequent servlets. What does your filter look like, and how is your
>>>> application configured?
>>>>
>>>> -Jared
>>>>
>>>> On Wed 16 May 2012 02:09:38 PM CDT, tarka wrote:
>>>>
>>>>> Hi, My question is pretty much in the title! I am trying to
>> implement a
>>>>> filter that redirects users based on their role but not surprisingly
>>>> I am
>>>>> getting an error message stating that No SecurityManager is
>>>> accessible to
>>>>> the calling code when I try to retrive the current users role.
>>>>>
>>>>> How would I go about making the SecurityManager available?
>>>>>
>>>>> --
>>>>> View this message in context:
>>>>
>> http://shiro-user.582556.n2.nabble.com/Making-Security-manager-accessible-in-Filter-tp7562478.html
>>>>> Sent from the Shiro User mailing list archive at Nabble.com.
>>>>
>>>>
>>>>
>>>>
>>>>
>> ------------------------------------------------------------------------
>>>> If you reply to this email, your message will be added to the
>>>> discussion below:
>>>>
>> http://shiro-user.582556.n2.nabble.com/Making-Security-manager-accessible-in-Filter-tp7562478p7562488.html
>>>>
>>>> To unsubscribe from Making Security manager accessible in Filter,
>>>> click here
>>>> <
>>>> NAML
>>>>
>> <http://shiro-user.582556.n2.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml
>> <http://shiro-user.582556.n2.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>>
>>
>>>>
>>>
>>>
>>> --
>>> View this message in context:
>> http://shiro-user.582556.n2.nabble.com/Making-Security-manager-accessible-in-Filter-tp7562478p7562493.html
>>> Sent from the Shiro User mailing list archive at Nabble.com.
>>
>>
>>
>>
>> ------------------------------------------------------------------------
>> If you reply to this email, your message will be added to the
>> discussion below:
>> http://shiro-user.582556.n2.nabble.com/Making-Security-manager-accessible-in-Filter-tp7562478p7562537.html
>>
>> To unsubscribe from Making Security manager accessible in Filter,
>> click here
>> <http://shiro-user.582556.n2.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=7562478&code=aW5mb0B0YXJrYS50dnw3NTYyNDc4fC0xNjQ5ODA1ODk5>.
>> NAML
>> <http://shiro-user.582556.n2.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>>
>
>
> --
> View this message in context: http://shiro-user.582556.n2.nabble.com/Making-Security-manager-accessible-in-Filter-tp7562478p7562554.html
> Sent from the Shiro User mailing list archive at Nabble.com.
Re: Making Security manager accessible in Filter
Posted by tarka <in...@tarka.tv>.
Thanks Jared, I have read that doc once before and have my application
setup in a very similar way. Two questions:
1. Do I just create a standard filter class or do I have to extend or
implement ShiroFilter in my custom filter?
2. Where do I declare the filter and specify the filter mapping?
Presumably it needs to be in the ini file, anywhere in particular?
Thanks for your help
On 16/05/2012 21:44, Jared Bunting-2 [via Shiro User] wrote:
> I would start here:
>
> http://shiro.apache.org/web.html#Web-Shiro1.2andlater
>
> The gist of it is that you will use a EnvironmentLoaderListener and a
> ShiroFilter to bootstrap shiro in your web.xml.
>
> On Wed 16 May 2012 02:22:36 PM CDT, tarka wrote:
>
> > Aha, I actually wasn't using ShiroFilter I was just using a standard
> > Filter. Is there some doc on implementing a ShiroFilter?
> >
> > On 16/05/2012 21:19, Jared Bunting-2 [via Shiro User] wrote:
> >> If you're using ShiroFilter, the SecurityManager should always be
> >> available within that filter, any filters registered in shiro, and any
> >> subsequent servlets. What does your filter look like, and how is your
> >> application configured?
> >>
> >> -Jared
> >>
> >> On Wed 16 May 2012 02:09:38 PM CDT, tarka wrote:
> >>
> >>> Hi, My question is pretty much in the title! I am trying to
> implement a
> >>> filter that redirects users based on their role but not surprisingly
> >> I am
> >>> getting an error message stating that No SecurityManager is
> >> accessible to
> >>> the calling code when I try to retrive the current users role.
> >>>
> >>> How would I go about making the SecurityManager available?
> >>>
> >>> --
> >>> View this message in context:
> >>
> http://shiro-user.582556.n2.nabble.com/Making-Security-manager-accessible-in-Filter-tp7562478.html
> >>> Sent from the Shiro User mailing list archive at Nabble.com.
> >>
> >>
> >>
> >>
> >>
> ------------------------------------------------------------------------
> >> If you reply to this email, your message will be added to the
> >> discussion below:
> >>
> http://shiro-user.582556.n2.nabble.com/Making-Security-manager-accessible-in-Filter-tp7562478p7562488.html
> >>
> >> To unsubscribe from Making Security manager accessible in Filter,
> >> click here
> >> <
> >> NAML
> >>
> <http://shiro-user.582556.n2.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml
> <http://shiro-user.582556.n2.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>>
>
> >>
> >
> >
> > --
> > View this message in context:
> http://shiro-user.582556.n2.nabble.com/Making-Security-manager-accessible-in-Filter-tp7562478p7562493.html
> > Sent from the Shiro User mailing list archive at Nabble.com.
>
>
>
>
> ------------------------------------------------------------------------
> If you reply to this email, your message will be added to the
> discussion below:
> http://shiro-user.582556.n2.nabble.com/Making-Security-manager-accessible-in-Filter-tp7562478p7562537.html
>
> To unsubscribe from Making Security manager accessible in Filter,
> click here
> <http://shiro-user.582556.n2.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=7562478&code=aW5mb0B0YXJrYS50dnw3NTYyNDc4fC0xNjQ5ODA1ODk5>.
> NAML
> <http://shiro-user.582556.n2.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>
--
View this message in context: http://shiro-user.582556.n2.nabble.com/Making-Security-manager-accessible-in-Filter-tp7562478p7562554.html
Sent from the Shiro User mailing list archive at Nabble.com.
Re: Making Security manager accessible in Filter
Posted by Jared Bunting <ja...@peachjean.com>.
I would start here:
http://shiro.apache.org/web.html#Web-Shiro1.2andlater
The gist of it is that you will use a EnvironmentLoaderListener and a
ShiroFilter to bootstrap shiro in your web.xml.
On Wed 16 May 2012 02:22:36 PM CDT, tarka wrote:
> Aha, I actually wasn't using ShiroFilter I was just using a standard
> Filter. Is there some doc on implementing a ShiroFilter?
>
> On 16/05/2012 21:19, Jared Bunting-2 [via Shiro User] wrote:
>> If you're using ShiroFilter, the SecurityManager should always be
>> available within that filter, any filters registered in shiro, and any
>> subsequent servlets. What does your filter look like, and how is your
>> application configured?
>>
>> -Jared
>>
>> On Wed 16 May 2012 02:09:38 PM CDT, tarka wrote:
>>
>>> Hi, My question is pretty much in the title! I am trying to implement a
>>> filter that redirects users based on their role but not surprisingly
>> I am
>>> getting an error message stating that No SecurityManager is
>> accessible to
>>> the calling code when I try to retrive the current users role.
>>>
>>> How would I go about making the SecurityManager available?
>>>
>>> --
>>> View this message in context:
>> http://shiro-user.582556.n2.nabble.com/Making-Security-manager-accessible-in-Filter-tp7562478.html
>>> Sent from the Shiro User mailing list archive at Nabble.com.
>>
>>
>>
>>
>> ------------------------------------------------------------------------
>> If you reply to this email, your message will be added to the
>> discussion below:
>> http://shiro-user.582556.n2.nabble.com/Making-Security-manager-accessible-in-Filter-tp7562478p7562488.html
>>
>> To unsubscribe from Making Security manager accessible in Filter,
>> click here
>> <http://shiro-user.582556.n2.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=7562478&code=aW5mb0B0YXJrYS50dnw3NTYyNDc4fC0xNjQ5ODA1ODk5>.
>> NAML
>> <http://shiro-user.582556.n2.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>>
>
>
> --
> View this message in context: http://shiro-user.582556.n2.nabble.com/Making-Security-manager-accessible-in-Filter-tp7562478p7562493.html
> Sent from the Shiro User mailing list archive at Nabble.com.
Re: Making Security manager accessible in Filter
Posted by tarka <in...@tarka.tv>.
Aha, I actually wasn't using ShiroFilter I was just using a standard
Filter. Is there some doc on implementing a ShiroFilter?
On 16/05/2012 21:19, Jared Bunting-2 [via Shiro User] wrote:
> If you're using ShiroFilter, the SecurityManager should always be
> available within that filter, any filters registered in shiro, and any
> subsequent servlets. What does your filter look like, and how is your
> application configured?
>
> -Jared
>
> On Wed 16 May 2012 02:09:38 PM CDT, tarka wrote:
>
> > Hi, My question is pretty much in the title! I am trying to implement a
> > filter that redirects users based on their role but not surprisingly
> I am
> > getting an error message stating that No SecurityManager is
> accessible to
> > the calling code when I try to retrive the current users role.
> >
> > How would I go about making the SecurityManager available?
> >
> > --
> > View this message in context:
> http://shiro-user.582556.n2.nabble.com/Making-Security-manager-accessible-in-Filter-tp7562478.html
> > Sent from the Shiro User mailing list archive at Nabble.com.
>
>
>
>
> ------------------------------------------------------------------------
> If you reply to this email, your message will be added to the
> discussion below:
> http://shiro-user.582556.n2.nabble.com/Making-Security-manager-accessible-in-Filter-tp7562478p7562488.html
>
> To unsubscribe from Making Security manager accessible in Filter,
> click here
> <http://shiro-user.582556.n2.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=7562478&code=aW5mb0B0YXJrYS50dnw3NTYyNDc4fC0xNjQ5ODA1ODk5>.
> NAML
> <http://shiro-user.582556.n2.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>
--
View this message in context: http://shiro-user.582556.n2.nabble.com/Making-Security-manager-accessible-in-Filter-tp7562478p7562493.html
Sent from the Shiro User mailing list archive at Nabble.com.
Re: Making Security manager accessible in Filter
Posted by Jared Bunting <ja...@peachjean.com>.
If you're using ShiroFilter, the SecurityManager should always be
available within that filter, any filters registered in shiro, and any
subsequent servlets. What does your filter look like, and how is your
application configured?
-Jared
On Wed 16 May 2012 02:09:38 PM CDT, tarka wrote:
> Hi, My question is pretty much in the title! I am trying to implement a
> filter that redirects users based on their role but not surprisingly I am
> getting an error message stating that No SecurityManager is accessible to
> the calling code when I try to retrive the current users role.
>
> How would I go about making the SecurityManager available?
>
> --
> View this message in context: http://shiro-user.582556.n2.nabble.com/Making-Security-manager-accessible-in-Filter-tp7562478.html
> Sent from the Shiro User mailing list archive at Nabble.com.