Ejemplo n.º 1
0
        public static void ConfigureAppEndpoints(
            [NotNull] this IGlobalConfiguration configuration,
            IConfiguration config)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            var sections = config.GetSection("AccessData:AppEndpoints");

            foreach (var section in sections.GetChildren())
            {
                var options = new AppEndpointOptions()
                {
                    Login        = config[$"{section.Path}:Login"],
                    Password     = config[$"{section.Path}:Password"],
                    Schema       = config[$"{section.Path}:Schema"],
                    ServerName   = config[$"{section.Path}:ServerName"],
                    PathOnServer = config[$"{section.Path}:PathOnServer"]
                };

                AppEndpointHost.Add(config[$"{section.Path}:Name"],
                                    new AppEndpoint(options));
            }
        }
Ejemplo n.º 2
0
        public AppEndpoint(AppEndpointOptions options)
        {
            _options = options;

            var credentials = $"{_options.Login}:{_options.Password}";
            var bytes       = Encoding.ASCII.GetBytes(credentials);

            _authenticationHeader = new AuthenticationHeaderValue("Basic",
                                                                  Convert.ToBase64String(bytes));

            _stringURI = $"{_options.Schema}://{_options.ServerName}/{_options.PathOnServer}";
        }