Beispiel #1
0
        public DefaultRequestHandler(IOptions <S3Config> options, IValidatorFactory validator, IMarshalFactory marshaller, IPostMapperFactory postMapper, INetworkDriver networkDriver, HeaderAuthorizationBuilder authBuilder, ILogger <DefaultRequestHandler> logger, IEnumerable <IRequestStreamWrapper>?requestStreamWrappers = null)
        {
            Validator.RequireNotNull(options, nameof(options));
            Validator.RequireNotNull(validator, nameof(validator));
            Validator.RequireNotNull(marshaller, nameof(marshaller));
            Validator.RequireNotNull(networkDriver, nameof(networkDriver));
            Validator.RequireNotNull(authBuilder, nameof(authBuilder));
            Validator.RequireNotNull(logger, nameof(logger));

            validator.ValidateAndThrow(options.Value);

            _validator     = validator;
            _options       = options;
            _networkDriver = networkDriver;
            _authBuilder   = authBuilder;
            _marshaller    = marshaller;
            _postMapper    = postMapper;
            _logger        = logger;

            if (requestStreamWrappers == null)
            {
                _requestStreamWrappers = Array.Empty <IRequestStreamWrapper>();
            }
            else
            {
                _requestStreamWrappers = requestStreamWrappers.ToList();
            }
        }
Beispiel #2
0
        private void Initialize(IOptions <S3Config> options, INetworkDriver networkDriver, ILoggerFactory loggerFactory)
        {
            Assembly assembly = typeof(S3Config).Assembly;

            SimpleServiceProvider provider = new SimpleServiceProvider(new Tuple <Type, object>(typeof(IOptions <S3Config>), options));

            IEnumerable <IValidator>       validators       = CreateInstances <IValidator>(assembly, provider);
            IEnumerable <IRequestMarshal>  requestMarshals  = CreateInstances <IRequestMarshal>(assembly, provider);
            IEnumerable <IResponseMarshal> responseMarshals = CreateInstances <IResponseMarshal>(assembly, provider);

            ValidatorFactory      validatorFactory     = new ValidatorFactory(validators);
            IMarshalFactory       marshalFactory       = new MarshalFactory(requestMarshals, responseMarshals);
            IScopeBuilder         scopeBuilder         = new ScopeBuilder(options);
            ISigningKeyBuilder    signingKeyBuilder    = new SigningKeyBuilder(options, loggerFactory.CreateLogger <SigningKeyBuilder>());
            ISignatureBuilder     signatureBuilder     = new SignatureBuilder(signingKeyBuilder, scopeBuilder, loggerFactory.CreateLogger <SignatureBuilder>(), options);
            IAuthorizationBuilder authorizationBuilder = new AuthorizationHeaderBuilder(options, scopeBuilder, signatureBuilder, loggerFactory.CreateLogger <AuthorizationHeaderBuilder>());
            DefaultRequestHandler requestHandler       = new DefaultRequestHandler(options, validatorFactory, marshalFactory, networkDriver, authorizationBuilder, Enumerable.Empty <IRequestStreamWrapper>(), loggerFactory.CreateLogger <DefaultRequestHandler>());

            ObjectOperations objectOperations = new ObjectOperations(requestHandler, Enumerable.Empty <IRequestWrapper>(), Enumerable.Empty <IResponseWrapper>());

            _objectClient = new S3ObjectClient(objectOperations);

            BucketOperations bucketOperations = new BucketOperations(requestHandler);

            _bucketClient = new S3BucketClient(bucketOperations);

            MultipartOperations multipartOperations = new MultipartOperations(requestHandler, Enumerable.Empty <IRequestWrapper>(), Enumerable.Empty <IResponseWrapper>());

            _multipartClient = new S3MultipartClient(multipartOperations, objectOperations);

            Transfer = new Transfer(objectOperations, multipartOperations);
        }
        public static SessionState GetNewSession(SessionTypes sessionType)
        {
            var maxOccupany = ConfigManager.GetValue <UInt32>("MaxOccupany", 100).Value;
            var maxUserID   = ConfigManager.GetValue <UInt32>("MaxUserID", 9999).Value;
            var userID      = (UInt32)0;
            var loops       = 0;

            if (sessionStates.Count >= maxOccupany)
            {
                return(null); // Server Full!
            }

            do
            {
                userID = ServerState.lastIssuedUserID = ((ServerState.lastIssuedUserID + 1) % maxUserID);

                if (userID == 0)
                {
                    loops++;
                }
                if (loops > 1)
                {
                    return(null);           // Server Full!
                }
            } while (userID == 0 || sessionStates.ContainsKey(userID));

            INetworkDriver driver = null;

            switch (sessionType)
            {
            case SessionTypes.TcpSocket:
                driver = new PalaceSocketDriver();

                break;
            //case SessionTypes.ProxySocket:
            //    driver = new ProxySocketDriver();

            //    break;
            case SessionTypes.WebSocket:
                driver = new WebSocketDriver();

                break;
            }

            lock (sessionStates)
            {
                sessionStates.TryAdd(userID, new SessionState
                {
                    UserID = userID,
                    driver = driver,
                });
            }

            return(sessionStates[userID]);
        }
Beispiel #4
0
        public DefaultRequestHandler(IOptions <S3Config> options, IValidatorFactory validator, IMarshalFactory marshaller, INetworkDriver networkDriver, IAuthorizationBuilder authBuilder, IEnumerable <IRequestStreamWrapper> requestStreamWrappers, ILogger <DefaultRequestHandler> logger)
        {
            Validator.RequireNotNull(options);
            Validator.RequireNotNull(validator);
            Validator.RequireNotNull(marshaller);
            Validator.RequireNotNull(networkDriver);
            Validator.RequireNotNull(authBuilder);
            Validator.RequireNotNull(requestStreamWrappers);
            Validator.RequireNotNull(logger);

            validator.ValidateAndThrow(options.Value);

            _validator             = validator;
            _options               = options;
            _networkDriver         = networkDriver;
            _authBuilder           = authBuilder;
            _marshaller            = marshaller;
            _requestStreamWrappers = requestStreamWrappers.ToList();
            _logger = logger;
        }
Beispiel #5
0
 public AmazonS3Client(AmazonS3Config config, INetworkDriver networkDriver) : base(new AmazonS3InputValidator(), config, networkDriver)
 {
 }
Beispiel #6
0
 public S3Client(IOptions <S3Config> options, INetworkDriver networkDriver, ILoggerFactory loggerFactory)
 {
     Initialize(options, networkDriver, loggerFactory);
 }
 public GoogleCloudStorageClient(GoogleCloudStorageConfig config, INetworkDriver networkDriver)
     : base(new GoogleCloudStorageInputValidator(), config, networkDriver)
 {
 }
Beispiel #8
0
 public WasabiClient(WasabiConfig config, INetworkDriver networkDriver) : base(new WasabiInputValidator(), config, networkDriver)
 {
 }
Beispiel #9
0
    protected internal ClientBase(IInputValidator inputValidator, SimpleS3Config config, INetworkDriver networkDriver)
    {
        ServiceCollection services = new ServiceCollection();

        services.AddSingleton(inputValidator);
        services.AddLogging();

        SimpleS3CoreServices.AddSimpleS3Core(services);

        services.AddSingleton(networkDriver);
        services.AddSingleton(Options.Create(config));

        Build(services);
    }
Beispiel #10
0
 public BackBlazeB2Client(BackBlazeB2Config config, INetworkDriver networkDriver) : base(new BackblazeB2InputValidator(), config, networkDriver)
 {
 }