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,81 +70,110 @@ class Provisioning extends RequestProcessor { ...@@ -69,81 +70,110 @@ 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:
if (self::$decoder->getElementStartTag(SYNC_PROVISION_REMOTEWIPE)) { // - Remote Wipe
if(!self::$decoder->getElementStartTag(SYNC_PROVISION_STATUS)) // - DeviceInformation
return false; // - Policies
// Each of them should only be once per request.
$instatus = self::$decoder->getElementContent(); while (1) {
if(!self::$decoder->getElementEndTag()) $requestName = "";
return false; 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(!self::$decoder->getElementEndTag()) if (!$requestName)
return false; break;
$phase2 = false; //set is available for OOF, device password and device information
$rwstatusWiped = true; switch ($requestName) {
} case SYNC_PROVISION_REMOTEWIPE:
else { if(!self::$decoder->getElementStartTag(SYNC_PROVISION_STATUS))
return false;
if(!self::$decoder->getElementStartTag(SYNC_PROVISION_POLICIES)) $instatus = self::$decoder->getElementContent();
return false;
if(!self::$decoder->getElementStartTag(SYNC_PROVISION_POLICY)) if(!self::$decoder->getElementEndTag())
return false; return false;
if(!self::$decoder->getElementStartTag(SYNC_PROVISION_POLICYTYPE)) if(!self::$decoder->getElementEndTag())
return false; return false;
$policytype = self::$decoder->getElementContent(); $phase2 = false;
if ($policytype != 'MS-WAP-Provisioning-XML' && $policytype != 'MS-EAS-Provisioning-WBXML') { $rwstatusWiped = true;
$status = SYNC_PROVISION_STATUS_SERVERERROR; //TODO check - do it after while(1) finished?
} break;
if(!self::$decoder->getElementEndTag()) //policytype
return false;
if (self::$decoder->getElementStartTag(SYNC_PROVISION_POLICYKEY)) { case SYNC_PROVISION_POLICIES:
$devpolicykey = self::$decoder->getElementContent(); if(!self::$decoder->getElementStartTag(SYNC_PROVISION_POLICY))
return false;
if(!self::$decoder->getElementEndTag()) if(!self::$decoder->getElementStartTag(SYNC_PROVISION_POLICYTYPE))
return false; return false;
if(!self::$decoder->getElementStartTag(SYNC_PROVISION_STATUS)) $policytype = self::$decoder->getElementContent();
return false; if ($policytype != 'MS-WAP-Provisioning-XML' && $policytype != 'MS-EAS-Provisioning-WBXML') {
$status = SYNC_PROVISION_STATUS_SERVERERROR;
}
if(!self::$decoder->getElementEndTag()) //policytype
return false;
$instatus = self::$decoder->getElementContent(); if (self::$decoder->getElementStartTag(SYNC_PROVISION_POLICYKEY)) {
$devpolicykey = self::$decoder->getElementContent();
if(!self::$decoder->getElementEndTag()) if(!self::$decoder->getElementEndTag())
return false; return false;
$phase2 = false; if(!self::$decoder->getElementStartTag(SYNC_PROVISION_STATUS))
} return false;
if(!self::$decoder->getElementEndTag()) //policy $instatus = self::$decoder->getElementContent();
return false;
if(!self::$decoder->getElementEndTag()) //policies if(!self::$decoder->getElementEndTag())
return false; return false;
if (self::$decoder->getElementStartTag(SYNC_PROVISION_REMOTEWIPE)) { $phase2 = false;
if(!self::$decoder->getElementStartTag(SYNC_PROVISION_STATUS)) }
return false;
$status = self::$decoder->getElementContent(); if(!self::$decoder->getElementEndTag()) //policy
return false;
if(!self::$decoder->getElementEndTag()) if(!self::$decoder->getElementEndTag()) //policies
return false; return false;
break;
if(!self::$decoder->getElementEndTag()) case SYNC_SETTINGS_DEVICEINFORMATION:
return false; // AS14.1 and later clients pass Device Information on the initial Provision request
if (!self::$decoder->getElementStartTag(SYNC_SETTINGS_SET))
return false;
$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()) // 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) { 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