Пример #1
0
/// Retrieve user's digest data as JSON object. Caller is responsible for deleting.
HTTPCode HSSConnection::get_digest_data(const std::string& private_user_identity,
                                        const std::string& public_user_identity,
                                        Json::Value*& digest_data,
                                        SAS::TrailId trail)
{
  Utils::StopWatch stopWatch;
  stopWatch.start();

  SAS::Event event(trail, SASEvent::HTTP_HOMESTEAD_DIGEST, 0);
  event.add_var_param(private_user_identity);
  event.add_var_param(public_user_identity);
  SAS::report_event(event);

  std::string path = "/impi/" +
                     Utils::url_escape(private_user_identity) +
                     "/digest";
  if (!public_user_identity.empty())
  {
    path += "?public_id=" + Utils::url_escape(public_user_identity);
  }

  HTTPCode rc = get_json_object(path, digest_data, trail);

  unsigned long latency_us = 0;
  if (stopWatch.read(latency_us))
  {
    _latency_stat.accumulate(latency_us);
    _digest_latency_stat.accumulate(latency_us);
  }

  return rc;
}
Пример #2
0
/// Get an Authentication Vector as JSON object. Caller is responsible for deleting.
HTTPCode HSSConnection::get_auth_vector(const std::string& private_user_identity,
                                        const std::string& public_user_identity,
                                        const std::string& auth_type,
                                        const std::string& autn,
                                        Json::Value*& av,
                                        SAS::TrailId trail)
{
  Utils::StopWatch stopWatch;
  stopWatch.start();

  SAS::Event event(trail, SASEvent::HTTP_HOMESTEAD_VECTOR, 0);
  event.add_var_param(private_user_identity);
  event.add_var_param(public_user_identity);
  event.add_var_param(auth_type);
  SAS::report_event(event);

  std::string path = "/impi/" +
                     Utils::url_escape(private_user_identity) +
                     "/av";

  if (!auth_type.empty())
  {
    path += "/" + auth_type;
  }

  if (!public_user_identity.empty())
  {
    path += "?impu=" + Utils::url_escape(public_user_identity);
  }

  if (!autn.empty())
  {
    path += public_user_identity.empty() ? "?" : "&";
    path += "autn=" + Utils::url_escape(autn);
  }

  HTTPCode rc = get_json_object(path, av, trail);

  unsigned long latency_us = 0;

  // Only accumulate the latency if we haven't already applied a
  // penalty
  if ((rc != HTTP_SERVER_UNAVAILABLE) &&
      (rc != HTTP_GATEWAY_TIMEOUT)    &&
      (stopWatch.read(latency_us)))
  {
    _latency_stat.accumulate(latency_us);
    _digest_latency_stat.accumulate(latency_us);
  }

  if (av == NULL)
  {
    LOG_ERROR("Failed to get Authentication Vector for %s",
              private_user_identity.c_str());
  }

  return rc;
}
Пример #3
0
// Makes a user authorization request, and returns the data as a JSON object.
HTTPCode HSSConnection::get_user_auth_status(const std::string& private_user_identity,
                                             const std::string& public_user_identity,
                                             const std::string& visited_network,
                                             const std::string& auth_type,
                                             const bool& emergency,
                                             rapidjson::Document*& user_auth_status,
                                             SAS::TrailId trail)
{
  Utils::StopWatch stopWatch;
  stopWatch.start();

  SAS::Event event(trail, SASEvent::HTTP_HOMESTEAD_AUTH_STATUS, 0);
  event.add_var_param(private_user_identity);
  event.add_var_param(public_user_identity);
  SAS::report_event(event);

  std::string path = "/impi/" +
                     Utils::url_escape(private_user_identity) +
                     "/registration-status" +
                     "?impu=" +
                     Utils::url_escape(public_user_identity);

  if (!visited_network.empty())
  {
    path += "&visited-network=" + Utils::url_escape(visited_network);
  }
  if (!auth_type.empty())
  {
    path += "&auth-type=" + Utils::url_escape(auth_type);
  }
  if (emergency)
  {
    path += "&sos=true";
  }

  HTTPCode rc = get_json_object(path, user_auth_status, trail);

  unsigned long latency_us = 0;
  // Only accumulate the latency if we haven't already applied a
  // penalty
  if ((rc != HTTP_SERVER_UNAVAILABLE) &&
      (rc != HTTP_GATEWAY_TIMEOUT)    &&
      (stopWatch.read(latency_us)))
  {
    _latency_tbl->accumulate(latency_us);
    _uar_latency_tbl->accumulate(latency_us);
  }

  return rc;
}
Пример #4
0
/// Makes a location information request, and returns the data as a JSON object.
HTTPCode HSSConnection::get_location_data(const std::string& public_user_identity,
                                          const bool& originating,
                                          const std::string& auth_type,
                                          Json::Value*& location_data,
                                          SAS::TrailId trail)
{
  Utils::StopWatch stopWatch;
  stopWatch.start();

  SAS::Event event(trail, SASEvent::HTTP_HOMESTEAD_LOCATION, 0);
  event.add_var_param(public_user_identity);
  SAS::report_event(event);

  std::string path = "/impu/" +
                     Utils::url_escape(public_user_identity) +
                     "/location";

  if (originating)
  {
    path += "?originating=true";
  }
  if (!auth_type.empty())
  {
    std::string prefix = !originating ? "?" : "&";
    path += prefix + "auth-type=" + Utils::url_escape(auth_type);
  }

  HTTPCode rc = get_json_object(path, location_data, trail);

  unsigned long latency_us = 0;
  // Only accumulate the latency if we haven't already applied a
  // penalty
  if ((rc != HTTP_SERVER_UNAVAILABLE) &&
      (rc != HTTP_GATEWAY_TIMEOUT)    &&
      (stopWatch.read(latency_us)))
  {
    _latency_stat.accumulate(latency_us);
    _location_latency_stat.accumulate(latency_us);
  }

  return rc;
}
Пример #5
0
// Makes a user authorization request, and returns the data as a JSON object.
HTTPCode HSSConnection::get_user_auth_status(const std::string& private_user_identity,
                                             const std::string& public_user_identity,
                                             const std::string& visited_network,
                                             const std::string& auth_type,
                                             Json::Value*& user_auth_status,
                                             SAS::TrailId trail)
{
  Utils::StopWatch stopWatch;
  stopWatch.start();

  SAS::Event event(trail, SASEvent::HTTP_HOMESTEAD_AUTH_STATUS, 0);
  event.add_var_param(private_user_identity);
  event.add_var_param(public_user_identity);
  SAS::report_event(event);

  std::string path = "/impi/" +
                     Utils::url_escape(private_user_identity) +
                     "/registration-status" +
                     "?impu=" +
                     Utils::url_escape(public_user_identity);

  if (!visited_network.empty())
  {
    path += "&visited-network=" + Utils::url_escape(visited_network);
  }
  if (!auth_type.empty())
  {
    path += "&auth-type=" + Utils::url_escape(auth_type);
  }

  HTTPCode rc = get_json_object(path, user_auth_status, trail);

  unsigned long latency_us = 0;
  if (stopWatch.read(latency_us))
  {
    _latency_stat.accumulate(latency_us);
    _user_auth_latency_stat.accumulate(latency_us);
  }

  return rc;
}