Pass the rest of the policy parameters to the activesync server.
authorMichael J. Rubinsky <mrubinsk@horde.org>
Thu, 1 Apr 2010 20:12:51 +0000 (16:12 -0400)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Thu, 1 Apr 2010 20:12:51 +0000 (16:12 -0400)
Simplify this a little while I'm at it..

framework/ActiveSync/lib/Horde/ActiveSync/Driver/Base.php
framework/ActiveSync/lib/Horde/ActiveSync/Request/Base.php
horde/rpc.php

index 7dbdc4e..173077c 100644 (file)
@@ -75,9 +75,8 @@ abstract class Horde_ActiveSync_Driver_Base
      *
      * <pre>
      * Currently supported settings are:
-     *   requirePin      - Device must have a pin lock enabled.
-     *   computerUnlock  - Device can be unlocked by a computer.
-     *   AEFrequencyType - AEFrequencyValue is set (1) or not (0)
+     *   pin      - Device must have a pin lock enabled.
+     *   computerunlock  - Device can be unlocked by a computer.
      *   AEFrequencyValue - Time (in minutes) of inactivity before device locks
      *   DeviceWipeThreshold - Number of failed unlock attempts before the
      *                         device should wipe on devices that support this.
@@ -89,14 +88,13 @@ abstract class Horde_ActiveSync_Driver_Base
      * </pre>
      */
     protected $_policies = array(
-        'requirePin' => true,
-        'computerUnlock' => true,
-        'AEFrequencyType' => 1,
-        'AEFrequencyValue' => 5,
-        'DeviceWipeThreshold' => 10,
-        'CodewordFrequency' => 5,
-        'MinimumPasswordLength' => 5,
-        'PasswordComplexity' => 2,
+        'pin' => true,
+        'computerunlock' => true,
+        'inactivity' => 5,
+        'wipethreshold' => 10,
+        'codewordfrequency' => 5,
+        'minimumlength' => 5,
+        'complexity' => 2,
         );
 
     /**
@@ -555,25 +553,25 @@ abstract class Horde_ActiveSync_Driver_Base
     public function getCurrentPolicy($policyType = 'MS-WAP-Provisioning-XML')
     {
         return '<wap-provisioningdoc><characteristic type="SecurityPolicy">'
-        . '<parm name="4131" value="' . ($this->_policies['requirePin'] ? 0 : 1) . '"/>'
-        . '<parm name="4133" value="' . ($this->_policies['computerUnlock'] ? 1 : 0) . '"/>'
+        . '<parm name="4131" value="' . ($this->_policies['pin'] ? 0 : 1) . '"/>'
+        . '<parm name="4133" value="' . ($this->_policies['computerunlock'] ? 1 : 0) . '"/>'
         . '</characteristic>'
         . '<characteristic type="Registry">'
         .   '<characteristic type="HKLM\Comm\Security\Policy\LASSD\AE\{50C13377-C66D-400C-889E-C316FC4AB374}">'
-        .        '<parm name="AEFrequencyType" value="' . $this->_policies['AEFrequencyType'] . '"/>'
-        .        (!empty($this->_policies['AEFrequencyValue']) ? '<parm name="AEFrequencyValue" value="' . $this->_policies['AEFrequencyValue'] . '"/>' : '')
+        .        '<parm name="AEFrequencyType" value="' . (!empty($this->_policies['inactivity']) ? 1 : 0) . '"/>'
+        .        (!empty($this->_policies['AEFrequencyValue']) ? '<parm name="AEFrequencyValue" value="' . $this->_policies['inactivity'] . '"/>' : '')
         .    '</characteristic>'
         .    '<characteristic type="HKLM\Comm\Security\Policy\LASSD">'
-        .        '<parm name="DeviceWipeThreshold" value="' . $this->_policies['DeviceWipeThreshold'] . '"/>'
+        .        '<parm name="DeviceWipeThreshold" value="' . $this->_policies['wipethreshold'] . '"/>'
         .    '</characteristic>'
         .    '<characteristic type="HKLM\Comm\Security\Policy\LASSD">'
-        .        '<parm name="CodewordFrequency" value="' . $this->_policies['CodewordFrequency'] . '"/>'
+        .        '<parm name="CodewordFrequency" value="' . $this->_policies['codewordfrequency'] . '"/>'
         .    '</characteristic>'
         .    '<characteristic type="HKLM\Comm\Security\Policy\LASSD\LAP\lap_pw">'
-        .        '<parm name="MinimumPasswordLength" value="' . $this->_policies['MinimumPasswordLength'] . '"/>'
+        .        '<parm name="MinimumPasswordLength" value="' . $this->_policies['minimumlength'] . '"/>'
         .    '</characteristic>'
         .    '<characteristic type="HKLM\Comm\Security\Policy\LASSD\LAP\lap_pw">'
-        .        '<parm name="PasswordComplexity" value="' . $this->_policies['PasswordComplexity'] . '"/>'
+        .        '<parm name="PasswordComplexity" value="' . $this->_policies['complexity'] . '"/>'
         .    '</characteristic>'
         . '</characteristic>'
         . '</wap-provisioningdoc>';
index be9c9ea..e63715a 100644 (file)
@@ -121,7 +121,7 @@ abstract class Horde_ActiveSync_Request_Base
             /* Loose provsioning should allow a blank key */
             if ((empty($storedKey) || $storedKey != $sentKey) &&
                ($this->_provisioning !== 'loose' ||
-               ($this->_provisioning === 'loose' && !empty($this->_policyKey)))) {
+               ($this->_provisioning === 'loose' && !is_null($this->_policyKey)))) {
 
                     Horde_ActiveSync::provisioningRequired();
                     return false;
index 217a91b..15cea1f 100644 (file)
@@ -35,7 +35,7 @@ $params['logger'] = $GLOBALS['injector']->getInstance('Horde_Log_Logger');
 
 /* Look at the Content-type of the request, if it is available, to try
  * and determine what kind of request this is. */
-if (!empty($conf['activesync']['enabled']) &&
+if (!empty($GLOBALS['conf']['activesync']['enabled']) &&
     ((strpos($request->getServer('CONTENT_TYPE'), 'application/vnd.ms-sync.wbxml') !== false) ||
     (strpos($request->getUri(), 'Microsoft-Server-ActiveSync') !== false))) {
     /* ActiveSync Request */
@@ -47,15 +47,16 @@ if (!empty($conf['activesync']['enabled']) &&
     $params['registry'] = $GLOBALS['registry'];
     $connector = new Horde_ActiveSync_Driver_Horde_Connector_Registry($params);
     $stateMachine = new Horde_ActiveSync_State_File(array('stateDir' => $GLOBALS['conf']['activesync']['state']['directory']));
-    $params['backend'] = new Horde_ActiveSync_Driver_Horde(array('connector' => $connector,
-                                                                 'state_basic' => $stateMachine));
+    $driver_params = array('connector' => $connector, 'state_basic' => $stateMachine);
+    if ($params['provisioning'] = $GLOBALS['conf']['activesync']['securitypolicies']['provisioning']) {
+        $driver_params['policies'] = $GLOBALS['conf']['activesync']['securitypolicies'];
+    }
+    $params['backend'] = new Horde_ActiveSync_Driver_Horde($driver_params);
     $params['server'] = new Horde_ActiveSync($params['backend'],
                                              new Horde_ActiveSync_Wbxml_Decoder(fopen('php://input', 'r')),
                                              new Horde_ActiveSync_Wbxml_Encoder(fopen('php://output', 'w+')),
                                              $request);
     $params['server']->setLogger($params['logger']);
-    $params['provisioning'] = $conf['activesync']['securitypolicies']['provisioning'];
-
 } elseif ($request->getServer('PATH_INFO') ||
     in_array($request->getServer('REQUEST_METHOD'), array('DELETE', 'PROPFIND', 'PUT', 'OPTIONS'))) {
     $serverType = 'Webdav';