Flex BlazeDS整合Spring在Tomcat下的安全验证
今天看了BlazeDS Developer Guide,在Tomcat在利用BASIC方法做了个安全验证的实例。Flex BlazeDS整合Spring在前面的例子中讲过了http://blog.youkuaiyun.com/stonywang/archive/2008/06/12/2537730.aspx。步骤如下:(1) 在Web应用的web.xml中加入如下代码,关键是对/messagebroker/amf,也就是BlazeDS发的请求进行验证: <security-constraint> <web-resource-collection> <web-resource-name>Protected Channel</web-resource-name> <url-pattern>/messagebroker/amf</url-pattern> <http-method>GET</http-method> <http-method>POST</http-method> </web-resource-collection> <auth-constraint> <role-name>tomcat</role-name> </auth-constraint> </security-constraint> <login-config> <auth-method>BASIC</auth-method> </login-config> <security-role> <role-name>tomcat</role-name> </security-role> (2)修改remoting-service.xml,对taxer进行验证。 <destination id="taxer"> <properties> <factory>spring</factory> <source>taxer</source> </properties> <security> <security-constraint> <auth-method>BASIC</auth-method> <roles> <role>tomcat</role> </roles> </security-constraint> </security> </destination> (2) 将D:/blazeds/resources/security/tomcat 下的flex-tomcat-common.jar拷贝到tomcat的 common/lib下;将flex-tomcat-server.jar拷贝到tomcat的server/lib下。(3) Add <Valve className="flex.messaging.security.TomcatValve"/> tag to the Context Descriptors, 这个好像不加也没事。Tomcat5加上后无法启动,tomcat6可以启动。(4) 重启tomcat。访问:http://localhost:8080/SpringBlazeDSDemo/SpringBlazeDSDemo.html弹出对话框要求输入用户名和密码,输入tomcat/tomcat,成功登入。