Ejemplo n.º 1
0
        private void AddKeys()
        {
            string text = base[this.RequestParamName];

            if (text != null && text != string.Empty)
            {
                ParamEncoder paramEncoder = new ParamEncoder(this.PrivateKey);
                try
                {
                    if (!paramEncoder.SetToken(text))
                    {
                        throw new EncryptedParamException("InvalidToken", null);
                    }
                }
                catch (Exception innerException)
                {
                    throw new EncryptedParamException("DecryptingTokenFailed", innerException);
                }
                this._type   = base.GetType();
                this._fields = this._type.GetFields();
                foreach (FieldInfo fieldInfo in this._fields)
                {
                    object[] customAttributes = fieldInfo.GetCustomAttributes(typeof(RequestParamAttribute), false);
                    if (customAttributes.Length == 1)
                    {
                        RequestParamAttribute requestParamAttribute = customAttributes[0] as RequestParamAttribute;
                        if (requestParamAttribute.Key != null && requestParamAttribute.Key != string.Empty)
                        {
                            object paramValue = paramEncoder.GetParamValue(requestParamAttribute.Key);
                            if (paramValue != null)
                            {
                                try
                                {
                                    fieldInfo.SetValue(this, paramValue);
                                }
                                catch (MethodAccessException)
                                {
                                    throw new EncryptedParamException("FieldAccessDenied : " + fieldInfo.Name);
                                }
                                catch (ArgumentException)
                                {
                                    throw new EncryptedParamException("ConvertingFailed : " + fieldInfo.Name);
                                }
                                catch (Exception innerException2)
                                {
                                    throw new EncryptedParamException("DecodingFieldsFailed : " + fieldInfo.Name, innerException2);
                                }
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private string GetToken()
        {
            ParamEncoder paramEncoder = new ParamEncoder(this.PrivateKey);

            this._type   = base.GetType();
            this._fields = this._type.GetFields();
            foreach (FieldInfo fieldInfo in this._fields)
            {
                object[] customAttributes = fieldInfo.GetCustomAttributes(typeof(RequestParamAttribute), false);
                if (customAttributes.Length == 1)
                {
                    RequestParamAttribute requestParamAttribute = customAttributes[0] as RequestParamAttribute;
                    EncryptedRequestParam.AddParam(paramEncoder, requestParamAttribute.Key, fieldInfo.GetValue(this));
                }
            }
            return(paramEncoder.GetToken());
        }
Ejemplo n.º 3
0
 private void AddKeys()
 {
     this._type       = base.GetType();
     this._properties = this._type.GetProperties();
     foreach (PropertyInfo propertyInfo in this._properties)
     {
         object[] customAttributes = propertyInfo.GetCustomAttributes(typeof(RequestParamAttribute), false);
         if (customAttributes.Length == 1)
         {
             RequestParamAttribute requestParamAttribute = customAttributes[0] as RequestParamAttribute;
             if (requestParamAttribute.Key != null && requestParamAttribute.Key != string.Empty && !this._keys.Contains(requestParamAttribute.Key))
             {
                 this._keys.Add(requestParamAttribute.Key);
             }
         }
     }
 }