Example #1
0
        /// <summary>
        /// Uses file system as a db of crawled uris. Creates directories to represent a url crawled. This prevents OutOfMemoryException
        /// by storing crawled uris to disk instead of holding them all in memory. This class should only be used when you expect a crawler
        /// to encounter hundreds of thousands of links during a single crawl. Otherwise use the InMemoryCrawledUrlRepository
        /// </summary>
        /// <param name="hashGenerator">Generates hashes from uris to be used as directory names</param>
        /// <param name="uriDbDirectory">Directory to use as the parent. Will create directories to represent crawled uris in this directory.</param>
        /// <param name="deleteUriDbDirectoryOnDispose">Whether the uriDbDirectory should be deleted after the crawl completes</param>
        public OnDiskCrawledUrlRepository(IHashGenerator hashGenerator, DirectoryInfo uriDbDirectory = null, bool deleteUriDbDirectoryOnDispose = false)
        {
            _hashGenerator = hashGenerator ?? new Murmur3HashGenerator();

            if (uriDbDirectory == null)
            {
                _uriDbDirectory = new DirectoryInfo("UriDb");
            }
            else
            {
                _uriDbDirectory = uriDbDirectory;
            }

            if (_uriDbDirectory.Exists)
            {
                _logger.WarnFormat("The directory [{0}] already exists and will be reused as the disk crawled url db. Any urls already stored there will not be recrawled", _uriDbDirectory.FullName);
            }
            else
            {
                _logger.InfoFormat("Creating directory [{0}] and will use as the on disk crawled url db", _uriDbDirectory.FullName);
                _uriDbDirectory.Create();
            }

            _deleteUriDbOnDispose = deleteUriDbDirectoryOnDispose;

            _cancellationToken = new CancellationTokenSource();
            Task.Factory.StartNew(() => WriteUrisToDisk(), _cancellationToken.Token);
        }
Example #2
0
 public ConsistentHashDistributionStrategy(IHashGenerator hashGenerator, HashKeyProvider<T> keyProvider, byte replicate = DefaultReplicationCount)
 {
     _hashGenerator = hashGenerator;
     _keyProvider = keyProvider;
     _replicate = replicate;
     _keyCache = RebuildKeyCache();
 }
 public UserTokenGenerator(IDatabase database, IReadOnlyAccountManager accountManager,
                           IHashGenerator hashGenerator)
 {
     this.database       = database;
     this.accountManager = accountManager;
     this.hashGenerator  = hashGenerator;
 }
 public AuthenticationManager(
     IAuthenticationService authenticationService,
     IHashGenerator hashGenerator)
 {
     this.authenticationService = authenticationService;
     this.hashGenerator         = hashGenerator;
 }
Example #5
0
 /// <summary>
 /// Create a new bucket collection
 /// </summary>
 /// <param name="size">the number of buckets</param>
 /// <param name="hash">the hashing implementation</param>
 /// <param name="comparer">the equality comparer implementation</param>
 public MultiItemBucketCollection(int size, IHashGenerator hash, IKeyEqualityComparer comparer)
 {
     this.Capacity = size;
     this.hash     = hash;
     this.comparer = comparer;
     Clear();
 }
 public AppQueryExecutorDecorator(string login, string password, IHashGenerator hashGenerator, IQueryExecutor executor)
 {
     _login         = login;
     _password      = password;
     _hashGenerator = hashGenerator;
     _executor      = executor;
 }
Example #7
0
 public AuthService(IDatabase database, IRolesService rolesService, IJwtAuthorizationTokenGenerator jwtAuthorizationTokenGenerator, IHashGenerator hashGenerator)
 {
     this.database     = database;
     this.rolesService = rolesService;
     this.jwtAuthorizationTokenGenerator = jwtAuthorizationTokenGenerator;
     this.hashGenerator = hashGenerator;
 }
Example #8
0
 public DuplicatedSortedTree(IComparer <T> comparer, IHashGenerator <T> hashGenerator = null)
 {
     _comparer      = comparer;
     _set           = new SortedSet <T>(_comparer);
     _hashGenerator = hashGenerator;
     _counter       = new Dictionary <T, List <T> >(new EqualityComparer(_comparer, hashGenerator));
 }
 public UserManager(
     IUserService userService,
     IHashGenerator hashGenerator)
 {
     this.userService   = userService;
     this.hashGenerator = hashGenerator;
 }
Example #10
0
        public CacheRedis(
            IRedisConfig config,
            IHashGenerator hashGenerator,
            ISerializer serializer,
            ILogger logger)
        {
            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }
            if (hashGenerator == null)
            {
                throw new ArgumentNullException(nameof(hashGenerator));
            }
            if (serializer == null)
            {
                throw new ArgumentNullException(nameof(serializer));
            }
            if (logger == null)
            {
                throw new ArgumentNullException(nameof(logger));
            }

            this._hashGenerator = hashGenerator;
            this._logger        = logger;
            this._serializer    = serializer;
            this._config        = config;
        }
Example #11
0
 public ProfileService(IDatabase database, IFilesManager filesManager, IHttpContextReader httpContextReader,
                       IHashGenerator hashGenerator)
 {
     this.database          = database;
     this.filesManager      = filesManager;
     this.httpContextReader = httpContextReader;
     this.hashGenerator     = hashGenerator;
 }
Example #12
0
 public AccountManager(IDatabase database, IHashGenerator hashGenerator, IReadOnlyUserService userService,
                       IHttpContextReader httpContextReader)
 {
     this.database          = database;
     this.hashGenerator     = hashGenerator;
     this.userService       = userService;
     this.httpContextReader = httpContextReader;
 }
Example #13
0
 public TokenController(IHashGenerator hashGenerator,
                        ICustomJwtTokenProvider customJwtTokenProvider,
                        KinlyConfiguration kinlyConfiguration)
 {
     _hashGenerator          = hashGenerator;
     _customJwtTokenProvider = customJwtTokenProvider;
     _kinlyConfiguration     = kinlyConfiguration;
 }
 /// <summary>
 /// Create a new bucket collection
 /// </summary>
 /// <param name="size">the number of buckets</param>
 /// <param name="hash">the hashing implementation</param>
 /// <param name="comparer">the equality comparer implementation</param>
 public SingleItemBucketCollection(int size, float load, IHashGenerator hash, IKeyEqualityComparer comparer)
 {
     LoadFactor    = load;
     Capacity      = size;
     this.hash     = hash;
     this.comparer = comparer;
     Clear();
 }
Example #15
0
 public UserService(
     IValidator<UserCredentials> credentialValidator, 
     IHashGenerator hashGenerator,
     IUserRepository userRepository)
 {
     _credentialValidator = credentialValidator;
     _hashGenerator = hashGenerator;
     _userRepository = userRepository;
 }
 public AuthentificationController(IRepository repository, ICustomLogger logger,
                                   IHashGenerator hashGenerator, IUserIdentityProvider userIdentityProvider, IJWTProvider jWTProvider)
 {
     this.repository           = repository ?? throw new ArgumentNullException(nameof(repository));
     this.logger               = logger ?? throw new ArgumentNullException(nameof(logger));
     this.hashGenerator        = hashGenerator ?? throw new ArgumentNullException(nameof(hashGenerator));
     this.userIdentityProvider = userIdentityProvider ?? throw new ArgumentNullException(nameof(userIdentityProvider));
     this.jWTProvider          = jWTProvider ?? throw new ArgumentNullException(nameof(jWTProvider));
 }
 public AccountService(
     IAccountRepository accountRepository,
     IHashGenerator hashGenerator,
     IJwtGenerator jwtGenerator)
 {
     AccountRepository = accountRepository;
     HashGenerator     = hashGenerator;
     JwtGenerator      = jwtGenerator;
 }
Example #18
0
 protected KeyHashGenerator(IHashGenerator crypto)
 {
     if (crypto == null)
     {
         throw new ArgumentNullException("crypto");
     }
     this._key    = null;
     this._crypto = crypto;
 }
Example #19
0
 public UserController(ISessionProvider sessionProvider, IHashGenerator hashGenerator, IUserManager userManager, IUserProvider userProvider,
                       IRegionProvider regionProvider, IMapper mapper)
 {
     _sessionProvider = sessionProvider;
     _hashGenerator   = hashGenerator;
     _userManager     = userManager;
     _userProvider    = userProvider;
     _regionProvider  = regionProvider;
     _mapper          = mapper;
 }
Example #20
0
        public Partitioner(int partitionCount, IHashGenerator hashGenerator)
        {
            _id = NewId.NextGuid().ToString("N");

            _partitionCount = partitionCount;
            _hashGenerator  = hashGenerator;
            _partitions     = Enumerable.Range(0, partitionCount)
                              .Select(index => new Partition(index))
                              .ToArray();
        }
 public IndexModel(
     IAuthorizationRequestValidator validator,
     IDatabaseContext context,
     IPublicApiAccessTokenGenerator <TokenResult> tokenGenerator,
     IHashGenerator hashGenerator)
 {
     _validator      = validator;
     _context        = context;
     _tokenGenerator = tokenGenerator;
     _hashGenerator  = hashGenerator;
 }
            public InsecureManager(CryptManager cryptManager)
            {
                this.cryptManager = cryptManager;

                md5HashGenerator =
                    new Implementations.Hash.Insecure.MD5HashAdapter();

                symmetricRC4CryptGenerator =

                    new Implementations.Crypt.Insecure.RC4Adapter();
            }
        private string ToGuidToBase64(string data, IHashGenerator hashGenerator)
        {
            #if DEBUG
            if (data.IsEmpty())
            {
                throw new ArgumentNullException("data");
            }
            #endif

            return(EncodeBase64(data.IsEmpty()? Guid.Empty: ToGuid(data, hashGenerator)));
        }
        private static Guid ToGuidUsingDefaultEncoding(string text, IHashGenerator hashGenerator)
        {
            #if DEBUG
            if (text.IsEmpty())
            {
                throw new ArgumentNullException("text");
            }
            #endif

            return(text.IsEmpty()? Guid.Empty: ToGuid(EncodeDefault(text), hashGenerator));
        }
        private static Guid ToGuidWithSaltAndUTF16(string data, string salt, IHashGenerator hashGenerator)
        {
            #if DEBUG
            if (data.IsEmpty())
            {
                throw new ArgumentNullException("data");
            }
            #endif

            return(data.IsEmpty()? Guid.Empty: ToGuid(EncodeUTF16(data + salt), hashGenerator));
        }
        public void When_HashGenerator_Is_Null_Then_Constructor_Throws_ArgumentNullException()
        {
            // set up
            IHashGenerator hashGenerator = null;

            // execute
            var ex = Assert.Throws <ArgumentNullException>(() => new TokenGenerator(hashGenerator, _dateTimeProvider.Object));

            // verify
            Assert.Equal("hashGenerator", ex.ParamName);
        }
Example #27
0
 public UsersController(ITokenProvider tokenProvider,
                        IUserRepository userRepository,
                        IMapper mapper,
                        IHashGenerator hashGenerator,
                        ILogger <UsersController> logger)
 {
     this.tokenProvider  = tokenProvider;
     this.userRepository = userRepository;
     this.mapper         = mapper;
     this.hashGenerator  = hashGenerator;
     this.logger         = logger;
 }
Example #28
0
 public UserLoginQueryHandler(
     IDatabaseContext context,
     IHashGenerator hashGenerator,
     IJwtTokenGenerator tokenGenerator,
     IPlaceHolderImageProvider placeHolderImageProvider
     )
 {
     _context                  = context;
     _hashGenerator            = hashGenerator;
     _tokenGenerator           = tokenGenerator;
     _placeHolderImageProvider = placeHolderImageProvider;
 }
Example #29
0
 public PackageUploader(IStorageUploader storageUploader,
                        IPackageValidator packageValidator,
                        IHashGenerator hashGenerator,
                        IOptions <AccessOptions> accessOptions,
                        IOptions <PackageOptions> packageOptions)
 {
     _storageUploader  = storageUploader;
     _packageValidator = packageValidator;
     _hashGenerator    = hashGenerator;
     _accessOptions    = accessOptions;
     _packageOptions   = packageOptions;
 }
 public RegisterService(
     IUserRepository repository,
     IRegexValidator regexValidator,
     IHashGenerator hashGenerator,
     IMessageQueuePublisher messageQueuePublisher
     )
 {
     _repository            = repository;
     _regexValidator        = regexValidator;
     _hashGenerator         = hashGenerator;
     _messageQueuePublisher = messageQueuePublisher;
 }
 public UserRegisterCommandHandler(
     IUserRepository userRepository,
     IHashGenerator hashGenerator,
     IJwtTokenGenerator tokenGenerator,
     IPlaceHolderImageProvider placeholderImageProvider,
     IUnitOfWork unitOfWork
     )
 {
     _userRepository           = userRepository;
     _hashGenerator            = hashGenerator;
     _tokenGenerator           = tokenGenerator;
     _placeholderImageProvider = placeholderImageProvider;
     _unitOfWork = unitOfWork;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ManagedHashPartitionResolver" /> class.
 /// </summary>
 /// <param name="partitionKeyExtractor">The partition key extractor function.</param>
 /// <param name="client">The DocumentDB client instance.</param>
 /// <param name="database">The database to use.</param>
 /// <param name="numberOfCollections">the number of collections.</param>
 /// <param name="hashGenerator">the hash generator.</param>
 /// <param name="collectionSpec">the specification/template to create collections from.</param>
 /// <param name="collectionIdPrefix">the prefix to use for collections.</param>
 public ManagedHashPartitionResolver(
     Func<object, string> partitionKeyExtractor,
     DocumentClient client,
     Database database,
     int numberOfCollections,
     IHashGenerator hashGenerator = null,
     DocumentCollectionSpec collectionSpec = null,
     string collectionIdPrefix = "ManagedHashCollection.")
     : base(partitionKeyExtractor,
     GetCollections(client, database, numberOfCollections, collectionIdPrefix, collectionSpec),
     128,
     hashGenerator)
 {
     this.DocumentCollectionSpec = collectionSpec;
 }
        /// <summary>
        /// Uses file system as a db of crawled uris. Creates directories to represent a url crawled. This prevents OutOfMemoryException
        /// by storing crawled uris to disk instead of holding them all in memory. This class should only be used when you expect a crawler
        /// to encounter hundreds of thousands of links during a single crawl. Otherwise use the InMemoryCrawledUrlRepository
        /// </summary>
        /// <param name="hashGenerator">Generates hashes from uris to be used as directory names</param>
        /// <param name="uriDbDirectory">Directory to use as the parent. Will create directories to represent crawled uris in this directory.</param>
        /// <param name="deleteUriDbDirectoryOnDispose">Whether the uriDbDirectory should be deleted after the crawl completes</param>
        public OnDiskCrawledUrlRepository(IHashGenerator hashGenerator, DirectoryInfo uriDbDirectory = null, bool deleteUriDbDirectoryOnDispose = false)
        {
            _hashGenerator = hashGenerator ?? new Murmur3HashGenerator();

            if (uriDbDirectory == null)
                _uriDbDirectory = new DirectoryInfo("UriDb");
            else
                _uriDbDirectory = uriDbDirectory;

            if (_uriDbDirectory.Exists)
            {
                _logger.WarnFormat("The directory [{0}] already exists and will be reused as the disk crawled url db. Any urls already stored there will not be recrawled", _uriDbDirectory.FullName);
            }
            else
            {
                _logger.InfoFormat("Creating directory [{0}] and will use as the on disk crawled url db", _uriDbDirectory.FullName);
                _uriDbDirectory.Create();
            }

            _deleteUriDbOnDispose = deleteUriDbDirectoryOnDispose;

            _cancellationToken = new CancellationTokenSource();
            Task.Factory.StartNew(() => WriteUrisToDisk(), _cancellationToken.Token);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="MembershipService"/> class.
        /// </summary>
        /// <param name="unitOfWork">
        /// The unit of work.
        /// </param>
        /// <param name="userValidator">
        /// The user validator.
        /// </param>
        /// <param name="roleValidator">
        /// The role validator.
        /// </param>
        /// <param name="profileValidator">
        /// The profile validator.
        /// </param>
        /// <param name="accessRightValidator">
        /// The access right validator.
        /// </param>
        /// <param name="hashGenerator">
        /// The hash generator.
        /// </param>
        public MembershipService(
            IUnitOfWork unitOfWork, 
            IEntityValidator<User> userValidator, 
            IEntityValidator<Role> roleValidator, 
            IEntityValidator<Profile> profileValidator, 
            IHashGenerator hashGenerator)
            : base(unitOfWork)
        {
            this._userValidator = userValidator;
            this._roleValidator = roleValidator;
            this._profileValidator = profileValidator;
            this._hashGenerator = hashGenerator;

            this._userRepository = this.UnitOfWork.Repository<User, int>() as IUserRepository;
            this._profileRepository =
                this.UnitOfWork.Repository<Profile, int>() as IProfileRepository;
            this._roleRepository = this.UnitOfWork.Repository<Role, int>();
        }
 public ContentSignatureGenerator(IHashGenerator hashGenerator)
 {
     this.hashGenerator = hashGenerator;
 }
Example #36
0
 public PasswordHasher(IHashGenerator hashGenerator)
 {
     Contract.Requires(hashGenerator != null);
     Contract.Ensures(_hashGenerator != null);
     _hashGenerator = hashGenerator;
 }
 public UserAccountMapper(IHashGenerator hashGenerator)
 {
     this._hashGenerator = hashGenerator;
 }
Example #38
0
 public void Setup()
 {
     _unitUnderTest = GetInstance();
 }
 /// <summary>
 /// Creates an authorizer.
 /// </summary>
 /// <param name="privateKeyProvider">Private key provider.</param>
 /// <param name="hashGenerator">Hash generator.</param>
 public PrivateKeyQueryAuthorizer(IPrivateKeyProvider privateKeyProvider, IHashGenerator hashGenerator)
 {
     _privateKeyProvider = privateKeyProvider;
     _hashGenerator = hashGenerator;
 }