You are here

function simple_ldap_sso_get_cookie_data in Simple LDAP 7

Same name and namespace in other branches
  1. 7.2 simple_ldap_sso/simple_ldap_sso.inc \simple_ldap_sso_get_cookie_data()

Read the SSO data from the cookie.

Parameters

string $cookie_value: Optional cookie value to read the data from. If left blank, the cookie will be read from $_COOKIE. This argument likely will only be used during testing.

Return value

mixed An array of data, or FALSE if it was unable to be read.

4 calls to simple_ldap_sso_get_cookie_data()
SimpleLdapSSOTestCase::getSSOCookieData in simple_ldap_sso/simple_ldap_sso.test
Get the SSO cookie data from the current SSO cookie.
simple_ldap_sso_init in simple_ldap_sso/simple_ldap_sso.module
Implements hook_init().
simple_ldap_sso_populate_session in simple_ldap_sso/simple_ldap_sso.inc
Helper function to decrypt the SSO cookie, and verify its data.
simple_ldap_sso_validate_ldap in simple_ldap_sso/simple_ldap_sso.inc
Validate the SSO data matches what we have in LDAP.
1 string reference to 'simple_ldap_sso_get_cookie_data'
SimpleLdapSSOTestCase::getSSOCookieData in simple_ldap_sso/simple_ldap_sso.test
Get the SSO cookie data from the current SSO cookie.

File

simple_ldap_sso/simple_ldap_sso.inc, line 167
Simple LDAP SSO API functions.

Code

function simple_ldap_sso_get_cookie_data($cookie_value = NULL) {
  $result =& drupal_static(__FUNCTION__);

  // If this has already been called, return what we have.
  if (isset($result)) {
    return $result;
  }

  // Check to make sure the cookie exists.
  if (!isset($cookie_value)) {
    if (!isset($_COOKIE[SIMPLE_LDAP_SSO_COOKIE])) {
      $result = FALSE;
      return $result;
    }
    $cookie_value = $_COOKIE[SIMPLE_LDAP_SSO_COOKIE];
  }
  $result = simple_ldap_sso_decrypt($cookie_value);

  // Validate the user exists on this site, by looking up the uid.
  if ($result && ($uid = simple_ldap_sso_validate_user($result))) {
    $result['uid'] = $uid;
  }
  else {
    $result = FALSE;
  }
  return $result;
}