public static bool IsHeaderContainToken(HttpRequestHeaders header) { if (header.Contains(Constants.AccessTokenKey)) { return true; } return false; }
public static bool AuthenticateUser(HttpRequestHeaders HttpHeaders) { if (HttpHeaders.Contains(HttpRequestHeaderName)) { var authHeader = HttpHeaders.GetValues(HttpRequestHeaderName).First(); return _authenticateHeaderValue(authHeader); } return false; }
public static int? ParseFirstValue(string header, HttpRequestHeaders headers) { IEnumerable<string> value = (headers.Contains(header) ? headers.GetValues(header) : null); return GetIntValue(value); }
public static string GetHeaderValue(string header, HttpRequestHeaders headers) { IEnumerable<string> value = (headers.Contains(header) ? headers.GetValues(header) : null); return GetStringValue(value); }
private AuthorizationComponents TakeHeaderData(HttpRequestHeaders headers) { string key = "", hash = "", dateTimeSent = ""; if (headers.Contains("Key")) key = headers.GetValues("key").First(); else { throw new NoKeyProvidedException(); } if (headers.Contains("Hash")) hash = headers.GetValues("hash").First(); else { throw new NoHashProvidedEception(); } if (headers.Contains("DateSent")) dateTimeSent = headers.GetValues("DateSent").First(); else { throw new NoDateProvidedException(); } if (String.IsNullOrWhiteSpace(key)) { throw new InvalidHeaderException("key"); } if(String.IsNullOrWhiteSpace(hash)) { throw new InvalidHeaderException("hash"); } if(String.IsNullOrWhiteSpace(dateTimeSent)) { throw new InvalidHeaderException("date"); } DateTime sent = DateTime.Parse(dateTimeSent, this.EndUserDateFormat, DateTimeStyles.AssumeUniversal); return new AuthorizationComponents { PublicKey = key, DataHash = hash, TimeRequestExecuted = sent }; }