加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

Flex-Security权限控制框架

发布时间:2020-12-15 04:00:21 所属栏目:百科 来源:网络整理
导读:转自:http://code.google.com/p/flex-security/ flex UI组件权限控制框架 一.快速开始 1) 下载并添加flex_security.swf在你的flex libs中 2) 启动权限控制 //启动权限控制,permissions为用户拥有的权限字符串列表 SecurityControler . start ( permissions

转自:http://code.google.com/p/flex-security/

flex UI组件权限控制框架

一.快速开始

1) 下载并添加flex_security.swf在你的flex libs中

2) 启动权限控制

//启动权限控制,permissions为用户拥有的权限字符串列表 SecurityControler.start(permissions,'visible');

3) 通过增加styleName=security(permission,controlBy)为你的按钮增加权限控制

<mx:Button label="new user" styleName"security(user_new)" /> "update user" "security(user_update)"/>

如上,如果用户拥有这两个权限(permissions):user_new,user_update,则可以见到这两个按钮,然后执行相关操作

二.ActionScript代码的权限控制

if(.isPermitted('blog_delete')) { ? ? //execute delete blog action }

三.在线demo

  • helloworld_by_styleName?示例使用styleName添加权限保护
  • helloworld_by_interface?示例使用实现接口来添加权限保护
  • helloworld_by_annotation?示例使用annotation:Projected来添加权限保护
  • helloworld_by_manual?示例使用手工的方式添加权限保护
  • demo源代码地址

四.详细描述

styleName: security(permission,controlBy)

  • permission: 权限标识,用户拥有该权限,才可以执行相关操作。可选参数,如果为空,则会取该comp.id作为permission
  • controlBy: 按什么方式来控制权限,有(visible,enabled,includeInLayout,remove)。可选参数,如果为空,则取SecurityControler.start(perms,defaultControlBy)中的defaultControlBy的值,默认是visible

controlBy

按什么方式来控制权限。

  • visible : 可见性,有权限为true,没有权限为false
  • enabled : 激活状态,有权限为true,没有权限为false
  • includeInLayout : 有权限为true,没有权限为false
  • remove : 使用removeChild()将对象从parent中remove掉,有权限不remove,没有权限则remove
  • all : 包含前面所讲的:visible,但不包含remove

SecurityControler类,包含全部的主要权限控制操作:

/** ?* 启动权限控制 ?* permissions: 字符串列表,为拥有的权限 ?* default_control_by: 按那种方式控制权限,可选值: visible,remove,includeInLayout ?*/ public static function start:ArrayCollection = nulldefault_control_by : String = "visible"):void //停止权限控制  function stop():// 移除所有权限 function removeAllPerms/** ?* 更新拥有的权限 ?* perms: 字符串列表,用户拥有的权限 ?*/ ? ? ? ? ? ? function updatePerms(permsArrayCollection//增加一条权限 ? ? ? ? function addPerm(permNameString// 减少一条权限 function removePerm// 判断是否拥有权限 //示例: if(SecurityControler.isPermitted('blog_delete')) { do some thing}  function isPermitted(permboolean

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读