Ejemplo n.º 1
0
            protected override void Arrange()
            {
                var packedHashConverter = mocks.Stub <IPackedHashConverter>();
                var secureHasher        = mocks.Stub <ISecureHasher>();

                _secretVerifier = new SecureHashAwareSecretVerifier(packedHashConverter, secureHasher);
            }
Ejemplo n.º 2
0
            protected override void Arrange()
            {
                var packedHash = new PackedHash
                {
                    Format = 1, HashAlgorithm = 123, HashBytes = new byte[]
                    {
                        111, 222, 200
                    },
                    Iterations = 321, Salt = new byte[]
                    {
                        100, 200, 201
                    }
                };

                var packedHashConverter = mocks.Stub <IPackedHashConverter>();

                packedHashConverter.Stub(phc => phc.GetPackedHash("MyHashedSecret"))
                .Return(packedHash);

                var secureHasher = mocks.Stub <ISecureHasher>();

                secureHasher.Stub(
                    sh => sh.ComputeHash(
                        "MySecret",
                        123,
                        321,
                        new byte[]
                {
                    100, 200, 201
                }))
                .Return(packedHash);

                _secretVerifier = new SecureHashAwareSecretVerifier(packedHashConverter, secureHasher);
            }
 public ApiClientAuthenticator(
     IApiClientIdentityProvider apiClientIdentityProvider,
     IApiClientSecretProvider apiClientSecretProvider,
     ISecretVerifier secretVerifier)
 {
     _apiClientIdentityProvider = apiClientIdentityProvider;
     _apiClientSecretProvider   = apiClientSecretProvider;
     _secretVerifier            = secretVerifier;
 }
Ejemplo n.º 4
0
            protected override void Arrange()
            {
                var packedHashConverter = Stub <IPackedHashConverter>();
                var secureHasher        = Stub <ISecureHasher>();

                _secretVerifier = new SecureHashAwareSecretVerifier(
                    packedHashConverter, new SecureHasherProvider(new List <ISecureHasher> {
                    secureHasher
                }));
            }
Ejemplo n.º 5
0
 public AutoUpgradingHashedSecretVerifierDecorator(
     IApiClientSecretProvider apiClientSecretProvider,
     ISecretVerifier next,
     IPackedHashConverter packedHashConverter,
     ISecurePackedHashProvider securePackedHashProvider,
     IHashConfigurationProvider hashConfigurationProvider)
 {
     _apiClientSecretProvider = apiClientSecretProvider;
     _next = next;
     _packedHashConverter      = packedHashConverter;
     _securePackedHashProvider = securePackedHashProvider;
     _hashConfiguration        = hashConfigurationProvider.GetHashConfiguration();
 }
Ejemplo n.º 6
0
            protected override void Arrange()
            {
                var packedHash = new PackedHash
                {
                    Format        = 1,
                    HashAlgorithm = 123,
                    HashBytes     = new byte[]
                    {
                        111,
                        222,
                        200
                    },
                    Iterations = 321,
                    Salt       = new byte[]
                    {
                        100,
                        200,
                        201
                    }
                };

                var packedHashConverter = Stub <IPackedHashConverter>();

                A.CallTo(() => packedHashConverter.GetPackedHash("MyHashedSecret"))
                .Returns(packedHash);

                var secureHasher = Stub <ISecureHasher>();

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

                _secretVerifier = new SecureHashAwareSecretVerifier(
                    packedHashConverter, new SecureHasherProvider(new List <ISecureHasher> {
                    secureHasher
                }));
            }
Ejemplo n.º 7
0
 protected override void Arrange()
 {
     _secretVerifier = new PlainTextSecretVerifier();
 }
Ejemplo n.º 8
0
            protected override void Arrange()
            {
                var packedHashConverter = Stub <IPackedHashConverter>();

                A.CallTo(() => packedHashConverter.GetPackedHash("MyHashedSecret"))
                .Returns(
                    new PackedHash
                {
                    Format        = 1,
                    HashAlgorithm = 123,
                    HashBytes     = new byte[]
                    {
                        100,
                        100,
                        100
                    },
                    Iterations = 321,
                    Salt       = new byte[]
                    {
                        100,
                        200,
                        201
                    }
                });

                var secureHasher = Stub <ISecureHasher>();

                A.CallTo(
                    () => secureHasher.ComputeHash(
                        "MyDifferentSecret",
                        123,
                        321,
                        new byte[]
                {
                    100,
                    200,
                    201
                }))
                .Returns(
                    new PackedHash
                {
                    Format        = 1,
                    HashAlgorithm = 123,
                    HashBytes     = new byte[]
                    {
                        200,
                        200,
                        200
                    },
                    Iterations = 321,
                    Salt       = new byte[]
                    {
                        100,
                        200,
                        201
                    }
                });

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