コード例 #1
0
        internal bool RemoveAccessRule(string appFriendlyName, string deviceFriendlyName)
        {
            bool removedSomething = false;

            lock (this)
            {
                List <Assertion> asserstionsToRemove = new List <Assertion>();
                foreach (var assertion in policyAssertions)
                {
                    ResourceAccessFact fact = assertion.Claim.Fact as ResourceAccessFact;

                    if (fact != null &&
                        fact.Module.Name.Equals("mod:" + appFriendlyName) &&
                        fact.Resource.Name.Equals("port:" + deviceFriendlyName))
                    {
                        asserstionsToRemove.Add(assertion);
                    }
                }

                foreach (var assertion in asserstionsToRemove)
                {
                    policyAssertions.Remove(assertion);
                    removedSomething = true;
                }
            }

            //PrintPolicies();

            return(removedSomething);
        }
コード例 #2
0
ファイル: SecPal.cs プロジェクト: gurashishs/CameraImager
        /// <summary>
        /// Returns true if the given object is equal to this one.
        /// </summary>
        /// <param name="obj">
        /// The object to be compared against.
        /// </param>
        /// <returns>
        /// True if the two objects are equal.
        /// </returns>
        public override bool Equals(object obj)
        {
            ResourceAccessFact otherObj = obj as ResourceAccessFact;

            if (otherObj == null)
            {
                return(false);
            }

            if (!this.Module.Equals(otherObj.Module) ||
                !this.Resource.Equals(otherObj.Resource) ||
                !this.Group.Equals(otherObj.Group) ||

                !this.From.Equals(otherObj.From) ||
                !this.To.Equals(otherObj.To) ||
                !this.DayOfWeek.Equals(otherObj.DayOfWeek) ||

                !this.AccessMode.Equals(otherObj.AccessMode) ||
                !this.Priority.Equals(otherObj.Priority))
            {
                return(false);
            }

            return(base.Equals(obj));
        }
コード例 #3
0
        //add a new user to the policy database
        internal void RemoveUser(UserInfo userInfo)
        {
            lock (this)
            {
                List <Assertion> asserstionsToRemove = new List <Assertion>();
                foreach (var assertion in policyAssertions)
                {
                    if (assertion.Claim.Fact is UserGroupMembershipFact)
                    {
                        UserGroupMembershipFact fact = (UserGroupMembershipFact)assertion.Claim.Fact;

                        if (fact.User.Name.Equals("usr:"******"grp:" + userInfo.Name))
                        {
                            asserstionsToRemove.Add(assertion);
                        }
                    }
                    else
                    {
                        throw new Exception("Unknown fact type!");
                    }
                }

                foreach (var assertion in asserstionsToRemove)
                {
                    policyAssertions.Remove(assertion);
                }
            }

            //PrintPolicies();
        }
コード例 #4
0
        internal void RemoveAccessRulesForModule(string moduleFriendlyName)
        {
            lock (this)
            {
                List <Assertion> asserstionsToRemove = new List <Assertion>();
                foreach (var assertion in policyAssertions)
                {
                    ResourceAccessFact fact = assertion.Claim.Fact as ResourceAccessFact;

                    if (fact != null &&
                        fact.Module.Name.Equals("mod:" + moduleFriendlyName))
                    {
                        asserstionsToRemove.Add(assertion);
                    }
                }

                foreach (var assertion in asserstionsToRemove)
                {
                    policyAssertions.Remove(assertion);
                }
            }

            //PrintPolicies();
        }
コード例 #5
0
        internal void AddAccessRule(AccessRule rule)
        {
            lock (this)
            {
                foreach (string portName in rule.DeviceList)
                {
                    foreach (TimeOfWeek timeOfWeek in rule.TimeList)
                    {
                        ResourceAccessFact fact = new ResourceAccessFact(new StringPrincipal("port:" + portName),
                                                                         new StringPrincipal("mod:" + rule.ModuleName),
                                                                         new StringPrincipal("grp:" + rule.UserGroup),

                                                                         new IntegerHolder(timeOfWeek.StartMins),
                                                                         new IntegerHolder(timeOfWeek.EndMins),
                                                                         new IntegerHolder(timeOfWeek.DayOfWeek),

                                                                         new VerbHolder(rule.AccessMode.ToString()),
                                                                         new IntegerHolder(rule.Priority));
                        resourceAccessFacts.Add(fact);
                        policyAssertions.Add(new Assertion(localAuthority, new Claim(fact)));
                    }
                }
            }
        }
コード例 #6
0
        internal void AddAccessRule(AccessRule rule)
        {
            lock (this)
            {
                foreach (string portName in rule.DeviceList)
                {
                    foreach (TimeOfWeek timeOfWeek in rule.TimeList)
                    {
                        ResourceAccessFact fact = new ResourceAccessFact(new StringPrincipal("port:" + portName),
                                                                         new StringPrincipal("mod:" + rule.ModuleName),
                                                                         new StringPrincipal("grp:" + rule.UserGroup),

                                                                         new IntegerHolder(timeOfWeek.StartMins),
                                                                         new IntegerHolder(timeOfWeek.EndMins),
                                                                         new IntegerHolder(timeOfWeek.DayOfWeek),

                                                                         new VerbHolder(rule.AccessMode.ToString()),
                                                                         new IntegerHolder(rule.Priority));
                        resourceAccessFacts.Add(fact);
                        policyAssertions.Add(new Assertion(localAuthority, new Claim(fact)));
                    }
                }
            }
        }