我正在寫一個服務,我使用Shiro作爲安全性。我也將Guice與它結合在一起。我在GuiceServletContextListener
創建吉斯注射器:Shiro AOP with GUICE not working
//Custom Shiro Web module with defined REALM
new MyShiroWebModule(this.servletContext, "/v1/*"),
//Shiro annotations
new MyAOPModule(),
我也綁定吉斯容器和GuiceShiroFilter在JerseyServletModule
:
serve("/v1/*").with(GuiceContainer.class, params);
//Adds Shiro filtering
MyShiroWebModule.bindGuiceFilter(binder());
但是從四郎的註解似乎只是不工作!
我配置MyShiroWebModule
鏈:
@RolesAllowed("SomeFancyRole")
(請參閱編輯)
addFilterChain("/v1/res/test", ANON);
addFilterChain("/v1/**", ROLES, AUTHC_BASIC);
所以,如果我使用了 「角色」 過濾器然後將它的AOP方式掃描角色
但我想利用GUICE Shiro AOP功能。我試過基本的ShiroAOPModule而不是我自己的 - >我的調試是用來查看配置是否被調用。
@User, @Authenticated etc.
如何我可以將這個功能的文檔指出只有「加入」 ShiroAOPModule應開箱的? 預先感謝您
編輯:
原來,@RolesAllowed
正在得益於加入:
params.put(PackagesResourceConfig.PROPERTY_RESOURCE_FILTER_FACTORIES, "com.sun.jersey.api.container.filter.RolesAllowedResourceFilterFactory");
serve("/v1/*").with(GuiceContainer.class, params);
所以AOP
從四郎仍然沒有過濾。
你可以在這裏查看示例項目 [https://開頭github上。 COM/pabiagioli /四郎-吉斯-球衣的自舉(https://github.com/pabiagioli/shiro-guice-jersey-bootstrap) – pampanet 2014-10-30 15:55:15