Skip to content

Commit

Permalink
Merge branch 'master' into kronolith_4_2
Browse files Browse the repository at this point in the history
  • Loading branch information
mrubinsk committed Nov 20, 2013
2 parents ca51cce + 57aca33 commit 050baa7
Show file tree
Hide file tree
Showing 34 changed files with 294 additions and 178 deletions.
65 changes: 0 additions & 65 deletions framework/ActiveSync/doc/Horde/ActiveSync/UPGRADING

This file was deleted.

13 changes: 13 additions & 0 deletions framework/ActiveSync/lib/Horde/ActiveSync.php
Expand Up @@ -834,6 +834,19 @@ public function handleRequest($cmd, $devId)
}
}

// Lastly, check if the device has been set to blocked.
if ($this->_device->blocked) {
$msg = sprintf(
'The device %s was blocked.',
$this->_device->id);
self::$_logger->err($msg);
if ($version > self::VERSION_TWELVEONE) {
$this->_globalError = Horde_ActiveSync_Status::DEVICE_BLOCKED_FOR_USER;
} else {
throw new Horde_ActiveSync_Exception($msg);
}
}

// Don't bother with everything else if all we want are Options
if ($cmd == 'Options') {
$this->_doOptionsRequest();
Expand Down
5 changes: 5 additions & 0 deletions framework/ActiveSync/lib/Horde/ActiveSync/Device.php
Expand Up @@ -40,6 +40,7 @@
* folders for, therefore all sources must
* be multiplexed together. Masks are
* the MULTIPLEX_* constants.
* @property boolean blocked True if device has been marked as blocked.
*
*/
class Horde_ActiveSync_Device
Expand All @@ -53,6 +54,8 @@ class Horde_ActiveSync_Device
const VERSION = 'version';
const MULTIPLEX = 'multiplex';
const ANNOUNCED_VERSION = 'announcedVersion';
const BLOCKED = 'blocked';


// Bitwise constants for flagging device must use multiplexed collections.
// @since 2.9.0
Expand Down Expand Up @@ -102,6 +105,7 @@ public function &__get($property)
switch ($property) {
case self::MULTIPLEX:
case self::ANNOUNCED_VERSION:
case self::BLOCKED:
return $this->_properties['properties'][$property];
default:
if (isset($this->_properties[$property])) {
Expand All @@ -121,6 +125,7 @@ public function __set($property, $value)
switch ($property) {
case self::MULTIPLEX:
case self::ANNOUNCED_VERSION:
case self::BLOCKED:
$properties = $this->properties;
if (empty($properties)) {
$properties = array();
Expand Down
23 changes: 14 additions & 9 deletions framework/ActiveSync/lib/Horde/ActiveSync/Folder/Imap.php
Expand Up @@ -377,16 +377,21 @@ public function serialize()
* @throws Horde_ActiveSync_Exception_StaleState
*/
public function unserialize($data)
{ $data = json_decode($data, true);
if (!is_array($data) || empty($data['v']) || $data['v'] != self::VERSION) {
throw new Horde_ActiveSync_Exception_StaleState('Cache version change');
{ $d_data = json_decode($data, true);
if (!is_array($d_data) || empty($d_data['v']) || $d_data['v'] != self::VERSION) {
// Try using the old serialization strategy, since this would save
// an expensive resync of email collections.
$d_data = @unserialize($data);
if (!is_array($d_data) || empty($d_data['v']) || $d_data['v'] != 1) {
throw new Horde_ActiveSync_Exception_StaleState('Cache version change');
}
}
$this->_status = $data['s'];
$this->_messages = $data['m'];
$this->_serverid = $data['f'];
$this->_class = $data['c'];
$this->_lastSinceDate = $data['lsd'];
$this->_softDelete = $data['sd'];
$this->_status = $d_data['s'];
$this->_messages = $d_data['m'];
$this->_serverid = $d_data['f'];
$this->_class = $d_data['c'];
$this->_lastSinceDate = $d_data['lsd'];
$this->_softDelete = $d_data['sd'];
}

/**
Expand Down
8 changes: 8 additions & 0 deletions framework/ActiveSync/lib/Horde/ActiveSync/Request/Sync.php
Expand Up @@ -360,6 +360,9 @@ protected function _handle()
// iOS need this in order to catch missing state.
$this->_logger->err($e->getMessage());
$statusCode = self::STATUS_FOLDERSYNC_REQUIRED;
} catch (Horde_ActiveSync_Exception_StaleState $e) {
$this->_logger->notice($e->getMessage());
return false;
} catch (Horde_ActiveSync_Exception $e) {
$this->_logger->err($e->getMessage());
return false;
Expand Down Expand Up @@ -857,6 +860,11 @@ protected function _parseSyncCommands(&$collection)
$this->_statusCode = self::STATUS_KEYMISM;
$this->_handleError($collection);
return false;
} catch (Horde_ActiveSync_Exception_StaleState $e) {
$this->_logger->notice($e->getMessage());
$this->_statusCode = self::STATUS_SERVERERROR;
$this->_handleGlobalSyncError();
return false;
} catch (Horde_ActiveSync_Exception $e) {
$this->_logger->err($e->getMessage());
$this->_statusCode = self::STATUS_SERVERERROR;
Expand Down
13 changes: 12 additions & 1 deletion framework/ActiveSync/lib/Horde/ActiveSync/State/Mongo.php
Expand Up @@ -668,16 +668,27 @@ public function deviceExists($devId, $user = null)
*
* @param string $user The username to list devices for. If empty, will
* return all devices.
* @param array $filter An array of optional filters where the keys are
* field names and the values are values to match
* exactly.
*
* @return array An array of device hashes
* @throws Horde_ActiveSync_Exception
*/
public function listDevices($user = null)
public function listDevices($user = null, $filter = array())
{
$query = array();
if (!empty($user)) {
$query['users.device_user'] = $user;
}
$explicit_fields = array('device_id', 'device_type', 'device_agent', 'device_user');
foreach ($filter as $key => $value) {
if (in_array($key, $explicit_fields)) {
$query[$key] = $value;
} else {
$query['device_properties.' . $key] = new MongoRegex("/^$value*/");
}
}
try {
$cursor = $this->_db->HAS_device->find($query);
} catch (Exception $e) {
Expand Down
13 changes: 12 additions & 1 deletion framework/ActiveSync/lib/Horde/ActiveSync/State/Sql.php
Expand Up @@ -691,20 +691,31 @@ public function deviceExists($devId, $user = null)
*
* @param string $user The username to list devices for. If empty, will
* return all devices.
* @param array $filter An array of optional filters where the keys are
* field names and the values are values to match.
*
* @return array An array of device hashes
* @throws Horde_ActiveSync_Exception
*/
public function listDevices($user = null)
public function listDevices($user = null, $filter = array())
{
$query = 'SELECT d.device_id AS device_id, device_type, device_agent,'
. ' device_policykey, device_rwstatus, device_user, device_properties FROM '
. $this->_syncDeviceTable . ' d INNER JOIN ' . $this->_syncUsersTable
. ' u ON d.device_id = u.device_id';
$values = array();
$glue = false;
if (!empty($user)) {
$query .= ' WHERE u.device_user = ?';
$values[] = $user;
$glue = true;
}
$explicit_fields = array('device_id', 'device_type', 'device_agent', 'device_user');
foreach ($filter as $key => $value) {
if (in_array($key, $explicit_fields)) {
$query .= ($glue ? ' AND ' : ' WHERE ') . 'd.' . $key . ' LIKE ?';
$values[] = $value . '%';
}
}

try {
Expand Down
30 changes: 21 additions & 9 deletions framework/ActiveSync/package.xml
Expand Up @@ -10,9 +10,9 @@
<email>mrubinsk@horde.org</email>
<active>yes</active>
</lead>
<date>2013-10-22</date>
<date>2013-11-19</date>
<version>
<release>2.9.0</release>
<release>2.9.1</release>
<api>2.9.0</api>
</version>
<stability>
Expand All @@ -21,10 +21,9 @@
</stability>
<license uri="http://www.horde.org/licenses/gpl">GPL-2.0</license>
<notes>
* [mjr] Fix generating EAS folder uids for devices that can&apos;t tell the difference between a string and an integer.
* [mjr] Changes to support multiple non-email collections of the same type.
* [mjr] Improvements to memory and database usage.
* [mjr] Add MongoDB state driver.
* [mjr] Add ability to flag a specific device as blocked.
* [mjr] Add ability to filter the list of devices on more than username.
* [mjr] Attempt to recover old serialized data before forcing a repairing of Email collections.
</notes>
<contents>
<dir baseinstalldir="/" name="/">
Expand All @@ -33,7 +32,6 @@
<dir name="ActiveSync">
<file name="COPYING" role="doc" />
<file name="TODO" role="doc" />
<file name="UPGRADING" role="doc" />
</dir> <!-- /doc/Horde/ActiveSync -->
</dir> <!-- /doc/Horde -->
</dir> <!-- /doc -->
Expand Down Expand Up @@ -363,7 +361,6 @@
<filelist>
<install as="COPYING" name="doc/Horde/ActiveSync/COPYING" />
<install as="TODO" name="doc/Horde/ActiveSync/TODO" />
<install as="UPGRADING" name="doc/Horde/ActiveSync/UPGRADING" />
<install as="Horde/ActiveSync.php" name="lib/Horde/ActiveSync.php" />
<install as="Horde/ActiveSync/Collections.php" name="lib/Horde/ActiveSync/Collections.php" />
<install as="Horde/ActiveSync/Device.php" name="lib/Horde/ActiveSync/Device.php" />
Expand Down Expand Up @@ -1803,7 +1800,7 @@
<stability>
<release>stable</release>
<api>stable</api></stability>
<date>2013-10-22</date>
<date>2013-11-18</date>
<license uri="http://www.horde.org/licenses/gpl">GPL-2.0</license>
<notes>
* [mjr] Fix generating EAS folder uids for devices that can&apos;t tell the difference between a string and an integer.
Expand All @@ -1812,5 +1809,20 @@
* [mjr] Add MongoDB state driver.
</notes>
</release>
<release>
<version>
<release>2.9.1</release>
<api>2.9.0</api></version>
<stability>
<release>stable</release>
<api>stable</api></stability>
<date>2013-11-19</date>
<license uri="http://www.horde.org/licenses/gpl">GPL-2.0</license>
<notes>
* [mjr] Add ability to flag a specific device as blocked.
* [mjr] Add ability to filter the list of devices on more than username.
* [mjr] Attempt to recover old serialized data before forcing a repairing of Email collections.
</notes>
</release>
</changelog>
</package>
Expand Up @@ -40,7 +40,7 @@ public function testDuplicatePIMAddition()
// @TODO. For now, cheat and add the data directly to the db.
try {
$mongo = new Horde_Mongo_Client();
$mongo->activesync_test->map->insert(array(
$mongo->activesync_test->HAS_map->insert(array(
'sync_clientid' => 'abc',
'sync_user' => 'mike',
'message_uid' => 'def',
Expand Down
2 changes: 1 addition & 1 deletion framework/Auth/lib/Horde/Auth.php
Expand Up @@ -247,7 +247,7 @@ static public function getSalt($encryption = 'md5-hex', $seed = '',
case 'sha256':
case 'ssha256':
return $seed
? substr(base64_decode(preg_replace('|^{SSHA256}|i', '', $seed)), 20)
? substr(base64_decode(preg_replace('|^{SSHA256}|i', '', $seed)), 32)
: substr(pack('H*', hash('sha256', substr(pack('h*', hash('md5', mt_rand())), 0, 8) . $plaintext)), 0, 4);

case 'smd5':
Expand Down
4 changes: 2 additions & 2 deletions framework/Auth/package.xml
Expand Up @@ -34,7 +34,7 @@
</stability>
<license uri="http://www.horde.org/licenses/lgpl21">LGPL-2.1</license>
<notes>
*
* [mms] Fix parsing salted SHA256 entries (Adam James &lt;adam.james@transitiv.co.uk&gt;).
</notes>
<contents>
<dir baseinstalldir="/" name="/">
Expand Down Expand Up @@ -904,7 +904,7 @@
<date>2013-10-15</date>
<license uri="http://www.horde.org/licenses/lgpl21">LGPL-2.1</license>
<notes>
*
* [mms] Fix parsing salted SHA256 entries (Adam James &lt;adam.james@transitiv.co.uk&gt;).
</notes>
</release>
</changelog>
Expand Down
Binary file modified framework/Auth/test/Horde/Auth/TestCase.php
Binary file not shown.
4 changes: 2 additions & 2 deletions framework/Auth/test/Horde/Auth/Unit/AuthTest.php
Expand Up @@ -27,8 +27,8 @@ public function testGetSalt($encryption, $password, $salt)
/**
* @dataProvider getCredentials
*/
public function testGetCryptedPassword($encryption, $password, $salt)
public function testGetCryptedPassword($encryption, $password, $salt, $show_encryption = false)
{
$this->assertEquals($password, Horde_Auth::getCryptedPassword('foobar', $password, $encryption, false));
$this->assertEquals($password, Horde_Auth::getCryptedPassword('foobar', $password, $encryption, $show_encryption));
}
}
2 changes: 1 addition & 1 deletion framework/Auth/test/Horde/Auth/Unit/Sql/Pdo/SqliteTest.php
Expand Up @@ -20,7 +20,7 @@ public static function setUpBeforeClass()
self::$db = $factory_db->create();
parent::setUpBeforeClass();
} catch (Horde_Test_Exception $e) {
self::$_reason = 'Sqlite not available.';
self::$reason = 'Sqlite not available.';
}
}

Expand Down
4 changes: 3 additions & 1 deletion framework/Core/lib/Horde/Core/Factory/Mail.php
Expand Up @@ -49,7 +49,9 @@ public function create($config = null)

if (strcasecmp($transport, 'smtp') === 0) {
$transport = 'Smtphorde';
} elseif (empty($params['auth'])) {
}

if (empty($params['auth'])) {
unset($params['username'], $params['password']);
}

Expand Down

0 comments on commit 050baa7

Please sign in to comment.