/** * Check authentication. Different backends may handle * authentication in different ways. The base class implementation * checks for HTTP Authentication against the Horde auth setup. * * @return boolean Returns true if authentication is successful. * Should send appropriate "not authorized" headers * or other response codes/body if auth fails, * and take care of exiting. */ public function authorize() { $this->_logger->debug('Horde_Rpc::authorize() starting'); if (!$this->_requireAuthorization) { return true; } // @TODO: inject this $auth = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Auth')->create(); $serverVars = $this->_request->getServerVars(); if (!empty($serverVars['PHP_AUTH_USER'])) { $user = $serverVars['PHP_AUTH_USER']; $pass = $serverVars['PHP_AUTH_PW']; } elseif (!empty($serverVars['Authorization'])) { $hash = str_replace('Basic ', '', $serverVars['Authorization']); $hash = base64_decode($hash); if (strpos($hash, ':') !== false) { list($user, $pass) = explode(':', $hash, 2); } } if (!isset($user) || !$auth->authenticate($user, array('password' => $pass))) { if ($this->_requestMissingAuthorization) { header('WWW-Authenticate: Basic realm="Horde RPC"'); } header('HTTP/1.0 401 Unauthorized'); echo '401 Unauthorized'; exit; } $this->_logger->debug('Horde_Rpc::authorize() exiting'); return true; }
/** * Logs the SQL query for debugging. * * @param string $sql SQL statement. * @param string $name TODO * @param float $runtime Runtime interval. */ protected function _logInfo($sql, $name, $runtime = null) { if ($this->_logger) { $name = (empty($name) ? '' : $name) . (empty($runtime) ? '' : sprintf(" (%.4fs)", $runtime)); $this->_logger->debug($this->_formatLogEntry($name, $sql)); } }
/** * Update the history log for an object. * * @param string $object The object ID. * @param string $bid The backend ID of the object. * @param boolean $force Force update */ protected function _updateLog($object, $bid, $force = false) { $last = $this->_history->getLatestEntry($object); if ($last === false) { // New, unknown object $this->_logger->debug(sprintf('[KOLAB_STORAGE] New object to log in Horde_History: %s, uid: %d', $object, $bid)); $this->_history->log($object, array('action' => 'add', 'bid' => $bid), true); } else { // If the last action for this object was 'delete', we issue an 'add'. // Objects can vanish and re-appear using the same object uid. // (a foreign client is sending an update over a slow link) if ($last['action'] == 'delete') { $this->_logger->debug(sprintf('[KOLAB_STORAGE] Re-adding previously deleted object in Horde_History: %s, uid: %d', $object, $bid)); $this->_history->log($object, array('action' => 'add', 'bid' => $bid), true); } if (!isset($last['bid']) || $last['bid'] != $bid || $force) { $this->_logger->debug(sprintf('[KOLAB_STORAGE] Modifying object in Horde_History: %s, uid: %d, force: %d', $object, $bid, $force)); $this->_history->log($object, array('action' => 'modify', 'bid' => $bid), true); } } }
/** * Calls the specified normal REST API method. * * @param string $method Name of the Facebook method to invoke * @param array $params A map of param names => param values * * @return mixed Result of method call */ public function callMethod($method, array $params = array()) { $this->_logger->debug(sprintf('Calling method %s with parameters %s', $method, print_r($params, true))); $request = new Horde_Service_Facebook_Request_Rest($this, $method, $params); return $request->run(); }
/** * Destructor. * * Logs the counted events. */ public function __destruct() { foreach ($this->_count as $method => $count) { $this->_logger->debug(sprintf('Horde_Kolab_Server: Method %s called %s times.', $method, $count)); } }
/** * Log the missing scope. * * @param Exception $e The exception that occurred. * @param string $scope The scope that was attempted to get. * * @return NULL */ private function _logMissingScope(Exception $e, $scope) { if ($this->_logger !== null) { $this->_logger->debug(sprintf(__CLASS__ . ': No preference information available for scope %s (%s).', $scope, $e->getMessage())); } }