private bool AuthenticateUser(DigestToken token, string httpMethod) { return token.Verify(SecretProvider.RetrieveServerSecret(token.Username), httpMethod); }
private static DigestToken CreateDigestToken(string digestHeader) { var result = new DigestToken(); var match = new Regex("username=\"(?<v>.*?)\"", RegexOptions.IgnoreCase).Match(digestHeader); if (!match.Groups["v"].Success) return null; result.Username = match.Groups["v"].Value; match = new Regex("nonce=\"(?<v>.*?)\"", RegexOptions.IgnoreCase).Match(digestHeader); if (!match.Groups["v"].Success) return null; result.ServerNonce = match.Groups["v"].Value; match = new Regex("uri=\"(?<v>.*?)\"", RegexOptions.IgnoreCase).Match(digestHeader); if (!match.Groups["v"].Success) return null; result.Path = match.Groups["v"].Value; match = new Regex(@"nc=(?<v>\d+)", RegexOptions.IgnoreCase).Match(digestHeader); if (!match.Groups["v"].Success) return null; result.SequenceNumber = match.Groups["v"].Value; match = new Regex("cnonce=\"(?<v>.*?)\"", RegexOptions.IgnoreCase).Match(digestHeader); if (!match.Groups["v"].Success) return null; result.ClientNonce = match.Groups["v"].Value; match = new Regex("response=\"(?<v>.*?)\"", RegexOptions.IgnoreCase).Match(digestHeader); if (!match.Groups["v"].Success) return null; result.Digest = match.Groups["v"].Value; match = new Regex("opaque=\"(?<v>.*?)\"", RegexOptions.IgnoreCase).Match(digestHeader); if (!match.Groups["v"].Success) return null; result.Opaque = match.Groups["v"].Value; return result; }