コード例 #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);
        }
コード例 #2
0
 public ConsistentHashDistributionStrategy(IHashGenerator hashGenerator, HashKeyProvider<T> keyProvider, byte replicate = DefaultReplicationCount)
 {
     _hashGenerator = hashGenerator;
     _keyProvider = keyProvider;
     _replicate = replicate;
     _keyCache = RebuildKeyCache();
 }
コード例 #3
0
 public UserTokenGenerator(IDatabase database, IReadOnlyAccountManager accountManager,
                           IHashGenerator hashGenerator)
 {
     this.database       = database;
     this.accountManager = accountManager;
     this.hashGenerator  = hashGenerator;
 }
コード例 #4
0
 public AuthenticationManager(
     IAuthenticationService authenticationService,
     IHashGenerator hashGenerator)
 {
     this.authenticationService = authenticationService;
     this.hashGenerator         = hashGenerator;
 }
コード例 #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();
 }
コード例 #6
0
 public AppQueryExecutorDecorator(string login, string password, IHashGenerator hashGenerator, IQueryExecutor executor)
 {
     _login         = login;
     _password      = password;
     _hashGenerator = hashGenerator;
     _executor      = executor;
 }
コード例 #7
0
 public AuthService(IDatabase database, IRolesService rolesService, IJwtAuthorizationTokenGenerator jwtAuthorizationTokenGenerator, IHashGenerator hashGenerator)
 {
     this.database     = database;
     this.rolesService = rolesService;
     this.jwtAuthorizationTokenGenerator = jwtAuthorizationTokenGenerator;
     this.hashGenerator = hashGenerator;
 }
コード例 #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));
 }
コード例 #9
0
 public UserManager(
     IUserService userService,
     IHashGenerator hashGenerator)
 {
     this.userService   = userService;
     this.hashGenerator = hashGenerator;
 }
コード例 #10
0
ファイル: CacheRedis.cs プロジェクト: DofD/MarketParserNet
        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;
        }
コード例 #11
0
 public ProfileService(IDatabase database, IFilesManager filesManager, IHttpContextReader httpContextReader,
                       IHashGenerator hashGenerator)
 {
     this.database          = database;
     this.filesManager      = filesManager;
     this.httpContextReader = httpContextReader;
     this.hashGenerator     = hashGenerator;
 }
コード例 #12
0
 public AccountManager(IDatabase database, IHashGenerator hashGenerator, IReadOnlyUserService userService,
                       IHttpContextReader httpContextReader)
 {
     this.database          = database;
     this.hashGenerator     = hashGenerator;
     this.userService       = userService;
     this.httpContextReader = httpContextReader;
 }
コード例 #13
0
 public TokenController(IHashGenerator hashGenerator,
                        ICustomJwtTokenProvider customJwtTokenProvider,
                        KinlyConfiguration kinlyConfiguration)
 {
     _hashGenerator          = hashGenerator;
     _customJwtTokenProvider = customJwtTokenProvider;
     _kinlyConfiguration     = kinlyConfiguration;
 }
コード例 #14
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 SingleItemBucketCollection(int size, float load, IHashGenerator hash, IKeyEqualityComparer comparer)
 {
     LoadFactor    = load;
     Capacity      = size;
     this.hash     = hash;
     this.comparer = comparer;
     Clear();
 }
コード例 #15
0
ファイル: UserService.cs プロジェクト: PQ4NOEH/.NET-recipes
 public UserService(
     IValidator<UserCredentials> credentialValidator, 
     IHashGenerator hashGenerator,
     IUserRepository userRepository)
 {
     _credentialValidator = credentialValidator;
     _hashGenerator = hashGenerator;
     _userRepository = userRepository;
 }
コード例 #16
0
 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));
 }
コード例 #17
0
 public AccountService(
     IAccountRepository accountRepository,
     IHashGenerator hashGenerator,
     IJwtGenerator jwtGenerator)
 {
     AccountRepository = accountRepository;
     HashGenerator     = hashGenerator;
     JwtGenerator      = jwtGenerator;
 }
コード例 #18
0
 protected KeyHashGenerator(IHashGenerator crypto)
 {
     if (crypto == null)
     {
         throw new ArgumentNullException("crypto");
     }
     this._key    = null;
     this._crypto = crypto;
 }
コード例 #19
0
ファイル: UserController.cs プロジェクト: kripergvg/OID
 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;
 }
コード例 #20
0
ファイル: Partitioner.cs プロジェクト: zagyar/MassTransit
        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();
        }
コード例 #21
0
 public IndexModel(
     IAuthorizationRequestValidator validator,
     IDatabaseContext context,
     IPublicApiAccessTokenGenerator <TokenResult> tokenGenerator,
     IHashGenerator hashGenerator)
 {
     _validator      = validator;
     _context        = context;
     _tokenGenerator = tokenGenerator;
     _hashGenerator  = hashGenerator;
 }
コード例 #22
0
            public InsecureManager(CryptManager cryptManager)
            {
                this.cryptManager = cryptManager;

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

                symmetricRC4CryptGenerator =

                    new Implementations.Crypt.Insecure.RC4Adapter();
            }
コード例 #23
0
        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)));
        }
コード例 #24
0
        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));
        }
コード例 #25
0
        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));
        }
コード例 #26
0
        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);
        }
コード例 #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;
 }
コード例 #28
0
 public UserLoginQueryHandler(
     IDatabaseContext context,
     IHashGenerator hashGenerator,
     IJwtTokenGenerator tokenGenerator,
     IPlaceHolderImageProvider placeHolderImageProvider
     )
 {
     _context                  = context;
     _hashGenerator            = hashGenerator;
     _tokenGenerator           = tokenGenerator;
     _placeHolderImageProvider = placeHolderImageProvider;
 }
コード例 #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;
 }
コード例 #30
0
 public RegisterService(
     IUserRepository repository,
     IRegexValidator regexValidator,
     IHashGenerator hashGenerator,
     IMessageQueuePublisher messageQueuePublisher
     )
 {
     _repository            = repository;
     _regexValidator        = regexValidator;
     _hashGenerator         = hashGenerator;
     _messageQueuePublisher = messageQueuePublisher;
 }
コード例 #31
0
 public UserRegisterCommandHandler(
     IUserRepository userRepository,
     IHashGenerator hashGenerator,
     IJwtTokenGenerator tokenGenerator,
     IPlaceHolderImageProvider placeholderImageProvider,
     IUnitOfWork unitOfWork
     )
 {
     _userRepository           = userRepository;
     _hashGenerator            = hashGenerator;
     _tokenGenerator           = tokenGenerator;
     _placeholderImageProvider = placeholderImageProvider;
     _unitOfWork = unitOfWork;
 }
コード例 #32
0
 /// <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;
 }
コード例 #33
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);
        }
コード例 #34
0
        /// <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>();
        }
コード例 #35
0
 public ContentSignatureGenerator(IHashGenerator hashGenerator)
 {
     this.hashGenerator = hashGenerator;
 }
コード例 #36
0
 public PasswordHasher(IHashGenerator hashGenerator)
 {
     Contract.Requires(hashGenerator != null);
     Contract.Ensures(_hashGenerator != null);
     _hashGenerator = hashGenerator;
 }
コード例 #37
0
 public UserAccountMapper(IHashGenerator hashGenerator)
 {
     this._hashGenerator = hashGenerator;
 }
コード例 #38
0
ファイル: HashGeneratorTest.cs プロジェクト: CocoaLab/abot
 public void Setup()
 {
     _unitUnderTest = GetInstance();
 }
コード例 #39
0
 /// <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;
 }