- 浏览: 1418622 次
- 性别:
- 来自: 广州
文章分类
- 全部博客 (409)
- Java (48)
- Spring (29)
- struts2 (17)
- hibernate (4)
- 设计模式 (24)
- jbpm (1)
- JavaScript (5)
- 统计报表 (7)
- ExtJS_3.0 (35)
- struts1 (1)
- 分析设计 (3)
- Flex3 (24)
- UML (2)
- 数据库 (18)
- PowerDesigner (2)
- 应用服务器 (3)
- WebService (5)
- ActiveMQ_5.3.2 (6)
- Java通信技术 (11)
- GWT (6)
- OSGi (15)
- android (11)
- liferay6.0.6 (13)
- jquery (13)
- Linux (3)
- java.util.concurrent (16)
- guava (9)
- 开发模式 (1)
- 大数据 (2)
- 互联网金融 (4)
- treegrid-3.0 (7)
- 分布式 (8)
- GO语言 (4)
- maven (1)
- 缓存技术 (6)
- 其他 (2)
- 前端页面 (1)
- heasy (1)
- spring cloud(F版) (21)
- springboot (12)
- springmvc (5)
- mybatis (3)
- dubbo (1)
- 物联网 (0)
最新评论
-
raymond.chen:
谢谢您的分享
使用Ngrok解决通过外网访问内网web应用 -
wangyudong:
速度有点慢,不过在也找到了一个开源的holer,配置一个key ...
使用Ngrok解决通过外网访问内网web应用 -
a1006458222:
...
Axis2的部署和应用 -
偷师来了:
不好意思 这样的博客我觉得就灭有必要分享出来了 命令大家都会看 ...
Consul框架介绍 -
lliiqiang:
怎么直接删除文件夹啊?固定的几个文件可以删除,不固定的呢?需要 ...
Flex AIR —— 文件读写
一、web.xml文件的配置
<context-param> <param-name>contextConfigLocation</param-name> <param-value> /WEB-INF/config/applicationContext*.xml </param-value> </context-param> <context-param> <param-name>graniteConfigPath</param-name> <param-value>/WEB-INF/granite/granite-config.xml</param-value> </context-param> <context-param> <param-name>servicesConfigPath</param-name> <param-value>/WEB-INF/flex/services-config.xml</param-value> </context-param> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <listener> <listener-class>org.springframework.security.ui.session.HttpSessionEventPublisher</listener-class> </listener> <listener> <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class> </listener> <listener> <listener-class>org.granite.config.GraniteConfigListener</listener-class> </listener> <!-- SpringSecurity框架的过滤器 --> <filter> <filter-name>springSecurityFilterChain</filter-name> <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class> </filter> <filter-mapping> <filter-name>springSecurityFilterChain</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <!-- GraniteDS框架的过滤器 --> <filter> <filter-name>AMFMessageFilter</filter-name> <filter-class>org.granite.messaging.webapp.AMFMessageFilter</filter-class> </filter> <filter-mapping> <filter-name>AMFMessageFilter</filter-name> <url-pattern>/graniteamf/*</url-pattern> </filter-mapping> <!-- Servlet --> <servlet> <servlet-name>AMFMessageServlet</servlet-name> <servlet-class>org.granite.messaging.webapp.AMFMessageServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>AMFMessageServlet</servlet-name> <url-pattern>/graniteamf/*</url-pattern> </servlet-mapping>
二、services-config.xml文件的配置
<services-config> <services> <service id="granite-service" class="flex.messaging.services.RemotingService" messageTypes="flex.messaging.messages.RemotingMessage"> <default-channels> <channel ref="my-graniteamf"/> </default-channels> <destination id="securityService"> <properties> <factory>spring</factory> <source>securityService</source> </properties> </destination> </service> </services> <factories> <factory id="spring" class="org.granite.spring.SpringServiceFactory"/> </factories> <channels> <channel-definition id="my-graniteamf" class="mx.messaging.channels.AMFChannel"> <endpoint uri="http://{server.name}:{server.port}/{context.root}/graniteamf/amf" class="flex.messaging.endpoints.AMFEndpoint"/> </channel-definition> </channels> </services-config>
三、granite-config.xml文件的配置
<!DOCTYPE granite-config PUBLIC "-//Granite Data Services//DTD granite-config internal//EN" "http://www.graniteds.org/public/dtd/2.0.0/granite-config.dtd"> <granite-config> <security type="org.granite.messaging.service.security.SpringSecurityService"/> </granite-config>
四、applicationContext.xml文件的配置
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"> <bean id="securityService" class="com.achievo.web.service.SecurityServiceImpl"/> </beans>
五、applicationContext-security.xml文件的配置
<b:beans xmlns="http://www.springframework.org/schema/security" xmlns:b="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-2.0.4.xsd"> <http auto-config="true" lowercase-comparisons="false" path-type="ant" access-decision-manager-ref="accessDecisionManager" access-denied-page="/index.html"> <intercept-url pattern="/index.html*" filters="none"/> <intercept-url pattern="/**/*.css*" filters="none"/> <intercept-url pattern="/**/*.js*" filters="none"/> <intercept-url pattern="/**/*.swf*" filters="none"/> <intercept-url pattern="/graniteamf/amf*" filters="none"/> <intercept-url pattern="/**" access="ADMIN"/> <form-login login-page="/index.html" authentication-failure-url="/index.html"/> <logout logout-success-url="/index.html" invalidate-session="true"/> <concurrent-session-control max-sessions="1" exception-if-maximum-exceeded="false" expired-url="/index.html"/> <remember-me /> </http> <!-- 方法级安全配置 --> <global-method-security access-decision-manager-ref="accessDecisionManager" secured-annotations="enabled" jsr250-annotations="enabled"> <protect-pointcut expression="execution(* com.achievo.web.service..*.*(..))" access="ADMIN"/> </global-method-security> <b:bean id="accessDecisionManager" class="org.springframework.security.vote.AffirmativeBased"> <b:property name="allowIfAllAbstainDecisions" value="false"/> <b:property name="decisionVoters"> <b:list> <b:bean class="org.springframework.security.vote.RoleVoter"> <b:property name="rolePrefix" value=""/> </b:bean> </b:list> </b:property> </b:bean> <authentication-provider> <user-service> <user name="admin" password="admin" authorities="ADMIN"/> <user name="user" password="user" authorities="USER"/> </user-service> </authentication-provider> </b:beans>
六、java类源码
public interface SecurityService { public String[] getUserRoles(); } public class SecurityServiceImpl implements SecurityService { public String[] getUserRoles(){ Authentication auth = SecurityContextHolder.getContext().getAuthentication(); GrantedAuthority[] ga = SecurityContextHolder.getContext().getAuthentication().getAuthorities(); String[] roles = new String[ga.length]; for(int i=0;i<ga.length;i++){ roles[i] = ga[i].getAuthority(); } return roles; } }
七、mxml文件源码
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" initialize="init()"> <mx:Script> <![CDATA[ import mx.messaging.Channel; import mx.messaging.ChannelSet; import mx.controls.Alert; import org.granite.events.SecurityEvent; import org.granite.rpc.remoting.mxml.SecureRemoteObject; import com.achievo.flex.common.StringUtils; import mx.rpc.Fault; import mx.rpc.events.FaultEvent; import mx.rpc.events.ResultEvent; private var roles:Array; private var src:SecureRemoteObject = null; private function init():void{ src = new SecureRemoteObject("securityService"); src.showBusyCursor = true; src.addEventListener(ResultEvent.RESULT, resultHandler); src.addEventListener(FaultEvent.FAULT, faultHandler); src.addEventListener(SecurityEvent.ALL, securityHandler); username.setFocus(); btnLogout.enabled = false; } private function login():void{ btnLogin.enabled = false; try{ src.setCredentials(username.text, password.text, "UTF-8"); src.getOperation("getUserRoles").send(); }catch(ex:Error){ errorMsg.text = "getUserRoles error: " + ex.toString(); } } private function logout():void{ src.logout(); errorMsg.text = ""; username.text = ""; password.text = ""; btnLogin.enabled = true; btnLogout.enabled = false; username.setFocus(); } private function resultHandler(e:ResultEvent):void{ errorMsg.text = "用户角色: " + e.result; btnLogin.enabled = false; btnLogout.enabled = true; } private function faultHandler(e:FaultEvent):void{ var fault:Fault = e.fault; var s:String = (fault.faultDetail!=null) ? fault.faultDetail : fault.faultString; errorMsg.text = "faultHandler: " + s; btnLogin.enabled = true; } private function securityHandler(e:SecurityEvent):void{ switch(e.type){ case SecurityEvent.INVALID_CREDENTIALS: src.logout(); errorMsg.text = "用户名或者密码不正确"; btnLogin.enabled = true; break; case SecurityEvent.NOT_LOGGED_IN: src.logout(); errorMsg.text = "尚未登录"; btnLogin.enabled = true; break; case SecurityEvent.SESSION_EXPIRED: src.logout(); errorMsg.text = "Session过期"; btnLogin.enabled = true; break; case SecurityEvent.ACCESS_DENIED: src.logout(); errorMsg.text = "没有访问权限"; btnLogin.enabled = true; break; } } ]]> </mx:Script> <mx:Panel id="p1" x="159" y="58" horizontalCenter="0" verticalCenter="0" width="359" height="332" layout="absolute" title="系统登录" fontSize="12"> <mx:VBox width="100%"> <mx:Form id="form1" x="0" y="0" width="100%" defaultButton="{btnLogin}"> <mx:FormItem label="用户名" width="100%"> <mx:TextInput id="username"/> </mx:FormItem> <mx:FormItem label="密 码" width="100%"> <mx:TextInput id="password" displayAsPassword="true"/> </mx:FormItem> </mx:Form> <mx:HBox horizontalAlign="center" width="100%" horizontalGap="19"> <mx:Button id="btnLogin" label="登录" click="login()"/> <mx:Button label="注销" id="btnLogout" click="logout()"/> </mx:HBox> </mx:VBox> <mx:Text x="10" y="136" width="319" height="111" id="errorMsg"/> </mx:Panel> </mx:Application>
发表评论
-
Flex AIR —— 文件读写
2009-08-12 20:59 4231一、文件内容 <funds> <fu ... -
Graniteds-2.x源码分析(一)
2009-07-23 17:08 2121一、org.granite.config.GraniteCon ... -
通过RemoteObject组件从服务端返回Map对象
2009-07-16 14:52 15731、Java类方法源码 public Map mapData ... -
通过RemoteObject组件从服务端返回Array对象
2009-07-16 14:34 14251、Java类方法源码 public User[] user ... -
通过RemoteObject组件从服务端返回List对象
2009-07-16 14:18 18751、Java类方法源码 public List listUs ... -
通过RemoteObject在客户端与服务端间传递复杂对象:传递Bean对象
2009-07-16 11:25 2236一、Java服务端类源码 1、User类源码 p ... -
在Flex中访问JSP的session、application属性值
2009-07-15 16:35 6143在开发web程序的过程中,我们经常要从sessio ... -
Flex与JavaScript之间的交互
2009-07-15 16:04 1515一、mxml文件中的源码 <?xml version= ... -
URLLoader的使用
2009-07-15 14:25 1587<mx:Script> <![CDATA ... -
用Flex Ant Tasks手工编译源文件
2009-07-14 11:28 2947<?xml version="1.0" ... -
RemoteObject组件访问Spring Bean的整合方法
2009-07-08 22:27 17931、下载第三方组件flex_spring,将SpringFac ... -
在使用RPC组件时经常会碰到的问题
2009-07-08 22:00 30471、在用HttpService组件获取数据,并将数据转成JSO ... -
Flex RPC服务组件的使用
2009-07-08 20:53 3303Flex RPC服务组件包括三种服务组件:Web ... -
数字步进器(NumericStepper Control)
2009-06-29 21:06 2776一、常用属性 1、minValue:步进器的最小 ... -
树形控件(Tree Control)的使用
2009-06-24 21:17 5080一、树形控件的常用属性 1、dragMoveEn ... -
组合框(ComboBox)的使用
2009-06-22 18:08 1980一、常用属性 二、范例 <?xml versi ... -
数据表格控件(DataGrid Control)的使用
2009-06-21 22:11 3451一、数据表格控件的常用属性 1、draggabl ... -
列表控件的使用(二)
2009-06-20 18:13 1509四、瓦片式列表控件(TileList Control)的使用 ... -
列表控件的使用(一)
2009-06-20 16:15 4355与列表相关的控 ... -
滑块控件(Slider Control)的使用
2009-06-19 22:48 2783一、控件主要属性 1、labels:控件的起点和终 ...
相关推荐
GraniteDS Flex Java 代码转换 自动代码转换 超好用的Flex代码自动生成工具。直接放到Eclipse的Dropin目录,选择Java项目点右键就可以看到 GraniteDS 的功能了
java 代码 转 flex actionscript 工具
***警告***:此项目已移至GITHUB。 转到http://www.graniteds.org获取最新信息和链接。 Granite数据服务(GraniteDS)是用于构建Flex / JavaEE RIA的综合开发和集成解决方案。
Apache Flex BlazeDS(AMF) 火烈鸟AMF(AMF) GraniteDS(AMF) Java WebORB(AMF) SnakeYAML(YAML) jYAML(YAML) YamlBeans(YAML) “安全”反序列化 Java本机序列化(二进制) 概述 Java反序列化...
Apache Flex BlazeDS(AMF) 火烈鸟AMF(AMF) GraniteDS(AMF) Java WebORB(AMF) SnakeYAML(YAML) jYAML(YAML) YamlBeans(YAML) “安全”反序列化 Java本机序列化(二进制) 概述 Java反序列化...