From 2223896bbbcf36f242dff6ec7ded5bcf7686a8ea Mon Sep 17 00:00:00 2001 From: "Michael J. Rubinsky" Date: Mon, 26 Apr 2010 15:30:10 -0400 Subject: [PATCH] More improvements to provisioning, fix variable names. With this and the last commit, provisioning can now be set to Allow, while still allowing Android devices to connect. The Android devices will not be provisioned, so setting it to 'Force' will still prevent them from connecting, but now at least using Android won't prevent allowing other devices to be provisioned. --- framework/ActiveSync/lib/Horde/ActiveSync.php | 11 +++++++++ .../lib/Horde/ActiveSync/Request/Base.php | 8 +++---- .../lib/Horde/ActiveSync/Request/Options.php | 26 ---------------------- .../lib/Horde/ActiveSync/Request/Provision.php | 12 +++++----- framework/ActiveSync/package.xml | 2 -- 5 files changed, 21 insertions(+), 38 deletions(-) delete mode 100644 framework/ActiveSync/lib/Horde/ActiveSync/Request/Options.php diff --git a/framework/ActiveSync/lib/Horde/ActiveSync.php b/framework/ActiveSync/lib/Horde/ActiveSync.php index eee765331..d6b8c661d 100644 --- a/framework/ActiveSync/lib/Horde/ActiveSync.php +++ b/framework/ActiveSync/lib/Horde/ActiveSync.php @@ -991,7 +991,18 @@ class Horde_ActiveSync */ public function handleRequest($cmd, $devId) { + /* Don't bother with everything else if all we want are Options */ + if ($cmd == 'Options') { + self::activeSyncHeader(); + self::versionHeader(); + self::commandsHeader(); + return true; + } + /* Check that this device is known */ + if (is_null($devId)) { + throw new Horde_ActiveSync_Exception('Device failed to send device id.'); + } $state = $this->_driver->getStateObject(); if (!empty($devId) && !$state->deviceExists($devId)) { $get = $this->_request->getGetParams(); diff --git a/framework/ActiveSync/lib/Horde/ActiveSync/Request/Base.php b/framework/ActiveSync/lib/Horde/ActiveSync/Request/Base.php index 4d61f0c30..bea0b85c3 100644 --- a/framework/ActiveSync/lib/Horde/ActiveSync/Request/Base.php +++ b/framework/ActiveSync/lib/Horde/ActiveSync/Request/Base.php @@ -149,15 +149,15 @@ abstract class Horde_ActiveSync_Request_Base * header - which is against the specification. Check the user agent * for Android (maybe need version sniffing in the future) and set the * policykey to null for those devices. */ - $this->_device = $this->_state->getDeviceInfo($this->_devId); - if (strpos($this->_device->agent, 'Android') !== false) { + $this->_device = $this->_state->getDeviceInfo($this->_device->id); + if (strpos($this->_device->userAgent, 'Android') !== false) { $sentKey = null; } /* Don't attempt if we don't care */ if ($this->_provisioning !== false) { $state = $this->_driver->getStateObject(); - $storedKey = $state->getPolicyKey($this->_devId); + $storedKey = $state->getPolicyKey($this->_device->id); /* Loose provsioning should allow a blank key */ if ((empty($storedKey) || $storedKey != $sentKey) && ($this->_provisioning !== 'loose' || @@ -185,7 +185,7 @@ abstract class Horde_ActiveSync_Request_Base */ public function handle() { - $this->_version = $activeSync->getProtocolVersion(); + $this->_version = $this->_activeSync->getProtocolVersion(); $this->_logger->info('Request received from device: ' . $this->_device->id . ' Supporting protocol version: ' . $this->_version); } diff --git a/framework/ActiveSync/lib/Horde/ActiveSync/Request/Options.php b/framework/ActiveSync/lib/Horde/ActiveSync/Request/Options.php deleted file mode 100644 index 21b4a4bff..000000000 --- a/framework/ActiveSync/lib/Horde/ActiveSync/Request/Options.php +++ /dev/null @@ -1,26 +0,0 @@ - - * @package Horde_ActiveSync - */ -/** - * Zarafa Deutschland GmbH, www.zarafaserver.de - * This file is distributed under GPL v2. - * Consult LICENSE file for details - */ -class Horde_ActiveSync_Request_Options extends Horde_ActiveSync_Request_Base -{ - public function handle() - { - Horde_ActiveSync::activeSyncHeader(); - Horde_ActiveSync::versionHeader(); - Horde_ActiveSync::commandsHeader(); - - return true; - } - -} diff --git a/framework/ActiveSync/lib/Horde/ActiveSync/Request/Provision.php b/framework/ActiveSync/lib/Horde/ActiveSync/Request/Provision.php index 7424a1441..22ff75f93 100644 --- a/framework/ActiveSync/lib/Horde/ActiveSync/Request/Provision.php +++ b/framework/ActiveSync/lib/Horde/ActiveSync/Request/Provision.php @@ -140,7 +140,7 @@ class Horde_ActiveSync_Request_Provision extends Horde_ActiveSync_Request_Base return $this->_globalError(self::STATUS_PROTERROR); } if ($status == self::STATUS_CLIENT_SUCCESS) { - $this->_state->setDeviceRWStatus($this->_devId, Horde_ActiveSync::RWSTATUS_WIPED); + $this->_state->setDeviceRWStatus($this->_device->id, Horde_ActiveSync::RWSTATUS_WIPED); } } } @@ -156,17 +156,17 @@ class Horde_ActiveSync_Request_Provision extends Horde_ActiveSync_Request_Base send it to the client. */ if (!$phase2) { /* Verify intermediate key */ - if ($this->_state->getPolicyKey($this->_devId) != $policykey) { + if ($this->_state->getPolicyKey($this->_device->id) != $policykey) { $policyStatus = self::STATUS_POLKEYMISM; } else { /* Set the final key */ $policykey = $this->_state->generatePolicyKey(); - $this->_state->setPolicyKey($this->_devId, $policykey); + $this->_state->setPolicyKey($this->_device->id, $policykey); } } elseif (empty($policykey)) { // This is phase2 - we need to set the intermediate key $policykey = $this->_state->generatePolicyKey(); - $this->_state->setPolicyKey($this->_devId, $policykey); + $this->_state->setPolicyKey($this->_device->id, $policykey); } $this->_encoder->startTag(Horde_ActiveSync::PROVISION_PROVISION); @@ -175,10 +175,10 @@ class Horde_ActiveSync_Request_Provision extends Horde_ActiveSync_Request_Base $this->_encoder->endTag(); /* Wipe data if status is pending or wiped */ - $rwstatus = $this->_state->getDeviceRWStatus($this->_devId); + $rwstatus = $this->_state->getDeviceRWStatus($this->_device->id); if ($rwstatus == Horde_ActiveSync::RWSTATUS_PENDING || $rwstatus == Horde_ActiveSync::RWSTATUS_WIPED) { $this->_encoder->startTag(Horde_ActiveSync::PROVISION_REMOTEWIPE, false, true); - $this->_state->setDeviceRWStatus($this->_devId, Horde_ActiveSync::RWSTATUS_WIPED); + $this->_state->setDeviceRWStatus($this->_device->id, Horde_ActiveSync::RWSTATUS_WIPED); } else { $this->_encoder->startTag(Horde_ActiveSync::PROVISION_POLICIES); $this->_encoder->startTag(Horde_ActiveSync::PROVISION_POLICY); diff --git a/framework/ActiveSync/package.xml b/framework/ActiveSync/package.xml index 5302062df..9d16796de 100644 --- a/framework/ActiveSync/package.xml +++ b/framework/ActiveSync/package.xml @@ -68,7 +68,6 @@ http://pear.php.net/dtd/package-2.0.xsd"> - @@ -121,7 +120,6 @@ http://pear.php.net/dtd/package-2.0.xsd"> - -- 2.11.0