/// <summary> /// Authenticates a request /// </summary> /// <param name="command"></param> /// <returns></returns> public bool Authenticate(AuthenticateCommand command) { if (Nonce.IsValid(command.Nonce, command.Counter)) { SecurityKeysPair securityKeysPair = _securityKeysRepository.GetByApiKey(command.Apikey); string computedHash = CalculateHash(command.Apikey, command.Uri, securityKeysPair.SecretKey); if (Log.IsDebugEnabled) { Log.Debug("Computed Hash:" + computedHash); Log.Debug("Received Hash:" + command.Response); } if (String.CompareOrdinal(computedHash, command.Response) == 0) { return(ApiKeyValidation(command)); } throw new InvalidCredentialException("API, URI and Secret Key Hash not found as expected."); } return(false); }
/// <summary> /// Generates Nounce /// </summary> /// <returns></returns> public string GenerateNonce() { return(Nonce.Generate()); }