#pragma warning disable S107 public TestcontainersConfiguration( Uri endpoint, IAuthenticationConfiguration authenticationConfigurations, IDockerImage image, string name, string workingDirectory, IEnumerable <string> entrypoint, IEnumerable <string> command, IReadOnlyDictionary <string, string> environments, IReadOnlyDictionary <string, string> labels, IReadOnlyDictionary <string, string> exposedPorts, IReadOnlyDictionary <string, string> portBindings, IEnumerable <IBind> mounts, IOutputConsumer outputConsumer, IEnumerable <IWaitUntil> waitStrategies, bool cleanUp = true) { this.CleanUp = cleanUp; this.Endpoint = endpoint; this.AuthConfig = authenticationConfigurations; this.Image = image; this.Name = name; this.WorkingDirectory = workingDirectory; this.Entrypoint = entrypoint; this.Command = command; this.Environments = environments; this.Labels = labels; this.ExposedPorts = exposedPorts; this.PortBindings = portBindings; this.Mounts = mounts; this.OutputConsumer = outputConsumer; this.WaitStrategies = waitStrategies; }
public AuthController( IUsersService usersService, IAuthenticationConfiguration authConfig) { _usersService = usersService; _authConfig = authConfig; }
private MemcachedClientApiConfiguration( IEnumerable<IPEndPoint> servers, ISocketPoolConfiguration socketPoolConfiguration, IMemcachedKeyTransformer keyTransformer, IMemcachedNodeLocator nodeLocator, Func<IMemcachedNodeLocator> nodeLocatorFactory, ITranscoder transcoder, IAuthenticationConfiguration authentication, MemcachedProtocol protocol, IPerformanceMonitor performanceMonitor) { Condition.Requires(socketPoolConfiguration, "socket pool configuration").IsNotNull(); Condition.Requires(keyTransformer, "key transformer").IsNotNull(); Condition.Requires(transcoder, "transcoder").IsNotNull(); Condition.Requires(authentication, "authentication").IsNotNull(); Condition.Requires(nodeLocator, "node locator") .Evaluate(!(nodeLocator == null && nodeLocatorFactory == null), "Both node locator and node locator factory are not set. Requires only one to be set."); Condition.Requires(nodeLocator, "node locator") .Evaluate(!(nodeLocator == null && nodeLocatorFactory == null), "Both node locator and node locator are set. Requires only one to be set."); Condition.Requires(servers, "servers").IsNotNull(); _socketPoolConfiguration = socketPoolConfiguration; _keyTransformer = keyTransformer; _nodeLocator = nodeLocator; _nodeLocatorFactory = nodeLocatorFactory; _transcoder = transcoder; _authentication = authentication; PerformanceMonitor = performanceMonitor; Protocol = protocol; _servers = servers.ToList(); }
private MemcachedClientApiConfiguration( IEnumerable <IPEndPoint> servers, ISocketPoolConfiguration socketPoolConfiguration, IMemcachedKeyTransformer keyTransformer, IMemcachedNodeLocator nodeLocator, Func <IMemcachedNodeLocator> nodeLocatorFactory, ITranscoder transcoder, IAuthenticationConfiguration authentication, MemcachedProtocol protocol, IPerformanceMonitor performanceMonitor) { Condition.Requires(socketPoolConfiguration, "socket pool configuration").IsNotNull(); Condition.Requires(keyTransformer, "key transformer").IsNotNull(); Condition.Requires(transcoder, "transcoder").IsNotNull(); Condition.Requires(authentication, "authentication").IsNotNull(); Condition.Requires(nodeLocator, "node locator") .Evaluate(!(nodeLocator == null && nodeLocatorFactory == null), "Both node locator and node locator factory are not set. Requires only one to be set."); Condition.Requires(nodeLocator, "node locator") .Evaluate(!(nodeLocator == null && nodeLocatorFactory == null), "Both node locator and node locator are set. Requires only one to be set."); Condition.Requires(servers, "servers").IsNotNull(); _socketPoolConfiguration = socketPoolConfiguration; _keyTransformer = keyTransformer; _nodeLocator = nodeLocator; _nodeLocatorFactory = nodeLocatorFactory; _transcoder = transcoder; _authentication = authentication; PerformanceMonitor = performanceMonitor; Protocol = protocol; _servers = servers.ToList(); }
/// <summary> /// Initializes a new instance of the <see cref="SecretConfiguration"/> class. /// </summary> /// <param name="authentication">The authentication.</param> /// <param name="microsoftAppCredentials">The Microsoft application credentials.</param> public SecretConfiguration( IAuthenticationConfiguration authentication, IMicrosoftCredentialConfiguration microsoftAppCredentials) { Authentication = authentication; MicrosoftAppCredentials = microsoftAppCredentials; }
#pragma warning disable S107 private static ITestcontainersConfiguration Apply( Uri endpoint = null, IAuthenticationConfiguration authConfig = null, IDockerImage image = null, string name = null, string workingDirectory = null, IEnumerable <string> entrypoint = null, IEnumerable <string> command = null, IReadOnlyDictionary <string, string> environments = null, IReadOnlyDictionary <string, string> labels = null, IReadOnlyDictionary <string, string> exposedPorts = null, IReadOnlyDictionary <string, string> portBindings = null, IEnumerable <IBind> mounts = null, IOutputConsumer outputConsumer = null, IEnumerable <IWaitUntil> waitStrategies = null, bool cleanUp = true) { return(new TestcontainersConfiguration( endpoint ?? DockerApiEndpoint.Local, authConfig, image, name, workingDirectory, entrypoint, command, environments, labels, exposedPorts, portBindings, mounts, outputConsumer, waitStrategies, cleanUp)); }
/// <summary> /// Constructs a TCAPI object with no asynchronous support. /// </summary> /// <param name="endpoint">The endpoint for the TCAPI</param> /// <param name="authentification">The authentification object</param> public TCAPI(Uri endpoint, IAuthenticationConfiguration authentification) { this.endpoint = endpoint; this.Authentification = authentification; this.tcapiCallback = null; this.offlineStorage = null; this.version = DetermineVersioning(); }
public AuthenticationProcess(IAuthenticationConfiguration configuration, IUnitOfWorkScopeFactory scopeFactory, Logger logger, IAccountRepository accountRepository, ILogonHistoryRepository logonHistoryRepository, IBusinessTransactionObservable transaction) { _scopeFactory = scopeFactory; _logger = logger; _logonHistoryRepository = logonHistoryRepository; _accountRepository = accountRepository; _transaction = transaction; _configuration = configuration; }
private static void AddAuthHeader(WebHeaderCollection nvc, IAuthenticationConfiguration auth) { if (auth is BasicHTTPAuth) { nvc["Authorization"] = auth.GetAuthorization(); } else if (auth is OAuthAuthentication) { } }
public OwinWebServer() { _WebAppConfiguration = Factory.Singleton.Resolve <IWebAppConfiguration>(); _AuthenticationConfiguration = Factory.Singleton.ResolveSingleton <IAuthenticationConfiguration>(); _AccessConfiguration = Factory.Singleton.ResolveSingleton <IAccessConfiguration>(); var standardPipeline = Factory.Singleton.Resolve <IStandardPipeline>(); standardPipeline.Register(_WebAppConfiguration); }
/// <summary> /// Creates a new object. /// </summary> public BasicAuthenticationFilter() { _SharedConfiguration = Factory.Singleton.ResolveSingleton <ISharedConfiguration>(); _AuthenticationConfiguration = Factory.Singleton.ResolveSingleton <IAuthenticationConfiguration>(); _UserManager = Factory.Singleton.ResolveSingleton <IUserManager>(); _UserCache = Factory.Singleton.Resolve <IUserCache>(); _UserCache.LoadAllUsers = false; _UserCache.TagAction = (cachedUser) => cachedUser.Tag = new CachedUserTag(); _UserCache.Refresh(); }
public ExoftOAuthServerProvider(IAuthenticationService authService, IAuthenticationConfiguration configuration) { _authService = authService; _configuration = configuration; if (_configuration.AccessTokenLifetimeMinutes <= 0) { _configuration.AccessTokenLifetimeMinutes = OAuthServerConstants.AccessTokenExpireTimeMinutes; } if (_configuration.RefreshTokenLifetimeMinutes <= 0) { _configuration.RefreshTokenLifetimeMinutes = OAuthServerConstants.RefreshTokenExpireTimeMinutes; } }
public Task CreateAsync(IDockerImage image, IAuthenticationConfiguration authConfig, CancellationToken ct = default) { return(this.Docker.Images.CreateImageAsync( new ImagesCreateParameters { FromImage = image.FullName }, new AuthConfig { ServerAddress = authConfig.RegistryEndpoint?.AbsoluteUri, Username = authConfig.Username, Password = authConfig.Password }, new TraceProgress(), ct)); }
private async Task <IResponse> ValidateConfiguration(IEdFiOdsApiConfiguration apiConfig, IAuthenticationConfiguration abConfig) { var abresult = await _learningStandardsPlugin.LearningStandardsConfigurationValidator .ValidateLearningStandardProviderConfigurationAsync(abConfig); if (!abresult.IsSuccess) { return(abresult); } return(await _learningStandardsPlugin.LearningStandardsConfigurationValidator .ValidateEdFiOdsApiConfigurationAsync( apiConfig)); }
public HashStream(Stream binding, bool writing, IAuthenticationConfiguration config, bool closeOnDispose = true) { Contract.Requires(binding != null); _streamBinding = binding; Writing = writing; _closeOnDispose = closeOnDispose; if (config.FunctionType != AuthenticationFunctionType.Mac) { throw new ConfigurationInvalidException("Configuration specifies function type other than MAC."); } _digest = AuthenticatorFactory.CreateHashPrimitive(config.FunctionName.ToEnum <HashFunction>()); _buffer = new byte[BufferSize]; _output = new byte[_digest.OutputSize]; }
public static void AddAuth(this IServiceCollection services, IAuthenticationConfiguration config) { services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) .AddJwtBearer(opt => { opt.RequireHttpsMetadata = false; opt.TokenValidationParameters = new TokenValidationParameters { ValidateIssuer = true, ValidIssuer = config.Issuer, ValidateAudience = true, ValidAudience = config.Audience, ValidateLifetime = true, ValidateIssuerSigningKey = true, IssuerSigningKey = new SymmetricSecurityKey(Encoding.ASCII.GetBytes(config.Key)) }; }); }
public MacStream(Stream binding, bool writing, IAuthenticationConfiguration config, byte[] key, bool closeOnDispose = true) { Contract.Requires <ArgumentNullException>(binding != null); Contract.Requires <ArgumentNullException>(key != null); _streamBinding = binding; Writing = writing; _closeOnDispose = closeOnDispose; if (config.FunctionType != AuthenticationFunctionType.Mac) { throw new ConfigurationInvalidException("Configuration specifies function type other than MAC."); } _mac = AuthenticatorFactory.CreateMacPrimitive(config.FunctionName.ToEnum <MacFunction>(), key, config.Salt, config.FunctionConfiguration, config.Nonce); _output = new byte[_mac.OutputSize]; }
/// <summary> /// Sends a DELETE request /// </summary> /// <param name="deleteData">A name-value pair collection of query parameters</param> /// <returns>The response string</returns> public static string DeleteRequest(NameValueCollection deleteData, string endpoint, IAuthenticationConfiguration authentification, string x_experience_api_version) { string result = null; string end = endpoint + ToQueryString(deleteData); for (int attempt = 0; attempt <= REATTEMPT_COUNT; attempt++) { WebRequest request = WebRequest.Create(endpoint + ToQueryString(deleteData)); request.Method = "DELETE"; AddAuthHeader(request.Headers, authentification); AddExperienceVersionHeader(request.Headers, x_experience_api_version); try { result = SendRequest(request); } catch (InternalServerErrorException e) { if (attempt < REATTEMPT_COUNT) { Thread.Sleep(RETRY_TIMEOUT); continue; } throw e; } catch (ConnectionFailedException e) { if (attempt < REATTEMPT_COUNT) { Thread.Sleep(RETRY_TIMEOUT); continue; } throw e; } catch (WebException e) { ThrowHttpException(e); } break; } return result; }
private static ISaslAuthenticationProvider GetProvider(IMemcachedClientConfiguration configuration) { // create&initialize the authenticator, if any // we'll use this single instance everywhere, so it must be thread safe IAuthenticationConfiguration auth = configuration.Authentication; if (auth != null) { Type t = auth.Type; var provider = (t == null) ? null : IkCaching.Reflection.FastActivator.Create(t) as ISaslAuthenticationProvider; if (provider != null) { provider.Initialize(auth.Parameters); return(provider); } } return(null); }
public ClientService(IAuthenticationConfiguration authConfig, IDeveloperTokenProvider developerTokenProvider) { if (authConfig == null) { throw new ArgumentNullException(nameof(authConfig), $"{nameof(IAuthenticationConfiguration)} was not configured."); } if (developerTokenProvider == null) { throw new ArgumentNullException(nameof(developerTokenProvider), $"{nameof(developerTokenProvider)} was not configured."); } if (!developerTokenProvider.TryGetDeveloperToken(out string devToken)) { throw new Exception("Could not find developer token on principal."); } BoxConfig config = new BoxConfig(authConfig.ClientId, authConfig.ClientSecret, new Uri("http://localhost")); OAuthSession session = new OAuthSession(devToken, "NOT_NEEDED", 3600, "bearer"); Client = new BoxClient(config, session); }
/// <summary> /// Initializes a new instance of the <see cref="T:Guanima.Redis.Configuration.RedisClientConfiguration"/> class. /// </summary> public RedisClientConfiguration() { _socketPool = new SocketPoolConfiguration(); _authentication = new AuthenticationConfiguration(); _servers = new List<IEndPointConfiguration>(); }
//private ExoftOAuthServerOptions(){} public ExoftOAuthServerOptions(IAuthenticationService service, IAuthenticationConfiguration configuration) { Provider = new ExoftOAuthServerProvider(service, configuration); }
public void TestInitialise() { _Configuration = Factory.Singleton.ResolveNewInstance <IAuthenticationConfiguration>(); }
private static void AddAuthHeader(WebHeaderCollection nvc, IAuthenticationConfiguration auth) { if (auth is BasicHTTPAuth) { nvc["Authorization"] = auth.GetAuthorization(); } else if (auth is OAuthAuthentication) { } }
/// <summary> /// This method determines which version of the X-EXPERIENCE-API is being used by requesting a single statement /// and reading the versioning header. This allows proper serialization when communicating with the server. /// </summary> /// <returns></returns> private static TCAPIVersion DetermineVersioning(Uri endPoint, IAuthenticationConfiguration authentication, TCAPIVersion version) { WebHeaderCollection whc = GetWebHeaders(endPoint, authentication, version); string versionString = null; versionString = whc["X-Experience-API-Version"]; if (string.IsNullOrEmpty(versionString)) { } else if (versionString.Equals("0.95") || versionString.Equals(".95")) { return TCAPIVersion.TinCan095; } return TCAPIVersion.TinCan090; }
/// <summary> /// Constructs a TCAPI Object, forcibly setting the version. /// </summary> /// <param name="endpoint"></param> /// <param name="authentification"></param> /// <param name="version"></param> /// <remarks>Forcing the version is not recommended and should only be used if an issue with the LRS /// </remarks> public TCAPI(Uri endpoint, IAuthenticationConfiguration authentification, TCAPIVersion version) : this(endpoint, authentification) { this.version = version; }
/// <summary> /// Construct a TCAPI object with asynchronous support. /// </summary> /// <param name="endpoint">The LRS endpoint</param> /// <param name="authentification">Authentification object</param> /// <param name="tcapiCallback">Asynchornous callback object</param> /// <param name="offlineStorage">Offline Storage object</param> /// <param name="statementPostInterval">Interval for asynchronous operations to take place, in milliseconds</param> public TCAPI(Uri endpoint, IAuthenticationConfiguration authentification, ITCAPICallback tcapiCallback, IOfflineStorage offlineStorage, int statementPostInterval, int maxBatchSize) : this(endpoint, authentification, tcapiCallback, offlineStorage, statementPostInterval, maxBatchSize, DetermineVersioning(endpoint, authentification, TCAPIVersion.TinCan090)) { }
/// <summary> /// Construct a TCAPI object with asynchronous support and a default maxBatchSize of 10. /// </summary> /// <param name="endpoint">The LRS endpoint</param> /// <param name="authentification">Authentification object</param> /// <param name="tcapiCallback">Asynchornous callback object</param> /// <param name="offlineStorage">Offline Storage object</param> /// <param name="statementPostInterval">Interval for asynchronous operations to take place, in seconds</param> public TCAPI(Uri endpoint, IAuthenticationConfiguration authentification, ITCAPICallback tcapiCallback, IOfflineStorage offlineStorage, int statementPostInterval) : this(endpoint, authentification, tcapiCallback, offlineStorage, statementPostInterval, 10) { }
public TCAPI(Uri endpoint, IAuthenticationConfiguration authentification, ITCAPICallback tcapiCallback, IOfflineStorage offlineStorage, int statementPostInterval, int maxBatchSize, TCAPIVersion version) : this(endpoint, authentification, tcapiCallback, offlineStorage, statementPostInterval, maxBatchSize) { this.version = version; }
public OwinWebServer() { _WebAppConfiguration = Factory.Resolve <IWebAppConfiguration>(); _AuthenticationConfiguration = Factory.ResolveSingleton <IAuthenticationConfiguration>(); _AccessConfiguration = Factory.ResolveSingleton <IAccessConfiguration>(); }
public JwtService(IAuthenticationConfiguration configuration, ITimeService timeService) { _configuration = configuration; _timeService = timeService; }
public MacStream(Stream binding, bool writing, IAuthenticationConfiguration config, out byte[] output, byte[] key, bool closeOnDispose = true) : this(binding, writing, config, key, closeOnDispose) { output = _output; }
/// <summary> /// Sends a DELETE request /// </summary> /// <param name="deleteData">A name-value pair collection of query parameters</param> /// <returns>The response string</returns> public static string DeleteRequest(NameValueCollection deleteData, string endpoint, IAuthenticationConfiguration authentification, string x_experience_api_version) { string result = null; string end = endpoint + ToQueryString(deleteData); for (int attempt = 0; attempt <= REATTEMPT_COUNT; attempt++) { WebRequest request = WebRequest.Create(endpoint + ToQueryString(deleteData)); request.Method = "DELETE"; AddAuthHeader(request.Headers, authentification); AddExperienceVersionHeader(request.Headers, x_experience_api_version); try { result = SendRequest(request); } catch (InternalServerErrorException e) { if (attempt < REATTEMPT_COUNT) { Thread.Sleep(RETRY_TIMEOUT); continue; } throw e; } catch (ConnectionFailedException e) { if (attempt < REATTEMPT_COUNT) { Thread.Sleep(RETRY_TIMEOUT); continue; } throw e; } catch (WebException e) { ThrowHttpException(e); } break; } return(result); }
private static WebHeaderCollection GetWebHeaders(Uri endPoint, IAuthenticationConfiguration authentication, TCAPIVersion version) { WebHeaderCollection whc; var qo = new StatementQueryObject { Limit = 1 }; NameValueCollection nvc = qo.ToNameValueCollection(version); HttpMethods.GetRequest(nvc, endPoint + STATEMENTS, authentication, out whc, "0.95"); return whc; }
/// <summary> /// Construct a TCAPI object with asynchronous support with a default post interval of 500ms and a default maxBatchSize of 10. /// </summary> /// <param name="endpoint">The LRS endpoint</param> /// <param name="authentification">Authentification object</param> /// <param name="tcapiCallback">Asynchornous callback object</param> /// <param name="offlineStorage">Offline Storage object</param> public TCAPI(Uri endpoint, IAuthenticationConfiguration authentification, ITCAPICallback tcapiCallback, IOfflineStorage offlineStorage) : this(endpoint, authentification, tcapiCallback, offlineStorage, 500, 10) { }
/// <summary> /// Constructs a TCAPI object with no asynchronous support. /// </summary> /// <param name="endpoint">The endpoint for the TCAPI</param> /// <param name="authentification">The authentification object</param> public TCAPI(Uri endpoint, IAuthenticationConfiguration authentification) : this(endpoint, authentification, DetermineVersioning(endpoint, authentification, TCAPIVersion.TinCan090)) { }
/// <summary> /// Construct a TCAPI object with asynchronous support. /// </summary> /// <param name="endpoint">The LRS endpoint</param> /// <param name="authentification">Authentification object</param> /// <param name="tcapiCallback">Asynchornous callback object</param> /// <param name="offlineStorage">Offline Storage object</param> /// <param name="statementPostInterval">Interval for asynchronous operations to take place, in milliseconds</param> public TCAPI(Uri endpoint, IAuthenticationConfiguration authentification, ITCAPICallback tcapiCallback, IOfflineStorage offlineStorage, int statementPostInterval, int maxBatchSize) { this.endpoint = endpoint; this.authentification = authentification; this.tcapiCallback = tcapiCallback; this.offlineStorage = offlineStorage; this.statementPostInterval = statementPostInterval; this.maxBatchSize = maxBatchSize; this.asyncPostCallback = new AsyncPostCallback(this.PostSuccess, this.PostFailed, this.PostConnectionFailed); this.isAsyncFlushing = false; asyncPostTimer = new Timer(); asyncPostTimer.Elapsed += new ElapsedEventHandler(AsyncPostTimerElapsed); asyncPostTimer.Interval = this.statementPostInterval; asyncPostTimer.Enabled = this.statementPostInterval > 0; asyncPostTimer.AutoReset = true; this.version = DetermineVersioning(); }
public CookieProtector(IAuthenticationConfiguration configuration) { _encryption = Encryption.Create(configuration.EncryptionAlgorithm, configuration.EncryptionKey); _validation = Validation.Create(configuration.ValidationAlgorithm, configuration.ValidationKey); }
/// <summary> /// Sends a GET request /// </summary> /// <param name="getData">A name-value pair collection of query parameters</param> /// <param name="whc">Allows for retrieval of the webheaders if they are needed.</param> /// <returns>The response string</returns> public static string GetRequest(NameValueCollection getData, string endpoint, IAuthenticationConfiguration authentification, out WebHeaderCollection whc, string x_experience_api_version) { string result = null; whc = null; if (getData != null) { endpoint += ToQueryString(getData); } for (int attempt = 0; attempt <= REATTEMPT_COUNT; attempt++) { WebRequest request = WebRequest.Create(endpoint); request.Method = "GET"; AddAuthHeader(request.Headers, authentification); AddExperienceVersionHeader(request.Headers, x_experience_api_version); try { result = SendRequest(request, null, out whc); } catch (InternalServerErrorException e) { if (attempt < REATTEMPT_COUNT) { Thread.Sleep(RETRY_TIMEOUT); continue; } throw e; } catch (ConnectionFailedException e) { if (attempt < REATTEMPT_COUNT) { Thread.Sleep(RETRY_TIMEOUT); continue; } throw e; } catch (WebException e) { ThrowHttpException(e); } break; } return(result); }
/// <summary> /// Sends a PUT request /// </summary> /// <param name="putData">The data to PUT to the server</param> /// <param name="queryParameters">A name-value pair collection of query parameters</param> /// <param name="headers">Additional headers</param> /// <returns>The response string</returns> public static string PutRequest(string putData, NameValueCollection queryParameters, string endpoint, IAuthenticationConfiguration authentification, string contentType, string x_experience_api_version) { return PutRequest(putData, queryParameters, endpoint, authentification, contentType, string.Empty, x_experience_api_version); }
/// <summary> /// Sends a PUT request /// </summary> /// <param name="putData">The data to PUT to the server</param> /// <param name="queryParameters">A name-value pair collection of query parameters</param> /// <param name="headers">Additional headers</param> /// <returns>The response string</returns> public static string PutRequest(string putData, NameValueCollection queryParameters, string endpoint, IAuthenticationConfiguration authentification, string contentType, string eTag, string x_experience_api_version) { string result = null; if (queryParameters != null) endpoint += ToQueryString(queryParameters); for (int attempt = 0; attempt < REATTEMPT_COUNT; attempt++) { HttpWebRequest request = (HttpWebRequest)WebRequest.Create(endpoint); byte[] putDataByteArray = Encoding.UTF8.GetBytes(putData); request.Method = "PUT"; request.ContentType = contentType; request.ContentLength = putDataByteArray.Length; AddExperienceVersionHeader(request.Headers, x_experience_api_version); if (!String.IsNullOrEmpty(eTag)) request.Headers["If-Match"] = "\"" + eTag + "\""; AddAuthHeader(request.Headers, authentification); try { result = SendRequest(request, putDataByteArray); } catch (InternalServerErrorException e) { if (attempt < REATTEMPT_COUNT) { Thread.Sleep(RETRY_TIMEOUT); continue; } throw e; } catch (ConnectionFailedException e) { if (attempt < REATTEMPT_COUNT) { Thread.Sleep(RETRY_TIMEOUT); continue; } throw e; } catch (WebException e) { ThrowHttpException(e); } break; } return result; }
private async Task <IResponse> ValidateAcademicBenchmarkApiAuthConfiguration(IAuthenticationConfiguration abConfig) { return(await _learningStandardsPlugin.LearningStandardsConfigurationValidator .ValidateLearningStandardProviderConfigurationAsync(abConfig)); }
/// <summary> /// Gets a validation function that returns the output of a configured verification method. /// Input: <c>tag || salt || AD || message</c> /// </summary> /// <returns>Callable validation function.</returns> /// <param name="keyConfirmation">Key confirmation configuration defining validation method to be employed.</param> /// <param name="tag"></param> /// <param name="message"></param> /// <param name="outputSizeBytes">Expected length of output of verification function in bytes.</param> /// <exception cref="ConfigurationInvalidException"> /// Some aspect of configuration invalid - detailed inside exception message. /// </exception> internal static Func <byte[], byte[]> GetValidator(IAuthenticationConfiguration keyConfirmation, byte[] tag, byte[] message, int?outputSizeBytes = null) { AuthenticationFunctionType functionType = keyConfirmation.FunctionType; if (functionType == AuthenticationFunctionType.None) { throw new ConfigurationInvalidException("Authentication function type cannot be None."); } if (String.IsNullOrEmpty(keyConfirmation.FunctionName)) { throw new ConfigurationInvalidException("Authentication function name cannot be null or empty."); } const string lengthIncompatibleString = "Expected length incompatible with function specified."; Func <byte[], byte[]> validator; // Used as an adaptor between different validation methods switch (functionType) { case AuthenticationFunctionType.Kdf: { if (outputSizeBytes == null) { throw new ArgumentNullException("outputSizeBytes", "Cannot be null if KDF is being used."); } KeyDerivationFunction kdfEnum; try { kdfEnum = keyConfirmation.FunctionName.ToEnum <KeyDerivationFunction>(); } catch (EnumerationParsingException ex) { throw new ConfigurationInvalidException("Key derivation function is unsupported/unknown.", ex); } validator = key => { int superSaltSize = keyConfirmation.Salt.Length + (keyConfirmation.AdditionalData != null ? keyConfirmation.AdditionalData.Length : 0) + (tag != null ? tag.Length : 0) + (message != null ? message.Length : 0); var superSalt = new byte[superSaltSize]; tag.DeepCopy_NoChecks(0, superSalt, 0, tag.Length); int index = tag.Length; // Compose the rest of the input to the KDF (as a super-salt) if (keyConfirmation.Salt.IsNullOrZeroLength() == false) { keyConfirmation.Salt.DeepCopy_NoChecks(0, superSalt, index, keyConfirmation.Salt.Length); index += keyConfirmation.Salt.Length; } if (keyConfirmation.AdditionalData.IsNullOrZeroLength() == false) { keyConfirmation.AdditionalData.DeepCopy_NoChecks(0, superSalt, index, keyConfirmation.AdditionalData.Length); index += keyConfirmation.AdditionalData.Length; } if (message.IsNullOrZeroLength() == false) { message.DeepCopy_NoChecks(0, superSalt, index, message.Length); } return(KdfFactory.DeriveKeyWithKdf(kdfEnum, key, superSalt, outputSizeBytes.Value, keyConfirmation.FunctionConfiguration)); }; break; } case AuthenticationFunctionType.Mac: MacFunction macFEnum; try { macFEnum = keyConfirmation.FunctionName.ToEnum <MacFunction>(); } catch (EnumerationParsingException ex) { throw new ConfigurationInvalidException("MAC function is unsupported/unknown.", ex); } validator = key => { IMac macF = AuthenticatorFactory.CreateMacPrimitive(macFEnum, key, tag, keyConfirmation.FunctionConfiguration, keyConfirmation.Nonce); if (outputSizeBytes != null && outputSizeBytes != macF.OutputSize) { throw new ArgumentException(lengthIncompatibleString, "outputSizeBytes"); } if (keyConfirmation.Salt.IsNullOrZeroLength() == false) { macF.BlockUpdate(keyConfirmation.Salt, 0, keyConfirmation.Salt.Length); } if (keyConfirmation.AdditionalData.IsNullOrZeroLength() == false) { macF.BlockUpdate(keyConfirmation.AdditionalData, 0, keyConfirmation.AdditionalData.Length); } if (message.IsNullOrZeroLength() == false) { macF.BlockUpdate(message, 0, message.Length); } var output = new byte[macF.OutputSize]; macF.DoFinal(output, 0); return(output); }; break; default: throw new NotSupportedException("Function type not supported for key confirmation."); } return(validator); }
public static AuthorizationOptions SetPolicies(this AuthorizationOptions options, IAuthenticationConfiguration configuration) { var policiesInConfig = configuration.Policies; if (policiesInConfig != null) { foreach (var policyName in policiesInConfig) { options.AddPolicy(policyName, policy => policy.Requirements.Add(new HasScopeRequirement(policyName, configuration.Domain))); } } return(options); }
/// <summary> /// Creates a new object. /// </summary> public BasicAuthenticationFilter() { _SharedConfiguration = Factory.ResolveSingleton <ISharedConfiguration>(); _AuthenticationConfiguration = Factory.ResolveSingleton <IAuthenticationConfiguration>(); _BasicAuthentication = new BasicAuthenticationHelper(); }
/// <summary> /// Sends a POST request /// </summary> /// <param name="postData">A string of data to post</param> /// <param name="authentification">An IAuthentificationConfiguration. Only Basic is currently supported.</param> /// <param name="endpoint">The endpoint to send the statement to</param> /// <returns>A response string</returns> public static string PostRequest(string postData, string endpoint, IAuthenticationConfiguration authentification, string x_experience_api_version) { return PostRequest(postData, endpoint, authentification, null, x_experience_api_version); }
public AccountController(IAuthenticationConfiguration configuration) { this._configuration = configuration; }
/// <summary> /// Sends a POST request. /// </summary> /// <param name="postData">A string of data to post</param> /// <param name="authentification">An IAuthentificationConfiguration. Only Basic is currently supported.</param> /// <param name="endpoint">The endpoint to send the statement to</param> /// <param name="callback">The asynchronous callback</param> /// <returns>The returned stream</returns> /// <remarks>Providing null for the callback means this is intended to be synchronous. Any exceptions will be thrown and must be handled in the main thread.</remarks> public static string PostRequest(string postData, string endpoint, IAuthenticationConfiguration authentification, TCAPI.AsyncPostCallback callback, string x_experience_api_version) { string result = null; byte[] postDataByteArray = Encoding.UTF8.GetBytes(postData); for (int attempt = 0; attempt <= REATTEMPT_COUNT; attempt++) { WebRequest request = (HttpWebRequest)WebRequest.Create(endpoint); request.Method = "POST"; request.ContentType = "application/json"; request.ContentLength = postDataByteArray.Length; AddExperienceVersionHeader(request.Headers, x_experience_api_version); AddAuthHeader(request.Headers, authentification); try { result = SendRequest(request, postDataByteArray); } catch (WebException e) { if (attempt < REATTEMPT_COUNT) { try { ThrowHttpException(e); } catch (InternalServerErrorException) { Thread.Sleep(RETRY_TIMEOUT); continue; } catch (ConnectionFailedException) { Thread.Sleep(RETRY_TIMEOUT); continue; } catch (Exception) { // Suppress it for now } } if (callback == null) { // Synchronous request, let the implementer decide throw e; } else { try { ThrowHttpException(e); } catch (InternalServerErrorException) { // Connectivity Issues callback.AsyncPostConnectionFailed(e); } catch (ConnectionFailedException) { // Connectivity Issues callback.AsyncPostConnectionFailed(e); } catch (Exception) { // Permanent failure callback.AsyncPostFailure(e); } } } break; } return result; }
/// <summary> /// Initializes a new instance of the <see cref="JwtTokenGenerator"/> class. /// </summary> /// <param name="configuration">The configuration.</param> public JwtTokenGenerator(IAuthenticationConfiguration configuration) { this.configuration = configuration; }
public AccountController(IAuthenticationConfiguration configuration) { this._configuration = configuration; }