private BoxManager(IRequestAuthenticator requestAuthenticator, IWebProxy proxy, BoxManagerOptions options, string onBehalfOf = null) : this() { requestAuthenticator.SetOnBehalfOf(onBehalfOf); _restClient = new BoxRestClient(requestAuthenticator, proxy, options); _uploadClient = new BoxUploadClient(requestAuthenticator, proxy, options); }
public DefaultRequestExecutor( IHttpClient httpClient, IClientApiKey apiKey, AuthenticationScheme authenticationScheme, ILogger logger, IBackoffStrategy defaultBackoffStrategy, IBackoffStrategy throttlingBackoffStrategy) { if (!apiKey.IsValid()) { throw new ApplicationException("API Key is invalid."); } this.httpClient = httpClient; this.syncHttpClient = httpClient as ISynchronousHttpClient; this.asyncHttpClient = httpClient as IAsynchronousHttpClient; this.apiKey = apiKey; this.authenticationScheme = authenticationScheme; IRequestAuthenticatorFactory requestAuthenticatorFactory = new DefaultRequestAuthenticatorFactory(); this.requestAuthenticator = requestAuthenticatorFactory.Create(authenticationScheme); this.logger = logger; this.defaultBackoffStrategy = defaultBackoffStrategy; this.throttlingBackoffStrategy = throttlingBackoffStrategy; }
public RequestAuthenticationMiddleware( ILogger <RequestAuthenticationMiddleware> logger, IRequestAuthenticator requestAuthenticator) { _logger = logger; _requestAuthenticator = requestAuthenticator; }
/// <summary> /// Returns a new REST service client instance /// </summary> /// <param name="restEndpoint">The URI of the BrightstarDB REST endpoint to connect to</param> /// <param name="requestAuthenticator">The service to use to apply authentication information to outgoing requests</param> /// <param name="queryCache">A cache instance for the client to use for caching SPARQL query responses</param> /// <returns>A new <see cref="IBrightstarService"/> instance</returns> public static IBrightstarService GetRestClient(string restEndpoint, IRequestAuthenticator requestAuthenticator = null, ICache queryCache = null) { if (requestAuthenticator == null) { requestAuthenticator = new PassthroughRequestAuthenticator(); } return(new BrightstarRestClient(restEndpoint, requestAuthenticator, queryCache)); }
/// <summary> /// Authentication filter for Brightspace OAuth 2.0 /// </summary> /// <param name="logProvider"></param> /// <param name="requestAuthenticator"></param> /// <param name="principalDependencyRegistry">Called to do out-of-band actions like set up ID2LPrincipal for dependency injection.</param> public OAuth2AuthenticationFilter( ILogProvider logProvider, IRequestAuthenticator requestAuthenticator, ID2LPrincipalDependencyRegistry principalDependencyRegistry ) { m_log = logProvider.Get( this.GetType() ); m_requestAuthenticator = requestAuthenticator; m_principalDependencyRegistry = principalDependencyRegistry; }
public IClientSettingsBuilder UseAuthenticator(IRequestAuthenticator authenticator) { if (authenticator == null) { throw new ArgumentNullException(nameof(authenticator)); } requestAuthenticator = authenticator; return(this); }
/// <summary> /// Authentication filter for Brightspace OAuth 2.0 /// </summary> /// <param name="logProvider"></param> /// <param name="requestAuthenticator"></param> /// <param name="principalDependencyRegistry">Called to do out-of-band actions like set up ID2LPrincipal for dependency injection.</param> public OAuth2AuthenticationFilter( ILogProvider logProvider, IRequestAuthenticator requestAuthenticator, ID2LPrincipalDependencyRegistry principalDependencyRegistry ) { m_log = logProvider.Get(this.GetType()); m_requestAuthenticator = requestAuthenticator; m_principalDependencyRegistry = principalDependencyRegistry; }
public BoxRestClientBase(string serviceUrlBase, IRequestAuthenticator authenticator, IWebProxy proxy, BoxManagerOptions options) : base(serviceUrlBase) { Options = options; Authenticator = authenticator; Proxy = proxy; ClearHandlers(); var xmlDeserializer = new XmlDeserializer(); var jsonDeserializer = new JsonDeserializer(); AddHandler(XmlMimeType, xmlDeserializer); AddHandler(XmlAltMimeType, xmlDeserializer); AddHandler(JsonMimeType, jsonDeserializer); }
/// <summary> /// Returns a new REST service client instance /// </summary> /// <param name="restEndpoint">The URI of the BrightstarDB REST endpoint to connect to</param> /// <param name="requestAuthenticator">The service to use to apply authentication information to outgoing requests</param> /// <param name="queryCache">A cache instance for the client to use for caching SPARQL query responses</param> /// <returns>A new <see cref="IBrightstarService"/> instance</returns> public static IBrightstarService GetRestClient(string restEndpoint, IRequestAuthenticator requestAuthenticator = null, ICache queryCache = null) { if (requestAuthenticator == null) requestAuthenticator = new PassthroughRequestAuthenticator(); return new BrightstarRestClient(restEndpoint, requestAuthenticator, queryCache); }
public BoxUploadClient(IRequestAuthenticator authenticator, IWebProxy proxy, BoxManagerOptions options) : base(ServiceUrl, authenticator, proxy, options) { }
private static async Task HandleRequest(Method method, HttpContext aspNetCoreContext, IRequestAuthenticator authenticator) { var(_, uri) = aspNetCoreContext.Request.Path.Value.TSplit(RootUri); var headers = new Headers(aspNetCoreContext.Request.Headers); var client = GetClient(aspNetCoreContext); var context = new AspNetCoreRESTableContext(client, aspNetCoreContext); if (!authenticator.TryAuthenticate(context, ref uri, headers, out var notAuthorized)) { WriteResponse(aspNetCoreContext, notAuthorized); return; } var body = aspNetCoreContext.Request.Body; var request = context.CreateRequest(method, uri, body, headers); await using var result = await request.GetResult().ConfigureAwait(false); switch (result) { case WebSocketTransferSuccess: return; case WebSocketUpgradeSuccessful ws: { await using var webSocket = ws.WebSocket; await webSocket.LifetimeTask.ConfigureAwait(false); break; } default: { WriteResponse(aspNetCoreContext, result); var remote = aspNetCoreContext.Response.Body; #if NETSTANDARD2_1 await using (remote) #else using (remote) #endif { await using var serializedResult = await result.Serialize(remote).ConfigureAwait(false); } break; } } }
public IRequestBuilder UseAuthenticator(IRequestAuthenticator authenticator) { requestAuthenticator = authenticator; authenticate = true; return(this); }
private void SetClient(IRequestAuthenticator requestAuthenticator, IWebProxy proxy, BoxManagerOptions options) { _restClient = new BoxRestClient(requestAuthenticator, proxy, options); }
private BoxManager(IRequestAuthenticator requestAuthenticator, IWebProxy proxy, BoxManagerOptions options) : this() { _restClient = new BoxRestClient(requestAuthenticator, proxy, options); _uploadClient = new BoxUploadClient(requestAuthenticator, proxy, options); }
public BitstampClient(IRequestAuthenticator requestAuthenticator, ILogFactory logFactory) { _log = logFactory.CreateLog(nameof(BitstampClient)); _requestAuthenticator = requestAuthenticator; _lastApiCallTimestamp = DateTime.Now; }