Fwd: SyncML Session Question
Logan Owen <[email protected]>
| Newsgroups | gmane.comp.horde.sync |
|---|---|
| Message-ID | <[email protected]> |
All, Updated patch to address my typo. I am able to successfully sync calendar items both ways with the Funambol Android client. -- Logan On Mon, Feb 28, 2011 at 8:39 AM, Logan Owen <[email protected]> wrote: > Stephan, > > Oops, that was a typo when cleaning up my code for a patch. It shouldn't > be parent::__close(), it should be parent::close(). Still may not help your > syncing issues, though. > > -- Logan > > > On Mon, Feb 28, 2011 at 8:23 AM, <[email protected]> wrote: > >> Hi Logan >> >> Thank you for the patch. However I had to "fix" something. I had to >> uncomment >> this: >> >> parent::__close(); >> >> otherwise I would have gotten errors. >> >> The sync from cell phone -> horde works fine. HOwever nothing is being >> synced >> from horde -> cell phone. >> >> Stephan >> -- >> sync mailing list - Join the hunt: http://horde.org/bounties/#sync >> Frequently Asked Questions: http://horde.org/faq/ >> To unsubscribe, mail: [email protected] >> > > -- sync mailing list - Join the hunt: http://horde.org/bounties/#sync Frequently Asked Questions: http://horde.org/faq/ To unsubscribe, mail: [email protected]
0001-Update-SyncML-to-enable-syncing-with-at-least-the-An.patch
(application/octet-stream, 2.8 KB)
From 1d1193e45f49bbaa097c548adb74aedcad29d2f7 Mon Sep 17 00:00:00 2001 From: Logan Owen <[email protected]> Date: Mon, 28 Feb 2011 08:28:55 -0500 Subject: [PATCH] Update SyncML to enable syncing with at least the Android Funambol Client --- framework/SyncML/SyncML/Backend/Horde.php | 38 ++++++++++++++++++++++------ 1 files changed, 30 insertions(+), 8 deletions(-) diff --git a/framework/SyncML/SyncML/Backend/Horde.php b/framework/SyncML/SyncML/Backend/Horde.php index 92f6d3c..fd0335f 100644 --- a/framework/SyncML/SyncML/Backend/Horde.php +++ b/framework/SyncML/SyncML/Backend/Horde.php @@ -66,19 +66,33 @@ class SyncML_Backend_Horde extends SyncML_Backend { /* Only the server needs to start a session. */ if ($this->_backendMode == SYNCML_BACKENDMODE_SERVER) { /* Reload the Horde SessionHandler if necessary. */ - $GLOBALS['session']->setup(false); + /* SyncML carries the session information in the message.* + * This is neccessary to force PHP to associate multiple + * requests with the same session. + */ + + $sid = md5($syncDeviceID . $sessionId); + session_id($sid); + $GLOBALS['session']->setup(); $this->state = $GLOBALS['session']->get('horde', 'syncml'); - register_shutdown_function(array($this, 'sessionShutdown')); } } - function sessionShutdown() + /** + * Cleanup function called after all message processing is finished. + * + * Allows for things like closing databases or flushing logs. When + * running in test mode, tearDown() must be called rather than close. + */ + function close() { - if ($this->state) { - $GLOBALS['session']->set('horde', 'syncml', $this->state); - } - } + if ($this->state) { + $GLOBALS['session']->set('horde', 'syncml', $this->state); + } + parent::close(); + } + /** * Returns entries that have been modified in the server database. * @@ -469,10 +483,18 @@ class SyncML_Backend_Horde extends SyncML_Backend { */ function _checkAuthentication($username, $password) { + /* $auth->authenticate() calls a method which regenerates the session_id + * to prevent session fixation. Usually, this is a good idea, but because + * the server can't change the SyncML session ID, we need to force the + * session id back to the old value. + */ + $sid = session_id(); $auth = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Auth')->create(); - return $auth->authenticate($username, array('password' => $password)) + $auth_val = $auth->authenticate($username, array('password' => $password)) ? $GLOBALS['registry']->getAuth() : false; + session_id($sid); + return $auth_val; } /** -- 1.7.3.4