如何集成Spring Security和GWT?

我正在尝试集成Spring Security和GWT。 我也在使用gwt-incubator-security。 我按照wiki页面上的描述配置了所有内容。 我设法通过使用intercept-url来获得安全性,但我无法使用注释使其工作。 关于问题是什么的任何想法?

PS我使用的是Spring 2.5.6,Spring Security 2.0.5和gwt-incubator-security 1.0.1。 欢迎任何有用的链接和评论。

这是我的配置文件

applicationContext.xml中

   <!--  -->             

web.xml中

     Spring_test.html     org.springframework.web.context.ContextLoaderListener     spring org.springframework.web.servlet.DispatcherServlet 1    spring /spring_test/greet.rpc <!-- /org.example.gwtwisdom.GwtWisdom/services/* -->   greetServlet com.ct.test.server.GreetingServiceImpl   greetServlet /spring_test/greet.rpc    springSecurityFilterChain org.springframework.web.filter.DelegatingFilterProxy   springSecurityFilterChain /*  

为spring-servlet.xml

          

这是我尝试与Spring Security集成的示例项目: http : //www.filedropper.com/springtest_1

我正在使用GWT + Spring安全性。 我发现在你的配置中,存在一些误解。 实际上,有一种非常简单的方法可以让spring安全性与你的gwt一起工作,无论gwt-incubator-security如何 。 您只需要在web.xml中声明应用程序上下文。

   contextConfigLocation /WEB-INF/applicationContext-security.xml   springSecurityFilterChain org.springframework.web.filter.DelegatingFilterProxy   springSecurityFilterChain /*   org.springframework.web.context.ContextLoaderListener  

你没有在这里声明你的MVC dispatcherServlet! 然后一切正常,因为Spring Security框架机制。

但是这种配置方式并没有声明DispatcherServlet,它很简单,但是如果你需要一些需要DispatcherServlet的安全function,那就是一个“馅饼”。 所以我见过面。

然后,如果你坚持使用gwt-incubator-security。 我用法语阅读了一个非常好的解决方案,但它没有取消选中。 http://hugo.developpez.com/tutoriels/java/gwt/utilisation-gwt-avec-spring-et-hibernate/

  1. 使用GWT-SL在应用程序中集成Spring:事实上,对于Spring和hibernate的集成,问题是如何正确配置servlet。 应该知道Spring有自己的servlet“DispatcherServlet” ,因为gwt有“gwt servlet”。 通常,在GWT RPC的教程中,gwt-servlet在web-xml中声明,就像
   appService com.google.gwt.app.example.server.AppServiceImpl   appService /app/appService  

如果你非常喜欢Spring,并且想要使用DispatcherServlet来分派请求,那么GWT-handler可以帮助你摆脱这个问题。 首先,在web.xml中加载应用程序上下文,如下所示:

   contextConfigLocation   classpath:applicationContext_GWT.xml    org.springframework.web.context.ContextLoaderListener   

然后,您可以在Spring上下文中声明您的rpc服务: applicationContext_GWT.xml

   

但是你不应该忘记在应用程序上下文文件applicationContext_GWT.xml中添加GWTHandler声明
最后一件事是在web.xml中声明spring servlet:DispatcherServlet。 注意这是spring的正确servlet而不是GWT-SL的事实。 web.xml中

  handler  org.springframework.web.servlet.DispatcherServlet  1   handler *.rpc  

Servlet名称很重要,因为DispatcherServlet将搜索由“* -servlet.xml”命名的spring上下文文件。 由于servlet名称是handler,它将搜索spring上下文“handler-servlet.xml”。 所以在这里我们将解决这样的问题,我们将与DispatcherServlet无关的应用程序上下文放在“applicationContext_GWT.xml”中,然后将依赖于“-servlet.xml”中的DispatcherServlet的应用程序上下文作为servlet。 name是“handler”,然后我们应该有“handler-servlet.xml”,然后将来自applicationContext_GWT.xml的GWT_SL的以下配置放入handler-servlet.xml Handler-servlet.xml

          

然后在web.xml dans la declaration de servlet中添加以下配置。

  contextConfigLocation  /WEB-INF/handler-servlet.xml   

filter模式仅涉及带有后缀.rpc的RPC调用(我没有使用GWT-SL,因此尚未检查上面的集成方法。)

完成上述所有配置后,在applicationi上下文文件中创建filtreprocessentrypoint。

希望这可以帮到你!

您似乎缺少applicationContext.xml中的命名空间配置。

它应该如下所示:

   

Acris框架也使用Spring Security。 他们在他们的维基http://code.google.com/p/acris/wiki/SecurityServer上对此进行了描述

我猜你需要在applicationContext.xml中拥有模式,并启用注释:

   

参考: http : //weblogs.java.net/blog/seemarich/archive/2007/11/annotation_base.html

您可以使用Putnami Web Toolkit(PWT)框架,这里是一个集成Spring Framework和另一个Spring Security的教程。

请参阅https://bitbucket.org/gardellajuanpablo/gwt-sample