Back to index

d-push  2.0
syncprovisioning.php
Go to the documentation of this file.
00001 <?php
00002 /***********************************************
00003 * File      :   syncprovisioning.php
00004 * Project   :   Z-Push
00005 * Descr     :   WBXML AS12+ provisionign entities that
00006 *               can be parsed directly (as a stream) from WBXML.
00007 *               It is automatically decoded
00008 *               according to $mapping,
00009 *               and the Sync WBXML mappings.
00010 *
00011 * Created   :   05.09.2011
00012 *
00013 * Copyright 2007 - 2011 Zarafa Deutschland GmbH
00014 *
00015 * This program is free software: you can redistribute it and/or modify
00016 * it under the terms of the GNU Affero General Public License, version 3,
00017 * as published by the Free Software Foundation with the following additional
00018 * term according to sec. 7:
00019 *
00020 * According to sec. 7 of the GNU Affero General Public License, version 3,
00021 * the terms of the AGPL are supplemented with the following terms:
00022 *
00023 * "Zarafa" is a registered trademark of Zarafa B.V.
00024 * "Z-Push" is a registered trademark of Zarafa Deutschland GmbH
00025 * The licensing of the Program under the AGPL does not imply a trademark license.
00026 * Therefore any rights, title and interest in our trademarks remain entirely with us.
00027 *
00028 * However, if you propagate an unmodified version of the Program you are
00029 * allowed to use the term "Z-Push" to indicate that you distribute the Program.
00030 * Furthermore you may use our trademarks where it is necessary to indicate
00031 * the intended purpose of a product or service provided you use it in accordance
00032 * with honest practices in industrial or commercial matters.
00033 * If you want to propagate modified versions of the Program under the name "Z-Push",
00034 * you may only do so if you have a written permission by Zarafa Deutschland GmbH
00035 * (to acquire a permission please contact Zarafa at trademark@zarafa.com).
00036 *
00037 * This program is distributed in the hope that it will be useful,
00038 * but WITHOUT ANY WARRANTY; without even the implied warranty of
00039 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00040 * GNU Affero General Public License for more details.
00041 *
00042 * You should have received a copy of the GNU Affero General Public License
00043 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00044 *
00045 * Consult LICENSE file for details
00046 ************************************************/
00047 
00048 
00049 class SyncProvisioning extends SyncObject {
00050     //AS 12.0, 12.1 and 14.0 props
00051     public $devpwenabled;
00052     public $alphanumpwreq;
00053     public $devencenabled;
00054     public $pwrecoveryenabled;
00055     public $docbrowseenabled;
00056     public $attenabled;
00057     public $mindevpwlenngth;
00058     public $maxinacttimedevlock;
00059     public $maxdevpwfailedattempts;
00060     public $maxattsize;
00061     public $allowsimpledevpw;
00062     public $devpwexpiration;
00063     public $devpwhistory;
00064 
00065     //AS 12.1 and 14.0 props
00066     public $allostoragecard;
00067     public $allowcam;
00068     public $reqdevenc;
00069     public $allowunsignedapps;
00070     public $allowunsigninstallpacks;
00071     public $mindevcomplexchars;
00072     public $allowwifi;
00073     public $allowtextmessaging;
00074     public $allowpopimapemail;
00075     public $allowbluetooth;
00076     public $allowirda;
00077     public $reqmansyncroam;
00078     public $allowdesktopsync;
00079     public $maxcalagefilter;
00080     public $allowhtmlemail;
00081     public $maxemailagefilter;
00082     public $maxemailbodytruncsize;
00083     public $maxemailhtmlbodytruncsize;
00084     public $reqsignedsmimemessages;
00085     public $reqencsmimemessages;
00086     public $reqsignedsmimealgorithm;
00087     public $reqencsmimealgorithm;
00088     public $allowsmimeencalgneg;
00089     public $allowsmimesoftcerts;
00090     public $allowbrowser;
00091     public $allowconsumeremail;
00092     public $allowremotedesk;
00093     public $allowinternetsharing;
00094     public $unapprovedinromapplist;
00095     public $approvedapplist;
00096 
00097     function SyncProvisioning() {
00098         $mapping = array (
00099                     SYNC_PROVISION_DEVPWENABLED                         => array (  self::STREAMER_VAR      => "devpwenabled",
00100                                                                                     self::STREAMER_CHECKS   => array(   self::STREAMER_CHECK_ONEVALUEOF => array(0,1) )),
00101 
00102                     SYNC_PROVISION_ALPHANUMPWREQ                        => array (  self::STREAMER_VAR      => "alphanumpwreq",
00103                                                                                     self::STREAMER_CHECKS   => array(   self::STREAMER_CHECK_ONEVALUEOF => array(0,1) )),
00104 
00105                     SYNC_PROVISION_PWRECOVERYENABLED                    => array (  self::STREAMER_VAR      => "pwrecoveryenabled",
00106                                                                                     self::STREAMER_CHECKS   => array(   self::STREAMER_CHECK_ONEVALUEOF => array(0,1) )),
00107 
00108                     SYNC_PROVISION_DEVENCENABLED                        => array (  self::STREAMER_VAR      => "devencenabled",
00109                                                                                     self::STREAMER_CHECKS   => array(   self::STREAMER_CHECK_ONEVALUEOF => array(0,1) )),
00110 
00111                     SYNC_PROVISION_DOCBROWSEENABLED                     => array (  self::STREAMER_VAR      => "docbrowseenabled"), // depricated
00112                     SYNC_PROVISION_ATTENABLED                           => array (  self::STREAMER_VAR      => "attenabled",
00113                                                                                     self::STREAMER_CHECKS   => array(   self::STREAMER_CHECK_ONEVALUEOF => array(0,1) )),
00114 
00115                     SYNC_PROVISION_MINDEVPWLENGTH                       => array (  self::STREAMER_VAR      => "mindevpwlenngth",
00116                                                                                     self::STREAMER_CHECKS   => array(   self::STREAMER_CHECK_CMPHIGHER  => 0,
00117                                                                                                                         self::STREAMER_CHECK_CMPLOWER   => 17  )),
00118 
00119                     SYNC_PROVISION_MAXINACTTIMEDEVLOCK                  => array (  self::STREAMER_VAR      => "maxinacttimedevlock"),
00120                     SYNC_PROVISION_MAXDEVPWFAILEDATTEMPTS               => array (  self::STREAMER_VAR      => "maxdevpwfailedattempts",
00121                                                                                     self::STREAMER_CHECKS   => array(   self::STREAMER_CHECK_CMPHIGHER  => 3,
00122                                                                                                                         self::STREAMER_CHECK_CMPLOWER   => 17  )),
00123 
00124                     SYNC_PROVISION_MAXATTSIZE                           => array (  self::STREAMER_VAR      => "maxattsize",
00125                                                                                     self::STREAMER_PROP     => self::STREAMER_TYPE_SEND_EMPTY,
00126                                                                                     self::STREAMER_CHECKS   => array(   self::STREAMER_CHECK_CMPHIGHER  => -1 )),
00127 
00128                     SYNC_PROVISION_ALLOWSIMPLEDEVPW                     => array (  self::STREAMER_VAR      => "allowsimpledevpw",
00129                                                                                     self::STREAMER_CHECKS   => array(   self::STREAMER_CHECK_ONEVALUEOF => array(0,1) )),
00130 
00131                     SYNC_PROVISION_DEVPWEXPIRATION                      => array (  self::STREAMER_VAR      => "devpwexpiration",
00132                                                                                     self::STREAMER_CHECKS   => array(   self::STREAMER_CHECK_CMPHIGHER  => -1 )),
00133 
00134                     SYNC_PROVISION_DEVPWHISTORY                         => array (  self::STREAMER_VAR      => "devpwhistory",
00135                                                                                     self::STREAMER_CHECKS   => array(   self::STREAMER_CHECK_CMPHIGHER  => -1 )),
00136                 );
00137 
00138         if(Request::GetProtocolVersion() >= 12.1) {
00139             $mapping += array (
00140                     SYNC_PROVISION_ALLOWSTORAGECARD                     => array (  self::STREAMER_VAR      => "allostoragecard",
00141                                                                                     self::STREAMER_CHECKS   => array(   self::STREAMER_CHECK_ONEVALUEOF => array(0,1) )),
00142 
00143                     SYNC_PROVISION_ALLOWCAM                             => array (  self::STREAMER_VAR      => "allowcam",
00144                                                                                     self::STREAMER_CHECKS   => array(   self::STREAMER_CHECK_ONEVALUEOF => array(0,1) )),
00145 
00146                     SYNC_PROVISION_REQDEVENC                            => array (  self::STREAMER_VAR      => "reqdevenc",
00147                                                                                     self::STREAMER_CHECKS   => array(   self::STREAMER_CHECK_ONEVALUEOF => array(0,1) )),
00148 
00149                     SYNC_PROVISION_ALLOWUNSIGNEDAPPS                    => array (  self::STREAMER_VAR      => "allowunsignedapps",
00150                                                                                     self::STREAMER_CHECKS   => array(   self::STREAMER_CHECK_ONEVALUEOF => array(0,1) )),
00151 
00152                     SYNC_PROVISION_ALLOWUNSIGNEDINSTALLATIONPACKAGES    => array (  self::STREAMER_VAR      => "allowunsigninstallpacks",
00153                                                                                     self::STREAMER_CHECKS   => array(   self::STREAMER_CHECK_ONEVALUEOF => array(0,1) )),
00154 
00155                     SYNC_PROVISION_MINDEVPWCOMPLEXCHARS                 => array (  self::STREAMER_VAR      => "mindevcomplexchars",
00156                                                                                     self::STREAMER_CHECKS   => array(   self::STREAMER_CHECK_ONEVALUEOF => array(1,2,3,4) )),
00157 
00158                     SYNC_PROVISION_ALLOWWIFI                            => array (  self::STREAMER_VAR      => "allowwifi",
00159                                                                                     self::STREAMER_CHECKS   => array(   self::STREAMER_CHECK_ONEVALUEOF => array(0,1) )),
00160 
00161                     SYNC_PROVISION_ALLOWTEXTMESSAGING                   => array (  self::STREAMER_VAR      => "allowtextmessaging",
00162                                                                                     self::STREAMER_CHECKS   => array(   self::STREAMER_CHECK_ONEVALUEOF => array(0,1) )),
00163 
00164                     SYNC_PROVISION_ALLOWPOPIMAPEMAIL                    => array (  self::STREAMER_VAR      => "allowpopimapemail",
00165                                                                                     self::STREAMER_CHECKS   => array(   self::STREAMER_CHECK_ONEVALUEOF => array(0,1) )),
00166 
00167                     SYNC_PROVISION_ALLOWBLUETOOTH                       => array (  self::STREAMER_VAR      => "allowbluetooth",
00168                                                                                     self::STREAMER_CHECKS   => array(   self::STREAMER_CHECK_ONEVALUEOF => array(0,1,2) )),
00169 
00170                     SYNC_PROVISION_ALLOWIRDA                            => array (  self::STREAMER_VAR      => "allowirda",
00171                                                                                     self::STREAMER_CHECKS   => array(   self::STREAMER_CHECK_ONEVALUEOF => array(0,1) )),
00172 
00173                     SYNC_PROVISION_REQMANUALSYNCWHENROAM                => array (  self::STREAMER_VAR      => "reqmansyncroam",
00174                                                                                     self::STREAMER_CHECKS   => array(   self::STREAMER_CHECK_ONEVALUEOF => array(0,1) )),
00175 
00176                     SYNC_PROVISION_ALLOWDESKTOPSYNC                     => array (  self::STREAMER_VAR      => "allowdesktopsync",
00177                                                                                     self::STREAMER_CHECKS   => array(   self::STREAMER_CHECK_ONEVALUEOF => array(0,1) )),
00178 
00179                     SYNC_PROVISION_MAXCALAGEFILTER                      => array (  self::STREAMER_VAR      => "maxcalagefilter",
00180                                                                                     self::STREAMER_CHECKS   => array(   self::STREAMER_CHECK_ONEVALUEOF => array(0,4,5,6,7) )),
00181 
00182                     SYNC_PROVISION_ALLOWHTMLEMAIL                       => array (  self::STREAMER_VAR      => "allowhtmlemail",
00183                                                                                     self::STREAMER_CHECKS   => array(   self::STREAMER_CHECK_ONEVALUEOF => array(0,1) )),
00184 
00185                     SYNC_PROVISION_MAXEMAILAGEFILTER                    => array (  self::STREAMER_VAR      => "maxemailagefilter",
00186                                                                                      self::STREAMER_CHECKS   => array(   self::STREAMER_CHECK_CMPHIGHER  => -1,
00187                                                                                                                          self::STREAMER_CHECK_CMPLOWER   => 6  )),
00188 
00189                     SYNC_PROVISION_MAXEMAILBODYTRUNCSIZE                => array (  self::STREAMER_VAR      => "maxemailbodytruncsize",
00190                                                                                      self::STREAMER_CHECKS   => array(   self::STREAMER_CHECK_CMPHIGHER  => -2 )),
00191 
00192                     SYNC_PROVISION_MAXEMAILHTMLBODYTRUNCSIZE            => array (  self::STREAMER_VAR      => "maxemailhtmlbodytruncsize",
00193                                                                                      self::STREAMER_CHECKS   => array(   self::STREAMER_CHECK_CMPHIGHER  => -2 )),
00194 
00195                     SYNC_PROVISION_REQSIGNEDSMIMEMESSAGES               => array (  self::STREAMER_VAR      => "reqsignedsmimemessages",
00196                                                                                     self::STREAMER_CHECKS   => array(   self::STREAMER_CHECK_ONEVALUEOF => array(0,1) )),
00197 
00198                     SYNC_PROVISION_REQENCSMIMEMESSAGES                  => array (  self::STREAMER_VAR      => "reqencsmimemessages",
00199                                                                                     self::STREAMER_CHECKS   => array(   self::STREAMER_CHECK_ONEVALUEOF => array(0,1) )),
00200 
00201                     SYNC_PROVISION_REQSIGNEDSMIMEALGORITHM              => array (  self::STREAMER_VAR      => "reqsignedsmimealgorithm",
00202                                                                                     self::STREAMER_CHECKS   => array(   self::STREAMER_CHECK_ONEVALUEOF => array(0,1) )),
00203 
00204                     SYNC_PROVISION_REQENCSMIMEALGORITHM                 => array (  self::STREAMER_VAR      => "reqencsmimealgorithm",
00205                                                                                     self::STREAMER_CHECKS   => array(   self::STREAMER_CHECK_ONEVALUEOF => array(0,1,2,3,4) )),
00206 
00207                     SYNC_PROVISION_ALLOWSMIMEENCALGORITHNEG             => array (  self::STREAMER_VAR      => "allowsmimeencalgneg",
00208                                                                                     self::STREAMER_CHECKS   => array(   self::STREAMER_CHECK_ONEVALUEOF => array(0,1,2) )),
00209 
00210                     SYNC_PROVISION_ALLOWSMIMESOFTCERTS                  => array (  self::STREAMER_VAR      => "allowsmimesoftcerts",
00211                                                                                     self::STREAMER_CHECKS   => array(   self::STREAMER_CHECK_ONEVALUEOF => array(0,1) )),
00212 
00213                     SYNC_PROVISION_ALLOWBROWSER                         => array (  self::STREAMER_VAR      => "allowbrowser",
00214                                                                                     self::STREAMER_CHECKS   => array(   self::STREAMER_CHECK_ONEVALUEOF => array(0,1) )),
00215 
00216                     SYNC_PROVISION_ALLOWCONSUMEREMAIL                   => array (  self::STREAMER_VAR      => "allowconsumeremail",
00217                                                                                     self::STREAMER_CHECKS   => array(   self::STREAMER_CHECK_ONEVALUEOF => array(0,1) )),
00218 
00219                     SYNC_PROVISION_ALLOWREMOTEDESKTOP                   => array (  self::STREAMER_VAR      => "allowremotedesk",
00220                                                                                     self::STREAMER_CHECKS   => array(   self::STREAMER_CHECK_ONEVALUEOF => array(0,1) )),
00221 
00222                     SYNC_PROVISION_ALLOWINTERNETSHARING                 => array (  self::STREAMER_VAR      => "allowinternetsharing",
00223                                                                                     self::STREAMER_CHECKS   => array(   self::STREAMER_CHECK_ONEVALUEOF => array(0,1) )),
00224 
00225                     SYNC_PROVISION_UNAPPROVEDINROMAPPLIST               => array (  self::STREAMER_VAR      => "unapprovedinromapplist",
00226                                                                                     self::STREAMER_TYPE     => self::STREAMER_TYPE_SEND_EMPTY,
00227                                                                                     self::STREAMER_ARRAY    => SYNC_PROVISION_APPNAME),  //TODO check
00228 
00229                     SYNC_PROVISION_APPROVEDAPPLIST                      => array (  self::STREAMER_VAR      => "approvedapplist",
00230                                                                                     self::STREAMER_TYPE     => self::STREAMER_TYPE_SEND_EMPTY,
00231                                                                                     self::STREAMER_ARRAY    => SYNC_PROVISION_HASH), //TODO check
00232             );
00233         }
00234 
00235         parent::SyncObject($mapping);
00236     }
00237 
00238     public function Load($policies = array()) {
00239         if (empty($policies)) {
00240             $this->LoadDefaultPolicies();
00241         }
00242         else foreach ($policies as $p=>$v) {
00243             if (!isset($this->mapping[$p])) {
00244                 ZLog::Write(LOGLEVEL_INFO, sprintf("Policy '%s' not supported by the device, ignoring", substr($p, strpos($p,':')+1)));
00245                 continue;
00246             }
00247             ZLog::Write(LOGLEVEL_INFO, sprintf("Policy '%s' enforced with: %s", substr($p, strpos($p,':')+1), Utils::PrintAsString($v)));
00248 
00249             $var = $this->mapping[$p][self::STREAMER_VAR];
00250             $this->$var = $v;
00251         }
00252     }
00253 
00254     public function LoadDefaultPolicies() {
00255         //AS 12.0, 12.1 and 14.0 props
00256         $this->devpwenabled = 0;
00257         $this->alphanumpwreq = 0;
00258         $this->devencenabled = 0;
00259         $this->pwrecoveryenabled = 0;
00260         $this->docbrowseenabled;
00261         $this->attenabled = 1;
00262         $this->mindevpwlenngth = 4;
00263         $this->maxinacttimedevlock = 900;
00264         $this->maxdevpwfailedattempts = 8;
00265         $this->maxattsize = '';
00266         $this->allowsimpledevpw = 1;
00267         $this->devpwexpiration = 0;
00268         $this->devpwhistory = 0;
00269 
00270         //AS 12.1 and 14.0 props
00271         $this->allostoragecard = 1;
00272         $this->allowcam = 1;
00273         $this->reqdevenc = 0;
00274         $this->allowunsignedapps = 1;
00275         $this->allowunsigninstallpacks = 1;
00276         $this->mindevcomplexchars = 3;
00277         $this->allowwifi = 1;
00278         $this->allowtextmessaging = 1;
00279         $this->allowpopimapemail = 1;
00280         $this->allowbluetooth = 2;
00281         $this->allowirda = 1;
00282         $this->reqmansyncroam = 0;
00283         $this->allowdesktopsync = 1;
00284         $this->maxcalagefilter = 0;
00285         $this->allowhtmlemail = 1;
00286         $this->maxemailagefilter = 0;
00287         $this->maxemailbodytruncsize = -1;
00288         $this->maxemailhtmlbodytruncsize = -1;
00289         $this->reqsignedsmimemessages = 0;
00290         $this->reqencsmimemessages = 0;
00291         $this->reqsignedsmimealgorithm = 0;
00292         $this->reqencsmimealgorithm = 0;
00293         $this->allowsmimeencalgneg = 2;
00294         $this->allowsmimesoftcerts = 1;
00295         $this->allowbrowser = 1;
00296         $this->allowconsumeremail = 1;
00297         $this->allowremotedesk = 1;
00298         $this->allowinternetsharing = 1;
00299         $this->unapprovedinromapplist = array();
00300         $this->approvedapplist = array();
00301     }
00302 }
00303 
00304 ?>