Esempio n. 1
0
 public ShortUrlGenerator(
     IFromShortUrlRepository fromShortUrlRepository,
     IRandomStringGenerator randomStringGenerator)
 {
     this.fromShortUrlRepository = fromShortUrlRepository;
     this.randomStringGenerator  = randomStringGenerator;
 }
Esempio n. 2
0
 public UnitOfWork(
     DbContext dbContext,
     IRandomStringGenerator randomStringGenerator)
 {
     DbContext             = dbContext;
     RandomStringGenerator = randomStringGenerator;
 }
 public RepositorySeeder(
     IUnitOfWork uow,
     IRandomStringGenerator randomStringGenerator)
 {
     Uow = uow;
     RandomStringGenerator = randomStringGenerator;
 }
Esempio n. 4
0
 public ClaimCodeGenerator(int length, int interval, string seperator, IRandomStringGenerator randomStringGenerator)
 {
     _length                = length;
     _interval              = interval;
     _seperator             = seperator;
     _randomStringGenerator = randomStringGenerator;
 }
 internal ScramSha256Authenticator(
     UsernamePasswordCredential credential,
     IRandomStringGenerator randomStringGenerator,
     ServerApi serverApi)
     : base(credential, HashAlgorithmName.SHA256, randomStringGenerator, H256, Hi256, Hmac256, new ScramCache(), serverApi)
 {
 }
Esempio n. 6
0
 public CreateQuizCommandHandler(DataContext context, IRandomStringGenerator stringGenerator,
                                 ICustomMapper customMapper)
 {
     _context         = context;
     _stringGenerator = stringGenerator;
     _customMapper    = customMapper;
 }
        public void GivenRandomStringGeneratorWhenRandomStringsGeneratedThenAllCharactersAreUsed()
        {
            ISet <char> alphaChars = new HashSet <char> {
                '0', '1', '2', '3', '4', '5'
            };
            ISet <char> foundChars = new HashSet <char>();

            string alpha                     = string.Join("", alphaChars);
            int    maxIterations             = 100;
            int    rndStringLength           = 4;
            IRandomStringGenerator generator = NewGenerator();

            for (int index = 0; index < maxIterations; index++)
            {
                string rnd      = generator.RandomString(rndStringLength, alpha);
                char[] rndChars = rnd.ToCharArray();
                foreach (char c in rndChars)
                {
                    foundChars.Add(c);
                }
                if (alphaChars.Count == foundChars.Count)
                {
                    Assert.Pass("All chars found at index: " + index);
                }
            }
            Assert.Fail(string.Format("Not all characters found in random strings. Found: '{0}'", string.Join(", ", alphaChars)));
        }
Esempio n. 8
0
 internal DefaultAuthenticator(
     UsernamePasswordCredential credential,
     IRandomStringGenerator randomStringGenerator,
     ServerApi serverApi)
 {
     _credential            = Ensure.IsNotNull(credential, nameof(credential));
     _randomStringGenerator = Ensure.IsNotNull(randomStringGenerator, nameof(randomStringGenerator));
     _serverApi             = serverApi;
 }
Esempio n. 9
0
 public StringEditViewModel(ICharacterSetProvider stringConfiguration, ICharacterSetService characterSetService, IRandomStringGenerator randomStringGenerator)
 {
     this.stringConfiguration   = stringConfiguration;
     this.characterSetService   = characterSetService;
     this.randomStringGenerator = randomStringGenerator;
     GenerateCommand            = new RelayCommand(RunGenerate, CanExecuteGenerate);
     AddCharactersCommand       = new RelayCommand(RunGenerate, CanExecuteGenerate);
     RemoveCharactersCommand    = new RelayCommand(RunRemoveCharacters, CanExecuteRemoveCharacters);
 }
Esempio n. 10
0
 public VermittlerNoGenerator(
     IInsuranceDbContext insuranceDbContext,
     IRandomStringGenerator randomStringGenerator,
     ILogger <VermittlerNoGenerator> logger)
 {
     _insuranceDbContext    = insuranceDbContext;
     _randomStringGenerator = randomStringGenerator;
     _logger = logger;
 }
Esempio n. 11
0
 public ChunkGenerator(
     IChunkInfoBuilder chunkInfoBuilder,
     IRandomNumberGenerator randomNumberGenerator,
     IRandomStringGenerator randomStringGenerator)
 {
     _randomNumberGenerator = randomNumberGenerator;
     _randomStringGenerator = randomStringGenerator;
     _chunkInfoBuilder      = chunkInfoBuilder;
 }
Esempio n. 12
0
 public CreateToken(IClockProvider clockProvider,
                    IEncryptionProvider encryptionProvider,
                    IRandomStringGenerator randomStringGenerator,
                    IRequestTokenService requestTokenService)
 {
     _clockProvider         = clockProvider;
     _encryptionProvider    = encryptionProvider;
     _randomStringGenerator = randomStringGenerator;
     _requestTokenService   = requestTokenService;
 }
Esempio n. 13
0
 public DefaultPathNameGenerator(
     string prefix    = "",
     string postfix   = "",
     int randomLength = 5,
     IRandomStringGenerator?nameGenerator = default)
 {
     _nameGenerator = nameGenerator ?? new RandomStringGenerator();
     _prefix        = prefix;
     _postfix       = postfix;
     _randomLength  = randomLength;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ScramShaAuthenticator"/> class.
 /// </summary>
 /// <param name="credential">The credential.</param>
 /// <param name="hashAlgorithName">The hash algorithm name.</param>
 /// <param name="randomStringGenerator">The random string generator.</param>
 /// <param name="h">The H function to use.</param>
 /// <param name="hi">The Hi function to use.</param>
 /// <param name="hmac">The Hmac function to use.</param>
 internal ScramShaAuthenticator(
     UsernamePasswordCredential credential,
     HashAlgorithmName hashAlgorithName,
     IRandomStringGenerator randomStringGenerator,
     H h,
     Hi hi,
     Hmac hmac)
     : base(new ScramShaMechanism(credential, hashAlgorithName, randomStringGenerator, h, hi, hmac))
 {
     _databaseName = credential.Source;
 }
Esempio n. 15
0
 public LoginOtpService(ILoginOtpRepository loginOtpRepository, IConfigurationSettingRepository configurationSettingRepository, IRandomStringGenerator randomStringGenerator,
                        INotifier notifier, IPhoneNotificationModelsFactory smsNotificationModelsFactory, IEmailNotificationModelsFactory emailNotificationModelsFactory, ILoginSettingRepository loginSettingRepository,
                        ISessionContext sessionContext)
 {
     _loginOtpRepository             = loginOtpRepository;
     _configurationSettingRepository = configurationSettingRepository;
     _randomStringGenerator          = randomStringGenerator;
     _notifier = notifier;
     _smsNotificationModelsFactory   = smsNotificationModelsFactory;
     _emailNotificationModelsFactory = emailNotificationModelsFactory;
     _loginSettingRepository         = loginSettingRepository;
     _sessionContext = sessionContext;
 }
        public void GivenRandomStringGeneratorWhen1000StringsGeneratedThenNoDuplicatesFound()
        {
            int rndStringLength = 6;
            int maxIterations   = 1000;
            IRandomStringGenerator generator = NewGenerator();
            ISet <string>          resultSet = new HashSet <string>();

            for (int index = 0; index < maxIterations; index++)
            {
                string rnd = generator.RandomAlphaNumericUpperCaseString(rndStringLength);
                Assert.False(resultSet.Contains(rnd), string.Format("Duplicate random string found '{0}' at index {1}", rnd, index));
                resultSet.Add(rnd);
            }
        }
Esempio n. 17
0
 public CampaignService(ICampaignRepository campaignRepository, ICampaignActivityRepository campaignActivityRepository,
                        ICampaignAssignmentRepository campaignAssignmentRepository, ICampaignActivityAssignmentRepository campaignActivityAssignmentRepository,
                        IOrganizationRoleUserRepository organizationRoleUserRepository, ICampaignListModelFactory campaignListModelFactory, ICorporateAccountRepository corporateAccountRepository, IRandomStringGenerator randomStringGenerator, IDirectMailTypeRepository directMailTypeRepository)
 {
     _campaignRepository                   = campaignRepository;
     _campaignActivityRepository           = campaignActivityRepository;
     _campaignAssignmentRepository         = campaignAssignmentRepository;
     _campaignActivityAssignmentRepository = campaignActivityAssignmentRepository;
     _organizationRoleUserRepository       = organizationRoleUserRepository;
     _campaignListModelFactory             = campaignListModelFactory;
     _corporateAccountRepository           = corporateAccountRepository;
     _randomStringGenerator                = randomStringGenerator;
     _directMailTypeRepository             = directMailTypeRepository;
 }
Esempio n. 18
0
 public AccountService(
     IDinnerPrincipalProvider principalProvider,
     IAuthStorage authStorage,
     IPasswordHashProvider passwordHashProvider,
     IUserDinnerStorage userDinnerStorage,
     IRandomStringGenerator stringGenerator,
     IEmailSystem emailSystem)
 {
     this.principalProvider    = principalProvider;
     this.authStorage          = authStorage;
     this.passwordHashProvider = passwordHashProvider;
     this.userDinnerStorage    = userDinnerStorage;
     this.stringGenerator      = stringGenerator;
     this.emailSystem          = emailSystem;
 }
 public AddDocumentAssetCommandHandler(
     CofoundryDbContext dbContext,
     EntityAuditHelper entityAuditHelper,
     EntityTagHelper entityTagHelper,
     DocumentAssetCommandHelper documentAssetCommandHelper,
     ITransactionScopeManager transactionScopeFactory,
     IMessageAggregator messageAggregator,
     IRandomStringGenerator randomStringGenerator
     )
 {
     _dbContext                  = dbContext;
     _entityAuditHelper          = entityAuditHelper;
     _entityTagHelper            = entityTagHelper;
     _documentAssetCommandHelper = documentAssetCommandHelper;
     _transactionScopeFactory    = transactionScopeFactory;
     _messageAggregator          = messageAggregator;
     _randomStringGenerator      = randomStringGenerator;
 }
 public ScramShaMechanism(
     UsernamePasswordCredential credential,
     HashAlgorithmName hashAlgorithmName,
     IRandomStringGenerator randomStringGenerator,
     H h,
     Hi hi,
     Hmac hmac)
 {
     _credential = Ensure.IsNotNull(credential, nameof(credential));
     _h          = h;
     _hi         = hi;
     _hmac       = hmac;
     if (!hashAlgorithmName.ToString().StartsWith("SHA"))
     {
         throw new ArgumentException("Must specify a SHA algorithm.");
     }
     _name = $"SCRAM-SHA-{hashAlgorithmName.ToString().Substring(3)}";
     _randomStringGenerator = Ensure.IsNotNull(randomStringGenerator, nameof(randomStringGenerator));
 }
Esempio n. 21
0
 public AddImageAssetCommandHandler(
     CofoundryDbContext dbContext,
     EntityAuditHelper entityAuditHelper,
     EntityTagHelper entityTagHelper,
     IImageAssetFileService imageAssetFileService,
     ITransactionScopeManager transactionScopeFactory,
     IMessageAggregator messageAggregator,
     IRandomStringGenerator randomStringGenerator,
     IAssetFileTypeValidator assetFileTypeValidator
     )
 {
     _dbContext               = dbContext;
     _entityAuditHelper       = entityAuditHelper;
     _entityTagHelper         = entityTagHelper;
     _imageAssetFileService   = imageAssetFileService;
     _transactionScopeFactory = transactionScopeFactory;
     _messageAggregator       = messageAggregator;
     _randomStringGenerator   = randomStringGenerator;
     _assetFileTypeValidator  = assetFileTypeValidator;
 }
Esempio n. 22
0
 public TestMe(ITestManager testManager,
               ITestQuestionManager testQuestionManager,
               ITestAnswerManager testAnswerManager,
               ITestResultManager testResultManager,
               IRandomStringGenerator randomStringGenerator,
               IAnswerImageManager answerImageManager,
               ITestReportManager testReportManager,
               ITestMarkManager testMarkManager,
               IUserAnswerManager userAnswerManager)
 {
     TestManager           = testManager;
     TestQuestionManager   = testQuestionManager;
     TestAnswerManager     = testAnswerManager;
     TestResultManager     = testResultManager;
     RandomStringGenerator = randomStringGenerator;
     AnswerImageManager    = answerImageManager;
     TestReportManager     = testReportManager;
     TestMarkManager       = testMarkManager;
     UserAnswerManager     = userAnswerManager;
 }
        public void GivenRandomStringGeneratorWhenRandomStringsGeneratedThenAllCharactersHaveEvenDistributionWithin10Percent()
        {
            ISet <char> alphaChars = new HashSet <char> {
                '0', '1', '2', '3', '4', '5'
            };
            IDictionary <char, int> charCount = new Dictionary <char, int>();

            string alpha                     = string.Join("", alphaChars);
            int    maxIterations             = 10000;
            int    rndStringLength           = 1;
            IRandomStringGenerator generator = NewGenerator();

            for (int index = 0; index < maxIterations; index++)
            {
                string rnd      = generator.RandomString(rndStringLength, alpha);
                char[] rndChars = rnd.ToCharArray();
                foreach (char c in rndChars)
                {
                    if (charCount.ContainsKey(c))
                    {
                        charCount[c]++;
                    }
                    else
                    {
                        charCount.Add(c, 1);
                    }
                }
            }

            double expectedCharCount = (maxIterations * rndStringLength) / alphaChars.Count;
            double delta             = expectedCharCount * 0.1;

            foreach (var pair in charCount)
            {
                Assert.AreEqual(expectedCharCount, pair.Value, delta, "Character distribution for char '{0}' not even", pair.Key);
            }
        }
Esempio n. 24
0
 public QuizDetailEndpoint(IQuizService service, IRandomStringGenerator generator)
 {
     _service = service;
     _generator = generator;
 }
 public ScramSha1Mechanism(UsernamePasswordCredential credential, IRandomStringGenerator randomStringGenerator)
 {
     _credential = Ensure.IsNotNull(credential, "credential");
     _randomStringGenerator = Ensure.IsNotNull(randomStringGenerator, "randomStringGenerator");
 }
 internal ScramSha1Authenticator(UsernamePasswordCredential credential, IRandomStringGenerator randomStringGenerator)
     : base(new ScramSha1Mechanism(credential, randomStringGenerator))
 {
     _databaseName = credential.Source;
 }
 public SubscriptionStorage(IRandomStringGenerator rsg, SubscriptionContext db)
 {
     _rsg = rsg;
     _db  = db;
 }
 internal ScramSha1Authenticator(UsernamePasswordCredential credential, IRandomStringGenerator randomStringGenerator)
     : base(credential, HashAlgorithmName.SHA1, randomStringGenerator, H1, Hi1, Hmac1, new ScramCache())
 {
 }
Esempio n. 29
0
 internal ScramSha1Authenticator(UsernamePasswordCredential credential, IRandomStringGenerator randomStringGenerator)
     : base(new ScramSha1Mechanism(credential, randomStringGenerator))
 {
     _databaseName = credential.Source;
 }
Esempio n. 30
0
 internal ScramSha256Authenticator(UsernamePasswordCredential credential, IRandomStringGenerator randomStringGenerator)
     : base(credential, HashAlgorithmName.SHA256, randomStringGenerator, H256, Hi256, Hmac256)
 {
 }
 internal DefaultAuthenticator(UsernamePasswordCredential credential, IRandomStringGenerator randomStringGenerator)
 {
     _credential = Ensure.IsNotNull(credential, "credential");
     _randomStringGenerator = Ensure.IsNotNull(randomStringGenerator, "randomStringGenerator");
 }
 public RandomStringGeneratorTests()
 {
     _stringGenerator = new RandomBase64StringGenerator();
 }
Esempio n. 33
0
 public ScramSha1Mechanism(UsernamePasswordCredential credential, IRandomStringGenerator randomStringGenerator)
 {
     _credential            = Ensure.IsNotNull(credential, nameof(credential));
     _randomStringGenerator = Ensure.IsNotNull(randomStringGenerator, nameof(randomStringGenerator));
 }
Esempio n. 34
0
 public TodoItemRepository(
     DbContext dbContext, IRandomStringGenerator randomStringGenerator) : base(dbContext)
 {
     RandomStringGenerator = randomStringGenerator;
 }