Ejemplo n.º 1
0
        /// <summary>
        /// 删除授权节点信息
        /// </summary>
        /// <param name="authorizationUri">授权路径</param>
        public void Remove(string authorizationUri)
        {
            Guard.ArgumentNotNull(authorizationUri, "Authorization Uri");

            //if (authorizations.ContainsKey(authorizationUri)) {
            //    AuthorizationNode node = authorizations[authorizationUri];
            //    // 选择节点下的所有操作项的授权信息
            //    foreach (AuthorizationCommand cmd in node.Commands) {
            //        string key = SecurityUtility.HashObject(node.AuthorizationUri + cmd.CommandUri);
            //        if (actions.ContainsKey(key))
            //            actions.Remove(key);
            //    }
            //    authorizations.Remove(authorizationUri);
            //}

            foreach (AuthorizationNode node in authorizations)
            {
                if (node.AuthorizationUri == authorizationUri)
                {
                    foreach (AuthorizationCommand cmd in node.Commands)
                    {
                        string key = SecurityUtility.HashObject(node.AuthorizationUri + cmd.CommandUri);
                        AuthorizationActionInfo actionInfo = new AuthorizationActionInfo(key, cmd.Action);
                        if (actions.Contains(actionInfo))
                        {
                            actions.Remove(actionInfo);
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 存储授权节点
        /// </summary>
        /// <param name="node">授权节点</param>
        public void Store(AuthorizationNode node)
        {
            Guard.ArgumentNotNull(node, "node");

            Dictionary <string, AuthorizationAction> acs = new Dictionary <string, AuthorizationAction>();

            //// 原来的授权信息
            //foreach (AuthorizationCommand cmd in node.Commands) {
            //    string key = SecurityUtility.HashObject(node.AuthorizationUri + cmd.CommandUri);
            //    if (actions.ContainsKey(key))
            //        acs[key] = actions[key];
            //}

            //Remove(node.AuthorizationUri); // 删除原来的授权信息
            //authorizations[node.AuthorizationUri] = node;
            //foreach (AuthorizationCommand cmd in node.Commands) {
            //    string key = SecurityUtility.HashObject(node.AuthorizationUri + cmd.CommandUri);
            //    if (acs.ContainsKey(key))
            //        actions[key] = acs[key];
            //    else
            //        actions[key] = AuthorizationAction.Deny;
            //}

            // 首先删除原来的授权信息
            foreach (AuthorizationCommand cmd in node.Commands)
            {
                string key = SecurityUtility.HashObject(node.AuthorizationUri + cmd.CommandUri);
                AuthorizationActionInfo actionInfo = new AuthorizationActionInfo(key, cmd.Action);
                if (actions.Contains(actionInfo))
                {
                    actions.Remove(actionInfo);
                }
            }
            Remove(node.AuthorizationUri);
            authorizations.Add(node);
            foreach (AuthorizationCommand cmd in node.Commands)
            {
                string key = SecurityUtility.HashObject(node.AuthorizationUri + cmd.CommandUri);
                AuthorizationActionInfo actionInfo = new AuthorizationActionInfo(key, cmd.Action);
                actions.Add(actionInfo);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 存储授权节点
        /// </summary>
        /// <param name="node">授权节点</param>
        public void Store(AuthorizationNode node)
        {
            Guard.ArgumentNotNull(node, "node");

            Dictionary<string, AuthorizationAction> acs = new Dictionary<string, AuthorizationAction>();
            //// 原来的授权信息
            //foreach (AuthorizationCommand cmd in node.Commands) {
            //    string key = SecurityUtility.HashObject(node.AuthorizationUri + cmd.CommandUri);
            //    if (actions.ContainsKey(key))
            //        acs[key] = actions[key];
            //}

            //Remove(node.AuthorizationUri); // 删除原来的授权信息
            //authorizations[node.AuthorizationUri] = node;
            //foreach (AuthorizationCommand cmd in node.Commands) {
            //    string key = SecurityUtility.HashObject(node.AuthorizationUri + cmd.CommandUri);
            //    if (acs.ContainsKey(key))
            //        actions[key] = acs[key];
            //    else
            //        actions[key] = AuthorizationAction.Deny;
            //}

            // 首先删除原来的授权信息
            foreach (AuthorizationCommand cmd in node.Commands) {
                string key = SecurityUtility.HashObject(node.AuthorizationUri + cmd.CommandUri);
                AuthorizationActionInfo actionInfo = new AuthorizationActionInfo(key, cmd.Action);
                if (actions.Contains(actionInfo))
                    actions.Remove(actionInfo);
            }
            Remove(node.AuthorizationUri);
            authorizations.Add(node);
            foreach (AuthorizationCommand cmd in node.Commands) {
                string key = SecurityUtility.HashObject(node.AuthorizationUri + cmd.CommandUri);
                AuthorizationActionInfo actionInfo = new AuthorizationActionInfo(key, cmd.Action);
                actions.Add(actionInfo);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 删除授权节点信息
        /// </summary>
        /// <param name="authorizationUri">授权路径</param>
        public void Remove(string authorizationUri)
        {
            Guard.ArgumentNotNull(authorizationUri, "Authorization Uri");

            //if (authorizations.ContainsKey(authorizationUri)) {
            //    AuthorizationNode node = authorizations[authorizationUri];
            //    // 选择节点下的所有操作项的授权信息
            //    foreach (AuthorizationCommand cmd in node.Commands) {
            //        string key = SecurityUtility.HashObject(node.AuthorizationUri + cmd.CommandUri);
            //        if (actions.ContainsKey(key))
            //            actions.Remove(key);
            //    }
            //    authorizations.Remove(authorizationUri);
            //}

            foreach (AuthorizationNode node in authorizations) {
                if (node.AuthorizationUri == authorizationUri) {
                    foreach (AuthorizationCommand cmd in node.Commands) {
                        string key = SecurityUtility.HashObject(node.AuthorizationUri + cmd.CommandUri);
                        AuthorizationActionInfo actionInfo = new AuthorizationActionInfo(key, cmd.Action);
                        if (actions.Contains(actionInfo))
                            actions.Remove(actionInfo);
                    }
                }
            }
        }