Пример #1
0
        //整数出栈
        public IntConstant PopIntConst()
        {
            IConstant constant = operandStack.Pop();

            if (constant.Type != NumericType.INT)
            {
                throw reporter.Throw("值类型错误", VMExceptionType.WRONG_TYPE);
            }
            return((IntConstant)constant);
        }
Пример #2
0
 private int GetIntFromArg(String arg)
 {
     int retVal = 0;
     try
     {
        retVal = Convert.ToInt32(arg);
     }
     catch
     {
         throw reporter.Throw("参数类型错误", VMExceptionType.WRONG_TYPE);
     }
     return retVal;
 }
Пример #3
0
        /// <summary>
        /// Updates a providers user information
        /// </summary>
        /// <param name="user">MembershipUser object</param>
        public override void UpdateUser(MembershipUser user)
        {
            // Check User object is not null
            if (user == null)
            {
                ExceptionReporter.ThrowArgumentNull("MEMBERSHIP", "MEMBERSHIPUSERNULL");
            }

            // Update User
            int updateStatus = DB.UpdateUser(this.ApplicationName, user, this.RequiresUniqueEmail);

            // Check update was not successful
            if (updateStatus != 0)
            {
                // An error has occurred, determine which one.
                switch (updateStatus)
                {
                case 1: ExceptionReporter.Throw("MEMBERSHIP", "USERKEYNULL");
                    break;

                case 2: ExceptionReporter.Throw("MEMBERSHIP", "DUPLICATEEMAIL");
                    break;
                }
            }
        }
Пример #4
0
        /// <summary>
        /// Decrypt string using passwordFormat.
        /// </summary>
        /// <param name="pass">Password to be decrypted</param>
        /// <param name="passwordFormat">Method of encryption</param>
        /// <returns> Unencrypted string</returns>
        private static string DecodeString(string pass, int passwordFormat)
        {
            switch (( MembershipPasswordFormat )Enum.ToObject(typeof(MembershipPasswordFormat), passwordFormat))
            {
            case MembershipPasswordFormat.Clear:                     // MembershipPasswordFormat.Clear:
                return(pass);

            case MembershipPasswordFormat.Hashed:                     // MembershipPasswordFormat.Hashed:
                ExceptionReporter.Throw("MEMBERSHIP", "DECODEHASH");
                break;

            case MembershipPasswordFormat.Encrypted:
                byte [] bIn  = Convert.FromBase64String(pass);
                byte [] bRet = (new YafMembershipProvider()).DecryptPassword(bIn);
                if (bRet == null)
                {
                    return(null);
                }
                return(Encoding.Unicode.GetString(bRet, 16, bRet.Length - 16));

            default:
                ExceptionReporter.Throw("MEMBERSHIP", "DECODEHASH");
                break;
            }

            return(String.Empty);            // Removes "Not all paths return a value" warning.
        }
 //依据嵌套逐层查找变量
 public IConstant GetValue(String varName)
 {
     foreach (VariableTable table in tableStack.ToArray())
     {
         //找到最近层定义的变量后立即退出
         if (table.GetValue(varName, out IConstant value))
         {
             return(value);
         }
     }
     throw reporter.Throw("不能使用未定义的变量", VMExceptionType.UNDEFINED_VAR);
 }
Пример #6
0
 public bool DeclareIntVar(String varName)
 {
     if (varDict.ContainsKey(varName))
     {
         throw reporter.Throw("重复定义变量或函数名", VMExceptionType.REPEAT_DEFINE);
     }
     varDict.Add(varName, new IntConstant(0));
     return(true);
 }
Пример #7
0
        /// <summary>
        /// Initialie Membership Provider
        /// </summary>
        /// <param name="name">Membership Provider Name</param>
        /// <param name="config">NameValueCollection of configuration items</param>
        public override void Initialize(string name, NameValueCollection config)
        {
            // Verify that the configuration section was properly passed
            if (config == null)
            {
                ExceptionReporter.ThrowArgument("ROLES", "CONFIGNOTFOUND");
            }

            // Retrieve information for provider from web config
            // config ints

            // Minimum Required Password Length from Provider configuration
            _minimumRequiredPasswordLength = int.Parse(config ["minRequiredPasswordLength"] ?? "6");

            // Minimum Required Non Alpha-numeric Characters from Provider configuration
            _minRequiredNonAlphanumericCharacters = int.Parse(config ["minRequiredNonalphanumericCharacters"] ?? "1");

            // Maximum number of allowed password attempts
            _maxInvalidPasswordAttempts = int.Parse(config ["maxInvalidPasswordAttempts"] ?? "5");

            // Password Attempt Window when maximum attempts have been reached
            _passwordAttemptWindow = int.Parse(config ["passwordAttemptWindow"] ?? "10");

            // Check whething Hashing methods should use Salt
            _useSalt = Utils.Transform.ToBool(config ["useSalt"] ?? "false");

            // Application Name
            _appName = Utils.Transform.ToString(config ["applicationName"], "YetAnotherForum");

            _passwordStrengthRegularExpression = Utils.Transform.ToString(config ["passwordStrengthRegularExpression"]);

            // Password reset enabled from Provider Configuration
            _enablePasswordReset       = Utils.Transform.ToBool(config ["enablePasswordReset"] ?? "true");
            _enablePasswordRetrieval   = Utils.Transform.ToBool(config ["enablePasswordRetrieval"] ?? "false");
            _requiresQuestionAndAnswer = Utils.Transform.ToBool(config ["requiresQuestionAndAnswer"] ?? "true");

            _requiresUniqueEmail = Utils.Transform.ToBool(config ["requiresUniqueEmail"] ?? "true");

            string strPasswordFormat = Utils.Transform.ToString(config ["passwordFormat"], "Hashed");

            switch (strPasswordFormat)
            {
            case "Clear":
                _passwordFormat = MembershipPasswordFormat.Clear;
                break;

            case "Encrypted":
                _passwordFormat = MembershipPasswordFormat.Encrypted;
                break;

            case "Hashed":
                _passwordFormat = MembershipPasswordFormat.Hashed;
                break;

            default:
                ExceptionReporter.Throw("MEMBERSHIP", "BADPASSWORDFORMAT");
                break;
            }

            base.Initialize(name, config);
        }
Пример #8
0
        public IntConstant AllocIntArray(int size)
        {
            if (size <= 0 || size > MAXSIZE)
            {
                throw reporter.Throw("数组下标越界", VMExceptionType.WRONG_INDEX);
            }
            Int32 address = GetRandomAddress();

            int[] intArray;
            intArray = new int[1] {
                0
            };
            Array.Resize(ref intArray, size);
            Array.Fill(intArray, 0);
            heapMap.Add(address, intArray);
            return(new IntConstant(address, IntUsage.ARRAYADDR));
        }