I am writing a service in which i use Shiro for security. I have also incorporated Guice with it. I create the GUICE injector in a GuiceServletContextListener
:
//Custom Shiro Web module with defined REALM
new MyShiroWebModule(this.servletContext, "/v1/*"),
//Shiro annotations
new MyAOPModule(),
I also bind the Guice Container and GuiceShiroFilter in the JerseyServletModule
:
serve("/v1/*").with(GuiceContainer.class, params);
//Adds Shiro filtering
MyShiroWebModule.bindGuiceFilter(binder());
But the Annotations from Shiro just don't seem to work!
I configure the chains in MyShiroWebModule
:
addFilterChain("/v1/res/test", ANON);
addFilterChain("/v1/**", ROLES, AUTHC_BASIC);
So if I use the "ROLES" filter then it scans for roles in the AOP manner of:
@RolesAllowed("SomeFancyRole")
(SEE EDIT)
But i would like to leverage the GUICE Shiro AOP functionality. I have tried the base ShiroAOPModule instead of my own -> my is for debug to see if the configuration is called.
@User, @Authenticated etc.
How can I incorporate this functionality as the documentation states that only "adding" the ShiroAOPModule should work out of the box? Thank you in advance
EDIT:
Turns out that the @RolesAllowed
is working thanks to adding:
params.put(PackagesResourceConfig.PROPERTY_RESOURCE_FILTER_FACTORIES, "com.sun.jersey.api.container.filter.RolesAllowedResourceFilterFactory");
in the JerseyServletModule
serve("/v1/*").with(GuiceContainer.class, params);
So the AOP from Shiro is still not filtered.