Commit ea938852 authored by Sebastian Kummer's avatar Sebastian Kummer Committed by Vincent Sherwood

ZP-629 DeviceInformation in Provisioning cause WBXMLException. Released under...

ZP-629 DeviceInformation in Provisioning cause WBXMLException. Released under the Affero GNU General Public License (AGPL) version 3.

Code added to check for DeviceInformation node in Provision request
parents 6331dd1a ee459d6c
......@@ -57,6 +57,7 @@ class Provisioning extends RequestProcessor {
$rwstatus = self::$deviceManager->GetProvisioningWipeStatus();
$rwstatusWiped = false;
$deviceInfoSet = false;
// if this is a regular provisioning require that an authenticated remote user
if ($rwstatus < SYNC_PROVISION_RWSTATUS_PENDING) {
......@@ -69,8 +70,30 @@ class Provisioning extends RequestProcessor {
if(!self::$decoder->getElementStartTag(SYNC_PROVISION_PROVISION))
return false;
//handle android remote wipe.
// Loop through Provision request tags. Possible are:
// - Remote Wipe
// - DeviceInformation
// - Policies
// Each of them should only be once per request.
while (1) {
$requestName = "";
if (self::$decoder->getElementStartTag(SYNC_PROVISION_REMOTEWIPE)) {
$requestName = SYNC_PROVISION_REMOTEWIPE;
}
if (self::$decoder->getElementStartTag(SYNC_PROVISION_POLICIES)) {
$requestName = SYNC_PROVISION_POLICIES;
}
if (self::$decoder->getElementStartTag(SYNC_SETTINGS_DEVICEINFORMATION)) {
$requestName = SYNC_SETTINGS_DEVICEINFORMATION;
}
if (!$requestName)
break;
//set is available for OOF, device password and device information
switch ($requestName) {
case SYNC_PROVISION_REMOTEWIPE:
if(!self::$decoder->getElementStartTag(SYNC_PROVISION_STATUS))
return false;
......@@ -84,12 +107,10 @@ class Provisioning extends RequestProcessor {
$phase2 = false;
$rwstatusWiped = true;
}
else {
if(!self::$decoder->getElementStartTag(SYNC_PROVISION_POLICIES))
return false;
//TODO check - do it after while(1) finished?
break;
case SYNC_PROVISION_POLICIES:
if(!self::$decoder->getElementStartTag(SYNC_PROVISION_POLICY))
return false;
......@@ -125,25 +146,34 @@ class Provisioning extends RequestProcessor {
if(!self::$decoder->getElementEndTag()) //policies
return false;
break;
if (self::$decoder->getElementStartTag(SYNC_PROVISION_REMOTEWIPE)) {
if(!self::$decoder->getElementStartTag(SYNC_PROVISION_STATUS))
case SYNC_SETTINGS_DEVICEINFORMATION:
// AS14.1 and later clients pass Device Information on the initial Provision request
if (!self::$decoder->getElementStartTag(SYNC_SETTINGS_SET))
return false;
$status = self::$decoder->getElementContent();
if(!self::$decoder->getElementEndTag())
$deviceInfoSet = true;
$deviceinformation = new SyncDeviceInformation();
$deviceinformation->Decode(self::$decoder);
$deviceinformation->Status = SYNC_SETTINGSSTATUS_SUCCESS;
self::$deviceManager->SaveDeviceInformation($deviceinformation);
if (!self::$decoder->getElementEndTag()) // SYNC_SETTINGS_SET
return false;
if(!self::$decoder->getElementEndTag())
if (!self::$decoder->getElementEndTag()) // SYNC_SETTINGS_DEVICEINFORMATION
return false;
break;
$rwstatusWiped = true;
default:
//TODO: a special status code needed?
ZLog::Write(LOGLEVEL_WARN, sprintf ("This property ('%s') is not allowed to be used in a provision request", $requestName));
}
}
if(!self::$decoder->getElementEndTag()) //provision
return false;
if(!self::$decoder->getElementEndTag()) { //provision
ZLog::Write(LOGLEVEL_INFO, "No End Provision");
return false;
}
if (PROVISIONING !== true) {
ZLog::Write(LOGLEVEL_INFO, "No policies deployed to device");
$policystatus = SYNC_PROVISION_POLICYSTATUS_NOPOLICY;
......@@ -170,6 +200,14 @@ class Provisioning extends RequestProcessor {
self::$encoder->content($status);
self::$encoder->endTag();
if ($deviceInfoSet) {
self::$encoder->startTag(SYNC_SETTINGS_DEVICEINFORMATION);
self::$encoder->startTag(SYNC_SETTINGS_STATUS);
self::$encoder->content($deviceinformation->Status);
self::$encoder->endTag(); //SYNC_SETTINGS_STATUS
self::$encoder->endTag(); //SYNC_SETTINGS_DEVICEINFORMATION
}
self::$encoder->startTag(SYNC_PROVISION_POLICIES);
self::$encoder->startTag(SYNC_PROVISION_POLICY);
......@@ -227,3 +265,4 @@ class Provisioning extends RequestProcessor {
return true;
}
}
?>
\ No newline at end of file
......@@ -60,16 +60,20 @@ class SyncResolveRecipient extends SyncObject {
SYNC_RESOLVERECIPIENTS_DISPLAYNAME => array ( self::STREAMER_VAR => "displayname"),
SYNC_RESOLVERECIPIENTS_EMAILADDRESS => array ( self::STREAMER_VAR => "emailaddress"),
SYNC_RESOLVERECIPIENTS_AVAILABILITY => array ( self::STREAMER_VAR => "availability",
self::STREAMER_TYPE => "SyncResolveRecipientsAvailability"),
SYNC_RESOLVERECIPIENTS_CERTIFICATES => array ( self::STREAMER_VAR => "certificates",
self::STREAMER_TYPE => "SyncResolveRecipientsCertificates"),
SYNC_RESOLVERECIPIENTS_PICTURE => array ( self::STREAMER_VAR => "picture",
self::STREAMER_TYPE => "SyncResolveRecipientsPicture"),
self::STREAMER_TYPE => "SyncResolveRecipientsCertificates")
);
if (Request::GetProtocolVersion() >= 14.0) {
$mapping[SYNC_RESOLVERECIPIENTS_AVAILABILITY] = array ( self::STREAMER_VAR => "availability",
self::STREAMER_TYPE => "SyncResolveRecipientsAvailability");
}
if (Request::GetProtocolVersion() >= 14.1) {
$mapping[SYNC_RESOLVERECIPIENTS_PICTURE] = array ( self::STREAMER_VAR => "picture",
self::STREAMER_TYPE => "SyncResolveRecipientsPicture");
}
parent::SyncObject($mapping);
}
......
......@@ -52,12 +52,14 @@ class SyncResolveRecipientsAvailability extends SyncObject {
public $mergedfreebusy;
public function SyncResolveRecipientsAvailability() {
$mapping = array (
SYNC_RESOLVERECIPIENTS_STARTTIME => array ( self::STREAMER_VAR => "starttime"),
SYNC_RESOLVERECIPIENTS_ENDTIME => array ( self::STREAMER_VAR => "endtime"),
SYNC_RESOLVERECIPIENTS_STATUS => array ( self::STREAMER_VAR => "status"),
SYNC_RESOLVERECIPIENTS_MERGEDFREEBUSY => array ( self::STREAMER_VAR => "mergedfreebusy"),
);
$mapping = array ();
if (Request::GetProtocolVersion() >= 14.0) {
$mapping[SYNC_RESOLVERECIPIENTS_STARTTIME] = array ( self::STREAMER_VAR => "starttime");
$mapping[SYNC_RESOLVERECIPIENTS_ENDTIME] = array ( self::STREAMER_VAR => "endtime");
$mapping[SYNC_RESOLVERECIPIENTS_STATUS] = array ( self::STREAMER_VAR => "status");
$mapping[SYNC_RESOLVERECIPIENTS_MERGEDFREEBUSY] = array ( self::STREAMER_VAR => "mergedfreebusy");
}
parent::SyncObject($mapping);
}
......
......@@ -52,12 +52,14 @@ class SyncResolveRecipientsPicture extends SyncObject {
public $data;
public function SyncResolveRecipientsPicture() {
$mapping = array (
SYNC_RESOLVERECIPIENTS_MAXSIZE => array ( self::STREAMER_VAR => "maxsize"),
SYNC_RESOLVERECIPIENTS_MAXPICTURES => array ( self::STREAMER_VAR => "maxpictures"),
SYNC_RESOLVERECIPIENTS_STATUS => array ( self::STREAMER_VAR => "status"),
SYNC_RESOLVERECIPIENTS_DATA => array ( self::STREAMER_VAR => "data"),
);
$mapping = array ();
if (Request::GetProtocolVersion() >= 14.1) {
$mapping[SYNC_RESOLVERECIPIENTS_MAXSIZE] = array ( self::STREAMER_VAR => "maxsize");
$mapping[SYNC_RESOLVERECIPIENTS_MAXPICTURES] = array ( self::STREAMER_VAR => "maxpictures");
$mapping[SYNC_RESOLVERECIPIENTS_STATUS] = array ( self::STREAMER_VAR => "status");
$mapping[SYNC_RESOLVERECIPIENTS_DATA] = array ( self::STREAMER_VAR => "data");
}
parent::SyncObject($mapping);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment