Ejemplo n.º 1
0
        public bool CheckPermission(MafPermission perm, bool isThrowException = true)
        {
            var role     = GetRole(perm);
            var isInRole = Thread.CurrentPrincipal.IsInRole(role);

            if (isThrowException && !isInRole)
            {
                throw new SecurityException("权限不足");
            }
            return(isInRole);
        }
Ejemplo n.º 2
0
 private static string GetRole(MafPermission perm)
 {
     return(_map[perm]);
 }
Ejemplo n.º 3
0
 static SecurityPermissions()
 {
     AddUser = new MafPermission("Add", "User");
     AddRole = new MafPermission("Add", "Role");
 }