/** * Create a Context object (used for session management) for a given ticket and token * * */ public function context($ticket = null, $token = null, $check_if_valid = true) { $Context = null; if ($this->_authmode == QuickBooks_IPP::AUTHMODE_OAUTH) { $Context = new QuickBooks_IPP_Context($this, null, $token); // @todo Support for checking if it's valid or not } else { if (is_null($ticket)) { $ticket = QuickBooks_IPP_Federator::getCookie(); } $Context = new QuickBooks_IPP_Context($this, $ticket, $token); //print('check if valid [' . $check_if_valid . ']'); if ($check_if_valid) { // Now, let's check to make sure the context is valid $User = $this->getUserInfo($Context); if (!$User or !is_object($User) or $User->isAnonymous()) { return null; } } } //print_r($Context); return $Context; }
protected function _doCallback($auth_id, $ticket, $target_url, $realm_id_pseudonym) { if ($this->_callback) { $err = ''; $redirect = QuickBooks_Callbacks::callSAMLCallback($this->_driver, $this->_callback, $auth_id, $ticket, $target_url, $realm_id_pseudonym, $this->_config, $err); if ($err) { $this->_setError(QuickBooks_IPP_Federator::ERROR_CALLBACK, 'Callback said: ' . $err); return false; } } else { // Just set the cookie $cookie_expire = (int) $this->_config['cookie_expire']; $cookie_path = $this->_config['cookie_path']; $cookie_domain = $this->_config['cookie_domain']; $cookie_secure = (bool) $this->_config['cookie_secure']; $cookie_httponly = (bool) $this->_config['cookie_httponly']; //print('setting cookie: ' . print_r($this->_config, true)); if (QuickBooks_IPP_Federator::setCookie($ticket, $cookie_expire, $cookie_path, $cookie_domain, $cookie_secure, $cookie_httponly)) { $redirect = true; } else { // Cookie failed to set for some reason $this->_setError(QuickBooks_IPP_Federator::ERROR_COOKIE, 'Could not set the IPP context cookie (did you make sure *not* to send any output yet?)'); return false; } } if ($redirect) { $this->_doRedirect($target_url); } return true; }