readonly JsonConfigLoader _jsonConfigLoader = new JsonConfigLoader(Environment.CurrentDirectory); //todo public IEnumerable <HeroWinRate> GetHeroWinratesAgainstHero( [NotNull] int heroId) { return(_cache.Get( $"GetHeroWinratesAgainstHero({heroId})", GetHeroWinRate(heroId))); }
public void AuthenticateRequest(IRestRequest request) { string sysToken = _simpleMemoryCache.Get <string>(nameof(AdminAuthentification)); if (!string.IsNullOrEmpty(sysToken)) { request.AddHeader(HeaderNames.Authorization, sysToken); } }
public void AuthenticateRequest(IRestRequest request) { var user = _simpleMemoryCache.Get <ClaimsPrincipal>(_token); var token = user?.Claims?.FirstOrDefault(x => x?.Type == @"http://spisum.cz/identity/claims/token"); if (token != null) { request.AddHeader(HeaderNames.Authorization, token.Value); } }
public async Task <List <PathsModel> > GetAllPaths() { if (_simpleMemoryCache.IsExist(_cacheKey)) { return(_simpleMemoryCache.Get <List <PathsModel> >(_cacheKey)); } var paths = await FindAllPaths(); _simpleMemoryCache.Create(_cacheKey, paths, new MemoryCacheEntryOptions { Priority = CacheItemPriority.NeverRemove }); return(paths); }
protected override async Task <AuthenticateResult> HandleAuthenticateAsync() { string authorization = Request.Headers[HeaderNames.Authorization]; if (string.IsNullOrEmpty(authorization)) { return(AuthenticateResult.Fail("Authentication not provided.")); } ClaimsPrincipal principal = null; if (!_simpleMemoryCache.IsExist(authorization)) { var alfrescoProfile = await _alfrescoHttpClient.GetPerson("-me-"); if (alfrescoProfile?.Entry?.Id != null) { principal = _mapper.Map <ClaimsPrincipal>((alfrescoProfile, authorization)); } if (principal?.Claims == null) { return(AuthenticateResult.Fail("Authentication not provided.")); } lock (Sync) { if (!_simpleMemoryCache.IsExist(authorization)) { _simpleMemoryCache.Create(authorization, principal, new MemoryCacheEntryOptions { SlidingExpiration = TimeSpan.FromMinutes(_alfrescoConfiguration.TokenExpire ?? 30), Priority = CacheItemPriority.High }); } } } else { principal = _simpleMemoryCache.Get <ClaimsPrincipal>(authorization); } return(AuthenticateResult.Success(new AuthenticationTicket(principal, new AuthenticationProperties { AllowRefresh = false, IsPersistent = true }, "Alfresco Scheme"))); }
public async Task <List <CodeListModel> > GetAllListsOfValues() { if (_simpleMemoryCache.IsExist(_cacheKey)) { return(_simpleMemoryCache.Get <List <CodeListModel> >(_cacheKey)); } var codeLists = new List <CodeListModel>(); var alfrescoResponse = await _alfrescoHttpClient.CodeListGetAll(); foreach (var list in alfrescoResponse.CodeLists.Where(x => x.Name != "rmc_smList")) { codeLists.Add(await GetListValues(list.Name)); } _simpleMemoryCache.Create(_cacheKey, codeLists); return(codeLists); }
public async Task <List <SignerStatus> > Status([FromQuery] SignerGetStatus signerStatus) { var componentValidator = new ComponentValidator(_alfrescoHttpClient); await signerStatus.ComponentId.ForEachAsync(async x => { var component = x.Split('_'); if (component.Length != 2) { throw new BadRequestException($"Component {x} is not in form 'guid_componentId'"); } //await componentValidator.ValidateAsync(new DocumentProperties(component[1])); }); return((from component in signerStatus.ComponentId where _simpleMemoryCache.IsExist($"{SignerStatus}{component}") select new SignerStatus { Id = component.Split('_')[0], Component = component.Split('_')[1], Status = _simpleMemoryCache.Get <string>($"{SignerStatus}{component}") }).ToList()); }
public JsonContainers.CountersConfig GetCounters() { return(_cache.Get( $"GetCounters()", _GetCounters())); }