Пример #1
0
        public BaseController()
        {
            _sendGmail = new SendGmail();
            _fileSettingsServiceService = new FileSettingsServiceService();
            _appAppSettings             = _fileSettingsServiceService.GetSettings();



            _customerSettingsService = new CustomerSettingsService();

            _headersParser = new HeadersParser();
            _headers       = _headersParser.ParseHeadersFromFile(
                System.Web.Hosting.HostingEnvironment.MapPath(@"~/App_Data/RequestHeaders.txt"));

            _restService = new RestService(new HttpClientServiceFactory());

            //This is now fetched via cookies parsing
            //_restService.SetAuthorizationHeader("Bearer", _appAppSettings.Bearer);
            #region get Bearer token from Cookies
            var cookies          = _headers.SingleOrDefault(x => x.Key.ToUpper() == "COOKIE").Value.Split(';');
            var bearerAuthString = cookies.First(x => x.Contains("aveapps=")).Substring(10);

            _restService.SetAuthorizationHeader("Bearer", bearerAuthString);
            #endregion



            #region check for expired authorization
            var getUser = _restService.Get <User>("https://api.waveapps.com/user/");
            if (!getUser.IsSuccessStatusCode)
            {
                throw new InvalidCredentialException();
            }
            #endregion
        }
Пример #2
0
        protected XElement GetSettings(string settingsKey)
        {
            XElement element = null;

            IFileSettingsService fileSettingsService = ToolsUIApplication.Instance.RootServiceProvider.GetService(typeof(IFileSettingsService)) as IFileSettingsService;

            if (fileSettingsService != null)
            {
                if (this.targetAlias == null)
                {
                    element = fileSettingsService.GetSettings(this.clipSource, settingsKey);
                }
                else
                {
                    element = fileSettingsService.GetSettings(targetAlias, this.clipSource, settingsKey);
                }
            }

            return(element);
        }