示例#1
0
        public override void Uninstall()
        {
            WebApiCachingControllingData.Remove();
            WebApiCachingUserData.Remove();

            _settingService.DeleteSetting <WebApiSettings>();

            base.Uninstall();
        }
示例#2
0
        public override void Install()
        {
            _settingService.SaveSetting(new WebApiSettings());
            _localizationService.ImportPluginResourcesFromXml(PluginDescriptor);

            base.Install();

            WebApiCachingControllingData.Remove();
            WebApiCachingUserData.Remove();
        }
示例#3
0
        public override void Uninstall()
        {
            WebApiCachingControllingData.Remove();
            WebApiCachingUserData.Remove();

            _settingService.DeleteSetting <WebApiSettings>();

            _permissionService.UninstallPermissions(new WebApiPermissionProvider());

            base.Uninstall();
        }
示例#4
0
        public override void Uninstall()
        {
            WebApiCachingControllingData.Remove();
            WebApiCachingUserData.Remove();

            _settingService.DeleteSetting <WebApiSettings>();

            _permissionService.UninstallPermissions(new WebApiPermissionProvider());

            _localizationService.DeleteLocaleStringResources(this.PluginDescriptor.ResourceRootKey);
            _localizationService.DeleteLocaleStringResources("Plugins.FriendlyName.Api.WebApi", false);

            base.Uninstall();
        }
示例#5
0
        public override void Install()
        {
            _permissionService.InstallPermissions(new WebApiPermissionProvider());

            var apiSettings = new WebApiSettings
            {
                LogUnauthorized   = true,
                ValidMinutePeriod = WebApiGlobal.DefaultTimePeriodMinutes
            };

            _settingService.SaveSetting <WebApiSettings>(apiSettings);

            _localizationService.ImportPluginResourcesFromXml(this.PluginDescriptor);

            base.Install();

            WebApiCachingControllingData.Remove();
            WebApiCachingUserData.Remove();
        }
示例#6
0
        public void RemoveKeys(int customerId)
        {
            if (customerId != 0)
            {
                var data = (
                    from a in _genericAttributes.Table
                    where a.EntityId == customerId && a.KeyGroup == "Customer" && a.Key == WebApiCachingUserData.Key
                    select a).ToList();

                if (data.Count > 0)
                {
                    foreach (var itm in data)
                    {
                        _genericAttributeService.DeleteAttribute(itm);
                    }

                    WebApiCachingUserData.Remove();
                }
            }
        }
示例#7
0
        public bool CreateKeys(int customerId)
        {
            if (customerId != 0)
            {
                var    hmac = new HmacAuthentication();
                var    userData = WebApiCachingUserData.Data();
                string key1, key2;

                for (int i = 0; i < 9999; ++i)
                {
                    if (hmac.CreateKeys(out key1, out key2) && !userData.Exists(x => x.PublicKey.IsCaseInsensitiveEqual(key1)))
                    {
                        var apiUser = new WebApiUserCacheData
                        {
                            CustomerId = customerId,
                            PublicKey  = key1,
                            SecretKey  = key2,
                            Enabled    = true
                        };

                        RemoveKeys(customerId);

                        var attribute = new GenericAttribute
                        {
                            EntityId = customerId,
                            KeyGroup = "Customer",
                            Key      = WebApiCachingUserData.Key,
                            Value    = apiUser.ToString()
                        };

                        _genericAttributeService.InsertAttribute(attribute);

                        WebApiCachingUserData.Remove();
                        return(true);
                    }
                }
            }
            return(false);
        }