public OnPremFirstTimeSetupService(
     IUsersContext usersContext,
     ISecurePackedHashProvider securePackedHashProvider,
     IHashConfigurationProvider hashConfigurationProvider)
     : base(usersContext, securePackedHashProvider, hashConfigurationProvider)
 {
 }
Exemplo n.º 2
0
        public AzureFirstTimeSetupService(
            IUsersContext usersContext,
            ISecurityContext securityContext,
            ISecurePackedHashProvider securePackedHashProvider,
            IHashConfigurationProvider hashConfigurationProvider)
            : base(usersContext, securePackedHashProvider, hashConfigurationProvider)
        {
            MaxAttempts   = 5;
            RunsAttempted = 0;

            _securityContext = securityContext;
        }
Exemplo n.º 3
0
 public SetupAcademicBenchmarksConnectService(IUsersContext usersContext
                                              , ISecurePackedHashProvider securePackedHashProvider
                                              , IHashConfigurationProvider hashConfigurationProvider
                                              , IOdsSecretConfigurationProvider odsSecretConfigurationProvider
                                              , InstanceContext instanceContext
                                              )
 {
     _usersContext                   = usersContext;
     _securePackedHashProvider       = securePackedHashProvider;
     _hashConfigurationProvider      = hashConfigurationProvider;
     _odsSecretConfigurationProvider = odsSecretConfigurationProvider;
     _instanceContext                = instanceContext;
 }
Exemplo n.º 4
0
 public AutoUpgradingHashedSecretVerifierDecorator(
     IApiClientSecretProvider apiClientSecretProvider,
     ISecretVerifier next,
     IPackedHashConverter packedHashConverter,
     ISecurePackedHashProvider securePackedHashProvider,
     IHashConfigurationProvider hashConfigurationProvider)
 {
     _apiClientSecretProvider = apiClientSecretProvider;
     _next = next;
     _packedHashConverter      = packedHashConverter;
     _securePackedHashProvider = securePackedHashProvider;
     _hashConfiguration        = hashConfigurationProvider.GetHashConfiguration();
 }
            protected override void Arrange()
            {
                var packedHashConverter = new PackedHashConverter();

                var originalHashAlgorithm = 1495316179;

                var packedHash = new PackedHash
                {
                    Format        = 0,
                    HashAlgorithm = originalHashAlgorithm,
                    HashBytes     = new byte[]
                    {
                        246, 198, 84, 57, 46, 87, 69, 64, 36, 89, 195, 42, 154,
                        103, 212, 113, 134, 129, 0, 29, 59, 36, 38, 212, 67, 32,
                        67, 113, 96, 103, 22, 129
                    },
                    Iterations = 100,
                    Salt       = new byte[] { 5, 8, 4, 2, 3, 6, 12, 34 }
                };

                _configProvider = new DefaultHashConfigurationProvider();

                _apiClientSecret = new ApiClientSecret
                {
                    IsHashed = true,

                    // GetHashCode is consistent
                    Secret = "ANO2IFlkAAAACAAAAAUIBAIDBgwi9sZUOS5XRUAkWcMqmmfUcYaBAB07JCbUQyBDcWBnFoE="
                };

                _apiClientSecretProvider = Stub <IApiClientSecretProvider>();

                var secureHasher   = new Pbkdf2HmacSha1SecureHasher();
                var originalHasher = A.Fake <ISecureHasher>();

                A.CallTo(() => originalHasher.AlgorithmHashCode).Returns(originalHashAlgorithm);
                A.CallTo(() => originalHasher.ComputeHash(A <string> ._, A <int> ._, A <int> ._, A <byte[]> ._)).Returns(packedHash);

                var next = new SecureHashAwareSecretVerifier(
                    packedHashConverter, new SecureHasherProvider(
                        new List <ISecureHasher>
                {
                    secureHasher,
                    originalHasher
                }));

                _securePackedHashProvider = Stub <ISecurePackedHashProvider>();

                _autoUpgradingHashedSecretVerifierDecorator = new AutoUpgradingHashedSecretVerifierDecorator(
                    _apiClientSecretProvider, next, packedHashConverter, _securePackedHashProvider, _configProvider);
            }
Exemplo n.º 6
0
            protected override void Arrange()
            {
                var packedHashConverter = new PackedHashConverter();

                var packedHash = new PackedHash
                {
                    Format        = 0,
                    HashAlgorithm = "GOOD".GetHashCode(), // simulation of a hash routine that used GetHashCode
                    HashBytes     = new byte[]
                    {
                        246, 198, 84, 57, 46, 87, 69, 64, 36, 89, 195, 42, 154,
                        103, 212, 113, 134, 129, 0, 29, 59, 36, 38, 212, 67, 32,
                        67, 113, 96, 103, 22, 129
                    },
                    Iterations = 100,
                    Salt       = new byte[] { 5, 8, 4, 2, 3, 6, 12, 34 }
                };

                _configProvider = new DefaultHashConfigurationProvider();

                _apiClientSecret = new ApiClientSecret
                {
                    IsHashed = true,

                    // GetHashCode is consistent
                    Secret = "ANO2IFlkAAAACAAAAAUIBAIDBgwi9sZUOS5XRUAkWcMqmmfUcYaBAB07JCbUQyBDcWBnFoE="
                };

                _apiClientSecretProvider = Stub <IApiClientSecretProvider>();

                var secureHasher = new Pbkdf2HmacSha1SecureHasher(null);
                var next         = new SecureHashAwareSecretVerifier(packedHashConverter, secureHasher);

                _securePackedHashProvider = Stub <ISecurePackedHashProvider>();

                _autoUpgradingHashedSecretVerifierDecorator = new AutoUpgradingHashedSecretVerifierDecorator(
                    _apiClientSecretProvider, next, packedHashConverter, _securePackedHashProvider, _configProvider);
            }
 protected FirstTimeSetupServiceBase(IUsersContext usersContext, ISecurePackedHashProvider securePackedHashProvider, IHashConfigurationProvider hashConfigurationProvider)
 {
     UsersContext = usersContext;
     _securePackedHashProvider  = securePackedHashProvider;
     _hashConfigurationProvider = hashConfigurationProvider;
 }
Exemplo n.º 8
0
 public ApiClientFactory(ISecurePackedHashProvider securePackedHashProvider,
                         IHashConfigurationProvider hashConfigurationProvider)
 {
     _securePackedHashProvider  = securePackedHashProvider;
     _hashConfigurationProvider = hashConfigurationProvider;
 }
        /// <summary>
        /// Generates a new Secret for the given ApiClient object; the new Secret is hashed, and the pre-hash plain text is returned
        /// </summary>
        /// <param name="apiClient">ApiClient entity for which a new secure secret should be generated</param>
        /// <param name="securePackedHashProvider">Hash provider service</param>
        /// <param name="hashConfigurationProvider">Hash configuration settings provider</param>
        /// <returns>Plain text value of Secret, before hasing algorithm has been applied</returns>
        public static string GenerateSecureClientSecret(this ApiClient apiClient, ISecurePackedHashProvider securePackedHashProvider, IHashConfigurationProvider hashConfigurationProvider)
        {
            var hashConfiguration = hashConfigurationProvider.GetHashConfiguration();
            var plainTextSecret   = apiClient.GenerateSecret();

            var hashedSecret = securePackedHashProvider.ComputePackedHashString(
                plainTextSecret,
                hashConfiguration.GetAlgorithmHashCode(),
                hashConfiguration.Iterations,
                hashConfiguration.GetSaltSizeInBytes());

            apiClient.Secret         = hashedSecret;
            apiClient.SecretIsHashed = true;

            return(plainTextSecret);
        }