public void ShouldIndicateThatNonceIsStaleWithOldTimeStamp()
        {
            var md5Encoder = new MD5Encoder();
             var base64Converter = new Base64Converter();
             var privateHashEncoder = new PrivateHashEncoder(TestResources.PrivateKey, md5Encoder);

             var nonceTimeStampParser = new NonceTimeStampParser();
             var nonceValidator = new NonceValidator(privateHashEncoder, base64Converter, nonceTimeStampParser, 600);
             bool result = nonceValidator.IsStale(TestResources.GeneratedValidNonce);
             Assert.That(result, Is.True);
        }
        public void ShouldPositivelyValidateNonceWhenNonceIsGeneratedUsingPrivateKey()
        {
            var md5Encoder = new MD5Encoder();
             var base64Converter = new Base64Converter();
             var privateHashEncoder = new PrivateHashEncoder(TestResources.PrivateKey, md5Encoder);

             var nonceTimeStampParser = new NonceTimeStampParser();
             var nonceValidator = new NonceValidator(privateHashEncoder, base64Converter, nonceTimeStampParser, 600);
             bool result = nonceValidator.Validate(TestResources.GeneratedValidNonce, TestResources.IpAddress);
             Assert.That(result, Is.True);
        }
        public void ShouldIndicateThatNonceIsNotStale()
        {
            var md5Encoder = new MD5Encoder();
             var base64Converter = new Base64Converter();
             var privateHashEncoder = new PrivateHashEncoder(TestResources.PrivateKey, md5Encoder);

             var nonceTimeStampParser = new NonceTimeStampParser();
             var nonceValidator = new NonceValidator(privateHashEncoder, base64Converter, nonceTimeStampParser, 600);
             var nonceGenerator = new NonceGenerator(privateHashEncoder, base64Converter);

             bool result = nonceValidator.IsStale(nonceGenerator.Generate(TestResources.IpAddress));
             Assert.That(result, Is.False);
        }
 public void ShouldEncodeRandomUnicodeString()
 {
     var md5Encoder = new MD5Encoder();
      string result = md5Encoder.Encode("\u0080\0\u0080\0\0");
      Assert.That(result, Is.EqualTo("3adae15227f3ce0b058bb526aeb3791b"));
 }
 public void ShouldCalculateMD5HashFromString()
 {
     var md5Encoder = new MD5Encoder();
      string result = md5Encoder.Encode("Hash It");
      Assert.That(result, Is.EqualTo("1deafc92595a02703f5736ecfb440563"));
 }
 public AuthDigestEncoder(MD5Encoder md5Encoder)
     : base(md5Encoder)
 {
 }
 public PrivateHashEncoder(string privateKey, MD5Encoder md5Encoder)
 {
     this.privateKey = privateKey;
      this.md5Encoder = md5Encoder;
 }
 protected DigestEncoderBase(MD5Encoder md5Encoder)
 {
     this.md5Encoder = md5Encoder;
 }
 public DefaultDigestEncoder(MD5Encoder md5Encoder)
     : base(md5Encoder)
 {
 }