protected function Bakery::validateData in Bakery Single Sign-On System 7.3
Validate and decrypt baked data.
Parameters
string $data Baked data.:
string $type Cookie type.:
Return value
array Original, raw data.
2 calls to Bakery::validateData()
- Bakery::validateSsoCookie in ./bakery.inc 
- Check and validate account SSO cookie for request.
- Bakery::validateSubCookie in ./bakery.inc 
- Check and validate cookie used in login or registration from sub-site.
File
- ./bakery.inc, line 239 
Class
Code
protected function validateData($data, $type) {
  $this
    ->debug('validated data', $data);
  $data = base64_decode($data);
  $signature = substr($data, 0, 64);
  $encrypted_data = substr($data, 64);
  if ($signature !== $this
    ->sign($encrypted_data)) {
    throw new BakeryException(3001, 'Signature mismatch');
  }
  $data = $this
    ->decrypt($encrypted_data);
  $decrypted_data = $this
    ->unserialize($data);
  $this
    ->debug('decrypted', $decrypted_data);
  // Prevent one cookie being used in place of another.
  if ($type !== NULL && $decrypted_data['type'] !== $type) {
    throw new BakeryException(3002, 'Type mismatch');
  }
  if ($decrypted_data['timestamp'] + $this->lifetime >= $_SERVER['REQUEST_TIME']) {
    return $decrypted_data;
  }
  else {
    throw new BakeryException(3003, 'Data expired');
  }
}