/** * (non-PHPdoc) * @see Tinebase_Server_Interface::handle() */ public function handle(\Zend\Http\Request $request = null, $body = null) { $this->_request = $request instanceof \Zend\Http\Request ? $request : Tinebase_Core::get(Tinebase_Core::REQUEST); $this->_body = $this->_getBody($body); try { list($loginName, $password) = $this->_getAuthData($this->_request); } catch (Tinebase_Exception_NotFound $tenf) { header('WWW-Authenticate: Basic realm="ActiveSync for Tine 2.0"'); header('HTTP/1.1 401 Unauthorized'); return; } if (Tinebase_Core::isLogLevel(Zend_Log::INFO)) { Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' is ActiveSync request.'); } Tinebase_Core::initFramework(); try { $authResult = $this->_authenticate($loginName, $password, $this->_request); } catch (Exception $e) { Tinebase_Exception::log($e); $authResult = false; } if ($authResult !== true) { header('WWW-Authenticate: Basic realm="ActiveSync for Tine 2.0"'); header('HTTP/1.1 401 Unauthorized'); return; } if (!$this->_checkUserPermissions($loginName)) { return; } $this->_initializeRegistry(); $request = new Zend_Controller_Request_Http(); $request->setRequestUri($this->_request->getRequestUri()); $syncFrontend = new Syncroton_Server(Tinebase_Core::getUser()->accountId, $request, $this->_body); $syncFrontend->handle(); Tinebase_Controller::getInstance()->logout(); }
/** * @run2InSeparateProcess */ public function testFetchMultiPart() { $_SERVER['REQUEST_METHOD'] = 'POST'; $_SERVER['HTTP_MS_ASPROTOCOLVERSION'] = '2.5'; $_SERVER['HTTP_USER_AGENT'] = 'Apple-iPhone/705.18'; $_SERVER['HTTP_MS_ASACCEPTMULTIPART'] = 'T'; $doc = new DOMDocument(); $doc->loadXML('<?xml version="1.0" encoding="utf-8"?> <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/"> <Sync xmlns="uri:AirSync" xmlns:AirSyncBase="uri:AirSyncBase"><Collections><Collection><Class>Contacts</Class><SyncKey>1356</SyncKey><CollectionId>48ru47fhf7ghf7fgh4</CollectionId><DeletesAsMoves/><GetChanges/><WindowSize>100</WindowSize><Options><AirSyncBase:BodyPreference><AirSyncBase:Type>1</AirSyncBase:Type><AirSyncBase:TruncationSize>5120</AirSyncBase:TruncationSize></AirSyncBase:BodyPreference><Conflict>1</Conflict></Options></Collection></Collections></Sync>'); $request = new CakeRequest('http://localhost/Microsoft-Server-ActiveSync?User=abc1234&DeviceId=Appl7R743U8YWH8&DeviceType=iPhone&Cmd=Sync'); ob_start(); $server = new Syncroton_Server('abc1234', $request, $doc); $server->handle(); $result = ob_get_contents(); ob_end_clean(); header("Content-Type: text/html"); $this->assertEquals('AQAAAAwAAAAqAAAAAwFqAEVcT0sDMAABUgM0OHJ1NDdmaGY3Z2hmN2ZnaDQAAU4DMwABAQEB', base64_encode($result)); }
if (!defined('WEBROOT_DIR')) { define('WEBROOT_DIR', basename(dirname(__FILE__))); } if (!defined('WWW_ROOT')) { define('WWW_ROOT', dirname(__FILE__) . DS); } if (!defined('CAKE_CORE_INCLUDE_PATH')) { if (function_exists('ini_set')) { ini_set('include_path', ROOT . DS . 'lib' . PATH_SEPARATOR . ini_get('include_path')); } if (!(include 'Cake' . DS . 'bootstrap.php')) { $failed = true; } } else { if (!(include CAKE_CORE_INCLUDE_PATH . DS . 'Cake' . DS . 'bootstrap.php')) { $failed = true; } } if (!empty($failed)) { trigger_error("CakePHP core could not be found. Check the value of CAKE_CORE_INCLUDE_PATH in APP/webroot/index.php. It should point to the directory containing your " . DS . "cake core directory and your " . DS . "vendors root directory.", E_USER_ERROR); } App::uses('ConnectionManager', 'Model'); Syncroton_Registry::setDatabase(ConnectionManager::getDataSource('default')); Syncroton_Registry::set('loggerBackend', new Syncroton_Log()); Syncroton_Registry::setContactsDataClass('Syncroton_Data_Contacts'); Syncroton_Registry::setCalendarDataClass('Syncroton_Data_Calendar'); Syncroton_Registry::setTasksDataClass('Syncroton_Data_Tasks'); Syncroton_Registry::setEmailDataClass('Syncroton_Data_Email'); Syncroton_Registry::setNotesDataClass('Syncroton_Data_Notes'); $server = new Syncroton_Server($_SERVER['PHP_AUTH_USER']); $server->handle();