You are here

function _securesite_digest_validate in Secure Site 7.2

Same name and namespace in other branches
  1. 6.2 securesite.inc \_securesite_digest_validate()

Get the result of digest validation.

Parameters

$status: Will be set to the return status of the validation script

$edit: An array of parameters to pass to the validation script

Return value

An HTTP header string.

6 calls to _securesite_digest_validate()
SecureSiteFunctionDigestValidateUnitTest::testSecureSiteFunctionDigestValidateData in ./securesite.test
Check output with data.
SecureSiteFunctionDigestValidateUnitTest::testSecureSiteFunctionDigestValidateEmpty in ./securesite.test
Check output without data.
SecureSiteFunctionDigestValidateUnitTest::testSecureSiteFunctionDigestValidateNull in ./securesite.test
Check output without input.
_securesite_denied in ./securesite.inc
Deny access to users who are not authorized to access secured pages.
_securesite_dialog in ./securesite.inc
Display authentication dialog and send password reset mails.

... See full list

File

./securesite.inc, line 145
Secure Site log-in functions.

Code

function _securesite_digest_validate(&$status, $edit = array()) {
  static $header;
  if (!empty($edit)) {
    $args = array();
    foreach ($edit as $key => $value) {
      $args[] = "{$key}=" . escapeshellarg($value);
    }
    $script = variable_get('securesite_digest_script', drupal_get_path('module', 'securesite') . '/digest_md5/digest_md5.php');
    $response = exec($script . ' ' . implode(' ', $args), $output, $status);

    // drupal_set_header() is now drupal_add_http_header() and requires headers passed as name, value in an array.
    // The script returns a string, so we shall break it up as best we can. The existing code doesn't seem
    // to worry about correct data to append to 'WWW-Authenticate: ' etc so I won't add any for the D7 conversion.
    $response = explode('=', $response);
    $name = array_shift($response);
    $value = implode('=', $response);
    if (isset($edit['data']) && empty($status)) {
      $header = array(
        'name' => "Authentication-Info: " . $name,
        'value' => $value,
      );
    }
    else {
      $header = array(
        'name' => "WWW-Authenticate: Digest " . $name,
        'value' => $value,
      );
    }
  }
  return $header;
}