コード例 #1
0
        internal bool AuthorizeSession(string userName, string computerName, Uri connectionUri, string configuration)
        {
            bool   flag;
            object obj;
            string statusSuccess;

            PowwaEvents.PowwaEVENT_GATEWAY_AUTHORIZATION_START(userName);
            bool length = false;
            PswaAuthorizationRuleManager instance = PswaAuthorizationRuleManager.Instance;

            instance.TestRuleInvalidRule += new EventHandler <TestRuleInvalidRuleEventArgs>(this.OnInvalidRule);
            try
            {
                ArrayList arrayLists = new ArrayList();
                SortedList <int, PswaAuthorizationRule> nums = PswaAuthorizationRuleManager.Instance.LoadFromFile(arrayLists);
                this.CheckLoadError(arrayLists);
                if (nums != null)
                {
                    PswaAuthorizationRule[] array = nums.Values.ToArray <PswaAuthorizationRule>();
                    this.invalidRules = 0;
                    if (computerName == null)
                    {
                        length = (int)PswaAuthorizationRuleManager.Instance.TestRule(array, userName, connectionUri, configuration, false, MatchingWildcard.None).Length > 0;
                    }
                    else
                    {
                        length = (int)PswaAuthorizationRuleManager.Instance.TestRule(array, userName, computerName, configuration, false, MatchingWildcard.None).Length > 0;
                    }
                    if (length || this.invalidRules <= 0)
                    {
                        flag = length;
                    }
                    else
                    {
                        CultureInfo invariantCulture = CultureInfo.InvariantCulture;
                        string      str      = "Test-PswaAuthorizationRule -UserName '{0}' -{1} '{2}' -ConfigurationName '{3}'";
                        object[]    objArray = new object[4];
                        objArray[0] = userName;
                        object[] objArray1 = objArray;
                        int      num       = 1;
                        if (computerName != null)
                        {
                            obj = "ComputerName";
                        }
                        else
                        {
                            obj = "ConnectionUri";
                        }
                        objArray1[num] = obj;
                        objArray[2]    = computerName;
                        objArray[3]    = configuration;
                        string str1 = string.Format(invariantCulture, str, objArray);
                        PowwaEvents.PowwaEVENT_AUTHORIZATION_FAILURE_INVALID_RULES(str1);
                        throw PowwaException.CreateLogOnFailureException(Resources.GatewayAuthorizationFailureInvalidRules);
                    }
                }
                else
                {
                    bool flag1 = false;
                    length = flag1;
                    flag   = flag1;
                }
            }
            finally
            {
                PswaAuthorizationRuleManager pswaAuthorizationRuleManager = PswaAuthorizationRuleManager.Instance;
                pswaAuthorizationRuleManager.TestRuleInvalidRule -= new EventHandler <TestRuleInvalidRuleEventArgs>(this.OnInvalidRule);
                string str2 = userName;
                if (length)
                {
                    statusSuccess = Resources.Status_Success;
                }
                else
                {
                    statusSuccess = Resources.Status_Failure;
                }
                PowwaEvents.PowwaEVENT_GATEWAY_AUTHORIZATION_STOP(str2, statusSuccess);
            }
            return(flag);
        }