zoukankan      html  css  js  c++  java
  • Activiti源码浅析:Activiti的活动授权机制

    1. IdentityLink与TaskEntity

    An identity link is used to associate a task with a certain identity. For example: - a user can be an assignee (= identity link type) for a task - a group can be a candidate-group (= identity link type) for a task

    TaskEntity包含了一系列的IdentityLink操作方法:

     public IdentityLinkEntity addIdentityLink(String userId, String groupId, String type) {
        IdentityLinkEntity identityLinkEntity = new IdentityLinkEntity();
        getIdentityLinks().add(identityLinkEntity);
        identityLinkEntity.setTask(this);
        identityLinkEntity.setUserId(userId);
        identityLinkEntity.setGroupId(groupId);
        identityLinkEntity.setType(type);
        identityLinkEntity.insert();
        if (userId != null && processInstanceId != null) {
          getProcessInstance().involveUser(userId, IdentityLinkType.PARTICIPANT);
        }
        return identityLinkEntity;
      }

    注意,IdentityLink有一个Type,有一些默认的Type:

      public void addCandidateUser(String userId) {
        addIdentityLink(userId, null, IdentityLinkType.CANDIDATE);
      }


      public void addCandidateGroup(String groupId) {
        addIdentityLink(null, groupId, IdentityLinkType.CANDIDATE);
      }


    2. IdentityLink与权限过滤

    如下查询语句对应于“用户kermit待签收任务列表”的调用过程:

    Preparing: select distinct RES.* from AC
    T_RU_TASK RES inner join ACT_RU_IDENTITYLINK I on I.TASK_ID_ = RES.ID_ WHERE RES.ASSIGNEE_ is null and I.TYPE_ = 'candidate' and ( I.USER_ID_ = ? or I.GROUP_ID_ IN ( ? , ? ) ) 
    
    Parameters: kermit(String), admin(String), management(String)

    其中admin和management来自于用户群组关系查询接口:

    UserEntityManager.findGroupsByUser("kermit")


  • 相关阅读:
    Mina之session
    GNU C 、ANSI C、标准C、标准c++区别和联系
    SOCKET CLOSE_WAIT 搜集
    [转]二维数组和二级指针的传递问题
    Linux下C语言线程池的实现(1)
    MINA2 之日志配置
    mina里的死锁检测
    MINA2中的拆包组包的处理及一些方法
    void及void指针含义的深刻解析
    JS轻松实现单击文本框弹出选择日期
  • 原文地址:https://www.cnblogs.com/bluejoe/p/5115942.html
Copyright © 2011-2022 走看看