You are here

function MiniorangeSAMLCustomer::getHeader in SAML SP 2.0 Single Sign On (SSO) - SAML Service Provider 7

1 call to MiniorangeSAMLCustomer::getHeader()
MiniorangeSAMLCustomer::callService in includes/customer_setup.php

File

includes/customer_setup.php, line 138
Contains miniOrange Customer class.

Class

MiniorangeSAMLCustomer
@file This class represents configuration for customer.

Code

function getHeader($addExtendedHeader = FALSE) {
  $header = array(
    'Content-Type' => 'application/json',
    'charset' => 'UTF - 8',
    'Authorization' => 'Basic',
  );
  if ($addExtendedHeader) {

    /* Current time in milliseconds since midnight, January 1, 1970 UTC. */
    $current_time_in_millis = $this
      ->getTimeStamp();

    /* Creating the Hash using SHA-512 algorithm */
    list($customerId, $apiKey) = $this
      ->getCustomerDetails();
    $string_to_hash = $customerId . $current_time_in_millis . $apiKey;
    $hashValue = hash("sha512", $string_to_hash);
    $timestamp_header = number_format($current_time_in_millis, 0, '', '');
    $header = array_merge($header, array(
      "Customer-Key" => $customerId,
      "Timestamp" => $timestamp_header,
      "Authorization" => $hashValue,
    ));
  }
  return $header;
}