Research Article

Data Access Control Based on Blockchain in Medical Cyber Physical Systems

Algorithm 3

Permission management.
Input: the information of the access initiator, such as the organization org, the node peer, and the user ID
Output: the access log file of the subject and the operation record of the chain code
(1)logger.Info (Sprintf (”get args: %s,” args)); //Get the information of the access initiator
(2)/read org/
(3)if err ! = nil then
(4)logger.Error (fmt.Sprintf (”get deptAttrVal err: %s,” err.Error ()))
(5)end
(6)else
(7)if deptAttrVal = = df then
(8)logger.Info (fmt.Sprintf (”get deptAttrVal: %s,” dv));
(9)end
(10)else
(11)logger.Debug (fmt.Sprintf (”not found deptAttr”));
(12)end
(13)end
(14)/read peer/
(15)if err ! = nil then
(16)logger.Error (fmt.Sprintf (”get orgAttrVal err:%s,” err.Error ()));
(17)end
(18)else
(19)if orgAttrVal = = of then
(20)logger.Info (fmt.Sprintf (”got orgAttrVal: %s,” ov));
(21)end
(22)else
(23)logger.Debug (fmt.Sprintf (”not found orgAttr”));
(24)end
(25)end
(26)pv, pf, err \coloneq sinfo.GetAttributeValue (”peer”);
(27)/read user/
(28)if err ! = nil then
(29)logger.Error (fmt.Sprintf (”get peerAttrVal err: %s,” err.Error ()));
(30)end
(31)else
(32)if peerAttrVal = = pf then
(33)logger.Info (fmt.Sprintf (”got peerAttrVal: %s,” pv));
(34)end
(35)else
(36)logger.Debug (fmt.Sprintf (”not found peerAttr”));
(37)end
(38)end
(39)if err! = nil then
(40)logger.Error(fmt.Sprintf (”get userAttrVal err: %s,” err.Error ()));
(41)end
(42)else
(43)if userAttrVal = = uf then
(44)logger.Info (fmt.Sprintf (”got userAttrVal: %s,” uv));
(45)end
(46)else
(47)logger.Debug (fmt.Sprintf (”not found userAttr”));
(48)end
(49)end
(50)return shim.Success ( [] byte (”log”));