public Task Delete(BCAuthorize bcAuthorize, CancellationToken cancellationToken) { var record = _bcAuthorizeLst.First(_ => _.Id == bcAuthorize.Id); _bcAuthorizeLst.Remove(record); return(Task.CompletedTask); }
public async Task <bool> Notify(BCAuthorize bcAuthorize, CancellationToken cancellationToken) { try { var handler = new HttpClientHandler { AllowAutoRedirect = false }; using (var httpClient = _httpClientFactory.GetHttpClient(handler)) { var content = new JObject { { BCAuthenticationResponseParameters.AuthReqId, bcAuthorize.Id } }; var httpRequestMessage = new HttpRequestMessage { RequestUri = new Uri(bcAuthorize.NotificationEdp), Content = new StringContent(content.ToString(), Encoding.UTF8, "application/json") }; httpRequestMessage.Headers.Add("Authorization", $"Bearer {bcAuthorize.NotificationToken}"); var httpResult = await httpClient.SendAsync(httpRequestMessage, cancellationToken); httpResult.EnsureSuccessStatusCode(); return(true); } } catch (Exception ex) { _logger.LogError(ex.ToString()); return(false); } }
public Task Update(BCAuthorize bcAuthorize, CancellationToken cancellationToken) { var bcAuth = _bcAuthorizeLst.First(_ => _.Id == bcAuthorize.Id); _bcAuthorizeLst.Remove(bcAuth); _bcAuthorizeLst.Add(bcAuthorize); return(Task.CompletedTask); }
public async Task <bool> Notify(BCAuthorize bcAuthorize, CancellationToken cancellationToken) { try { var handler = new HttpClientHandler { AllowAutoRedirect = false }; using (var httpClient = _httpClientFactory.GetHttpClient(handler)) { var jObjBody = new JObject(); var context = new HandlerContext(new HandlerContextRequest(null, null, jObjBody, null, null, null)); var user = await _oauthUserRepository.FindOAuthUserByLogin(bcAuthorize.UserId, cancellationToken); var oauthClient = await _oauthClientRepository.FindOAuthClientById(bcAuthorize.ClientId, cancellationToken); context.SetUser(user); context.SetClient(oauthClient); foreach (var tokenBuilder in _tokenBuilders) { await tokenBuilder.Build(bcAuthorize.Scopes, context, cancellationToken); } var content = new JObject { { BCAuthenticationResponseParameters.AuthReqId, bcAuthorize.Id } }; foreach (var resp in context.Response.Parameters) { content.Add(resp.Key, resp.Value); } var httpRequestMessage = new HttpRequestMessage { RequestUri = new Uri(bcAuthorize.NotificationEdp), Content = new StringContent(content.ToString(), Encoding.UTF8, "application/json") }; httpRequestMessage.Headers.Add("Authorization", bcAuthorize.NotificationToken); var httpResult = await httpClient.SendAsync(httpRequestMessage, cancellationToken); httpResult.EnsureSuccessStatusCode(); return(true); } } catch (Exception ex) { _logger.LogError(ex.ToString()); return(false); } }
public Task Update(BCAuthorize bcAuhtorize, CancellationToken cancellationToken) { _dbContext.BCAuthorizeLst.Update(bcAuhtorize); return(Task.CompletedTask); }
public Task Add(BCAuthorize bcAuthorize, CancellationToken cancellationToken) { _dbContext.BCAuthorizeLst.Add(bcAuthorize); return(Task.CompletedTask); }
public Task Add(BCAuthorize bcAuthorize, CancellationToken cancellationToken) { _bcAuthorizeLst.Add((BCAuthorize)bcAuthorize.Clone()); return(Task.CompletedTask); }