You are here

function KalturaNotificationClient::validate_signature in Kaltura 6

Same name and namespace in other branches
  1. 5 kaltura_client/kaltura_notification_client.php \KalturaNotificationClient::validate_signature()
  2. 6.2 kaltura_client/kaltura_notification_client.php \KalturaNotificationClient::validate_signature()
  3. 7.3 kaltura_client/kaltura_notification_client.php \KalturaNotificationClient::validate_signature()
  4. 7.2 kaltura_client/kaltura_notification_client.php \KalturaNotificationClient::validate_signature()
1 call to KalturaNotificationClient::validate_signature()
KalturaNotificationClient::KalturaNotificationClient in kaltura_client/kaltura_notification_client.php

File

kaltura_client/kaltura_notification_client.php, line 60

Class

KalturaNotificationClient

Code

function validate_signature($notification_params, $admin_secret) {
  ksort($notification_params);
  $str = "";
  $valid_params = array();
  if (key_exists('signed_fields', $notification_params)) {
    $valid_params = explode(',', $notification_params['signed_fields']);
  }
  foreach ($notification_params as $k => $v) {
    if ($k == "sig") {
      continue;
    }
    if (!in_array($k, $valid_params) && count($valid_params) > 1 && !$notification_params['multi_notification']) {
      if ($k != 'multi_notification' && $k != 'number_of_notifications') {
        continue;
      }
    }
    $str .= $k . $v;
  }
  if (md5($admin_secret . $str) == $notification_params['sig']) {
    $this->valid_signature = true;
  }
  else {
    $this->valid_signature = false;
  }
}