Here's one approach:

1) Build a WebEnvironment (
http://shiro.apache.org/static/1.2.0/apidocs/org/apache/shiro/web/env/WebEnvironment.html
)
2) Load the WebEnvironment with an EnvironmentLoader (
http://shiro.apache.org/static/1.2.0/apidocs/org/apache/shiro/web/env/EnvironmentLoader.html
)

For this approach, you'll probably also need to write a minimal
implementation of ServletContext to use with the above classes.

But all things considered, you might be better off just using the
functionality in Shiro Core to build something more in line with general
OSGi principles. Shiro Web makes extensive use of the servlet
specification, most of which isn't supported in the OSGi specification
(though you can achieve a compromise with many of the Shiro Web classes).


On Thu, Jan 19, 2012 at 4:05 PM, Cristiano Gavião - [email protected]
 wrote:

>  Well,  I think it was because I don't know that I could do that :)
>
> Could you please, point me to any place showing how could I do that?
>
> thanks
>
> Cristiano
>
>
>
> On 19/01/12 17:32, [email protected] wrote:
>
> Why can't you just initialize the Environment manually in your bundle
> activator?
>
>
> On Thu, Jan 19, 2012 at 3:23 PM, Cristiano Gavião - [email protected]
>  wrote:
>
>>  Answering myself for the records...
>>
>> Yes, you can use shiro 1.2 with any OSGi environment that uses the
>> org.osgi.service.http, with each container specific extended(Felix and
>> Equinox has one), but ONLY if you use the deprecated Filter
>> org.apache.shiro.web.servlet.IniShiroFilter
>>
>> If you try to use the new recomended filter
>> org.apache.shiro.web.servlet.ShiroFilter you will receive this error:
>>
>> ERROR org.eclipse.equinox.cm - javax.servlet.ServletException:
>> java.lang.IllegalStateException: No WebEnvironment found: no
>> EnvironmentLoaderListener registered?
>> java.lang.RuntimeException: javax.servlet.ServletException:
>> java.lang.IllegalStateException: No WebEnvironment found: no
>> EnvironmentLoaderListener registered?
>>
>>
>> To use IniShiroFilter you MUST create a Bundle-Fragment and include the
>> shiro.ini inside it and export it.
>>
>> regards
>>
>>
>>
>> On 18/01/12 13:55, Cristiano Gavião wrote:
>>
>> Hi,
>>
>> I have one web application that is running inside a equinox osgi
>> container and it don't use web.xml.
>>
>> Now I'm trying to figure out how could I use Shiro in such environment.
>>
>> I already could figure out how to setup the Filter using equinox
>> ExtendedHttpService. But I couldn't find in Equinox a defined API to
>> register listeners.
>>
>> So, would be possible to use Shiro without registering the
>> org.apache.shiro.web.env.EnvironmentLoaderListener ?
>>
>> thanks for any tip.
>>
>> regards,
>>
>> Cristiano
>>
>>
>>
>>
>>
>>
>
>

Reply via email to