Could I use Apache Shiro with Vaadin OSGi?

679 views
Skip to first unread message

Cristiano Gavião

unread,
Jan 16, 2012, 11:24:30 AM1/16/12
to Vaadin OSGi Collaboration
Hi,

I've found an interested example of using Apache Shiro with Vaadin:

http://eneuwirt.de/2011/04/22/using-apache-shiro-to-secure-vaading-application/
https://github.com/eneuwirt/vaadin-shiro-simple

The trick is to setup servlet filter and servlet mapping for it...

<?xml version="1.0" encoding="UTF-8"?>
<web-app ...>
  <!-- all declarations in shiro.ini file -->
  <filter>
    <filter-name>ShiroFilter</filter-name>
      <filter-class>
        org.apache.shiro.web.servlet.IniShiroFilter
      </filter-class>
  </filter> 

  <filter-mapping>
    <filter-name>ShiroFilter</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>

...
</web-app>

I would like try to use this with Vaadin-OSGi. But, could I create such filter stuff in the vaadin-osgi add-on ?

thanks for any tip.

regards

Cristiano


Neil Bartlett

unread,
Jan 16, 2012, 11:45:04 AM1/16/12
to vaadi...@googlegroups.com
This could be awkward because the current HttpService specification is stuck at Servlet 2.1 API, which doesn't support filters. You might want to look at the Felix ExtHttpService[1] that extends the standard service with support for filters.

Although this service is strictly non-standard (i.e. not defined in the OSGi specification), the implementation offered by Felix does run on all the OSGi R4.x frameworks, including Equinox etc.

Neil

[1] https://cwiki.apache.org/FELIX/apache-felix-http-service.html


On Monday, 16 January 2012 at 16:24, Cristiano Gavião wrote:

> Hi,
>
> I've found an interested example of using Apache Shiro with Vaadin:
>
> http://eneuwirt.de/2011/04/22/using-apache-shiro-to-secure-vaading-application/
> https://github.com/eneuwirt/vaadin-shiro-simple
>
> The trick is to setup servlet filter and servlet mapping for it...
>

> > <?xml version="1.0" encoding="UTF-8"?> <web-app ...> <!-- all declarations in shiro.ini file --> <filter> <filter-name>ShiroFilter</filter-name> <filter-class> org.apache.shiro.web.servlet.IniShiroFilter (http://web.servlet.IniShiroFilter) </filter-class> </filter> <filter-mapping> <filter-name>ShiroFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> ... </web-app>

Cristiano Gavião

unread,
Jan 16, 2012, 2:00:17 PM1/16/12
to vaadi...@googlegroups.com
Hi Neil,

well, I'm ok with the non-standard thing, it is not a problem for me.
Indeed the equinox (the container that I'm using) has such extension too
in its org.eclipse.equinox.http.servlet package.

what I really want to now is to understand where should I create such
filters in the vaadin-osgi bundle activation procedure... :)

My guess is that it should be in HttpServiceTracker class. At the
addingService method and before the AppRegistration instantiation...:

> @Override
> public Object addingService(ServiceReference reference) {
> HttpService http = (HttpService) super.addingService(reference);
> AppRegistration config = new AppRegistration(http, factory,
> alias);


Am I right ?

cheers

Cristiano

Reply all
Reply to author
Forward
0 new messages