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 { ...@@ -57,6 +57,7 @@ class Provisioning extends RequestProcessor {
$rwstatus = self::$deviceManager->GetProvisioningWipeStatus(); $rwstatus = self::$deviceManager->GetProvisioningWipeStatus();
$rwstatusWiped = false; $rwstatusWiped = false;
$deviceInfoSet = false;
// if this is a regular provisioning require that an authenticated remote user // if this is a regular provisioning require that an authenticated remote user
if ($rwstatus < SYNC_PROVISION_RWSTATUS_PENDING) { if ($rwstatus < SYNC_PROVISION_RWSTATUS_PENDING) {
...@@ -69,8 +70,30 @@ class Provisioning extends RequestProcessor { ...@@ -69,8 +70,30 @@ class Provisioning extends RequestProcessor {
if(!self::$decoder->getElementStartTag(SYNC_PROVISION_PROVISION)) if(!self::$decoder->getElementStartTag(SYNC_PROVISION_PROVISION))
return false; 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)) { 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)) if(!self::$decoder->getElementStartTag(SYNC_PROVISION_STATUS))
return false; return false;
...@@ -84,12 +107,10 @@ class Provisioning extends RequestProcessor { ...@@ -84,12 +107,10 @@ class Provisioning extends RequestProcessor {
$phase2 = false; $phase2 = false;
$rwstatusWiped = true; $rwstatusWiped = true;
} //TODO check - do it after while(1) finished?
else { break;
if(!self::$decoder->getElementStartTag(SYNC_PROVISION_POLICIES))
return false;
case SYNC_PROVISION_POLICIES:
if(!self::$decoder->getElementStartTag(SYNC_PROVISION_POLICY)) if(!self::$decoder->getElementStartTag(SYNC_PROVISION_POLICY))
return false; return false;
...@@ -125,25 +146,34 @@ class Provisioning extends RequestProcessor { ...@@ -125,25 +146,34 @@ class Provisioning extends RequestProcessor {
if(!self::$decoder->getElementEndTag()) //policies if(!self::$decoder->getElementEndTag()) //policies
return false; return false;
break;
if (self::$decoder->getElementStartTag(SYNC_PROVISION_REMOTEWIPE)) { case SYNC_SETTINGS_DEVICEINFORMATION:
if(!self::$decoder->getElementStartTag(SYNC_PROVISION_STATUS)) // AS14.1 and later clients pass Device Information on the initial Provision request
if (!self::$decoder->getElementStartTag(SYNC_SETTINGS_SET))
return false; return false;
$deviceInfoSet = true;
$status = self::$decoder->getElementContent(); $deviceinformation = new SyncDeviceInformation();
$deviceinformation->Decode(self::$decoder);
if(!self::$decoder->getElementEndTag()) $deviceinformation->Status = SYNC_SETTINGSSTATUS_SUCCESS;
self::$deviceManager->SaveDeviceInformation($deviceinformation);
if (!self::$decoder->getElementEndTag()) // SYNC_SETTINGS_SET
return false; return false;
if (!self::$decoder->getElementEndTag()) // SYNC_SETTINGS_DEVICEINFORMATION
if(!self::$decoder->getElementEndTag())
return false; 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) { if (PROVISIONING !== true) {
ZLog::Write(LOGLEVEL_INFO, "No policies deployed to device"); ZLog::Write(LOGLEVEL_INFO, "No policies deployed to device");
$policystatus = SYNC_PROVISION_POLICYSTATUS_NOPOLICY; $policystatus = SYNC_PROVISION_POLICYSTATUS_NOPOLICY;
...@@ -170,6 +200,14 @@ class Provisioning extends RequestProcessor { ...@@ -170,6 +200,14 @@ class Provisioning extends RequestProcessor {
self::$encoder->content($status); self::$encoder->content($status);
self::$encoder->endTag(); 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_POLICIES);
self::$encoder->startTag(SYNC_PROVISION_POLICY); self::$encoder->startTag(SYNC_PROVISION_POLICY);
...@@ -227,3 +265,4 @@ class Provisioning extends RequestProcessor { ...@@ -227,3 +265,4 @@ class Provisioning extends RequestProcessor {
return true; return true;
} }
} }
?>
\ No newline at end of file
...@@ -60,16 +60,20 @@ class SyncResolveRecipient extends SyncObject { ...@@ -60,16 +60,20 @@ class SyncResolveRecipient extends SyncObject {
SYNC_RESOLVERECIPIENTS_DISPLAYNAME => array ( self::STREAMER_VAR => "displayname"), SYNC_RESOLVERECIPIENTS_DISPLAYNAME => array ( self::STREAMER_VAR => "displayname"),
SYNC_RESOLVERECIPIENTS_EMAILADDRESS => array ( self::STREAMER_VAR => "emailaddress"), 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", SYNC_RESOLVERECIPIENTS_CERTIFICATES => array ( self::STREAMER_VAR => "certificates",
self::STREAMER_TYPE => "SyncResolveRecipientsCertificates"), self::STREAMER_TYPE => "SyncResolveRecipientsCertificates")
SYNC_RESOLVERECIPIENTS_PICTURE => array ( self::STREAMER_VAR => "picture",
self::STREAMER_TYPE => "SyncResolveRecipientsPicture"),
); );
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); parent::SyncObject($mapping);
} }
......
...@@ -52,12 +52,14 @@ class SyncResolveRecipientsAvailability extends SyncObject { ...@@ -52,12 +52,14 @@ class SyncResolveRecipientsAvailability extends SyncObject {
public $mergedfreebusy; public $mergedfreebusy;
public function SyncResolveRecipientsAvailability() { public function SyncResolveRecipientsAvailability() {
$mapping = array ( $mapping = array ();
SYNC_RESOLVERECIPIENTS_STARTTIME => array ( self::STREAMER_VAR => "starttime"),
SYNC_RESOLVERECIPIENTS_ENDTIME => array ( self::STREAMER_VAR => "endtime"), if (Request::GetProtocolVersion() >= 14.0) {
SYNC_RESOLVERECIPIENTS_STATUS => array ( self::STREAMER_VAR => "status"), $mapping[SYNC_RESOLVERECIPIENTS_STARTTIME] = array ( self::STREAMER_VAR => "starttime");
SYNC_RESOLVERECIPIENTS_MERGEDFREEBUSY => array ( self::STREAMER_VAR => "mergedfreebusy"), $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); parent::SyncObject($mapping);
} }
......
...@@ -52,12 +52,14 @@ class SyncResolveRecipientsPicture extends SyncObject { ...@@ -52,12 +52,14 @@ class SyncResolveRecipientsPicture extends SyncObject {
public $data; public $data;
public function SyncResolveRecipientsPicture() { public function SyncResolveRecipientsPicture() {
$mapping = array ( $mapping = array ();
SYNC_RESOLVERECIPIENTS_MAXSIZE => array ( self::STREAMER_VAR => "maxsize"),
SYNC_RESOLVERECIPIENTS_MAXPICTURES => array ( self::STREAMER_VAR => "maxpictures"), if (Request::GetProtocolVersion() >= 14.1) {
SYNC_RESOLVERECIPIENTS_STATUS => array ( self::STREAMER_VAR => "status"), $mapping[SYNC_RESOLVERECIPIENTS_MAXSIZE] = array ( self::STREAMER_VAR => "maxsize");
SYNC_RESOLVERECIPIENTS_DATA => array ( self::STREAMER_VAR => "data"), $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); 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