>>>>> Francois Papon <[email protected]>:
> Yes you can register whatever instance class you want in the service
> registry with related properties.
Thanks, but I was wondering if it was possible to go the other way, so
to speak...?
I.e. is it possible to have an existing shiro WebEnviroment belonging to
a particular ServletContext, injected?
> For example, you can register a ShiroFilter as an osgi service in the
> service registry:
> Dictionary shiroProps = new Hashtable();
> String[] urls = {"/*"};
> String[] servlets = {restServlet.getServletConfig().getServletName()};
> shiroProps.put("filter-name", "Shiro Filter");
> shiroProps.put("urlPatterns", urls);
> shiroProps.put("servletNames", servlets);
> ShiroFilter shiroFilter = new ShiroFilter();
> ServiceRegistration filterRegistration =
> componentContext
> .getBundleContext()
> .registerService(Filter.class.getName(),
> shiroFilter, shiroProps);
> So you could registrer a WebEnvironment the same way.
Thanks!
Right now what I do is
1. Create a ServletContextHelper component
https://github.com/steinarb/oldalbum/blob/master/oldalbum.web.security/src/main/java/no/priv/bang/oldalbum/web/security/OldAlbumServletContextHelper.java#L22
2. Then I create a component creating ShiroFilter plugging into the
servlet context created by the ServletContextHelper
https://github.com/steinarb/oldalbum/blob/master/oldalbum.web.security/src/main/java/no/priv/bang/oldalbum/web/security/OldAlbumShiroFilter.java#L35
and then the magic happens! :-)
The filter is set up from a shiro.ini.
What I would like to do, if possible, is to be able to manipulate the
filter list of the filter as I change the settings here:
https://github.com/steinarb/oldalbum/blob/master/oldalbum.web.security/src/main/java/no/priv/bang/oldalbum/web/security/OldAlbumShiroFilter.java#L35
https://github.com/steinarb/oldalbum/blob/master/oldalbum.web.frontend/src/main/frontend/src/components/ModifyPicture.js#L154
The exact mechanics is a little bit unclear to me, but what I want to
do, is to update the filter rules when I detect a change in picture or
album visibility.
What I would like to do is to make an album to initially require a login
but then make it possible to open anon access directly to a picture,
e.g. via a share button and "make this image visible to anyone with a
link".
So is this possible?
Or should I rethink?
Here is the album:
https://oldalbum.bang.priv.no