diff --git a/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/conf/alerts/Geo-ExecutionPlan-Within_alert.siddhiql b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/conf/alerts/Geo-ExecutionPlan-Within_alert.siddhiql index 85e57604ec..b58fd59e33 100644 --- a/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/conf/alerts/Geo-ExecutionPlan-Within_alert.siddhiql +++ b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/conf/alerts/Geo-ExecutionPlan-Within_alert.siddhiql @@ -12,9 +12,9 @@ define stream dataIn (id string, latitude double, longitude double, timeStamp lo @Export('org.wso2.geo.ProcessedSpatialEvents:1.0.0') define stream dataOut (id string, latitude double, longitude double, timeStamp long, type string ,speed float, heading float, eventId string, state string, information string); -from dataIn[geo:within(longitude,latitude,"$geoFenceGeoJSON")==true and id == $deviceId]#geodashboard:subscribe() +from dataIn[geo:within(longitude,latitude,"$geoFenceGeoJSON")==true and id == "$deviceId"]#geodashboard:subscribe() select id , latitude, longitude,timeStamp, type, speed, heading ,eventId , "ALERTED" as state, "This device is in $areaName restricted area!!!" as information insert into dataOut; -from dataIn[geo:within(longitude,latitude,"$geoFenceGeoJSON")!=true and id == $deviceId] +from dataIn[geo:within(longitude,latitude,"$geoFenceGeoJSON")!=true and id == "$deviceId"] select id , latitude, longitude,timeStamp, type, speed, heading ,eventId , "NORMAL" as state, "" as information insert into dataOut; diff --git a/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/js/geo_remote.js b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/js/geo_remote.js index b96b4194e2..b3b3ced6f4 100644 --- a/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/js/geo_remote.js +++ b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/js/geo_remote.js @@ -281,7 +281,8 @@ function setWithinAlert(leafletId) { 'parseData': JSON.stringify({ 'geoFenceGeoJSON': selectedAreaGeoJson, 'executionPlanName': createExecutionPlanName(queryName, "WithIn", deviceId), - 'areaName': areaName + 'areaName': areaName, + 'deviceId' : deviceId }), 'executionPlan': 'Within', 'customName': areaName, // TODO: fix , When template copies there can be two queryName and areaName id elements in the DOM diff --git a/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/js/websocket.js b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/js/websocket.js index 4e6d77126c..72fb6f7f21 100644 --- a/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/js/websocket.js +++ b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/js/websocket.js @@ -116,6 +116,10 @@ SpatialObject.prototype.update = function (geoJSON) { // Update the spatial object leaflet marker this.marker.setLatLng([this.latitude, this.longitude]); + + if (this.latitude, this.longitude) { + map.setView([this.latitude, this.longitude]); + } this.marker.setIconAngle(this.heading); this.marker.setIcon(this.stateIcon()); @@ -677,13 +681,14 @@ function intializeWebsocketUrls() { .constance.TENANT_INDEX + ApplicationOptions.constance.PATH_SEPARATOR + data.user.domain + ApplicationOptions.constance.PATH_SEPARATOR + ApplicationOptions.constance .CEP_WEB_SOCKET_OUTPUT_ADAPTOR_NAME + ApplicationOptions.constance.PATH_SEPARATOR + ApplicationOptions.constance.VERSION - + "?token=ee9971c8-bf09-3c83-b097-ce87a0c88806&deviceId=" + deviceId + "&deviceType=" + deviceType; + + "?deviceId=" + deviceId + "&deviceType=" + deviceType; alertWebSocketURL = 'wss://' + data.ip + ':' + data.httpsPort + ApplicationOptions.constance.PATH_SEPARATOR + ApplicationOptions.constance .CEP_WEB_SOCKET_OUTPUT_ADAPTOR_WEBAPP_NAME + ApplicationOptions.constance.PATH_SEPARATOR + ApplicationOptions .constance.TENANT_INDEX + ApplicationOptions.constance.PATH_SEPARATOR + data.user.domain + ApplicationOptions.constance.PATH_SEPARATOR + ApplicationOptions.constance .CEP_ON_ALERT_WEB_SOCKET_OUTPUT_ADAPTOR_NAME + ApplicationOptions.constance.PATH_SEPARATOR + ApplicationOptions.constance.VERSION - + "?token=ee9971c8-bf09-3c83-b097-ce87a0c88806&deviceId=" + deviceId + "&deviceType=" + deviceType; + + "?deviceId=" + deviceId + "&deviceType=" + deviceType; + document.cookie = "websocket-token=f98d6142-e988-3c7f-a8c9-7e6d74da7113; path=/"; initializeWebSocket(); initializeOnAlertWebSocket(); }); @@ -705,7 +710,8 @@ intializeWebsocketUrls(); SpatialObject.prototype.stateIcon = function () { - var iconUrl = "/portal/store/carbon.super/fs/gadget/geo-dashboard/img/markers/object-types/" + this.type.toLowerCase(); + //TODO : Need to add separate icons for each device type + var iconUrl = "/portal/store/carbon.super/fs/gadget/geo-dashboard/img/markers/object-types/default"; if (0 < this.speed && (-360 <= this.heading && 360 >= this.heading)) { iconUrl = iconUrl + "/moving/" + this.state.toLowerCase(); } else { diff --git a/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/Geo-ExecutionPlan-EventsFusionGenerateNotifications_1.0.0/Geo-ExecutionPlan-EventsFusionGenerateNotifications-1.0.0.siddhiql b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/Geo-ExecutionPlan-EventsFusionGenerateNotifications_1.0.0/Geo-ExecutionPlan-EventsFusionGenerateNotifications-1.0.0.siddhiql index 71a2ee9535..7c232af0c2 100644 --- a/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/Geo-ExecutionPlan-EventsFusionGenerateNotifications_1.0.0/Geo-ExecutionPlan-EventsFusionGenerateNotifications-1.0.0.siddhiql +++ b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/Geo-ExecutionPlan-EventsFusionGenerateNotifications_1.0.0/Geo-ExecutionPlan-EventsFusionGenerateNotifications-1.0.0.siddhiql @@ -12,7 +12,7 @@ define stream dataIn (id string, latitude double, longitude double, timeStamp long, type string, speed float, heading float, eventId string, state string, information string ); @Export('org.wso2.geo.AlertsNotifications:1.0.0') -define stream alertsOut ( id string, state string, information string, timeStamp long, latitude double, longitude double ); +define stream alertsOut ( id string, state string, information string, timeStamp long, latitude double, longitude double, type string); @Export('org.wso2.geo.FusedSpatialEvent:1.0.0') define stream dataOut ( id string, latitude double, longitude double, timeStamp long, type string, speed float, heading float, state string, information string, notify bool ); @@ -25,5 +25,5 @@ select id, latitude, longitude, timeStamp, type, speed, heading, state , informa insert into dataOut; from dataOut[notify == true] -select id,state,information,timeStamp, latitude, longitude +select id, state, information,timeStamp, latitude, longitude, type insert into alertsOut; \ No newline at end of file diff --git a/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/Geo-Publisher-WebSocketLocal-FusedSpacialEvent_1.0.0/Geo-Publisher-WebSocketLocal-FusedSpacialEvent-1.0.0.xml b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/Geo-Publisher-WebSocketLocal-FusedSpacialEvent_1.0.0/Geo-Publisher-WebSocketLocal-FusedSpacialEvent-1.0.0.xml index f7f8f50eed..561ce7c05f 100644 --- a/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/Geo-Publisher-WebSocketLocal-FusedSpacialEvent_1.0.0/Geo-Publisher-WebSocketLocal-FusedSpacialEvent-1.0.0.xml +++ b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/Geo-Publisher-WebSocketLocal-FusedSpacialEvent_1.0.0/Geo-Publisher-WebSocketLocal-FusedSpacialEvent-1.0.0.xml @@ -7,8 +7,8 @@ "messageType" : "Point", "type": "Feature", "id": {{id}}, - "deviceId": "rkxb293yw2t2", - "deviceType": "virtual_firealarm", + "deviceId": {{id}}, + "deviceType": {{type}}, "properties": { "speed": {{speed}}, "heading": {{heading}}, diff --git a/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/Geo-Publisher-WebSocketLocal-GeoAlertNotifications_1.0.0/Geo-Publisher-WebSocketLocal-GeoAlertNotifications-1.0.0.xml b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/Geo-Publisher-WebSocketLocal-GeoAlertNotifications_1.0.0/Geo-Publisher-WebSocketLocal-GeoAlertNotifications-1.0.0.xml index 264069b11c..a8a35ce1b2 100644 --- a/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/Geo-Publisher-WebSocketLocal-GeoAlertNotifications_1.0.0/Geo-Publisher-WebSocketLocal-GeoAlertNotifications-1.0.0.xml +++ b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/Geo-Publisher-WebSocketLocal-GeoAlertNotifications_1.0.0/Geo-Publisher-WebSocketLocal-GeoAlertNotifications-1.0.0.xml @@ -8,8 +8,8 @@ "messageType" : "Alert", "type": "Feature", "id": {{id}}, - "deviceId": "rkxb293yw2t2", - "deviceType" : "virtual_firealarm", + "deviceId": {{id}}, + "deviceType" : "{{type}}", "state": {{state}}, "information": {{information}}, "longitude" : {{longitude}}, diff --git a/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/org.wso2.geo.AlertsNotifications_1.0.0/org.wso2.geo.AlertsNotifications-1.0.0.json b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/org.wso2.geo.AlertsNotifications_1.0.0/org.wso2.geo.AlertsNotifications-1.0.0.json index 23853ed93d..767f9d6d13 100644 --- a/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/org.wso2.geo.AlertsNotifications_1.0.0/org.wso2.geo.AlertsNotifications-1.0.0.json +++ b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/org.wso2.geo.AlertsNotifications_1.0.0/org.wso2.geo.AlertsNotifications-1.0.0.json @@ -27,6 +27,10 @@ { "name": "longitude", "type": "DOUBLE" + }, + { + "name": "type", + "type": "STRING" } ] } \ No newline at end of file diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/data/publisher/DataPublisherService.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/data/publisher/DataPublisherService.java index 28b515e98a..0335ffe50b 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/data/publisher/DataPublisherService.java +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/data/publisher/DataPublisherService.java @@ -29,14 +29,15 @@ import org.wso2.carbon.iot.android.sense.constants.SenseConstants; import org.wso2.carbon.iot.android.sense.data.publisher.mqtt.AndroidSenseMQTTHandler; import org.wso2.carbon.iot.android.sense.data.publisher.mqtt.transport.MQTTTransportHandler; import org.wso2.carbon.iot.android.sense.data.publisher.mqtt.transport.TransportHandlerException; -import org.wso2.carbon.iot.android.sense.event.streams.Location.LocationData; -import org.wso2.carbon.iot.android.sense.event.streams.Sensor.SensorData; -import org.wso2.carbon.iot.android.sense.event.streams.Speed.SpeedData; +import org.wso2.carbon.iot.android.sense.event.streams.location.LocationData; +import org.wso2.carbon.iot.android.sense.event.streams.sensor.SensorData; +import org.wso2.carbon.iot.android.sense.event.streams.speed.SpeedData; import org.wso2.carbon.iot.android.sense.event.streams.activity.ActivityData; import org.wso2.carbon.iot.android.sense.event.streams.application.ApplicationData; import org.wso2.carbon.iot.android.sense.event.streams.audio.AudioData; import org.wso2.carbon.iot.android.sense.event.streams.battery.BatteryData; import org.wso2.carbon.iot.android.sense.event.streams.call.CallData; +import org.wso2.carbon.iot.android.sense.event.streams.data.NetworkData; import org.wso2.carbon.iot.android.sense.event.streams.screen.ScreenData; import org.wso2.carbon.iot.android.sense.event.streams.sms.SmsData; import org.wso2.carbon.iot.android.sense.speech.detector.util.ProcessWords; @@ -277,6 +278,19 @@ public class DataPublisherService extends Service { } SenseDataHolder.resetApplicationDataHolder(); + //Retrieve network data + List networkDataList = SenseDataHolder.getNetworkDataHolder(); + if (!networkDataList.isEmpty()) { + for (NetworkData networkData : networkDataList) { + Event event = new Event(); + event.setTimestamp(networkData.getTimeStamp()); + event.setDataType(networkData.getDataType()); + event.setDataReceived(networkData.getDataReceived()); + event.setDataSent(networkData.getDataSent()); + events.add(event); + } + } + SenseDataHolder.resetNetworkDataHolder(); //publish the data if (events.size() > 0 && LocalRegistry.isEnrolled(context)) { diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/data/publisher/Event.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/data/publisher/Event.java index 1bc91c3a32..62a3659761 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/data/publisher/Event.java +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/data/publisher/Event.java @@ -61,6 +61,17 @@ public class Event { private String packageName; private String action; + /** + * Network data + * Time stamp + * Data type + * Data sent + * Data received. + * */ + private String dataType; + private long dataSent; + private long dataReceived; + private int getBattery() { return battery; } @@ -411,6 +422,36 @@ public class Event { this.confidence = confidence; } + public String getDataType() { + this.type = "data"; + return dataType; + } + + public void setDataType(String dataType) { + this.type = "data"; + this.dataType = dataType; + } + + public long getDataSent() { + this.type = "data"; + return dataSent; + } + + public void setDataSent(long dataSent) { + this.type = "data"; + this.dataSent = dataSent; + } + + public long getDataReceived() { + this.type = "data"; + return dataReceived; + } + + public void setDataReceived(long dataReceived) { + this.type = "data"; + this.dataReceived = dataReceived; + } + public JSONObject getEvent() throws JSONException { JSONObject jsonEvent = new JSONObject(); JSONObject jsonMetaData = new JSONObject(); @@ -502,6 +543,10 @@ public class Event { jsonPayloadData.put("application_name", getPackageName()); jsonPayloadData.put("action", getAction()); + //Network data + jsonPayloadData.put("data_type", getDataType()); + jsonPayloadData.put("data_received", getDataReceived()); + jsonPayloadData.put("data_sent", getDataSent()); jsonEvent.put("payloadData", jsonPayloadData); diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/SenseService.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/SenseService.java index 37e3356c68..ec62d8f4f4 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/SenseService.java +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/SenseService.java @@ -56,6 +56,7 @@ public class SenseService extends Service { SenseDataReceiverManager.registerActivityDataReceiver(this); SenseDataReceiverManager.registerSmsDataReceiver(this); SenseDataReceiverManager.registerAppDataReceiver(this); + SenseDataReceiverManager.registerNetworkDataReceiver(this); //service will not be stopped until we manually stop the service return Service.START_NOT_STICKY; @@ -69,6 +70,7 @@ public class SenseService extends Service { SenseDataReceiverManager.unregisterActivityDataReceiver(this); SenseDataReceiverManager.unregisterSmsDataReceiver(this); SenseDataReceiverManager.unregisterAppDataReceiver(this); + SenseDataReceiverManager.unregisterNetworkDataReceiver(this); SenseWakeLock.releaseCPUWakeLock(); super.onDestroy(); diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/SenseDataCollector.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/SenseDataCollector.java index 726e55fd41..086f7d40ab 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/SenseDataCollector.java +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/SenseDataCollector.java @@ -15,10 +15,9 @@ package org.wso2.carbon.iot.android.sense.event.streams; import android.content.Context; -import org.wso2.carbon.iot.android.sense.event.streams.Location.LocationDataReader; -import org.wso2.carbon.iot.android.sense.event.streams.Sensor.SensorDataReader; -import org.wso2.carbon.iot.android.sense.event.streams.Speed.SpeedDataReader; -import org.wso2.carbon.iot.android.sense.beacon.MonitoringActivity; +import org.wso2.carbon.iot.android.sense.event.streams.location.LocationDataReader; +import org.wso2.carbon.iot.android.sense.event.streams.sensor.SensorDataReader; +import org.wso2.carbon.iot.android.sense.event.streams.speed.SpeedDataReader; import org.wso2.carbon.iot.android.sense.event.streams.audio.AudioDataReader; /** diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/data/NetworkData.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/data/NetworkData.java new file mode 100644 index 0000000000..47b32325c7 --- /dev/null +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/data/NetworkData.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.iot.android.sense.event.streams.data; + +import java.util.Date; + +public class NetworkData { + + //Mobile or Wifi + private String DATA_TYPE; + private long dataReceived; + private long dataSent; + private long timeStamp; + + public NetworkData(long received, long sent) { + this.dataReceived = received; + this.dataSent = sent; + this.timeStamp = new Date().getTime(); + } + + public String getDataType() { + return DATA_TYPE; + } + + public long getDataReceived() { + return dataReceived; + } + + public void setDataReceived(long dataReceived) { + this.dataReceived = dataReceived; + } + + public long getDataSent() { + return dataSent; + } + + public void setDataSent(long dataSent) { + this.dataSent = dataSent; + } + + public long getTimeStamp() { + return timeStamp; + } +} diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/data/NetworkDataReceiver.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/data/NetworkDataReceiver.java new file mode 100644 index 0000000000..bcf353ffee --- /dev/null +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/data/NetworkDataReceiver.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.iot.android.sense.event.streams.data; + +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; +import android.util.Log; + +import org.wso2.carbon.iot.android.sense.util.SenseDataHolder; + +public class NetworkDataReceiver extends BroadcastReceiver{ + + @Override + public void onReceive(Context context, Intent intent) { + long sent = android.net.TrafficStats.getTotalTxBytes(); + long received = android.net.TrafficStats.getTotalRxBytes(); + Log.d("NetworkData :", "Received: " + sent + " Received : " + received); + + NetworkData networkData = new NetworkData(received, sent); + + SenseDataHolder.getNetworkDataHolder().add(networkData); + + } + +} diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/Location/LocationData.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/location/LocationData.java similarity index 95% rename from components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/Location/LocationData.java rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/location/LocationData.java index 3f5de2888f..c534990609 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/Location/LocationData.java +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/location/LocationData.java @@ -11,7 +11,7 @@ * See the License for the specific language governing permissions and limitations under the License. * */ -package org.wso2.carbon.iot.android.sense.event.streams.Location; +package org.wso2.carbon.iot.android.sense.event.streams.location; import java.util.Date; diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/Location/LocationDataReader.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/location/LocationDataReader.java similarity index 99% rename from components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/Location/LocationDataReader.java rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/location/LocationDataReader.java index b85969aa47..976e6d0bdc 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/Location/LocationDataReader.java +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/location/LocationDataReader.java @@ -11,7 +11,7 @@ * See the License for the specific language governing permissions and limitations under the License. * */ -package org.wso2.carbon.iot.android.sense.event.streams.Location; +package org.wso2.carbon.iot.android.sense.event.streams.location; import android.content.Context; import android.content.Intent; diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/Sensor/SensorData.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/sensor/SensorData.java similarity index 97% rename from components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/Sensor/SensorData.java rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/sensor/SensorData.java index abdfeb1555..a8c0d03643 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/Sensor/SensorData.java +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/sensor/SensorData.java @@ -12,7 +12,7 @@ * */ -package org.wso2.carbon.iot.android.sense.event.streams.Sensor; +package org.wso2.carbon.iot.android.sense.event.streams.sensor; import android.hardware.SensorEvent; diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/Sensor/SensorDataReader.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/sensor/SensorDataReader.java similarity index 95% rename from components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/Sensor/SensorDataReader.java rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/sensor/SensorDataReader.java index 3a57d4d48f..0ddc42236d 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/Sensor/SensorDataReader.java +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/sensor/SensorDataReader.java @@ -11,7 +11,7 @@ * See the License for the specific language governing permissions and limitations under the License. * */ -package org.wso2.carbon.iot.android.sense.event.streams.Sensor; +package org.wso2.carbon.iot.android.sense.event.streams.sensor; import android.content.Context; import android.content.SharedPreferences; @@ -26,6 +26,7 @@ import org.wso2.carbon.iot.android.sense.realtimeviewer.sensorlisting.SupportedS import org.wso2.carbon.iot.android.sense.util.SenseDataHolder; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -65,7 +66,7 @@ public class SensorDataReader extends DataReader implements SensorEventListener SensorData sensorInfo = senseDataStruct.get(sensor.getName()); sensorVector.add(sensorInfo); Log.d(TAG, "Sensor Name " + sensor.getName() + ", Type " + sensor.getType() + " " + - ", sensorValue :" + sensorInfo.getSensorValues()); + ", sensorValue :" + Arrays.toString(sensorInfo.getSensorValues())); } } catch (Throwable e) { Log.d(TAG, "error on sensors"); diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/Speed/SpeedData.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/speed/SpeedData.java similarity index 95% rename from components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/Speed/SpeedData.java rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/speed/SpeedData.java index a4e71301c4..2093fcbd44 100644 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/Speed/SpeedData.java +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/speed/SpeedData.java @@ -13,7 +13,7 @@ */ -package org.wso2.carbon.iot.android.sense.event.streams.Speed; +package org.wso2.carbon.iot.android.sense.event.streams.speed; import java.util.Date; diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/Speed/SpeedDataReader.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/speed/SpeedDataReader.java similarity index 96% rename from components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/Speed/SpeedDataReader.java rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/speed/SpeedDataReader.java index f306150f4c..f667391258 100644 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/Speed/SpeedDataReader.java +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/speed/SpeedDataReader.java @@ -12,10 +12,10 @@ * */ -package org.wso2.carbon.iot.android.sense.event.streams.Speed; +package org.wso2.carbon.iot.android.sense.event.streams.speed; import org.wso2.carbon.iot.android.sense.event.streams.DataReader; -import org.wso2.carbon.iot.android.sense.event.streams.Sensor.SensorData; +import org.wso2.carbon.iot.android.sense.event.streams.sensor.SensorData; import org.wso2.carbon.iot.android.sense.realtimeviewer.sensorlisting.SupportedSensors; import org.wso2.carbon.iot.android.sense.util.SenseDataHolder; import android.content.Context; @@ -37,9 +37,6 @@ import java.util.concurrent.TimeUnit; import android.content.BroadcastReceiver; import android.content.Intent; -import android.app.Activity; -import org.wso2.carbon.iot.android.sense.event.streams.Location.LocationDataReader; - public class SpeedDataReader extends DataReader implements SensorEventListener { diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/event/realtimesensor/RealTimeSensorReader.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/event/realtimesensor/RealTimeSensorReader.java index fc4b474e65..6504e65ab4 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/event/realtimesensor/RealTimeSensorReader.java +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/event/realtimesensor/RealTimeSensorReader.java @@ -42,9 +42,9 @@ public class RealTimeSensorReader implements SensorEventListener { RealTimeSensor realTimeSensor = new RealTimeSensor(); realTimeSensor.setName(supportedSensors.getType(event.sensor.getType()).toUpperCase()); - realTimeSensor.setValueX(event.values[0] + ""); - realTimeSensor.setValueY(event.values[1] + ""); - realTimeSensor.setValueZ(event.values[2] + ""); + realTimeSensor.setValueX(event.values == null ? "" : event.values[0] + ""); + realTimeSensor.setValueY(event.values == null || event.values.length <= 1 ? "" : event.values[1] + ""); + realTimeSensor.setValueZ(event.values == null || event.values.length <= 1 ? "" : event.values[2] + ""); TempStore.sensorDataMap.put(supportedSensors.getType(event.sensor.getType()), realTimeSensor); diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/speech/detector/util/ProcessWords.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/speech/detector/util/ProcessWords.java index 9933904a57..cbd1ed2b52 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/speech/detector/util/ProcessWords.java +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/speech/detector/util/ProcessWords.java @@ -18,9 +18,8 @@ import android.os.AsyncTask; import android.widget.EditText; import org.apache.commons.codec.language.Soundex; -import org.wso2.carbon.iot.android.sense.event.streams.Location.LocationData; import org.wso2.carbon.iot.android.sense.util.SenseDataHolder; -import java.util.ArrayList; + import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/SenseClientAsyncExecutor.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/SenseClientAsyncExecutor.java index 1d0e809cf5..6514fbb513 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/SenseClientAsyncExecutor.java +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/SenseClientAsyncExecutor.java @@ -23,6 +23,7 @@ import org.wso2.carbon.iot.android.sense.constants.SenseConstants; import org.wso2.carbon.iot.android.sense.util.dto.AccessTokenInfo; import org.wso2.carbon.iot.android.sense.util.dto.AndroidConfiguration; import org.wso2.carbon.iot.android.sense.util.dto.AndroidSenseManagerService; +import org.wso2.carbon.iot.android.sense.util.dto.ApiApplicationKey; import org.wso2.carbon.iot.android.sense.util.dto.ApiApplicationRegistrationService; import org.wso2.carbon.iot.android.sense.util.dto.ApiRegistrationProfile; import org.wso2.carbon.iot.android.sense.util.dto.DynamicClientRegistrationService; @@ -98,41 +99,24 @@ public class SenseClientAsyncExecutor extends AsyncTask activityDataHolder; private static List smsDataHolder; private static List applicationDataHolder; + private static List networkDataHolder; //LocationData gps; @@ -141,6 +143,13 @@ public class SenseDataHolder { return applicationDataHolder; } + public static List getNetworkDataHolder() { + if (networkDataHolder == null) { + networkDataHolder = new CopyOnWriteArrayList<>(); + } + return networkDataHolder; + } + public static void resetSensorDataHolder() { sensorDataHolder = null; } @@ -188,4 +197,8 @@ public class SenseDataHolder { public static void resetApplicationDataHolder() { applicationDataHolder = null; } + + public static void resetNetworkDataHolder() { + networkDataHolder = null; + } } diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/SenseDataReceiverManager.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/SenseDataReceiverManager.java index a72532464a..ed3abacd75 100644 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/SenseDataReceiverManager.java +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/SenseDataReceiverManager.java @@ -35,6 +35,7 @@ import org.wso2.carbon.iot.android.sense.event.streams.activity.ActivityReceiver import org.wso2.carbon.iot.android.sense.event.streams.application.ApplicationDataReceiver; import org.wso2.carbon.iot.android.sense.event.streams.battery.BatteryDataReceiver; import org.wso2.carbon.iot.android.sense.event.streams.call.CallDataReceiver; +import org.wso2.carbon.iot.android.sense.event.streams.data.NetworkDataReceiver; import org.wso2.carbon.iot.android.sense.event.streams.screen.ScreenDataReceiver; import org.wso2.carbon.iot.android.sense.event.streams.sms.SmsDataReceiver; @@ -51,6 +52,8 @@ public class SenseDataReceiverManager { private static ApplicationDataReceiver appDataReceiver; + private static NetworkDataReceiver networkDataReceiver; + private SenseDataReceiverManager() { } @@ -171,5 +174,21 @@ public class SenseDataReceiverManager { context.unregisterReceiver(appDataReceiver); appDataReceiver = null; } + } public static void registerNetworkDataReceiver(Context context) { + if (networkDataReceiver == null) { + networkDataReceiver = new NetworkDataReceiver(); + IntentFilter intentFilter = new IntentFilter(); + intentFilter.addAction(Intent.ACTION_MANAGE_NETWORK_USAGE); + context.registerReceiver(networkDataReceiver, intentFilter); + } + } + + public static void unregisterNetworkDataReceiver(Context context) { + if (networkDataReceiver != null) { + context.unregisterReceiver(networkDataReceiver); + } + networkDataReceiver = null; } + + } diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/dto/ApiApplicationKey.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/dto/ApiApplicationKey.java new file mode 100644 index 0000000000..e4130755e4 --- /dev/null +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/dto/ApiApplicationKey.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.iot.android.sense.util.dto; + +/** + * This holds api application consumer key and secret. + */ +public class ApiApplicationKey { + private String client_id; + private String client_secret; + + public String getConsumerKey() { + return this.client_id; + } + + public void setClient_id(String consumerKey) { + this.client_id = consumerKey; + } + + public String getConsumerSecret() { + return this.client_secret; + } + + public void setClient_secret(String consumerSecret) { + this.client_secret = consumerSecret; + } +} diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/dto/ApiApplicationRegistrationService.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/dto/ApiApplicationRegistrationService.java index e8cd26148b..64d4aa66f9 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/dto/ApiApplicationRegistrationService.java +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/dto/ApiApplicationRegistrationService.java @@ -21,5 +21,5 @@ public interface ApiApplicationRegistrationService { @POST @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) - String register(ApiRegistrationProfile registrationProfile); + ApiApplicationKey register(ApiRegistrationProfile registrationProfile); } diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/dto/TokenIssuerService.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/dto/TokenIssuerService.java index 161f07f45c..a23ccb8eb9 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/dto/TokenIssuerService.java +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/dto/TokenIssuerService.java @@ -29,5 +29,5 @@ public interface TokenIssuerService { @POST @Produces(MediaType.APPLICATION_JSON) AccessTokenInfo getToken(@QueryParam("grant_type") String grant, @QueryParam("username") String username, - @QueryParam("password") String password); + @QueryParam("password") String password, @QueryParam("deviceId") String deviceId); } diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_android_sense_executionplan/Android-Sense-ExecutionPlan.siddhiql b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_android_sense_executionplan/Android-Sense-ExecutionPlan.siddhiql index 743ec44f31..05eed95103 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_android_sense_executionplan/Android-Sense-ExecutionPlan.siddhiql +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_android_sense_executionplan/Android-Sense-ExecutionPlan.siddhiql @@ -29,6 +29,8 @@ define stream BatteryStream (meta_owner string, meta_deviceId string, meta_times @Export('org.wso2.iot.android.sms:1.0.0') define stream SmsStream (meta_owner string, meta_deviceId string, meta_timestamp long, number string, type string, body string); +@Export('org.wso2.geo.LocationStream:1.0.0') +define stream geoLocationStream (id string, timeStamp long, latitude double, longitude double, type string, speed float, heading float); from AndroidSense[meta_type == 'sms'] select meta_owner, meta_deviceId, meta_timestamp, sms_number as number, action as type, "" as body @@ -42,7 +44,7 @@ from AndroidSense[meta_type == 'audio'] select meta_owner, meta_deviceId, meta_timestamp, audio_playing, headset_on, music_volume insert into AudioStream; -from AndroidSense[meta_type == 'location'] +from AndroidSense[meta_type == 'gps'] select meta_owner, meta_deviceId, meta_timestamp, gps_lat as latitude, gps_long as longitude insert into LocationStream; @@ -60,4 +62,8 @@ insert into ActivityStream; from AndroidSense[meta_type == 'data'] select meta_owner, meta_deviceId, meta_timestamp, data_type as type, data_received as received, data_sent as sent -insert into DataStream; \ No newline at end of file +insert into DataStream; + +from AndroidSense[meta_type == 'gps'] +select meta_deviceId as id, meta_timestamp as timeStamp, gps_lat as latitude, gps_long as longitude, "android_sense" as type, speed_limit as speed, 0.0f as heading +insert into geoLocationStream; \ No newline at end of file diff --git a/components/extensions/mb-extensions/org.wso2.carbon.andes.extensions.device.mgt.mqtt.authorization/src/main/java/org/wso2/carbon/andes/extensions/device/mgt/mqtt/authorization/DeviceAccessBasedMQTTAuthorizer.java b/components/extensions/mb-extensions/org.wso2.carbon.andes.extensions.device.mgt.mqtt.authorization/src/main/java/org/wso2/carbon/andes/extensions/device/mgt/mqtt/authorization/DeviceAccessBasedMQTTAuthorizer.java index d64a77b0b4..0b98069627 100644 --- a/components/extensions/mb-extensions/org.wso2.carbon.andes.extensions.device.mgt.mqtt.authorization/src/main/java/org/wso2/carbon/andes/extensions/device/mgt/mqtt/authorization/DeviceAccessBasedMQTTAuthorizer.java +++ b/components/extensions/mb-extensions/org.wso2.carbon.andes.extensions.device.mgt.mqtt.authorization/src/main/java/org/wso2/carbon/andes/extensions/device/mgt/mqtt/authorization/DeviceAccessBasedMQTTAuthorizer.java @@ -64,12 +64,10 @@ public class DeviceAccessBasedMQTTAuthorizer implements IAuthorizer { private static final String CACHE_MANAGER_NAME = "mqttAuthorizationCacheManager"; private static final String CACHE_NAME = "mqttAuthorizationCache"; private static DeviceAccessAuthorizationAdminService deviceAccessAuthorizationAdminService; - private static Cache cache; public DeviceAccessBasedMQTTAuthorizer() { this.MQTTAuthorizationConfiguration = AuthorizationConfigurationManager.getInstance(); - createCache(); deviceAccessAuthorizationAdminService = Feign.builder() .requestInterceptor(new OAuthRequestInterceptor()) .contract(new JAXRSContract()).encoder(new GsonEncoder()).decoder(new GsonDecoder()) @@ -92,6 +90,7 @@ public class DeviceAccessBasedMQTTAuthorizer implements IAuthorizer { if (!tenantDomainFromTopic.equals(authorizationSubject.getTenantDomain())) { return false; } + Cache cache = getCache(); if (topics.length < 3) { AuthorizationCacheKey authorizationCacheKey = new AuthorizationCacheKey(tenantDomainFromTopic , authorizationSubject.getUsername(), "", ""); @@ -207,16 +206,15 @@ public class DeviceAccessBasedMQTTAuthorizer implements IAuthorizer { * This method is used to create the Caches. * @return Cachemanager */ - private void createCache() { + private synchronized Cache getCache() { PrivilegedCarbonContext.startTenantFlow(); PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain( MultitenantConstants.SUPER_TENANT_DOMAIN_NAME, true); try { - CacheManager cacheManager = Caching.getCacheManagerFactory().getCacheManager(CACHE_MANAGER_NAME); if (MQTTAuthorizationConfiguration.getCacheDuration() == 0) { - cache = cacheManager.getCache(CACHE_NAME); + return Caching.getCacheManagerFactory().getCacheManager(CACHE_MANAGER_NAME).getCache(CACHE_NAME); } else { - cache = cacheManager.createCacheBuilder(CACHE_NAME). + return Caching.getCacheManagerFactory().getCacheManager(CACHE_MANAGER_NAME).createCacheBuilder(CACHE_NAME). setExpiry(CacheConfiguration.ExpiryType.MODIFIED, new CacheConfiguration.Duration( TimeUnit.SECONDS, MQTTAuthorizationConfiguration.getCacheDuration())). setStoreByValue(false).build(); diff --git a/components/extensions/pom.xml b/components/extensions/pom.xml index 5a994a1614..15dc85a5ae 100644 --- a/components/extensions/pom.xml +++ b/components/extensions/pom.xml @@ -36,6 +36,7 @@ appm-connector cdmf-transport-adapters mb-extensions + siddhi-extensions @@ -44,7 +45,7 @@ org.apache.felix maven-scr-plugin - 1.7.2 + ${maven.scr.version} generate-scr-scrdescriptor diff --git a/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.execution.json/pom.xml b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.execution.json/pom.xml new file mode 100644 index 0000000000..b1671cc446 --- /dev/null +++ b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.execution.json/pom.xml @@ -0,0 +1,91 @@ + + + + + + + org.wso2.carbon.devicemgt-plugins + siddhi-extensions + 3.0.3-SNAPSHOT + ../pom.xml + + + 4.0.0 + org.wso2.extension.siddhi.execution.json + bundle + WSO2 Siddhi Execution Extension - Json + http://wso2.org + + + + org.wso2.siddhi + siddhi-core + + + org.wso2.siddhi + siddhi-query-api + + + log4j + log4j + + + org.json.wso2 + json + ${analytics.json.version} + + + junit + junit + test + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + ${wso2.maven.compiler.source} + ${wso2.maven.compiler.target} + + + + org.apache.felix + maven-bundle-plugin + true + + + ${project.artifactId} + ${project.artifactId} + + org.wso2.extension.siddhi.execution.json, + org.wso2.extension.siddhi.execution.json.* + + + org.json, + org.wso2.siddhi.core.*, + org.wso2.siddhi.query.api.*, + + + + + + + \ No newline at end of file diff --git a/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.execution.json/src/main/java/org/wso2/extension/siddhi/execution/json/getPropertyFunctionExtension.java b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.execution.json/src/main/java/org/wso2/extension/siddhi/execution/json/getPropertyFunctionExtension.java new file mode 100644 index 0000000000..8f68577a60 --- /dev/null +++ b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.execution.json/src/main/java/org/wso2/extension/siddhi/execution/json/getPropertyFunctionExtension.java @@ -0,0 +1,112 @@ +/* + * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.extension.siddhi.execution.json; + +import org.json.JSONException; +import org.json.JSONObject; +import org.wso2.siddhi.core.config.ExecutionPlanContext; +import org.wso2.siddhi.core.exception.ExecutionPlanRuntimeException; +import org.wso2.siddhi.core.executor.ExpressionExecutor; +import org.wso2.siddhi.core.executor.function.FunctionExecutor; +import org.wso2.siddhi.query.api.definition.Attribute; +import org.wso2.siddhi.query.api.exception.ExecutionPlanValidationException; + +/** + * getProperty(json , propertyName) + * Returns the vale of the property from the given json json + * Accept Type(s): (STRING, STRING) + * Return Type(s): (STRING|INT|DOUBLE|FLOAT|OBJECT) + */ +public class getPropertyFunctionExtension extends FunctionExecutor { + + Attribute.Type returnType = Attribute.Type.STRING; + + @Override + protected void init(ExpressionExecutor[] attributeExpressionExecutors, + ExecutionPlanContext executionPlanContext) { + if (attributeExpressionExecutors.length != 2) { + throw new ExecutionPlanValidationException( + "Invalid no of arguments passed to json:getProperty() function," + " required 2, but found " + + attributeExpressionExecutors.length); + } + if (attributeExpressionExecutors[0].getReturnType() != Attribute.Type.STRING) { + throw new ExecutionPlanValidationException( + "Invalid parameter type found for the first argument of json:getProperty() function, " + "required " + + Attribute.Type.STRING + ", but found " + attributeExpressionExecutors[0].getReturnType() + .toString()); + } + if (attributeExpressionExecutors[1].getReturnType() != Attribute.Type.STRING) { + throw new ExecutionPlanValidationException( + "Invalid parameter type found for the second argument of json:getProperty() function, " + "required " + + Attribute.Type.STRING + ", but found " + attributeExpressionExecutors[1].getReturnType() + .toString()); + } + } + + @Override + protected Object execute(Object[] data) { + if (data[0] == null) { + throw new ExecutionPlanRuntimeException("Invalid input given to json:getProperty() function. First argument cannot be null"); + } + if (data[1] == null) { + throw new ExecutionPlanRuntimeException("Invalid input given to json:getProperty() function. Second argument cannot be null"); + } + String jsonString = (String) data[0]; + String property = (String) data[1]; + JSONObject jsonObject = null; + try { + jsonObject = new JSONObject(jsonString); + return jsonObject.get(property).toString(); + } catch (JSONException e) { + throw new ExecutionPlanRuntimeException("Cannot parse JSON String in json:getPeroperty() function. " + e); + } + } + + @Override + protected Object execute(Object data) { + return null; //Since the getProperty function takes in 2 parameters, this method does not get called. Hence,not implemented. + } + + @Override + public void start() { + //Nothing to start + } + + @Override + public void stop() { + //Nothing to stop + } + + @Override + public Attribute.Type getReturnType() { + return returnType; + } + + @Override + public Object[] currentState() { + return null; //No need to maintain a state. + } + + @Override + public void restoreState(Object[] state) { + //Since there's no need to maintain a state, nothing needs to be done here. + } +} + + diff --git a/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.execution.json/src/main/resources/json.siddhiext b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.execution.json/src/main/resources/json.siddhiext new file mode 100644 index 0000000000..f1886dd63e --- /dev/null +++ b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.execution.json/src/main/resources/json.siddhiext @@ -0,0 +1,19 @@ +# +# Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. +# +# WSO2 Inc. licenses this file to you under the Apache License, +# Version 2.0 (the "License"); you may not use this file except +# in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +getProperty=org.wso2.extension.siddhi.execution.json.getPropertyFunctionExtension diff --git a/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.execution.json/src/test/java/org/wso2/extension/siddhi/execution/json/getPropertyFunctionTestCase.java b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.execution.json/src/test/java/org/wso2/extension/siddhi/execution/json/getPropertyFunctionTestCase.java new file mode 100644 index 0000000000..7bc66478c2 --- /dev/null +++ b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.execution.json/src/test/java/org/wso2/extension/siddhi/execution/json/getPropertyFunctionTestCase.java @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.extension.siddhi.execution.json; + +import junit.framework.Assert; +import org.apache.log4j.Logger; +import org.junit.Before; +import org.junit.Test; +import org.wso2.siddhi.core.ExecutionPlanRuntime; +import org.wso2.siddhi.core.SiddhiManager; +import org.wso2.siddhi.core.event.Event; +import org.wso2.siddhi.core.query.output.callback.QueryCallback; +import org.wso2.siddhi.core.stream.input.InputHandler; +import org.wso2.siddhi.core.util.EventPrinter; +import org.wso2.extension.siddhi.execution.json.test.util.SiddhiTestHelper; + +import java.util.concurrent.atomic.AtomicInteger; + +public class getPropertyFunctionTestCase { + static final Logger log = Logger.getLogger(getPropertyFunctionTestCase.class); + private AtomicInteger count = new AtomicInteger(0); + private volatile boolean eventArrived; + + @Before + public void init() { + count.set(0); + eventArrived = false; + } + + @Test + public void testGetPropertyFunctionExtension() throws InterruptedException { + log.info("getPropertyFunctionExtension TestCase"); + SiddhiManager siddhiManager = new SiddhiManager(); + + String inStreamDefinition = "define stream inputStream (payload string, id string, volume long);"; + String query = ("@info(name = 'query1') from inputStream select id, json:getProperty(payload, 'latitude') " + + "as latitude insert into outputStream;"); + ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(inStreamDefinition + query); + + executionPlanRuntime.addCallback("query1", new QueryCallback() { + @Override + public void receive(long timeStamp, Event[] inEvents, Event[] removeEvents) { + EventPrinter.print(timeStamp, inEvents, removeEvents); + for (Event event : inEvents) { + count.incrementAndGet(); + if (count.get() == 1) { + Assert.assertEquals("1.5", event.getData(1)); + eventArrived = true; + } + if (count.get() == 2) { + Assert.assertEquals("67.5", event.getData(1)); + eventArrived = true; + } + if (count.get() == 3) { + Assert.assertEquals("7.5", event.getData(1)); + eventArrived = true; + } + } + } + }); + + InputHandler inputHandler = executionPlanRuntime.getInputHandler("inputStream"); + executionPlanRuntime.start(); + inputHandler.send(new Object[]{"{'latitude' : 1.5, 'longitude' : 78.5}","IBM",100l}); + inputHandler.send(new Object[]{"{'latitude' : 67.5, 'longitude' : 34.9}","WSO2", 200l}); + inputHandler.send(new Object[]{"{'latitude' : 7.5, 'longitude' : 44.9}", "XYZ", 200l}); + SiddhiTestHelper.waitForEvents(100, 3, count, 60000); + Assert.assertEquals(3, count.get()); + Assert.assertTrue(eventArrived); + executionPlanRuntime.shutdown(); + } +} diff --git a/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.execution.json/src/test/java/org/wso2/extension/siddhi/execution/json/test/util/SiddhiTestHelper.java b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.execution.json/src/test/java/org/wso2/extension/siddhi/execution/json/test/util/SiddhiTestHelper.java new file mode 100644 index 0000000000..9cfd6c307d --- /dev/null +++ b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.execution.json/src/test/java/org/wso2/extension/siddhi/execution/json/test/util/SiddhiTestHelper.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.extension.siddhi.execution.json.test.util; + +import java.util.concurrent.atomic.AtomicInteger; + +public class SiddhiTestHelper { + public static void waitForEvents(long sleepTime, int expectedCount, AtomicInteger actualCount, long timeout) throws InterruptedException { + long currentWaitTime = 0; + long startTime = System.currentTimeMillis(); + while ((actualCount.get() < expectedCount) && (currentWaitTime <= timeout)) { + Thread.sleep(sleepTime); + currentWaitTime = System.currentTimeMillis() - startTime; + } + } +} diff --git a/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.execution.json/src/test/resources/log4j.properties b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.execution.json/src/test/resources/log4j.properties new file mode 100644 index 0000000000..96c79e9449 --- /dev/null +++ b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.execution.json/src/test/resources/log4j.properties @@ -0,0 +1,36 @@ +# +# Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. +# +# WSO2 Inc. licenses this file to you under the Apache License, +# Version 2.0 (the "License"); you may not use this file except +# in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + + +# For the general syntax of property based configuration files see the +# documenation of org.apache.log4j.PropertyConfigurator. + +# The root category uses the appender called A1. Since no priority is +# specified, the root category assumes the default priority for root +# which is DEBUG in log4j. The root category is the only category that +# has a default priority. All other categories need not be assigned a +# priority in which case they inherit their priority from the +# hierarchy. + +#log4j.rootLogger=DEBUG, stdout +log4j.rootLogger=INFO, stdout + +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.ConversionPattern=%m%n +#log4j.appender.stdout.layout.ConversionPattern=[%t] %-5p %c %x - %m%n diff --git a/components/extensions/siddhi-extensions/pom.xml b/components/extensions/siddhi-extensions/pom.xml new file mode 100644 index 0000000000..39b9741fe3 --- /dev/null +++ b/components/extensions/siddhi-extensions/pom.xml @@ -0,0 +1,58 @@ + + + + + + + org.wso2.carbon.devicemgt-plugins + extensions + 3.0.3-SNAPSHOT + ../pom.xml + + + 4.0.0 + siddhi-extensions + pom + WSO2 Carbon - Siddhi Extension + http://wso2.org + + + org.wso2.extension.siddhi.execution.json + + + + + + + org.apache.felix + maven-scr-plugin + ${maven.scr.version} + + + generate-scr-scrdescriptor + + scr + + + + + + + + diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.analytics/build.xml b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.analytics/build.xml new file mode 100644 index 0000000000..c0daeaa1ef --- /dev/null +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.analytics/build.xml @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.analytics/pom.xml b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.analytics/pom.xml new file mode 100644 index 0000000000..0cebffd07a --- /dev/null +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.analytics/pom.xml @@ -0,0 +1,76 @@ + + + + + + org.wso2.carbon.devicemgt-plugins + android-plugin + 3.0.3-SNAPSHOT + ../pom.xml + + + 4.0.0 + org.wso2.carbon.device.mgt.mobile.android.analytics + WSO2 Carbon - IoT Android Stream C-APP + http://wso2.org + This feature contains the android streams + pom + + + + + maven-antrun-plugin + ${maven-antrun-plugin.version} + + + process-resources + + + + + + + run + + + + + + maven-assembly-plugin + 2.5.5 + + ${project.artifactId}-${carbon.devicemgt.plugins.version} + false + + src/assembly/src.xml + + + + + create-archive + package + + single + + + + + + + \ No newline at end of file diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.analytics/src/assembly/src.xml b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.analytics/src/assembly/src.xml new file mode 100644 index 0000000000..a5a375010e --- /dev/null +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.analytics/src/assembly/src.xml @@ -0,0 +1,36 @@ + + + + src + + zip + + false + ${basedir}/src + + + ${basedir}/target/carbonapps + / + true + + + \ No newline at end of file diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.analytics/src/main/resources/carbonapps/Android-Agent-Event-Receiver_1.0.0/android_agent_event_receiver.xml b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.analytics/src/main/resources/carbonapps/Android-Agent-Event-Receiver_1.0.0/android_agent_event_receiver.xml new file mode 100644 index 0000000000..977e9a38c5 --- /dev/null +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.analytics/src/main/resources/carbonapps/Android-Agent-Event-Receiver_1.0.0/android_agent_event_receiver.xml @@ -0,0 +1,26 @@ + + + + + + false + + + + diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.analytics/src/main/resources/carbonapps/Android-Agent-Event-Receiver_1.0.0/artifact.xml b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.analytics/src/main/resources/carbonapps/Android-Agent-Event-Receiver_1.0.0/artifact.xml new file mode 100644 index 0000000000..078b058df1 --- /dev/null +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.analytics/src/main/resources/carbonapps/Android-Agent-Event-Receiver_1.0.0/artifact.xml @@ -0,0 +1,22 @@ + + + + + android_agent_event_receiver.xml + diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.analytics/src/main/resources/carbonapps/Android-Agent-ExecutionPlan/Android-Agent-ExecutionPlan.siddhiql b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.analytics/src/main/resources/carbonapps/Android-Agent-ExecutionPlan/Android-Agent-ExecutionPlan.siddhiql new file mode 100644 index 0000000000..a7b4691313 --- /dev/null +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.analytics/src/main/resources/carbonapps/Android-Agent-ExecutionPlan/Android-Agent-ExecutionPlan.siddhiql @@ -0,0 +1,20 @@ +/* Enter a unique ExecutionPlan */ +@Plan:name('Android-Agent-ExecutionPlan') + +/* Enter a unique description for ExecutionPlan */ +@Plan:description('To convert the android agent incoming stream to relvant streams') + +/* define streams/tables and write queries here ... */ + +@Plan:trace('false') + +@Import('org.wso2.android.agent.Stream:1.0.0') +define stream dataIn (deviceId string, payload string, type string); + +@Export('org.wso2.geo.LocationStream:1.0.0') +define stream dataOut (id string, timeStamp long, latitude double, longitude double, type string, speed float, heading float ); + +from dataIn[type == 'location'] +select deviceId as id, convert(json:getProperty(payload, 'timeStamp'), 'long') as timeStamp, convert(json:getProperty(payload, +'latitude'), 'double') as latitude, convert(json:getProperty(payload, 'longitude'), 'double') as longitude, +'android' as type, 0.0f as speed, 0.0f as heading insert into dataOut \ No newline at end of file diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.analytics/src/main/resources/carbonapps/Android-Agent-ExecutionPlan/artifact.xml b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.analytics/src/main/resources/carbonapps/Android-Agent-ExecutionPlan/artifact.xml new file mode 100644 index 0000000000..20093a25f3 --- /dev/null +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.analytics/src/main/resources/carbonapps/Android-Agent-ExecutionPlan/artifact.xml @@ -0,0 +1,23 @@ + + + + + Android-Agent-ExecutionPlan.siddhiql + + diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.analytics/src/main/resources/carbonapps/artifacts.xml b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.analytics/src/main/resources/carbonapps/artifacts.xml new file mode 100644 index 0000000000..61741f7c06 --- /dev/null +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.analytics/src/main/resources/carbonapps/artifacts.xml @@ -0,0 +1,29 @@ + + + + + + + + + + diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.analytics/src/main/resources/carbonapps/org.wso2.android.agent.Stream_1.0.0/artifact.xml b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.analytics/src/main/resources/carbonapps/org.wso2.android.agent.Stream_1.0.0/artifact.xml new file mode 100644 index 0000000000..4e4a656257 --- /dev/null +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.analytics/src/main/resources/carbonapps/org.wso2.android.agent.Stream_1.0.0/artifact.xml @@ -0,0 +1,23 @@ + + + + + org.wso2.android.agent.Stream_1.0.0.json + + diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.analytics/src/main/resources/carbonapps/org.wso2.android.agent.Stream_1.0.0/org.wso2.android.agent.Stream_1.0.0.json b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.analytics/src/main/resources/carbonapps/org.wso2.android.agent.Stream_1.0.0/org.wso2.android.agent.Stream_1.0.0.json new file mode 100755 index 0000000000..ed17c58f23 --- /dev/null +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.analytics/src/main/resources/carbonapps/org.wso2.android.agent.Stream_1.0.0/org.wso2.android.agent.Stream_1.0.0.json @@ -0,0 +1,20 @@ +{ + "name": "org.wso2.android.agent.Stream", + "version": "1.0.0", + "nickName": "", + "description": "Stream that receives various types of events from android agent", + "payloadData": [ + { + "name": "deviceId", + "type": "STRING" + }, + { + "name": "payload", + "type": "STRING" + }, + { + "name": "type", + "type": "STRING" + } + ] +} \ No newline at end of file diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/EventReceiverServiceImpl.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/EventReceiverServiceImpl.java index cf66771890..a11c678d02 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/EventReceiverServiceImpl.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/EventReceiverServiceImpl.java @@ -40,8 +40,7 @@ import java.util.List; @Path("/events") public class EventReceiverServiceImpl implements EventReceiverService { - - private static final String EVENT_STREAM_DEFINITION = "android_agent"; + private static final String EVENT_STREAM_DEFINITION = "org.wso2.android.agent.Stream"; private static final Log log = LogFactory.getLog(EventReceiverServiceImpl.class); @POST diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.operation-mod/public/js/operation-mod.js b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.operation-mod/public/js/operation-mod.js index b6b0795ca0..a4272f4421 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.operation-mod/public/js/operation-mod.js +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.operation-mod/public/js/operation-mod.js @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * * WSO2 Inc. licenses this file to you under the Apache License, * Version 2.0 (the "License"); you may not use this file except @@ -16,17 +16,10 @@ * under the License. */ -var operationModule = function () { +var androidOperationModule = function () { var publicMethods = {}; var privateMethods = {}; - // Constants to define platform types available - var platformTypeConstants = { - "ANDROID": "android", - "IOS": "ios", - "WINDOWS": "windows" - }; - // Constants to define operation types available var operationTypeConstants = { "PROFILE": "profile", @@ -85,731 +78,8 @@ var operationModule = function () { "KIOSK_APPS_CODE": "KIOSK_APPS" }; - // Constants to define Windows Operation Constants - var windowsOperationConstants = { - "PASSCODE_POLICY_OPERATION_CODE": "PASSCODE_POLICY", - "CAMERA_OPERATION_CODE": "CAMERA", - "ENCRYPT_STORAGE_OPERATION_CODE": "ENCRYPT_STORAGE", - "NOTIFICATION_OPERATION_CODE": "NOTIFICATION", - "CHANGE_LOCK_CODE_OPERATION_CODE": "CHANGE_LOCK_CODE" - }; - - // Constants to define iOS Operation Constants - var iosOperationConstants = { - "PASSCODE_POLICY_OPERATION_CODE": "PASSCODE_POLICY", - "RESTRICTIONS_OPERATION_CODE": "RESTRICTION", - "VPN_OPERATION_CODE": "VPN", - "WIFI_OPERATION_CODE": "WIFI", - "EMAIL_OPERATION_CODE": "EMAIL", - "AIRPLAY_OPERATION_CODE": "AIR_PLAY", - "LDAP_OPERATION_CODE": "LDAP", - "DOMAIN_OPERATION_CODE": "DOMAIN", - "CALENDAR_OPERATION_CODE": "CALDAV", - "NOTIFICATION_OPERATION_CODE": "NOTIFICATION", - "CALENDAR_SUBSCRIPTION_OPERATION_CODE": "CALENDAR_SUBSCRIPTION", - "APN_OPERATION_CODE": "APN", - "CELLULAR_OPERATION_CODE": "CELLULAR", - "PER_APP_VPN_OPERATION_CODE": "PER_APP_VPN", - "APP_TO_PER_APP_VPN_MAPPING_OPERATION_CODE": "APP_TO_PER_APP_VPN_MAPPING" - }; - - publicMethods.getIOSServiceEndpoint = function (operationCode) { - var featureMap = { - "DEVICE_LOCK": "lock", - "LOCATION": "location", - "ENTERPRISE_WIPE": "enterprise-wipe", - "NOTIFICATION": "notification", - "RING": "ring" - }; - return "/api/device-mgt/ios/v1.0/admin/devices/" + featureMap[operationCode]; - }; - - /** - * Convert the ios platform specific code to the generic payload. - * TODO: think of the possibility to follow a pattern to the key name (namespace?) - * @param operationCode - * @param operationPayload - * @returns {{}} - */ - privateMethods.generateGenericPayloadFromIOSPayload = function (operationCode, operationPayload) { - var payload = {}; - operationPayload = JSON.parse(operationPayload); - switch (operationCode) { - case iosOperationConstants["PASSCODE_POLICY_OPERATION_CODE"]: - payload = { - "passcodePolicyForcePIN": operationPayload["forcePIN"], - "passcodePolicyAllowSimple": operationPayload["allowSimple"], - "passcodePolicyRequireAlphanumeric": operationPayload["requireAlphanumeric"], - "passcodePolicyMinLength": operationPayload["minLength"], - "passcodePolicyMinComplexChars": operationPayload["minComplexChars"], - "passcodePolicyMaxPasscodeAgeInDays": operationPayload["maxPINAgeInDays"], - "passcodePolicyPasscodeHistory": operationPayload["pinHistory"], - "passcodePolicyMaxAutoLock": operationPayload["maxInactivity"], - "passcodePolicyGracePeriod": operationPayload["maxGracePeriod"], - "passcodePolicyMaxFailedAttempts": operationPayload["maxFailedAttempts"] - }; - break; - case iosOperationConstants["DOMAIN_OPERATION_CODE"]: - payload = { - "emailDomains": operationPayload["emailDomains"], - "webDomains": operationPayload["webDomains"] - }; - break; - case iosOperationConstants["RESTRICTIONS_OPERATION_CODE"]: - payload = { - "restrictionsAllowAccountModification": operationPayload["allowAccountModification"], - "restrictionsAllowAddingGameCenterFriends": operationPayload["allowAddingGameCenterFriends"], - "restrictionsAllowAirDrop": operationPayload["allowAirDrop"], - "restrictionsAllowAppCellularDataModification": operationPayload["allowAppCellularDataModification"], - "restrictionsAllowAppInstallation": operationPayload["allowAppInstallation"], - "restrictionsAllowAppRemoval": operationPayload["allowAppRemoval"], - "restrictionsAllowAssistant": operationPayload["allowAssistant"], - "restrictionsAllowAssistantUserGeneratedContent": operationPayload["allowAssistantUserGeneratedContent"], - "restrictionsAllowAssistantWhileLocked": operationPayload["allowAssistantWhileLocked"], - "restrictionsAllowBookstore": operationPayload["allowBookstore"], - "restrictionsAllowBookstoreErotica": operationPayload["allowBookstoreErotica"], - "restrictionsAllowCamera": operationPayload["allowCamera"], - "restrictionsAllowChat": operationPayload["allowChat"], - "restrictionsAllowCloudBackup": operationPayload["allowCloudBackup"], - "restrictionsAllowCloudDocumentSync": operationPayload["allowCloudDocumentSync"], - "restrictionsAllowCloudKeychainSync": operationPayload["allowCloudKeychainSync"], - "restrictionsAllowDiagnosticSubmission": operationPayload["allowDiagnosticSubmission"], - "restrictionsAllowExplicitContent": operationPayload["allowExplicitContent"], - "restrictionsAllowFindMyFriendsModification": operationPayload["allowFindMyFriendsModification"], - "restrictionsAllowFingerprintForUnlock": operationPayload["allowFingerprintForUnlock"], - "restrictionsAllowGameCenter": operationPayload["allowGameCenter"], - "restrictionsAllowGlobalBackgroundFetchWhenRoaming": operationPayload["allowGlobalBackgroundFetchWhenRoaming"], - "restrictionsAllowInAppPurchases": operationPayload["allowInAppPurchases"], - "restrictionsAllowLockScreenControlCenter": operationPayload["allowLockScreenControlCenter"], - "restrictionsAllowHostPairing": operationPayload["allowHostPairing"], - "restrictionsAllowLockScreenNotificationsView": operationPayload["allowLockScreenNotificationsView"], - "restrictionsAllowLockScreenTodayView": operationPayload["allowLockScreenTodayView"], - "restrictionsAllowMultiplayerGaming": operationPayload["allowMultiplayerGaming"], - "restrictionsAllowOpenFromManagedToUnmanaged": operationPayload["allowOpenFromManagedToUnmanaged"], - "restrictionsAllowOpenFromUnmanagedToManaged": operationPayload["allowOpenFromUnmanagedToManaged"], - "restrictionsAllowOTAPKIUpdates": operationPayload["allowOTAPKIUpdates"], - "restrictionsAllowPassbookWhileLocked": operationPayload["allowPassbookWhileLocked"], - "restrictionsAllowPhotoStream": operationPayload["allowPhotoStream"], - "restrictionsAllowSafari": operationPayload["allowSafari"], - "restrictionsSafariAllowAutoFill": operationPayload["safariAllowAutoFill"], - "restrictionsSafariForceFraudWarning": operationPayload["safariForceFraudWarning"], - "restrictionsSafariAllowJavaScript": operationPayload["safariAllowJavaScript"], - "restrictionsSafariAllowPopups": operationPayload["safariAllowPopups"], - "restrictionsAllowScreenShot": operationPayload["allowScreenShot"], - "restrictionsAllowSharedStream": operationPayload["allowSharedStream"], - "restrictionsAllowUIConfigurationProfileInstallation": operationPayload["allowUIConfigurationProfileInstallation"], - "restrictionsAllowUntrustedTLSPrompt": operationPayload["allowUntrustedTLSPrompt"], - "restrictionsAllowVideoConferencing": operationPayload["allowVideoConferencing"], - "restrictionsAllowVoiceDialing": operationPayload["allowVoiceDialing"], - "restrictionsAllowYouTube": operationPayload["allowYouTube"], - "restrictionsAllowITunes": operationPayload["allowiTunes"], - "restrictionsForceAssistantProfanityFilter": operationPayload["forceAssistantProfanityFilter"], - "restrictionsForceEncryptedBackup": operationPayload["forceEncryptedBackup"], - "restrictionsForceITunesStorePasswordEntry": operationPayload["forceITunesStorePasswordEntry"], - "restrictionsForceLimitAdTracking": operationPayload["forceLimitAdTracking"], - "restrictionsForceAirPlayOutgoingRequestsPairingPassword": operationPayload["forceAirPlayOutgoingRequestsPairingPassword"], - "restrictionsForceAirPlayIncomingRequestsPairingPassword": operationPayload["forceAirPlayIncomingRequestsPairingPassword"], - "restrictionsAllowManagedAppsCloudSync": operationPayload["allowManagedAppsCloudSync"], - "restrictionsAllowEraseContentAndSettings": operationPayload["allowEraseContentAndSettings"], - "restrictionsAllowSpotlightInternetResults": operationPayload["allowSpotlightInternetResults"], - "restrictionsAllowEnablingRestrictions": operationPayload["allowEnablingRestrictions"], - "restrictionsAllowActivityContinuation": operationPayload["allowActivityContinuation"], - "restrictionsAllowEnterpriseBookBackup": operationPayload["allowEnterpriseBookBackup"], - "restrictionsAllowEnterpriseBookMetadataSync": operationPayload["allowEnterpriseBookMetadataSync"], - "restrictionsAllowPodcasts": operationPayload["allowPodcasts"], - "restrictionsAllowDefinitionLookup": operationPayload["allowDefinitionLookup"], - "restrictionsAllowPredictiveKeyboard": operationPayload["allowPredictiveKeyboard"], - "restrictionsAllowAutoCorrection": operationPayload["allowAutoCorrection"], - "restrictionsAllowSpellCheck": operationPayload["allowSpellCheck"], - "restrictionsSafariAcceptCookies": operationPayload["safariAcceptCookies"], - "restrictionsAutonomousSingleAppModePermittedAppIDs": operationPayload["autonomousSingleAppModePermittedAppIDs"] - }; - break; - case iosOperationConstants["VPN_OPERATION_CODE"]: - var pptp = false; - var l2tp = false; - if (operationPayload["vpnType"] == "PPTP") { - pptp = true; - } else if (operationPayload["vpnType"] == "L2TP") { - l2tp = true; - } - - payload = { - "userDefinedName": operationPayload["userDefinedName"], - "overridePrimary": operationPayload["overridePrimary"], - "onDemandEnabled": operationPayload["onDemandEnabled"], - "onDemandMatchDomainsAlways": operationPayload["onDemandMatchDomainsAlways"], - "onDemandMatchDomainsNever": operationPayload["onDemandMatchDomainsNever"], - "onDemandMatchDomainsOnRetry": operationPayload["onDemandMatchDomainsOnRetry"], - "onDemandRules": operationPayload["onDemandRules"], - "vendorConfigs": operationPayload["vendorConfigs"], - "vpnType": operationPayload["vpnType"], - "pptpAuthName": pptp ? operationPayload.ppp["authName"] : "", - "pptpTokenCard": pptp ? operationPayload.ppp["tokenCard"] : "", - "pptpAuthPassword": pptp ? operationPayload.ppp["authPassword"] : "", - "pptpCommRemoteAddress": pptp ? operationPayload.ppp["commRemoteAddress"] : "", - "pptpRSASecureID": pptp ? operationPayload.ppp["RSASecureID"] : "", - "pptpCCPEnabled": pptp ? operationPayload.ppp["CCPEnabled"] : "", - "pptpCCPMPPE40Enabled": pptp ? operationPayload.ppp["CCPMPPE40Enabled"] : "", - "pptpCCPMPPE128Enabled": pptp ? operationPayload.ppp["CCPMPPE128Enabled"] : "", - "l2tpAuthName": l2tp ? operationPayload.ppp["authName"] : "", - "l2tpTokenCard": l2tp ? operationPayload.ppp["tokenCard"] : "", - "l2tpAuthPassword": l2tp ? operationPayload.ppp["authPassword"] : "", - "l2tpCommRemoteAddress": l2tp ? operationPayload.ppp["commRemoteAddress"] : "", - "l2tpRSASecureID": l2tp ? operationPayload.ppp["RSASecureID"] : "", - "ipsecRemoteAddress": operationPayload.ipSec["remoteAddress"], - "ipsecAuthenticationMethod": operationPayload.ipSec["authenticationMethod"], - "ipsecLocalIdentifier": operationPayload.ipSec["localIdentifier"], - "ipsecSharedSecret": operationPayload.ipSec["sharedSecret"], - "ipsecPayloadCertificateUUID": operationPayload.ipSec["payloadCertificateUUID"], - "ipsecXAuthEnabled": operationPayload.ipSec["XAuthEnabled"], - "ipsecXAuthName": operationPayload.ipSec["XAuthName"], - "ipsecPromptForVPNPIN": operationPayload.ipSec["promptForVPNPIN"], - "ikev2RemoteAddress": operationPayload.ikEv2["remoteAddress"], - "ikev2LocalIdentifier": operationPayload.ikEv2["localIdentifier"], - "ikev2RemoteIdentifier": operationPayload.ikEv2["remoteIdentifier"], - "ikev2AuthenticationMethod": operationPayload.ikEv2["authenticationMethod"], - "ikev2SharedSecret": operationPayload.ikEv2["sharedSecret"], - "ikev2PayloadCertificateUUID": operationPayload.ikEv2["payloadCertificateUUID"], - "ikev2ExtendedAuthEnabled": operationPayload.ikEv2["extendedAuthEnabled"], - "ikev2AuthName": operationPayload.ikEv2["authName"], - "ikev2AuthPassword": operationPayload.ikEv2["authPassword"], - "ikev2DeadPeerDetectionInterval": operationPayload.ikEv2["deadPeerDetectionInterval"], - "ikev2ServerCertificateIssuerCommonName": operationPayload.ikEv2["serverCertificateIssuerCommonName"], - "ikev2ServerCertificateCommonName": operationPayload.ikEv2["serverCertificateCommonName"] - }; - break; - case iosOperationConstants["PER_APP_VPN_OPERATION_CODE"]: - payload = { - "operation": { - "VPNUUID": operationPayload["PER-APP-VPNUUID"], - "safariDomains": operationPayload["safariDomains"], - "onDemandMatchAppEnabled": operationPayload["onDemandMatchAppEnabled"] - } - }; - break; - case iosOperationConstants["APP_TO_PER_APP_VPN_MAPPING_OPERATION_CODE"]: - payload = { - "operation": { - "appLayerVPNMappings": operationPayload["appLayerVPNMappings"] - } - }; - break; - case iosOperationConstants["WIFI_OPERATION_CODE"]: - payload = { - "wifiHiddenNetwork": operationPayload["hiddenNetwork"], - "wifiSSID": operationPayload["SSID"], - "wifiAutoJoin": operationPayload["autoJoin"], - "wifiProxyType": operationPayload["proxyType"], - "wifiEncryptionType": operationPayload["encryptionType"], - "wifiIsHotSpot": operationPayload["hotspot"], - "wifiDomainName": operationPayload["domainName"], - "wifiServiceProviderRoamingEnabled": operationPayload["serviceProviderRoamingEnabled"], - "wifiDisplayedOperatorName": operationPayload["displayedOperatorName"], - "wifiRoamingConsortiumOIs": operationPayload["roamingConsortiumOIs"], - "wifiPassword": operationPayload["password"], - "wifiPayloadCertUUID": operationPayload["payloadCertificateUUID"], - "wifiProxyServer": operationPayload["proxyServer"], - "wifiProxyPort": operationPayload["proxyPort"], - "wifiProxyUsername": operationPayload["proxyUsername"], - "wifiProxyPassword": operationPayload["proxyPassword"], - "wifiProxyPACURL": operationPayload["proxyPACURL"], - "wifiProxyPACFallbackAllowed": operationPayload["proxyPACFallbackAllowed"], - "wifiNAIRealmNames": operationPayload["nairealmNames"], - "wifiMCCAndMNCs": operationPayload["mccandMNCs"], - "wifiEAPUsername": operationPayload.clientConfiguration["username"], - "wifiAcceptedEAPTypes": operationPayload.clientConfiguration["acceptEAPTypes"], - "wifiEAPPassword": operationPayload.clientConfiguration["userPassword"], - "wifiEAPOneTimePassword": operationPayload.clientConfiguration["oneTimePassword"], - "wifiPayloadCertificateAnchorUUIDs": operationPayload.clientConfiguration["payloadCertificateAnchorUUID"], - "wifiEAPOuterIdentity": operationPayload.clientConfiguration["outerIdentity"], - "wifiTLSTrustedServerNames": operationPayload.clientConfiguration["tlstrustedServerNames"], - "wifiEAPTLSAllowTrustExceptions": operationPayload.clientConfiguration["tlsallowTrustExceptions"], - "wifiEAPTLSCertIsRequired": operationPayload.clientConfiguration["tlscertificateIsRequired"], - "wifiEAPTLSInnerAuthType": operationPayload.clientConfiguration["ttlsinnerAuthentication"], - "wifiEAPFastUsePAC": operationPayload.clientConfiguration["eapfastusePAC"], - "wifiEAPFastProvisionPAC": operationPayload.clientConfiguration["eapfastprovisionPAC"], - "wifiEAPFastProvisionPACAnonymously": operationPayload.clientConfiguration["eapfastprovisionPACAnonymously"], - "wifiEAPSIMNoOfRands": operationPayload.clientConfiguration["eapsimnumberOfRANDs"] - }; - break; - case iosOperationConstants["EMAIL_OPERATION_CODE"]: - payload = { - "emailAccountDescription": operationPayload["emailAccountDescription"], - "emailAccountName": operationPayload["emailAccountName"], - "emailAccountType": operationPayload["emailAccountType"], - "emailAddress": operationPayload["emailAddress"], - "emailIncomingMailServerAuthentication": operationPayload["incomingMailServerAuthentication"], - "emailIncomingMailServerHostname": operationPayload["incomingMailServerHostName"], - "emailIncomingMailServerPort": operationPayload["incomingMailServerPortNumber"], - "emailIncomingUseSSL": operationPayload["incomingMailServerUseSSL"], - "emailIncomingMailServerUsername": operationPayload["incomingMailServerUsername"], - "emailIncomingMailServerPassword": operationPayload["incomingPassword"], - "emailOutgoingMailServerPassword": operationPayload["outgoingPassword"], - "emailOutgoingPasswordSameAsIncomingPassword": operationPayload["outgoingPasswordSameAsIncomingPassword"], - "emailOutgoingMailServerAuthentication": operationPayload["outgoingMailServerAuthentication"], - "emailOutgoingMailServerHostname": operationPayload["outgoingMailServerHostName"], - "emailOutgoingMailServerPort": operationPayload["outgoingMailServerPortNumber"], - "emailOutgoingUseSSL": operationPayload["outgoingMailServerUseSSL"], - "emailOutgoingMailServerUsername": operationPayload["outgoingMailServerUsername"], - "emailPreventMove": operationPayload["preventMove"], - "emailPreventAppSheet": operationPayload["preventAppSheet"], - "emailDisableMailRecentsSyncing": operationPayload["disableMailRecentsSyncing"], - "emailIncomingMailServerIMAPPathPrefix": operationPayload["incomingMailServerIMAPPathPrefix"], - "emailSMIMEEnabled": operationPayload["smimeenabled"], - "emailSMIMESigningCertificateUUID": operationPayload["smimesigningCertificateUUID"], - "emailSMIMEEncryptionCertificateUUID": operationPayload["smimeencryptionCertificateUUID"], - "emailSMIMEEnablePerMessageSwitch": operationPayload["smimeenablePerMessageSwitch"] - }; - break; - case iosOperationConstants["AIRPLAY_OPERATION_CODE"]: - payload = { - "airplayDestinations": operationPayload["airPlayDestinations"], - "airplayCredentials": operationPayload["airPlayCredentials"] - }; - break; - case iosOperationConstants["LDAP_OPERATION_CODE"]: - payload = { - "ldapAccountDescription": operationPayload["accountDescription"], - "ldapAccountHostname": operationPayload["accountHostName"], - "ldapUseSSL": operationPayload["accountUseSSL"], - "ldapAccountUsername": operationPayload["accountUsername"], - "ldapAccountPassword": operationPayload["accountPassword"], - "ldapSearchSettings": operationPayload["ldapSearchSettings"] - }; - break; - case iosOperationConstants["CALENDAR_OPERATION_CODE"]: - payload = { - "calendarAccountDescription": operationPayload["accountDescription"], - "calendarAccountHostname": operationPayload["hostName"], - "calendarAccountUsername": operationPayload["username"], - "calendarAccountPassword": operationPayload["password"], - "calendarUseSSL": operationPayload["useSSL"], - "calendarAccountPort": operationPayload["port"], - "calendarPrincipalURL": operationPayload["principalURL"] - }; - break; - case iosOperationConstants["CALENDAR_SUBSCRIPTION_OPERATION_CODE"]: - payload = { - "calendarSubscriptionDescription": operationPayload["accountDescription"], - "calendarSubscriptionHostname": operationPayload["hostName"], - "calendarSubscriptionUsername": operationPayload["username"], - "calendarSubscriptionPassword": operationPayload["password"], - "calendarSubscriptionUseSSL": operationPayload["useSSL"] - }; - break; - case iosOperationConstants["APN_OPERATION_CODE"]: - payload = { - "apnConfigurations": operationPayload["apnConfigurations"] - }; - break; - case iosOperationConstants["CELLULAR_OPERATION_CODE"]: - payload = { - "cellularAttachAPNName": operationPayload["attachAPNName"], - "cellularAuthenticationType": operationPayload["authenticationType"], - "cellularUsername": operationPayload["username"], - "cellularPassword": operationPayload["password"], - "cellularAPNConfigurations": operationPayload["apnConfigurations"] - }; - break; - } - return payload; - }; - - privateMethods.generateIOSOperationPayload = function (operationCode, operationData, deviceList) { - var payload; - var operationType; - switch (operationCode) { - case iosOperationConstants["PASSCODE_POLICY_OPERATION_CODE"]: - operationType = operationTypeConstants["PROFILE"]; - payload = { - "operation": { - "forcePIN": operationData["passcodePolicyForcePIN"], - "allowSimple": operationData["passcodePolicyAllowSimple"], - "requireAlphanumeric": operationData["passcodePolicyRequireAlphanumeric"], - "minLength": operationData["passcodePolicyMinLength"], - "minComplexChars": operationData["passcodePolicyMinComplexChars"], - "maxPINAgeInDays": operationData["passcodePolicyMaxPasscodeAgeInDays"], - "pinHistory": operationData["passcodePolicyPasscodeHistory"], - "maxInactivity": operationData["passcodePolicyMaxAutoLock"], - "maxGracePeriod": operationData["passcodePolicyGracePeriod"], - "maxFailedAttempts": operationData["passcodePolicyMaxFailedAttempts"] - } - }; - break; - case iosOperationConstants["WIFI_OPERATION_CODE"]: - operationType = operationTypeConstants["PROFILE"]; - if (operationData["wifiProxyPort"] == "") { - operationData["wifiProxyPort"] = -1; - } - payload = { - "operation": { - "SSID": operationData["wifiSSID"], - "hiddenNetwork": operationData["wifiHiddenNetwork"], - "autoJoin": operationData["wifiAutoJoin"], - "proxyType": operationData["wifiProxyType"], - "encryptionType": operationData["wifiEncryptionType"], - "hotspot": operationData["wifiIsHotSpot"], - "domainName": operationData["wifiDomainName"], - "serviceProviderRoamingEnabled": operationData["wifiServiceProviderRoamingEnabled"], - "displayedOperatorName": operationData["wifiDisplayedOperatorName"], - "roamingConsortiumOIs": operationData["wifiRoamingConsortiumOIs"], - "password": operationData["wifiPassword"], - "clientConfiguration": { - "username": operationData["wifiEAPUsername"], - "acceptEAPTypes": operationData["wifiAcceptedEAPTypes"], - "userPassword": operationData["wifiEAPPassword"], - "oneTimePassword": operationData["wifiEAPOneTimePassword"], - "payloadCertificateAnchorUUID": operationData["wifiPayloadCertificateAnchorUUIDs"], - "outerIdentity": operationData["wifiEAPOuterIdentity"], - "tlstrustedServerNames": operationData["wifiTLSTrustedServerNames"], - "tlsallowTrustExceptions": operationData["wifiEAPTLSAllowTrustExceptions"], - "tlscertificateIsRequired": operationData["wifiEAPTLSCertIsRequired"], - "ttlsinnerAuthentication": operationData["wifiEAPTLSInnerAuthType"], - "eapfastusePAC": operationData["wifiEAPFastUsePAC"], - "eapfastprovisionPAC": operationData["wifiEAPFastProvisionPAC"], - "eapfastprovisionPACAnonymously": operationData["wifiEAPFastProvisionPACAnonymously"], - "eapsimnumberOfRANDs": operationData["wifiEAPSIMNoOfRands"] - }, - "payloadCertificateUUID": operationData["wifiPayloadCertUUID"], - "proxyServer": operationData["wifiProxyServer"], - "proxyPort": operationData["wifiProxyPort"], - "proxyUsername": operationData["wifiProxyUsername"], - "proxyPassword": operationData["wifiProxyPassword"], - "proxyPACURL": operationData["wifiProxyPACURL"], - "proxyPACFallbackAllowed": operationData["wifiProxyPACFallbackAllowed"], - "nairealmNames": operationData["wifiNAIRealmNames"], - "mccandMNCs": operationData["wifiMCCAndMNCs"] - } - }; - break; - case iosOperationConstants["VPN_OPERATION_CODE"]: - operationType = operationTypeConstants["PROFILE"]; - var ppp = {}; - var ipSec = {}; - var ikev2 = {}; - var pulseSecure = {}; - - if (operationData["vpnType"] == "PPTP") { - ppp = { - "authName": operationData["pptpAuthName"], - "tokenCard": operationData["pptpTokenCard"], - "authPassword": operationData["pptpAuthPassword"], - "commRemoteAddress": operationData["pptpCommRemoteAddress"], - "RSASecureID": operationData["pptpRSASecureID"], - "CCPEnabled": operationData["pptpCCPEnabled"], - "CCPMPPE40Enabled": operationData["pptpCCPMPPE40Enabled"], - "CCPMPPE128Enabled": operationData["pptpCCPMPPE128Enabled"] - }; - } else if (operationData["vpnType"] == "L2TP") { - ppp = { - "authName": operationData["l2tpAuthName"], - "tokenCard": operationData["l2tpTokenCard"], - "authPassword": operationData["l2tpAuthPassword"], - "commRemoteAddress": operationData["l2tpCommRemoteAddress"], - "RSASecureID": operationData["l2tpRSASecureID"] - }; - } else if (operationData["vpnType"] == "IPSec") { - ipSec = { - "remoteAddress": operationData["ipsecRemoteAddress"], - "authenticationMethod": operationData["ipsecAuthenticationMethod"], - "localIdentifier": operationData["ipsecLocalIdentifier"], - "sharedSecret": operationData["ipsecSharedSecret"], - "payloadCertificateUUID": operationData["ipsecPayloadCertificateUUID"], - "XAuthEnabled": operationData["ipsecXAuthEnabled"], - "XAuthName": operationData["ipsecXAuthName"], - "promptForVPNPIN": operationData["ipsecPromptForVPNPIN"] - }; - } else if (operationData["vpnType"] == "IKEv2") { - ikev2 = { - "remoteAddress": operationData["ikev2RemoteAddress"], - "localIdentifier": operationData["ikev2LocalIdentifier"], - "remoteIdentifier": operationData["ikev2RemoteIdentifier"], - "authenticationMethod": operationData["ikev2AuthenticationMethod"], - "sharedSecret": operationData["ikev2SharedSecret"], - "payloadCertificateUUID": operationData["ikev2PayloadCertificateUUID"], - "extendedAuthEnabled": operationData["ikev2ExtendedAuthEnabled"], - "authName": operationData["ikev2AuthName"], - "authPassword": operationData["ikev2AuthPassword"], - "deadPeerDetectionInterval": operationData["ikev2DeadPeerDetectionInterval"], - "serverCertificateIssuerCommonName": operationData["ikev2ServerCertificateIssuerCommonName"], - "serverCertificateCommonName": operationData["ikev2ServerCertificateCommonName"] - }; - } else if (operationData["vpnType"] == "PulseSecure") { - pulseSecure = { - "remoteAddress": operationData["pulsesecureRemoteAddress"], - "userName": operationData["pulsesecureName"], - "sharedSecret": operationData["pulsesecureSharedSecret"] - }; - } - - var domainsAlways = new Array(); - for (var i = 0; i < operationData["onDemandMatchDomainsAlways"].length; i++) { - domainsAlways.push(operationData["onDemandMatchDomainsAlways"][i].domain); - } - - var domainsNever = new Array(); - for (var i = 0; i < operationData["onDemandMatchDomainsNever"].length; i++) { - domainsNever.push(operationData["onDemandMatchDomainsNever"][i].domain); - } - - var domainsRetry = new Array(); - for (var i = 0; i < operationData["onDemandMatchDomainsOnRetry"].length; i++) { - domainsRetry.push(operationData["onDemandMatchDomainsOnRetry"][i].domain); - } - - payload = { - "operation": { - "userDefinedName": operationData["userDefinedName"], - "overridePrimary": operationData["overridePrimary"], - "onDemandEnabled": operationData["onDemandEnabled"], - "onDemandMatchDomainsAlways": domainsAlways, - "onDemandMatchDomainsNever": domainsNever, - "onDemandMatchDomainsOnRetry": domainsRetry, - "onDemandRules": operationData["onDemandRules"], - "vendorConfigs": operationData["vendorConfigs"], - "vpnType": operationData["vpnType"], - "ppp": ppp, - "ipSec": ipSec, - "ikEv2": ikev2, - "pulseSecure": pulseSecure - } - }; - break; - case iosOperationConstants["PER_APP_VPN_OPERATION_CODE"]: - operationType = operationTypeConstants["PROFILE"]; - var domains = new Array(); - for (var i = 0; i < operationData["safariDomains"].length; i++) { - domains.push(operationData["safariDomains"][i].domain); - } - payload = { - "operation": { - "VPNUUID": operationData["VPNUUID"], - "safariDomains": domains, - "onDemandMatchAppEnabled": operationData["onDemandMatchAppEnabled"] - } - }; - break; - case iosOperationConstants["APP_TO_PER_APP_VPN_MAPPING_OPERATION_CODE"]: - operationType = operationTypeConstants["PROFILE"]; - payload = { - "operation": { - "appLayerVPNMappings": operationData["appLayerVPNMappings"] - } - }; - break; - case iosOperationConstants["RESTRICTIONS_OPERATION_CODE"]: - operationType = operationTypeConstants["PROFILE"]; - payload = { - "operation": { - "allowAccountModification": operationData["restrictionsAllowAccountModification"], - "allowAddingGameCenterFriends": operationData["restrictionsAllowAddingGameCenterFriends"], - "allowAirDrop": operationData["restrictionsAllowAirDrop"], - "allowAppCellularDataModification": operationData["restrictionsAllowAppCellularDataModification"], - "allowAppInstallation": operationData["restrictionsAllowAppInstallation"], - "allowAppRemoval": operationData["restrictionsAllowAppRemoval"], - "allowAssistant": operationData["restrictionsAllowAssistant"], - "allowAssistantUserGeneratedContent": operationData["restrictionsAllowAssistantUserGeneratedContent"], - "allowAssistantWhileLocked": operationData["restrictionsAllowAssistantWhileLocked"], - "allowBookstore": operationData["restrictionsAllowBookstore"], - "allowBookstoreErotica": operationData["restrictionsAllowBookstoreErotica"], - "allowCamera": operationData["restrictionsAllowCamera"], - "allowChat": operationData["restrictionsAllowChat"], - "allowCloudBackup": operationData["restrictionsAllowCloudBackup"], - "allowCloudDocumentSync": operationData["restrictionsAllowCloudDocumentSync"], - "allowCloudKeychainSync": operationData["restrictionsAllowCloudKeychainSync"], - "allowDiagnosticSubmission": operationData["restrictionsAllowDiagnosticSubmission"], - "allowExplicitContent": operationData["restrictionsAllowExplicitContent"], - "allowFindMyFriendsModification": operationData["restrictionsAllowFindMyFriendsModification"], - "allowFingerprintForUnlock": operationData["restrictionsAllowFingerprintForUnlock"], - "allowGameCenter": operationData["restrictionsAllowGameCenter"], - "allowGlobalBackgroundFetchWhenRoaming": operationData["restrictionsAllowGlobalBackgroundFetchWhenRoaming"], - "allowInAppPurchases": operationData["restrictionsAllowInAppPurchases"], - "allowLockScreenControlCenter": operationData["restrictionsAllowLockScreenControlCenter"], - "allowHostPairing": operationData["restrictionsAllowHostPairing"], - "allowLockScreenNotificationsView": operationData["restrictionsAllowLockScreenNotificationsView"], - "allowLockScreenTodayView": operationData["restrictionsAllowLockScreenTodayView"], - "allowMultiplayerGaming": operationData["restrictionsAllowMultiplayerGaming"], - "allowOpenFromManagedToUnmanaged": operationData["restrictionsAllowOpenFromManagedToUnmanaged"], - "allowOpenFromUnmanagedToManaged": operationData["restrictionsAllowOpenFromUnmanagedToManaged"], - "allowOTAPKIUpdates": operationData["restrictionsAllowOTAPKIUpdates"], - "allowPassbookWhileLocked": operationData["restrictionsAllowPassbookWhileLocked"], - "allowPhotoStream": operationData["restrictionsAllowPhotoStream"], - "allowSafari": operationData["restrictionsAllowSafari"], - "safariAllowAutoFill": operationData["restrictionsSafariAllowAutoFill"], - "safariForceFraudWarning": operationData["restrictionsSafariForceFraudWarning"], - "safariAllowJavaScript": operationData["restrictionsSafariAllowJavaScript"], - "safariAllowPopups": operationData["restrictionsSafariAllowPopups"], - "allowScreenShot": operationData["restrictionsAllowScreenShot"], - "allowSharedStream": operationData["restrictionsAllowSharedStream"], - "allowUIConfigurationProfileInstallation": operationData["restrictionsAllowUIConfigurationProfileInstallation"], - "allowUntrustedTLSPrompt": operationData["restrictionsAllowUntrustedTLSPrompt"], - "allowVideoConferencing": operationData["restrictionsAllowVideoConferencing"], - "allowVoiceDialing": operationData["restrictionsAllowVoiceDialing"], - "allowYouTube": operationData["restrictionsAllowYouTube"], - "allowiTunes": operationData["restrictionsAllowITunes"], - "forceAssistantProfanityFilter": operationData["restrictionsForceAssistantProfanityFilter"], - "forceEncryptedBackup": operationData["restrictionsForceEncryptedBackup"], - "forceITunesStorePasswordEntry": operationData["restrictionsForceITunesStorePasswordEntry"], - "forceLimitAdTracking": operationData["restrictionsForceLimitAdTracking"], - "forceAirPlayOutgoingRequestsPairingPassword": operationData["restrictionsForceAirPlayOutgoingRequestsPairingPassword"], - "forceAirPlayIncomingRequestsPairingPassword": operationData["restrictionsForceAirPlayIncomingRequestsPairingPassword"], - "allowManagedAppsCloudSync": operationData["restrictionsAllowManagedAppsCloudSync"], - "allowEraseContentAndSettings": operationData["restrictionsAllowEraseContentAndSettings"], - "allowSpotlightInternetResults": operationData["restrictionsAllowSpotlightInternetResults"], - "allowEnablingRestrictions": operationData["restrictionsAllowEnablingRestrictions"], - "allowActivityContinuation": operationData["restrictionsAllowActivityContinuation"], - "allowEnterpriseBookBackup": operationData["restrictionsAllowEnterpriseBookBackup"], - "allowEnterpriseBookMetadataSync": operationData["restrictionsAllowEnterpriseBookMetadataSync"], - "allowPodcasts": operationData["restrictionsAllowPodcasts"], - "allowDefinitionLookup": operationData["restrictionsAllowDefinitionLookup"], - "allowPredictiveKeyboard": operationData["restrictionsAllowPredictiveKeyboard"], - "allowAutoCorrection": operationData["restrictionsAllowAutoCorrection"], - "allowSpellCheck": operationData["restrictionsAllowSpellCheck"], - "safariAcceptCookies": operationData["restrictionsSafariAcceptCookies"], - "autonomousSingleAppModePermittedAppIDs": operationData["restrictionsAutonomousSingleAppModePermittedAppIDs"] - } - }; - break; - case iosOperationConstants["EMAIL_OPERATION_CODE"]: - operationType = operationTypeConstants["PROFILE"]; - payload = { - "operation": { - "emailAccountDescription": operationData["emailAccountDescription"], - "emailAccountName": operationData["emailAccountName"], - "emailAccountType": operationData["emailAccountType"], - "emailAddress": operationData["emailAddress"], - "incomingMailServerAuthentication": operationData["emailIncomingMailServerAuthentication"], - "incomingMailServerHostName": operationData["emailIncomingMailServerHostname"], - "incomingMailServerPortNumber": operationData["emailIncomingMailServerPort"], - "incomingMailServerUseSSL": operationData["emailIncomingUseSSL"], - "incomingMailServerUsername": operationData["emailIncomingMailServerUsername"], - "incomingPassword": operationData["emailIncomingMailServerPassword"], - "outgoingPassword": operationData["emailOutgoingMailServerPassword"], - "outgoingPasswordSameAsIncomingPassword": operationData["emailOutgoingPasswordSameAsIncomingPassword"], - "outgoingMailServerAuthentication": operationData["emailOutgoingMailServerAuthentication"], - "outgoingMailServerHostName": operationData["emailOutgoingMailServerHostname"], - "outgoingMailServerPortNumber": operationData["emailOutgoingMailServerPort"], - "outgoingMailServerUseSSL": operationData["emailOutgoingUseSSL"], - "outgoingMailServerUsername": operationData["emailOutgoingMailServerUsername"], - "preventMove": operationData["emailPreventMove"], - "preventAppSheet": operationData["emailPreventAppSheet"], - "disableMailRecentsSyncing": operationData["emailDisableMailRecentsSyncing"], - "incomingMailServerIMAPPathPrefix": operationData["emailIncomingMailServerIMAPPathPrefix"], - "smimeenabled": operationData["emailSMIMEEnabled"], - "smimesigningCertificateUUID": operationData["emailSMIMESigningCertificateUUID"], - "smimeencryptionCertificateUUID": operationData["emailSMIMEEncryptionCertificateUUID"], - "smimeenablePerMessageSwitch": operationData["emailSMIMEEnablePerMessageSwitch"] - } - }; - break; - case iosOperationConstants["AIRPLAY_OPERATION_CODE"]: - operationType = operationTypeConstants["PROFILE"]; - payload = { - "operation": { - "airPlayDestinations": operationData["airplayDestinations"], - "airPlayCredentials": operationData["airplayCredentials"] - } - }; - break; - case iosOperationConstants["LDAP_OPERATION_CODE"]: - operationType = operationTypeConstants["PROFILE"]; - payload = { - "operation": { - "accountDescription": operationData["ldapAccountDescription"], - "accountHostName": operationData["ldapAccountHostname"], - "accountUseSSL": operationData["ldapUseSSL"], - "accountUsername": operationData["ldapAccountUsername"], - "accountPassword": operationData["ldapAccountPassword"], - "ldapSearchSettings": operationData["ldapSearchSettings"] - } - }; - break; - case iosOperationConstants["CALENDAR_OPERATION_CODE"]: - operationType = operationTypeConstants["PROFILE"]; - payload = { - "operation": { - "accountDescription": operationData["calendarAccountDescription"], - "hostName": operationData["calendarAccountHostname"], - "username": operationData["calendarAccountUsername"], - "password": operationData["calendarAccountPassword"], - "useSSL": operationData["calendarUseSSL"], - "port": operationData["calendarAccountPort"], - "principalURL": operationData["calendarPrincipalURL"] - } - }; - break; - case iosOperationConstants["CALENDAR_SUBSCRIPTION_OPERATION_CODE"]: - operationType = operationTypeConstants["PROFILE"]; - payload = { - "operation": { - "accountDescription": operationData["calendarSubscriptionDescription"], - "hostName": operationData["calendarSubscriptionHostname"], - "username": operationData["calendarSubscriptionUsername"], - "password": operationData["calendarSubscriptionPassword"], - "useSSL": operationData["calendarSubscriptionUseSSL"] - } - }; - break; - case iosOperationConstants["APN_OPERATION_CODE"]: - operationType = operationTypeConstants["PROFILE"]; - payload = { - "operation": { - "apnConfigurations": operationData["apnConfigurations"] - } - }; - break; - case iosOperationConstants["DOMAIN_OPERATION_CODE"]: - operationType = operationTypeConstants["PROFILE"]; - payload = { - "operation": { - "emailDomains": operationData["emailDomains"], - "webDomains": operationData["webDomains"] - } - }; - break; - case - iosOperationConstants["CELLULAR_OPERATION_CODE"] - : - operationType = operationTypeConstants["PROFILE"]; - payload = { - "operation": { - "attachAPNName": operationData["cellularAttachAPNName"], - "authenticationType": operationData["cellularAuthenticationType"], - "username": operationData["cellularUsername"], - "password": operationData["cellularPassword"], - "apnConfigurations": operationData["cellularAPNConfigurations"] - } - }; - break; - case - iosOperationConstants["NOTIFICATION_OPERATION_CODE"] - : - operationType = operationTypeConstants["PROFILE"]; - payload = { - "operation": { - "messageTitle": operationData["messageTitle"], - "messageText": operationData["messageText"] - } - }; - break; - default: - // If the operation is neither of above, it is a command operation - operationType = operationTypeConstants["COMMAND"]; - // Operation payload of a command operation is simply an array of device IDs - payload = deviceList; - } - - if (operationType == operationTypeConstants["PROFILE"] && deviceList) { - payload["deviceIDs"] = deviceList; - } - return payload; - } - ; - /** * Convert the android platform specific code to the generic payload. - * TODO: think of the possibility to follow a pattern to the key name (namespace?) * @param operationCode * @param operationPayload * @returns {{}} @@ -1124,118 +394,6 @@ var operationModule = function () { return "/api/device-mgt/android/v1.0/admin/devices/" + featureMap[operationCode]; }; - /** - * Convert the windows platform specific code to the generic payload. - * TODO: think of the possibility to follow a pattern to the key name (namespace?) - * @param operationCode - * @param operationPayload - * @returns {{}} - */ - privateMethods.generateGenericPayloadFromWindowsPayload = function (operationCode, operationPayload) { - var payload = {}; - operationPayload = JSON.parse(operationPayload); - switch (operationCode) { - case windowsOperationConstants["PASSCODE_POLICY_OPERATION_CODE"]: - payload = { - "passcodePolicyAllowSimple": operationPayload["allowSimple"], - "passcodePolicyRequireAlphanumeric": operationPayload["requireAlphanumeric"], - "passcodePolicyMinLength": operationPayload["minLength"], - "passcodePolicyMinComplexChars": operationPayload["minComplexChars"], - "passcodePolicyMaxPasscodeAgeInDays": operationPayload["maxPINAgeInDays"], - "passcodePolicyPasscodeHistory": operationPayload["pinHistory"], - "passcodePolicyMaxFailedAttempts": operationPayload["maxFailedAttempts"] - }; - break; - case windowsOperationConstants["CAMERA_OPERATION_CODE"]: - payload = { - "cameraEnabled": operationPayload["enabled"] - }; - break; - case windowsOperationConstants["ENCRYPT_STORAGE_OPERATION_CODE"]: - payload = { - "encryptStorageEnabled": operationPayload["encrypted"] - }; - break; - } - return payload; - }; - - privateMethods.generateWindowsOperationPayload = function (operationCode, operationData, deviceList) { - var payload; - var operationType; - switch (operationCode) { - case windowsOperationConstants["CAMERA_OPERATION_CODE"]: - operationType = operationTypeConstants["PROFILE"]; - payload = { - "operation": { - "enabled": operationData["cameraEnabled"] - } - }; - break; - case windowsOperationConstants["CHANGE_LOCK_CODE_OPERATION_CODE"]: - operationType = operationTypeConstants["PROFILE"]; - payload = { - "operation": { - "lockCode": operationData["lockCode"] - } - }; - break; - case windowsOperationConstants["ENCRYPT_STORAGE_OPERATION_CODE"]: - operationType = operationTypeConstants["PROFILE"]; - payload = { - "operation": { - "encrypted": operationData["encryptStorageEnabled"] - } - }; - break; - case windowsOperationConstants["NOTIFICATION_OPERATION_CODE"]: - operationType = operationTypeConstants["PROFILE"]; - payload = { - "operation": { - "message": operationData["message"] - } - }; - break; - case windowsOperationConstants["PASSCODE_POLICY_OPERATION_CODE"]: - operationType = operationTypeConstants["PROFILE"]; - payload = { - "operation": { - "allowSimple": operationData["passcodePolicyAllowSimple"], - "requireAlphanumeric": operationData["passcodePolicyRequireAlphanumeric"], - "minLength": operationData["passcodePolicyMinLength"], - "minComplexChars": operationData["passcodePolicyMinComplexChars"], - "maxPINAgeInDays": operationData["passcodePolicyMaxPasscodeAgeInDays"], - "pinHistory": operationData["passcodePolicyPasscodeHistory"], - "maxFailedAttempts": operationData["passcodePolicyMaxFailedAttempts"] - } - }; - break; - default: - // If the operation is neither of above, it is a command operation - operationType = operationTypeConstants["COMMAND"]; - // Operation payload of a command operation is simply an array of device IDs - payload = deviceList; - } - - if (operationType == operationTypeConstants["PROFILE"] && deviceList) { - payload["deviceIDs"] = deviceList; - } - - return payload; - }; - - - publicMethods.getWindowsServiceEndpoint = function (operationCode) { - var featureMap = { - "DEVICE_LOCK": "lock-devices", - "DISENROLL": "disenroll", - "DEVICE_RING": "ring-device", - "LOCK_RESET": "lock-reset", - "WIPE_DATA": "wipe-data" - }; - //return "/mdm-windows-agent/services/windows/operation/" + featureMap[operationCode]; - return "/api/device-mgt/windows/v1.0/services/windows/admin/devices/" + featureMap[operationCode]; - }; /** * Get the icon for the featureCode * @param operationCode @@ -1259,38 +417,6 @@ var operationModule = function () { return featureMap[operationCode]; }; - /** - * Get the icon for the featureCode - * @param operationCode - * @returns icon class - */ - publicMethods.getWindowsIconForFeature = function (operationCode) { - var featureMap = { - "DEVICE_LOCK": "fw-lock", - "DEVICE_RING": "fw-dial-up", - "DISENROLL": "fw-export", - "LOCK_RESET": "fw-key", - "WIPE_DATA": "fw-delete" - }; - return featureMap[operationCode]; - }; - - /** - * Get the icon for the featureCode - * @param operationCode - * @returns icon class - */ - publicMethods.getIOSIconForFeature = function (operationCode) { - var featureMap = { - "DEVICE_LOCK": "fw-lock", - "LOCATION": "fw-map-location", - "ENTERPRISE_WIPE": "fw-block", - "NOTIFICATION": "fw-message", - "RING": "fw-dial-up" - }; - return featureMap[operationCode]; - }; - /** * Filter a list by a data attribute. * @param prop @@ -1308,12 +434,11 @@ var operationModule = function () { /** * Method to generate Platform specific operation payload. * - * @param platformType Platform Type of the profile * @param operationCode Operation Codes to generate the profile from * @param deviceList Optional device list to include in payload body for operations * @returns {*} */ - publicMethods.generatePayload = function (platformType, operationCode, deviceList) { + publicMethods.generatePayload = function (operationCode, deviceList) { var payload; var operationData = {}; // capturing form input data designated by .operationDataKeys @@ -1430,47 +555,23 @@ var operationModule = function () { } } ); - - switch (platformType) { - case platformTypeConstants["ANDROID"]: - payload = privateMethods.generateAndroidOperationPayload(operationCode, operationData, deviceList); - break; - case platformTypeConstants["IOS"]: - payload = privateMethods.generateIOSOperationPayload(operationCode, operationData, deviceList); - break; - case platformTypeConstants["WINDOWS"]: - payload = privateMethods.generateWindowsOperationPayload(operationCode, operationData, deviceList); - break; - } + payload = privateMethods.generateAndroidOperationPayload(operationCode, operationData, deviceList); return payload; }; /** * Method to populate the Platform specific operation payload. * - * @param platformType Platform Type of the profile * @param operationCode Operation Codes to generate the profile from * @param operationPayload payload * @returns {*} */ - publicMethods.populateUI = function (platformType, operationCode, operationPayload) { - var uiPayload; - switch (platformType) { - case platformTypeConstants["ANDROID"]: - uiPayload = privateMethods.generateGenericPayloadFromAndroidPayload(operationCode, operationPayload); - break; - case platformTypeConstants["IOS"]: - uiPayload = privateMethods.generateGenericPayloadFromIOSPayload(operationCode, operationPayload); - break; - case platformTypeConstants["WINDOWS"]: - uiPayload = privateMethods.generateGenericPayloadFromWindowsPayload(operationCode, operationPayload); - break; - } + publicMethods.populateUI = function (operationCode, operationPayload) { + var uiPayload = privateMethods.generateGenericPayloadFromAndroidPayload(operationCode, operationPayload); // capturing form input data designated by .operationDataKeys $(".operation-data").filterByData("operation-code", operationCode).find(".operationDataKeys").each( function () { var operationDataObj = $(this); - //TODO :remove //operationDataObj.prop('disabled', true) var key = operationDataObj.data("key"); // retrieve corresponding input value associated with the key @@ -1612,18 +713,16 @@ var operationModule = function () { /** * generateProfile method is only used for policy-creation UIs. * - * @param platformType Platform Type of the profile * @param operationCodes Operation codes to generate the profile from - * @returns {{}} + * @returns {object} generated profile */ - publicMethods.generateProfile = function (platformType, operationCodes) { + publicMethods.generateProfile = function (operationCodes) { var generatedProfile = {}; for (var i = 0; i < operationCodes.length; ++i) { var operationCode = operationCodes[i]; - var payload = publicMethods.generatePayload(platformType, operationCode, null); + var payload = publicMethods.generatePayload(operationCode, null); - if (platformType == platformTypeConstants["ANDROID"] && - operationCodes[i] == androidOperationConstants["CAMERA_OPERATION_CODE"]) { + if (operationCodes[i] == androidOperationConstants["CAMERA_OPERATION_CODE"]) { var operations = payload["operation"]; for (var key in operations) { operationCode = key; @@ -1649,133 +748,130 @@ var operationModule = function () { /** * populateProfile method is used to populate the html ui with saved payload. * - * @param platformType Platform Type of the profile * @param payload List of profileFeatures * @returns [] configuredOperations array */ - publicMethods.populateProfile = function (platformType, payload) { + publicMethods.populateProfile = function (payload) { var i, configuredOperations = []; var restrictions = {}; for (i = 0; i < payload.length; ++i) { var configuredFeature = payload[i]; var featureCode = configuredFeature["featureCode"]; var operationPayload = configuredFeature["content"]; - if (platformType == platformTypeConstants["ANDROID"]) { - var restriction = JSON.parse(operationPayload); - if (featureCode == androidOperationConstants["CAMERA_OPERATION_CODE"]) { - restrictions["cameraEnabled"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["DISALLOW_ADJUST_VOLUME"]) { - restrictions["disallowAdjustVolumeEnabled"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["DISALLOW_CONFIG_BLUETOOTH"]) { - restrictions["disallowConfigBluetooth"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["DISALLOW_CONFIG_CELL_BROADCASTS"]) { - restrictions["disallowConfigCellBroadcasts"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["DISALLOW_CONFIG_CREDENTIALS"]) { - restrictions["disallowConfigCredentials"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["DISALLOW_CONFIG_MOBILE_NETWORKS"]) { - restrictions["disallowConfigMobileNetworks"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["DISALLOW_CONFIG_TETHERING"]) { - restrictions["disallowConfigTethering"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["DISALLOW_CONFIG_VPN"]) { - restrictions["disallowConfigVpn"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["DISALLOW_CONFIG_WIFI"]) { - restrictions["disallowConfigWifi"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["DISALLOW_APPS_CONTROL"]) { - restrictions["disallowAppControl"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["DISALLOW_CREATE_WINDOWS"]) { - restrictions["disallowCreateWindows"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["DISALLOW_CROSS_PROFILE_COPY_PASTE"]) { - restrictions["disallowCrossProfileCopyPaste"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["DISALLOW_DEBUGGING_FEATURES"]) { - restrictions["disallowDebugging"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["DISALLOW_FACTORY_RESET"]) { - restrictions["disallowFactoryReset"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["DISALLOW_ADD_USER"]) { - restrictions["disallowAddUser"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["DISALLOW_INSTALL_APPS"]) { - restrictions["disallowInstallApps"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["DISALLOW_INSTALL_UNKNOWN_SOURCES"]) { - restrictions["disallowInstallUnknownSources"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["DISALLOW_MODIFY_ACCOUNTS"]) { - restrictions["disallowModifyAccounts"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["DISALLOW_MOUNT_PHYSICAL_MEDIA"]) { - restrictions["disallowMountPhysicalMedia"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["DISALLOW_NETWORK_RESET"]) { - restrictions["disallowNetworkReset"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["DISALLOW_OUTGOING_BEAM"]) { - restrictions["disallowOutgoingBeam"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["DISALLOW_OUTGOING_CALLS"]) { - restrictions["disallowOutgoingCalls"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["DISALLOW_REMOVE_USER"]) { - restrictions["disallowRemoveUser"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["DISALLOW_SAFE_BOOT"]) { - restrictions["disallowSafeBoot"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["DISALLOW_SHARE_LOCATION"]) { - restrictions["disallowLocationSharing"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["DISALLOW_SMS"]) { - restrictions["disallowSMS"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["DISALLOW_UNINSTALL_APPS"]) { - restrictions["disallowUninstallApps"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["DISALLOW_UNMUTE_MICROPHONE"]) { - restrictions["disallowUnmuteMicrophone"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["DISALLOW_USB_FILE_TRANSFER"]) { - restrictions["disallowUSBFileTransfer"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["ALLOW_PARENT_PROFILE_APP_LINKING"]) { - restrictions["disallowParentProfileAppLinking"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["ENSURE_VERIFY_APPS"]) { - restrictions["ensureVerifyApps"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["AUTO_TIME"]) { - restrictions["enableAutoTime"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["SET_SCREEN_CAPTURE_DISABLED"]) { - restrictions["disableScreenCapture"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["SET_STATUS_BAR_DISABLED"]) { - restrictions["disableStatusBar"] = restriction["enabled"]; - continue; - } + var restriction = JSON.parse(operationPayload); + if (featureCode == androidOperationConstants["CAMERA_OPERATION_CODE"]) { + restrictions["cameraEnabled"] = restriction["enabled"]; + continue; + } else if (featureCode == androidOperationConstants["DISALLOW_ADJUST_VOLUME"]) { + restrictions["disallowAdjustVolumeEnabled"] = restriction["enabled"]; + continue; + } else if (featureCode == androidOperationConstants["DISALLOW_CONFIG_BLUETOOTH"]) { + restrictions["disallowConfigBluetooth"] = restriction["enabled"]; + continue; + } else if (featureCode == androidOperationConstants["DISALLOW_CONFIG_CELL_BROADCASTS"]) { + restrictions["disallowConfigCellBroadcasts"] = restriction["enabled"]; + continue; + } else if (featureCode == androidOperationConstants["DISALLOW_CONFIG_CREDENTIALS"]) { + restrictions["disallowConfigCredentials"] = restriction["enabled"]; + continue; + } else if (featureCode == androidOperationConstants["DISALLOW_CONFIG_MOBILE_NETWORKS"]) { + restrictions["disallowConfigMobileNetworks"] = restriction["enabled"]; + continue; + } else if (featureCode == androidOperationConstants["DISALLOW_CONFIG_TETHERING"]) { + restrictions["disallowConfigTethering"] = restriction["enabled"]; + continue; + } else if (featureCode == androidOperationConstants["DISALLOW_CONFIG_VPN"]) { + restrictions["disallowConfigVpn"] = restriction["enabled"]; + continue; + } else if (featureCode == androidOperationConstants["DISALLOW_CONFIG_WIFI"]) { + restrictions["disallowConfigWifi"] = restriction["enabled"]; + continue; + } else if (featureCode == androidOperationConstants["DISALLOW_APPS_CONTROL"]) { + restrictions["disallowAppControl"] = restriction["enabled"]; + continue; + } else if (featureCode == androidOperationConstants["DISALLOW_CREATE_WINDOWS"]) { + restrictions["disallowCreateWindows"] = restriction["enabled"]; + continue; + } else if (featureCode == androidOperationConstants["DISALLOW_CROSS_PROFILE_COPY_PASTE"]) { + restrictions["disallowCrossProfileCopyPaste"] = restriction["enabled"]; + continue; + } else if (featureCode == androidOperationConstants["DISALLOW_DEBUGGING_FEATURES"]) { + restrictions["disallowDebugging"] = restriction["enabled"]; + continue; + } else if (featureCode == androidOperationConstants["DISALLOW_FACTORY_RESET"]) { + restrictions["disallowFactoryReset"] = restriction["enabled"]; + continue; + } else if (featureCode == androidOperationConstants["DISALLOW_ADD_USER"]) { + restrictions["disallowAddUser"] = restriction["enabled"]; + continue; + } else if (featureCode == androidOperationConstants["DISALLOW_INSTALL_APPS"]) { + restrictions["disallowInstallApps"] = restriction["enabled"]; + continue; + } else if (featureCode == androidOperationConstants["DISALLOW_INSTALL_UNKNOWN_SOURCES"]) { + restrictions["disallowInstallUnknownSources"] = restriction["enabled"]; + continue; + } else if (featureCode == androidOperationConstants["DISALLOW_MODIFY_ACCOUNTS"]) { + restrictions["disallowModifyAccounts"] = restriction["enabled"]; + continue; + } else if (featureCode == androidOperationConstants["DISALLOW_MOUNT_PHYSICAL_MEDIA"]) { + restrictions["disallowMountPhysicalMedia"] = restriction["enabled"]; + continue; + } else if (featureCode == androidOperationConstants["DISALLOW_NETWORK_RESET"]) { + restrictions["disallowNetworkReset"] = restriction["enabled"]; + continue; + } else if (featureCode == androidOperationConstants["DISALLOW_OUTGOING_BEAM"]) { + restrictions["disallowOutgoingBeam"] = restriction["enabled"]; + continue; + } else if (featureCode == androidOperationConstants["DISALLOW_OUTGOING_CALLS"]) { + restrictions["disallowOutgoingCalls"] = restriction["enabled"]; + continue; + } else if (featureCode == androidOperationConstants["DISALLOW_REMOVE_USER"]) { + restrictions["disallowRemoveUser"] = restriction["enabled"]; + continue; + } else if (featureCode == androidOperationConstants["DISALLOW_SAFE_BOOT"]) { + restrictions["disallowSafeBoot"] = restriction["enabled"]; + continue; + } else if (featureCode == androidOperationConstants["DISALLOW_SHARE_LOCATION"]) { + restrictions["disallowLocationSharing"] = restriction["enabled"]; + continue; + } else if (featureCode == androidOperationConstants["DISALLOW_SMS"]) { + restrictions["disallowSMS"] = restriction["enabled"]; + continue; + } else if (featureCode == androidOperationConstants["DISALLOW_UNINSTALL_APPS"]) { + restrictions["disallowUninstallApps"] = restriction["enabled"]; + continue; + } else if (featureCode == androidOperationConstants["DISALLOW_UNMUTE_MICROPHONE"]) { + restrictions["disallowUnmuteMicrophone"] = restriction["enabled"]; + continue; + } else if (featureCode == androidOperationConstants["DISALLOW_USB_FILE_TRANSFER"]) { + restrictions["disallowUSBFileTransfer"] = restriction["enabled"]; + continue; + } else if (featureCode == androidOperationConstants["ALLOW_PARENT_PROFILE_APP_LINKING"]) { + restrictions["disallowParentProfileAppLinking"] = restriction["enabled"]; + continue; + } else if (featureCode == androidOperationConstants["ENSURE_VERIFY_APPS"]) { + restrictions["ensureVerifyApps"] = restriction["enabled"]; + continue; + } else if (featureCode == androidOperationConstants["AUTO_TIME"]) { + restrictions["enableAutoTime"] = restriction["enabled"]; + continue; + } else if (featureCode == androidOperationConstants["SET_SCREEN_CAPTURE_DISABLED"]) { + restrictions["disableScreenCapture"] = restriction["enabled"]; + continue; + } else if (featureCode == androidOperationConstants["SET_STATUS_BAR_DISABLED"]) { + restrictions["disableStatusBar"] = restriction["enabled"]; + continue; } //push the feature-code to the configuration array configuredOperations.push(featureCode); - publicMethods.populateUI(platformType, featureCode, operationPayload); + publicMethods.populateUI(featureCode, operationPayload); } if (typeof restrictions.cameraEnabled !== 'undefined') { configuredOperations.push(androidOperationConstants["CAMERA_OPERATION_CODE"]); - publicMethods.populateUI(platformType, androidOperationConstants["CAMERA_OPERATION_CODE"], JSON.stringify(restrictions)); + publicMethods.populateUI(androidOperationConstants["CAMERA_OPERATION_CODE"], JSON.stringify(restrictions)); } return configuredOperations; }; return publicMethods; -}(); +}(); \ No newline at end of file diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-edit/public/js/android-policy-edit.js b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-edit/public/js/android-policy-edit.js index d673b6d6a9..78b6e8054e 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-edit/public/js/android-policy-edit.js +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-edit/public/js/android-policy-edit.js @@ -15,6 +15,9 @@ * specific language governing permissions and limitations * under the License. */ + +var configuredOperations = []; + // Constants to define Android Operation Constants var androidOperationConstants = { "PASSCODE_POLICY_OPERATION": "passcode-policy", @@ -60,21 +63,56 @@ var updateGroupedInputVisibility = function (domElement) { * * This method will be invoked from the relevant cdmf unit when the edit page gets loaded. * - * @param configuredOperations selected configurations. + * @param profileFeatureList saved feature list */ -var polulateProfileOperations = function (configuredOperations) { +var polulateProfileOperations = function (profileFeatureList) { + var selectedOperations = androidOperationModule.populateProfile(profileFeatureList); $(".wr-advance-operations li.grouped-input").each(function () { updateGroupedInputVisibility(this); }); - for (var i = 0; i < configuredOperations.length; ++i) { - var configuredOperation = configuredOperations[i]; - $(".operation-data").filterByData("operation-code", configuredOperation) + for (var i = 0; i < selectedOperations.length; ++i) { + var selectedOperation = selectedOperations[i]; + $(".operation-data").filterByData("operation-code", selectedOperation) .find(".panel-title .wr-input-control.switch input[type=checkbox]").each(function () { $(this).click(); }); } }; +/** + * Generates policy profile feature list which will be saved with the profile. + * + * This function will be invoked from the relevant cdmf unit at the time of policy creation. + * + * @returns {Array} profile payloads + */ +var generateProfileFeaturesList = function () { + var profilePayloads = []; + var key; + for (key in policy["profile"]) { + if (policy["profile"].hasOwnProperty(key)) { + profilePayloads.push({ + "featureCode": key, + "deviceType": policy["platform"], + "content": policy["profile"][key] + }); + } + } + + return profilePayloads; +}; + +/** + * Generates policy profile object which will be saved with the profile. + * + * This function will be invoked from the relevant cdmf unit at the time of policy creation. + * + * @returns {object} generated profile. + */ +var generatePolicyProfile = function () { + return androidOperationModule.generateProfile(configuredOperations); +}; + /** * Checks if provided number is valid against a range. * @@ -542,30 +580,6 @@ var validatePolicyProfile = function () { return wizardIsToBeContinued; }; -/** - * Generates policy profile object which will be saved with the profile. - * - * This function will be invoked from the relevant cdmf unit at the time of policy creation. - * - * @returns {Array} profile payloads - */ -var generatePolicyProfile = function () { - var profilePayloads = []; - // traverses key by key in policy["profile"] - var key; - for (key in policy["profile"]) { - if (policy["profile"].hasOwnProperty(key)) { - profilePayloads.push({ - "featureCode": key, - "deviceType": policy["platform"], - "content": policy["profile"][key] - }); - } - } - - return profilePayloads; -}; - // Start of HTML embedded invoke methods var showAdvanceOperation = function (operation, button) { $(button).addClass('selected'); @@ -685,6 +699,22 @@ var slideDownPaneAgainstValueSet = function (selectElement, paneID, valueSet) { ); } }; + +var slideDownPaneAgainstValueSetForRadioButtons = function (selectElement, paneID, valueSet) { + var selectedValueOnChange = selectElement.value; + var slideDownVotes = 0; + for (var i = 0; i < valueSet.length; i++) { + if (selectedValueOnChange == valueSet[i]) { + slideDownVotes++; + } + } + var paneSelector = "#" + paneID; + if (slideDownVotes > 0) { + $(paneSelector).removeClass("hidden"); + } else { + $(paneSelector).addClass("hidden"); + } +}; // End of HTML embedded invoke methods diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-view/public/js/android-policy-view.js b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-view/public/js/android-policy-view.js index 7d6fecf7ea..ab45604880 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-view/public/js/android-policy-view.js +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-view/public/js/android-policy-view.js @@ -16,8 +16,6 @@ * under the License. */ -var configuredOperations = []; - /** * Method to update the visibility (i.e. disabled or enabled view) * of grouped input according to the values @@ -47,9 +45,10 @@ var updateGroupedInputVisibility = function (domElement) { * * This method will be invoked from the relevant cdmf unit when the edit page gets loaded. * - * @param selectedConfigurations selected configurations. + * @param profileFeatureList selected configurations. */ -var polulateProfileOperations = function (selectedConfigurations) { +var polulateProfileOperations = function (profileFeatureList) { + var selectedConfigurations = androidOperationModule.populateProfile(profileFeatureList); $(".wr-advance-operations li.grouped-input").each(function () { updateGroupedInputVisibility(this); }); @@ -169,35 +168,6 @@ var slideDownPaneAgainstValueSetForRadioButtons = function (selectElement, paneI }; // End of HTML embedded invoke methods - -// Start of functions related to grid-input-view - -/** - * Method to set count id to cloned elements. - * @param {object} addFormContainer - */ -var setId = function (addFormContainer) { - $(addFormContainer).find("[data-add-form-clone]").each(function (i) { - $(this).attr("id", $(this).attr("data-add-form-clone").slice(1) + "-" + (i + 1)); - if ($(this).find(".index").length > 0) { - $(this).find(".index").html(i + 1); - } - }); -}; - -/** - * Method to set count id to cloned elements. - * @param {object} addFormContainer - */ -var showHideHelpText = function (addFormContainer) { - var helpText = "[data-help-text=add-form]"; - if ($(addFormContainer).find("[data-add-form-clone]").length > 0) { - $(addFormContainer).find(helpText).hide(); - } else { - $(addFormContainer).find(helpText).show(); - } -}; - /** * This method will display appropriate fields based on wifi type * @param {object} wifi type select object @@ -229,148 +199,19 @@ var changeAndroidWifiPolicyEAP = function (select, superSelect) { }; $(document).ready(function () { - // Maintains an array of configured features of the profile var advanceOperations = ".wr-advance-operations"; $(advanceOperations).on("click", ".wr-input-control.switch", function (event) { - var operationCode = $(this).parents(".operation-data").data("operation-code"); var operation = $(this).parents(".operation-data").data("operation"); - var operationDataWrapper = $(this).data("target"); // prevents event bubbling by figuring out what element it's being called from. if (event.target.tagName == "INPUT") { var featureConfiguredIcon; if ($("input[type='checkbox']", this).is(":checked")) { - configuredOperations.push(operationCode); - // when a feature is enabled, if "zero-configured-features" msg is available, hide that. - var zeroConfiguredOperationsErrorMsg = "#policy-profile-main-error-msg"; - if (!$(zeroConfiguredOperationsErrorMsg).hasClass("hidden")) { - $(zeroConfiguredOperationsErrorMsg).addClass("hidden"); - } // add configured-state-icon to the feature featureConfiguredIcon = "#" + operation + "-configured"; if ($(featureConfiguredIcon).hasClass("hidden")) { $(featureConfiguredIcon).removeClass("hidden"); } - } else { - //splicing the array if operation is present. - var index = $.inArray(operationCode, configuredOperations); - if (index != -1) { - configuredOperations.splice(index, 1); - } - // when a feature is disabled, clearing all its current configured, error or success states - var subErrorMsgWrapper = "#" + operation + "-feature-error-msg"; - var subErrorIcon = "#" + operation + "-error"; - var subOkIcon = "#" + operation + "-ok"; - featureConfiguredIcon = "#" + operation + "-configured"; - - if (!$(subErrorMsgWrapper).hasClass("hidden")) { - $(subErrorMsgWrapper).addClass("hidden"); - } - if (!$(subErrorIcon).hasClass("hidden")) { - $(subErrorIcon).addClass("hidden"); - } - if (!$(subOkIcon).hasClass("hidden")) { - $(subOkIcon).addClass("hidden"); - } - if (!$(featureConfiguredIcon).hasClass("hidden")) { - $(featureConfiguredIcon).addClass("hidden"); - } - // reinitializing input fields into the defaults - $(operationDataWrapper + " input").each( - function () { - if ($(this).is("input:text")) { - $(this).val($(this).data("default")); - } else if ($(this).is("input:password")) { - $(this).val(""); - } else if ($(this).is("input:checkbox")) { - $(this).prop("checked", $(this).data("default")); - // if this checkbox is the parent input of a grouped-input - if ($(this).hasClass("parent-input")) { - var groupedInput = $(this).parent().parent().parent(); - updateGroupedInputVisibility(groupedInput); - } - } - } - ); - // reinitializing select fields into the defaults - $(operationDataWrapper + " select").each( - function () { - var defaultOption = $(this).data("default"); - $("option:eq(" + defaultOption + ")", this).prop("selected", "selected"); - } - ); - // collapsing expanded-panes (upon the selection of html-select-options) if any - $(operationDataWrapper + " .expanded").each( - function () { - if ($(this).hasClass("expanded")) { - $(this).removeClass("expanded"); - } - $(this).slideUp(); - } - ); - // removing all entries of grid-input elements if exist - $(operationDataWrapper + " .grouped-array-input").each( - function () { - var gridInputs = $(this).find("[data-add-form-clone]"); - if (gridInputs.length > 0) { - gridInputs.remove(); - } - var helpTexts = $(this).find("[data-help-text=add-form]"); - if (helpTexts.length > 0) { - helpTexts.show(); - } - } - ); } } }); - - // adding support for cloning multiple profiles per feature with cloneable class definitions - $(advanceOperations).on("click", ".multi-view.add.enabled", function () { - // get a copy of .cloneable and create new .cloned div element - var cloned = "

" + $(".cloneable", $(this).parent().parent()).html() + "
"; - // append newly created .cloned div element to panel-body - $(this).parent().parent().append(cloned); - // enable remove action of newly cloned div element - $(".cloned", $(this).parent().parent()).each( - function () { - if ($(".multi-view.remove", this).hasClass("disabled")) { - $(".multi-view.remove", this).removeClass("disabled"); - } - if (!$(".multi-view.remove", this).hasClass("enabled")) { - $(".multi-view.remove", this).addClass("enabled"); - } - } - ); - }); - - $(advanceOperations).on("click", ".multi-view.remove.enabled", function () { - $(this).parent().remove(); - }); - - // enabling or disabling grouped-input based on the status of a parent check-box - $(advanceOperations).on("click", ".grouped-input", function () { - updateGroupedInputVisibility(this); - }); - - // add form entry click function for grid inputs - $(advanceOperations).on("click", "[data-click-event=add-form]", function () { - var addFormContainer = $("[data-add-form-container=" + $(this).attr("href") + "]"); - var clonedForm = $("[data-add-form=" + $(this).attr("href") + "]").clone().find("[data-add-form-element=clone]").attr("data-add-form-clone", $(this).attr("href")); - - // adding class .child-input to capture text-input-array-values - $("input, select", clonedForm).addClass("child-input"); - - $(addFormContainer).append(clonedForm); - setId(addFormContainer); - showHideHelpText(addFormContainer); - }); - - // remove form entry click function for grid inputs - $(advanceOperations).on("click", "[data-click-event=remove-form]", function () { - var addFormContainer = $("[data-add-form-container=" + $(this).attr("href") + "]"); - - $(this).closest("[data-add-form-element=clone]").remove(); - setId(addFormContainer); - showHideHelpText(addFormContainer); - }); }); \ No newline at end of file diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-wizard/public/js/android-policy-operations.js b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-wizard/public/js/android-policy-operations.js index 22bf73250f..fa8a29cb0a 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-wizard/public/js/android-policy-operations.js +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-wizard/public/js/android-policy-operations.js @@ -16,6 +16,8 @@ * under the License. */ +var configuredOperations = []; + var androidOperationConstants = { "PASSCODE_POLICY_OPERATION": "passcode-policy", "PASSCODE_POLICY_OPERATION_CODE": "PASSCODE_POLICY", @@ -523,13 +525,13 @@ var validatePolicyProfile = function () { }; /** - * Generates policy profile object which will be saved with the profile. + * Generates policy profile feature list which will be saved with the profile. * * This function will be invoked from the relevant cdmf unit at the time of policy creation. * * @returns {Array} profile payloads */ -var generatePolicyProfile = function () { +var generateProfileFeaturesList = function () { var profilePayloads = []; // traverses key by key in policy["profile"] var key; @@ -546,6 +548,24 @@ var generatePolicyProfile = function () { return profilePayloads; }; +/** + * Generates policy profile object which will be saved with the profile. + * + * This function will be invoked from the relevant cdmf unit at the time of policy creation. + * + * @returns {object} generated profile. + */ +var generatePolicyProfile = function () { + return androidOperationModule.generateProfile(configuredOperations); +}; + +/** + * Resets policy profile configurations. + */ +var resetPolicyProfile = function () { + configuredOperations = []; +}; + // Start of HTML embedded invoke methods var showAdvanceOperation = function (operation, button) { $(button).addClass('selected'); @@ -665,6 +685,22 @@ var slideDownPaneAgainstValueSet = function (selectElement, paneID, valueSet) { ); } }; + +var slideDownPaneAgainstValueSetForRadioButtons = function (selectElement, paneID, valueSet) { + var selectedValueOnChange = selectElement.value; + var slideDownVotes = 0; + for (var i = 0; i < valueSet.length; i++) { + if (selectedValueOnChange == valueSet[i]) { + slideDownVotes++; + } + } + var paneSelector = "#" + paneID; + if (slideDownVotes > 0) { + $(paneSelector).removeClass("hidden"); + } else { + $(paneSelector).addClass("hidden"); + } +}; // End of HTML embedded invoke methods diff --git a/components/mobile-plugins/android-plugin/pom.xml b/components/mobile-plugins/android-plugin/pom.xml index 3349f4b2a4..3c67bfde64 100644 --- a/components/mobile-plugins/android-plugin/pom.xml +++ b/components/mobile-plugins/android-plugin/pom.xml @@ -36,6 +36,7 @@ org.wso2.carbon.device.mgt.mobile.android org.wso2.carbon.device.mgt.mobile.android.api org.wso2.carbon.device.mgt.mobile.android.ui + org.wso2.carbon.device.mgt.mobile.android.analytics diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.operation-mod/public/js/operation-mod.js b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.operation-mod/public/js/operation-mod.js index b6b0795ca0..4e5d74f56f 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.operation-mod/public/js/operation-mod.js +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.operation-mod/public/js/operation-mod.js @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * * WSO2 Inc. licenses this file to you under the Apache License, * Version 2.0 (the "License"); you may not use this file except @@ -16,17 +16,10 @@ * under the License. */ -var operationModule = function () { +var windowsOperationModule = function () { var publicMethods = {}; var privateMethods = {}; - // Constants to define platform types available - var platformTypeConstants = { - "ANDROID": "android", - "IOS": "ios", - "WINDOWS": "windows" - }; - // Constants to define operation types available var operationTypeConstants = { "PROFILE": "profile", @@ -34,57 +27,6 @@ var operationModule = function () { "COMMAND": "command" }; - // Constants to define Android Operation Constants - var androidOperationConstants = { - "PASSCODE_POLICY_OPERATION_CODE": "PASSCODE_POLICY", - "VPN_OPERATION_CODE": "VPN", - "CAMERA_OPERATION_CODE": "CAMERA", - "ENCRYPT_STORAGE_OPERATION_CODE": "ENCRYPT_STORAGE", - "WIFI_OPERATION_CODE": "WIFI", - "WIPE_OPERATION_CODE": "WIPE_DATA", - "NOTIFICATION_OPERATION_CODE": "NOTIFICATION", - "WORK_PROFILE_CODE": "WORK_PROFILE", - "CHANGE_LOCK_CODE_OPERATION_CODE": "CHANGE_LOCK_CODE", - "LOCK_OPERATION_CODE": "DEVICE_LOCK", - "UPGRADE_FIRMWARE": "UPGRADE_FIRMWARE", - "DISALLOW_ADJUST_VOLUME": "DISALLOW_ADJUST_VOLUME", - "DISALLOW_CONFIG_BLUETOOTH": "DISALLOW_CONFIG_BLUETOOTH", - "DISALLOW_CONFIG_CELL_BROADCASTS": "DISALLOW_CONFIG_CELL_BROADCASTS", - "DISALLOW_CONFIG_CREDENTIALS": "DISALLOW_CONFIG_CREDENTIALS", - "DISALLOW_CONFIG_MOBILE_NETWORKS": "DISALLOW_CONFIG_MOBILE_NETWORKS", - "DISALLOW_CONFIG_TETHERING": "DISALLOW_CONFIG_TETHERING", - "DISALLOW_CONFIG_VPN": "DISALLOW_CONFIG_VPN", - "DISALLOW_CONFIG_WIFI": "DISALLOW_CONFIG_WIFI", - "DISALLOW_APPS_CONTROL": "DISALLOW_APPS_CONTROL", - "DISALLOW_CREATE_WINDOWS": "DISALLOW_CREATE_WINDOWS", - "DISALLOW_CROSS_PROFILE_COPY_PASTE": "DISALLOW_CROSS_PROFILE_COPY_PASTE", - "DISALLOW_DEBUGGING_FEATURES": "DISALLOW_DEBUGGING_FEATURES", - "DISALLOW_FACTORY_RESET": "DISALLOW_FACTORY_RESET", - "DISALLOW_ADD_USER": "DISALLOW_ADD_USER", - "DISALLOW_INSTALL_APPS": "DISALLOW_INSTALL_APPS", - "DISALLOW_INSTALL_UNKNOWN_SOURCES": "DISALLOW_INSTALL_UNKNOWN_SOURCES", - "DISALLOW_MODIFY_ACCOUNTS": "DISALLOW_MODIFY_ACCOUNTS", - "DISALLOW_MOUNT_PHYSICAL_MEDIA": "DISALLOW_MOUNT_PHYSICAL_MEDIA", - "DISALLOW_NETWORK_RESET": "DISALLOW_NETWORK_RESET", - "DISALLOW_OUTGOING_BEAM": "DISALLOW_OUTGOING_BEAM", - "DISALLOW_OUTGOING_CALLS": "DISALLOW_OUTGOING_CALLS", - "DISALLOW_REMOVE_USER": "DISALLOW_REMOVE_USER", - "DISALLOW_SAFE_BOOT": "DISALLOW_SAFE_BOOT", - "DISALLOW_SHARE_LOCATION": "DISALLOW_SHARE_LOCATION", - "DISALLOW_SMS": "DISALLOW_SMS", - "DISALLOW_UNINSTALL_APPS": "DISALLOW_UNINSTALL_APPS", - "DISALLOW_UNMUTE_MICROPHONE": "DISALLOW_UNMUTE_MICROPHONE", - "DISALLOW_USB_FILE_TRANSFER": "DISALLOW_USB_FILE_TRANSFER", - "ALLOW_PARENT_PROFILE_APP_LINKING": "ALLOW_PARENT_PROFILE_APP_LINKING", - "ENSURE_VERIFY_APPS": "ENSURE_VERIFY_APPS", - "AUTO_TIME": "AUTO_TIME", - "SET_SCREEN_CAPTURE_DISABLED": "SET_SCREEN_CAPTURE_DISABLED", - "SET_STATUS_BAR_DISABLED": "SET_STATUS_BAR_DISABLED", - "APPLICATION_OPERATION_CODE": "APP-RESTRICTION", - "SYSTEM_UPDATE_POLICY_CODE": "SYSTEM_UPDATE_POLICY", - "KIOSK_APPS_CODE": "KIOSK_APPS" - }; - // Constants to define Windows Operation Constants var windowsOperationConstants = { "PASSCODE_POLICY_OPERATION_CODE": "PASSCODE_POLICY", @@ -94,1036 +36,6 @@ var operationModule = function () { "CHANGE_LOCK_CODE_OPERATION_CODE": "CHANGE_LOCK_CODE" }; - // Constants to define iOS Operation Constants - var iosOperationConstants = { - "PASSCODE_POLICY_OPERATION_CODE": "PASSCODE_POLICY", - "RESTRICTIONS_OPERATION_CODE": "RESTRICTION", - "VPN_OPERATION_CODE": "VPN", - "WIFI_OPERATION_CODE": "WIFI", - "EMAIL_OPERATION_CODE": "EMAIL", - "AIRPLAY_OPERATION_CODE": "AIR_PLAY", - "LDAP_OPERATION_CODE": "LDAP", - "DOMAIN_OPERATION_CODE": "DOMAIN", - "CALENDAR_OPERATION_CODE": "CALDAV", - "NOTIFICATION_OPERATION_CODE": "NOTIFICATION", - "CALENDAR_SUBSCRIPTION_OPERATION_CODE": "CALENDAR_SUBSCRIPTION", - "APN_OPERATION_CODE": "APN", - "CELLULAR_OPERATION_CODE": "CELLULAR", - "PER_APP_VPN_OPERATION_CODE": "PER_APP_VPN", - "APP_TO_PER_APP_VPN_MAPPING_OPERATION_CODE": "APP_TO_PER_APP_VPN_MAPPING" - }; - - publicMethods.getIOSServiceEndpoint = function (operationCode) { - var featureMap = { - "DEVICE_LOCK": "lock", - "LOCATION": "location", - "ENTERPRISE_WIPE": "enterprise-wipe", - "NOTIFICATION": "notification", - "RING": "ring" - }; - return "/api/device-mgt/ios/v1.0/admin/devices/" + featureMap[operationCode]; - }; - - /** - * Convert the ios platform specific code to the generic payload. - * TODO: think of the possibility to follow a pattern to the key name (namespace?) - * @param operationCode - * @param operationPayload - * @returns {{}} - */ - privateMethods.generateGenericPayloadFromIOSPayload = function (operationCode, operationPayload) { - var payload = {}; - operationPayload = JSON.parse(operationPayload); - switch (operationCode) { - case iosOperationConstants["PASSCODE_POLICY_OPERATION_CODE"]: - payload = { - "passcodePolicyForcePIN": operationPayload["forcePIN"], - "passcodePolicyAllowSimple": operationPayload["allowSimple"], - "passcodePolicyRequireAlphanumeric": operationPayload["requireAlphanumeric"], - "passcodePolicyMinLength": operationPayload["minLength"], - "passcodePolicyMinComplexChars": operationPayload["minComplexChars"], - "passcodePolicyMaxPasscodeAgeInDays": operationPayload["maxPINAgeInDays"], - "passcodePolicyPasscodeHistory": operationPayload["pinHistory"], - "passcodePolicyMaxAutoLock": operationPayload["maxInactivity"], - "passcodePolicyGracePeriod": operationPayload["maxGracePeriod"], - "passcodePolicyMaxFailedAttempts": operationPayload["maxFailedAttempts"] - }; - break; - case iosOperationConstants["DOMAIN_OPERATION_CODE"]: - payload = { - "emailDomains": operationPayload["emailDomains"], - "webDomains": operationPayload["webDomains"] - }; - break; - case iosOperationConstants["RESTRICTIONS_OPERATION_CODE"]: - payload = { - "restrictionsAllowAccountModification": operationPayload["allowAccountModification"], - "restrictionsAllowAddingGameCenterFriends": operationPayload["allowAddingGameCenterFriends"], - "restrictionsAllowAirDrop": operationPayload["allowAirDrop"], - "restrictionsAllowAppCellularDataModification": operationPayload["allowAppCellularDataModification"], - "restrictionsAllowAppInstallation": operationPayload["allowAppInstallation"], - "restrictionsAllowAppRemoval": operationPayload["allowAppRemoval"], - "restrictionsAllowAssistant": operationPayload["allowAssistant"], - "restrictionsAllowAssistantUserGeneratedContent": operationPayload["allowAssistantUserGeneratedContent"], - "restrictionsAllowAssistantWhileLocked": operationPayload["allowAssistantWhileLocked"], - "restrictionsAllowBookstore": operationPayload["allowBookstore"], - "restrictionsAllowBookstoreErotica": operationPayload["allowBookstoreErotica"], - "restrictionsAllowCamera": operationPayload["allowCamera"], - "restrictionsAllowChat": operationPayload["allowChat"], - "restrictionsAllowCloudBackup": operationPayload["allowCloudBackup"], - "restrictionsAllowCloudDocumentSync": operationPayload["allowCloudDocumentSync"], - "restrictionsAllowCloudKeychainSync": operationPayload["allowCloudKeychainSync"], - "restrictionsAllowDiagnosticSubmission": operationPayload["allowDiagnosticSubmission"], - "restrictionsAllowExplicitContent": operationPayload["allowExplicitContent"], - "restrictionsAllowFindMyFriendsModification": operationPayload["allowFindMyFriendsModification"], - "restrictionsAllowFingerprintForUnlock": operationPayload["allowFingerprintForUnlock"], - "restrictionsAllowGameCenter": operationPayload["allowGameCenter"], - "restrictionsAllowGlobalBackgroundFetchWhenRoaming": operationPayload["allowGlobalBackgroundFetchWhenRoaming"], - "restrictionsAllowInAppPurchases": operationPayload["allowInAppPurchases"], - "restrictionsAllowLockScreenControlCenter": operationPayload["allowLockScreenControlCenter"], - "restrictionsAllowHostPairing": operationPayload["allowHostPairing"], - "restrictionsAllowLockScreenNotificationsView": operationPayload["allowLockScreenNotificationsView"], - "restrictionsAllowLockScreenTodayView": operationPayload["allowLockScreenTodayView"], - "restrictionsAllowMultiplayerGaming": operationPayload["allowMultiplayerGaming"], - "restrictionsAllowOpenFromManagedToUnmanaged": operationPayload["allowOpenFromManagedToUnmanaged"], - "restrictionsAllowOpenFromUnmanagedToManaged": operationPayload["allowOpenFromUnmanagedToManaged"], - "restrictionsAllowOTAPKIUpdates": operationPayload["allowOTAPKIUpdates"], - "restrictionsAllowPassbookWhileLocked": operationPayload["allowPassbookWhileLocked"], - "restrictionsAllowPhotoStream": operationPayload["allowPhotoStream"], - "restrictionsAllowSafari": operationPayload["allowSafari"], - "restrictionsSafariAllowAutoFill": operationPayload["safariAllowAutoFill"], - "restrictionsSafariForceFraudWarning": operationPayload["safariForceFraudWarning"], - "restrictionsSafariAllowJavaScript": operationPayload["safariAllowJavaScript"], - "restrictionsSafariAllowPopups": operationPayload["safariAllowPopups"], - "restrictionsAllowScreenShot": operationPayload["allowScreenShot"], - "restrictionsAllowSharedStream": operationPayload["allowSharedStream"], - "restrictionsAllowUIConfigurationProfileInstallation": operationPayload["allowUIConfigurationProfileInstallation"], - "restrictionsAllowUntrustedTLSPrompt": operationPayload["allowUntrustedTLSPrompt"], - "restrictionsAllowVideoConferencing": operationPayload["allowVideoConferencing"], - "restrictionsAllowVoiceDialing": operationPayload["allowVoiceDialing"], - "restrictionsAllowYouTube": operationPayload["allowYouTube"], - "restrictionsAllowITunes": operationPayload["allowiTunes"], - "restrictionsForceAssistantProfanityFilter": operationPayload["forceAssistantProfanityFilter"], - "restrictionsForceEncryptedBackup": operationPayload["forceEncryptedBackup"], - "restrictionsForceITunesStorePasswordEntry": operationPayload["forceITunesStorePasswordEntry"], - "restrictionsForceLimitAdTracking": operationPayload["forceLimitAdTracking"], - "restrictionsForceAirPlayOutgoingRequestsPairingPassword": operationPayload["forceAirPlayOutgoingRequestsPairingPassword"], - "restrictionsForceAirPlayIncomingRequestsPairingPassword": operationPayload["forceAirPlayIncomingRequestsPairingPassword"], - "restrictionsAllowManagedAppsCloudSync": operationPayload["allowManagedAppsCloudSync"], - "restrictionsAllowEraseContentAndSettings": operationPayload["allowEraseContentAndSettings"], - "restrictionsAllowSpotlightInternetResults": operationPayload["allowSpotlightInternetResults"], - "restrictionsAllowEnablingRestrictions": operationPayload["allowEnablingRestrictions"], - "restrictionsAllowActivityContinuation": operationPayload["allowActivityContinuation"], - "restrictionsAllowEnterpriseBookBackup": operationPayload["allowEnterpriseBookBackup"], - "restrictionsAllowEnterpriseBookMetadataSync": operationPayload["allowEnterpriseBookMetadataSync"], - "restrictionsAllowPodcasts": operationPayload["allowPodcasts"], - "restrictionsAllowDefinitionLookup": operationPayload["allowDefinitionLookup"], - "restrictionsAllowPredictiveKeyboard": operationPayload["allowPredictiveKeyboard"], - "restrictionsAllowAutoCorrection": operationPayload["allowAutoCorrection"], - "restrictionsAllowSpellCheck": operationPayload["allowSpellCheck"], - "restrictionsSafariAcceptCookies": operationPayload["safariAcceptCookies"], - "restrictionsAutonomousSingleAppModePermittedAppIDs": operationPayload["autonomousSingleAppModePermittedAppIDs"] - }; - break; - case iosOperationConstants["VPN_OPERATION_CODE"]: - var pptp = false; - var l2tp = false; - if (operationPayload["vpnType"] == "PPTP") { - pptp = true; - } else if (operationPayload["vpnType"] == "L2TP") { - l2tp = true; - } - - payload = { - "userDefinedName": operationPayload["userDefinedName"], - "overridePrimary": operationPayload["overridePrimary"], - "onDemandEnabled": operationPayload["onDemandEnabled"], - "onDemandMatchDomainsAlways": operationPayload["onDemandMatchDomainsAlways"], - "onDemandMatchDomainsNever": operationPayload["onDemandMatchDomainsNever"], - "onDemandMatchDomainsOnRetry": operationPayload["onDemandMatchDomainsOnRetry"], - "onDemandRules": operationPayload["onDemandRules"], - "vendorConfigs": operationPayload["vendorConfigs"], - "vpnType": operationPayload["vpnType"], - "pptpAuthName": pptp ? operationPayload.ppp["authName"] : "", - "pptpTokenCard": pptp ? operationPayload.ppp["tokenCard"] : "", - "pptpAuthPassword": pptp ? operationPayload.ppp["authPassword"] : "", - "pptpCommRemoteAddress": pptp ? operationPayload.ppp["commRemoteAddress"] : "", - "pptpRSASecureID": pptp ? operationPayload.ppp["RSASecureID"] : "", - "pptpCCPEnabled": pptp ? operationPayload.ppp["CCPEnabled"] : "", - "pptpCCPMPPE40Enabled": pptp ? operationPayload.ppp["CCPMPPE40Enabled"] : "", - "pptpCCPMPPE128Enabled": pptp ? operationPayload.ppp["CCPMPPE128Enabled"] : "", - "l2tpAuthName": l2tp ? operationPayload.ppp["authName"] : "", - "l2tpTokenCard": l2tp ? operationPayload.ppp["tokenCard"] : "", - "l2tpAuthPassword": l2tp ? operationPayload.ppp["authPassword"] : "", - "l2tpCommRemoteAddress": l2tp ? operationPayload.ppp["commRemoteAddress"] : "", - "l2tpRSASecureID": l2tp ? operationPayload.ppp["RSASecureID"] : "", - "ipsecRemoteAddress": operationPayload.ipSec["remoteAddress"], - "ipsecAuthenticationMethod": operationPayload.ipSec["authenticationMethod"], - "ipsecLocalIdentifier": operationPayload.ipSec["localIdentifier"], - "ipsecSharedSecret": operationPayload.ipSec["sharedSecret"], - "ipsecPayloadCertificateUUID": operationPayload.ipSec["payloadCertificateUUID"], - "ipsecXAuthEnabled": operationPayload.ipSec["XAuthEnabled"], - "ipsecXAuthName": operationPayload.ipSec["XAuthName"], - "ipsecPromptForVPNPIN": operationPayload.ipSec["promptForVPNPIN"], - "ikev2RemoteAddress": operationPayload.ikEv2["remoteAddress"], - "ikev2LocalIdentifier": operationPayload.ikEv2["localIdentifier"], - "ikev2RemoteIdentifier": operationPayload.ikEv2["remoteIdentifier"], - "ikev2AuthenticationMethod": operationPayload.ikEv2["authenticationMethod"], - "ikev2SharedSecret": operationPayload.ikEv2["sharedSecret"], - "ikev2PayloadCertificateUUID": operationPayload.ikEv2["payloadCertificateUUID"], - "ikev2ExtendedAuthEnabled": operationPayload.ikEv2["extendedAuthEnabled"], - "ikev2AuthName": operationPayload.ikEv2["authName"], - "ikev2AuthPassword": operationPayload.ikEv2["authPassword"], - "ikev2DeadPeerDetectionInterval": operationPayload.ikEv2["deadPeerDetectionInterval"], - "ikev2ServerCertificateIssuerCommonName": operationPayload.ikEv2["serverCertificateIssuerCommonName"], - "ikev2ServerCertificateCommonName": operationPayload.ikEv2["serverCertificateCommonName"] - }; - break; - case iosOperationConstants["PER_APP_VPN_OPERATION_CODE"]: - payload = { - "operation": { - "VPNUUID": operationPayload["PER-APP-VPNUUID"], - "safariDomains": operationPayload["safariDomains"], - "onDemandMatchAppEnabled": operationPayload["onDemandMatchAppEnabled"] - } - }; - break; - case iosOperationConstants["APP_TO_PER_APP_VPN_MAPPING_OPERATION_CODE"]: - payload = { - "operation": { - "appLayerVPNMappings": operationPayload["appLayerVPNMappings"] - } - }; - break; - case iosOperationConstants["WIFI_OPERATION_CODE"]: - payload = { - "wifiHiddenNetwork": operationPayload["hiddenNetwork"], - "wifiSSID": operationPayload["SSID"], - "wifiAutoJoin": operationPayload["autoJoin"], - "wifiProxyType": operationPayload["proxyType"], - "wifiEncryptionType": operationPayload["encryptionType"], - "wifiIsHotSpot": operationPayload["hotspot"], - "wifiDomainName": operationPayload["domainName"], - "wifiServiceProviderRoamingEnabled": operationPayload["serviceProviderRoamingEnabled"], - "wifiDisplayedOperatorName": operationPayload["displayedOperatorName"], - "wifiRoamingConsortiumOIs": operationPayload["roamingConsortiumOIs"], - "wifiPassword": operationPayload["password"], - "wifiPayloadCertUUID": operationPayload["payloadCertificateUUID"], - "wifiProxyServer": operationPayload["proxyServer"], - "wifiProxyPort": operationPayload["proxyPort"], - "wifiProxyUsername": operationPayload["proxyUsername"], - "wifiProxyPassword": operationPayload["proxyPassword"], - "wifiProxyPACURL": operationPayload["proxyPACURL"], - "wifiProxyPACFallbackAllowed": operationPayload["proxyPACFallbackAllowed"], - "wifiNAIRealmNames": operationPayload["nairealmNames"], - "wifiMCCAndMNCs": operationPayload["mccandMNCs"], - "wifiEAPUsername": operationPayload.clientConfiguration["username"], - "wifiAcceptedEAPTypes": operationPayload.clientConfiguration["acceptEAPTypes"], - "wifiEAPPassword": operationPayload.clientConfiguration["userPassword"], - "wifiEAPOneTimePassword": operationPayload.clientConfiguration["oneTimePassword"], - "wifiPayloadCertificateAnchorUUIDs": operationPayload.clientConfiguration["payloadCertificateAnchorUUID"], - "wifiEAPOuterIdentity": operationPayload.clientConfiguration["outerIdentity"], - "wifiTLSTrustedServerNames": operationPayload.clientConfiguration["tlstrustedServerNames"], - "wifiEAPTLSAllowTrustExceptions": operationPayload.clientConfiguration["tlsallowTrustExceptions"], - "wifiEAPTLSCertIsRequired": operationPayload.clientConfiguration["tlscertificateIsRequired"], - "wifiEAPTLSInnerAuthType": operationPayload.clientConfiguration["ttlsinnerAuthentication"], - "wifiEAPFastUsePAC": operationPayload.clientConfiguration["eapfastusePAC"], - "wifiEAPFastProvisionPAC": operationPayload.clientConfiguration["eapfastprovisionPAC"], - "wifiEAPFastProvisionPACAnonymously": operationPayload.clientConfiguration["eapfastprovisionPACAnonymously"], - "wifiEAPSIMNoOfRands": operationPayload.clientConfiguration["eapsimnumberOfRANDs"] - }; - break; - case iosOperationConstants["EMAIL_OPERATION_CODE"]: - payload = { - "emailAccountDescription": operationPayload["emailAccountDescription"], - "emailAccountName": operationPayload["emailAccountName"], - "emailAccountType": operationPayload["emailAccountType"], - "emailAddress": operationPayload["emailAddress"], - "emailIncomingMailServerAuthentication": operationPayload["incomingMailServerAuthentication"], - "emailIncomingMailServerHostname": operationPayload["incomingMailServerHostName"], - "emailIncomingMailServerPort": operationPayload["incomingMailServerPortNumber"], - "emailIncomingUseSSL": operationPayload["incomingMailServerUseSSL"], - "emailIncomingMailServerUsername": operationPayload["incomingMailServerUsername"], - "emailIncomingMailServerPassword": operationPayload["incomingPassword"], - "emailOutgoingMailServerPassword": operationPayload["outgoingPassword"], - "emailOutgoingPasswordSameAsIncomingPassword": operationPayload["outgoingPasswordSameAsIncomingPassword"], - "emailOutgoingMailServerAuthentication": operationPayload["outgoingMailServerAuthentication"], - "emailOutgoingMailServerHostname": operationPayload["outgoingMailServerHostName"], - "emailOutgoingMailServerPort": operationPayload["outgoingMailServerPortNumber"], - "emailOutgoingUseSSL": operationPayload["outgoingMailServerUseSSL"], - "emailOutgoingMailServerUsername": operationPayload["outgoingMailServerUsername"], - "emailPreventMove": operationPayload["preventMove"], - "emailPreventAppSheet": operationPayload["preventAppSheet"], - "emailDisableMailRecentsSyncing": operationPayload["disableMailRecentsSyncing"], - "emailIncomingMailServerIMAPPathPrefix": operationPayload["incomingMailServerIMAPPathPrefix"], - "emailSMIMEEnabled": operationPayload["smimeenabled"], - "emailSMIMESigningCertificateUUID": operationPayload["smimesigningCertificateUUID"], - "emailSMIMEEncryptionCertificateUUID": operationPayload["smimeencryptionCertificateUUID"], - "emailSMIMEEnablePerMessageSwitch": operationPayload["smimeenablePerMessageSwitch"] - }; - break; - case iosOperationConstants["AIRPLAY_OPERATION_CODE"]: - payload = { - "airplayDestinations": operationPayload["airPlayDestinations"], - "airplayCredentials": operationPayload["airPlayCredentials"] - }; - break; - case iosOperationConstants["LDAP_OPERATION_CODE"]: - payload = { - "ldapAccountDescription": operationPayload["accountDescription"], - "ldapAccountHostname": operationPayload["accountHostName"], - "ldapUseSSL": operationPayload["accountUseSSL"], - "ldapAccountUsername": operationPayload["accountUsername"], - "ldapAccountPassword": operationPayload["accountPassword"], - "ldapSearchSettings": operationPayload["ldapSearchSettings"] - }; - break; - case iosOperationConstants["CALENDAR_OPERATION_CODE"]: - payload = { - "calendarAccountDescription": operationPayload["accountDescription"], - "calendarAccountHostname": operationPayload["hostName"], - "calendarAccountUsername": operationPayload["username"], - "calendarAccountPassword": operationPayload["password"], - "calendarUseSSL": operationPayload["useSSL"], - "calendarAccountPort": operationPayload["port"], - "calendarPrincipalURL": operationPayload["principalURL"] - }; - break; - case iosOperationConstants["CALENDAR_SUBSCRIPTION_OPERATION_CODE"]: - payload = { - "calendarSubscriptionDescription": operationPayload["accountDescription"], - "calendarSubscriptionHostname": operationPayload["hostName"], - "calendarSubscriptionUsername": operationPayload["username"], - "calendarSubscriptionPassword": operationPayload["password"], - "calendarSubscriptionUseSSL": operationPayload["useSSL"] - }; - break; - case iosOperationConstants["APN_OPERATION_CODE"]: - payload = { - "apnConfigurations": operationPayload["apnConfigurations"] - }; - break; - case iosOperationConstants["CELLULAR_OPERATION_CODE"]: - payload = { - "cellularAttachAPNName": operationPayload["attachAPNName"], - "cellularAuthenticationType": operationPayload["authenticationType"], - "cellularUsername": operationPayload["username"], - "cellularPassword": operationPayload["password"], - "cellularAPNConfigurations": operationPayload["apnConfigurations"] - }; - break; - } - return payload; - }; - - privateMethods.generateIOSOperationPayload = function (operationCode, operationData, deviceList) { - var payload; - var operationType; - switch (operationCode) { - case iosOperationConstants["PASSCODE_POLICY_OPERATION_CODE"]: - operationType = operationTypeConstants["PROFILE"]; - payload = { - "operation": { - "forcePIN": operationData["passcodePolicyForcePIN"], - "allowSimple": operationData["passcodePolicyAllowSimple"], - "requireAlphanumeric": operationData["passcodePolicyRequireAlphanumeric"], - "minLength": operationData["passcodePolicyMinLength"], - "minComplexChars": operationData["passcodePolicyMinComplexChars"], - "maxPINAgeInDays": operationData["passcodePolicyMaxPasscodeAgeInDays"], - "pinHistory": operationData["passcodePolicyPasscodeHistory"], - "maxInactivity": operationData["passcodePolicyMaxAutoLock"], - "maxGracePeriod": operationData["passcodePolicyGracePeriod"], - "maxFailedAttempts": operationData["passcodePolicyMaxFailedAttempts"] - } - }; - break; - case iosOperationConstants["WIFI_OPERATION_CODE"]: - operationType = operationTypeConstants["PROFILE"]; - if (operationData["wifiProxyPort"] == "") { - operationData["wifiProxyPort"] = -1; - } - payload = { - "operation": { - "SSID": operationData["wifiSSID"], - "hiddenNetwork": operationData["wifiHiddenNetwork"], - "autoJoin": operationData["wifiAutoJoin"], - "proxyType": operationData["wifiProxyType"], - "encryptionType": operationData["wifiEncryptionType"], - "hotspot": operationData["wifiIsHotSpot"], - "domainName": operationData["wifiDomainName"], - "serviceProviderRoamingEnabled": operationData["wifiServiceProviderRoamingEnabled"], - "displayedOperatorName": operationData["wifiDisplayedOperatorName"], - "roamingConsortiumOIs": operationData["wifiRoamingConsortiumOIs"], - "password": operationData["wifiPassword"], - "clientConfiguration": { - "username": operationData["wifiEAPUsername"], - "acceptEAPTypes": operationData["wifiAcceptedEAPTypes"], - "userPassword": operationData["wifiEAPPassword"], - "oneTimePassword": operationData["wifiEAPOneTimePassword"], - "payloadCertificateAnchorUUID": operationData["wifiPayloadCertificateAnchorUUIDs"], - "outerIdentity": operationData["wifiEAPOuterIdentity"], - "tlstrustedServerNames": operationData["wifiTLSTrustedServerNames"], - "tlsallowTrustExceptions": operationData["wifiEAPTLSAllowTrustExceptions"], - "tlscertificateIsRequired": operationData["wifiEAPTLSCertIsRequired"], - "ttlsinnerAuthentication": operationData["wifiEAPTLSInnerAuthType"], - "eapfastusePAC": operationData["wifiEAPFastUsePAC"], - "eapfastprovisionPAC": operationData["wifiEAPFastProvisionPAC"], - "eapfastprovisionPACAnonymously": operationData["wifiEAPFastProvisionPACAnonymously"], - "eapsimnumberOfRANDs": operationData["wifiEAPSIMNoOfRands"] - }, - "payloadCertificateUUID": operationData["wifiPayloadCertUUID"], - "proxyServer": operationData["wifiProxyServer"], - "proxyPort": operationData["wifiProxyPort"], - "proxyUsername": operationData["wifiProxyUsername"], - "proxyPassword": operationData["wifiProxyPassword"], - "proxyPACURL": operationData["wifiProxyPACURL"], - "proxyPACFallbackAllowed": operationData["wifiProxyPACFallbackAllowed"], - "nairealmNames": operationData["wifiNAIRealmNames"], - "mccandMNCs": operationData["wifiMCCAndMNCs"] - } - }; - break; - case iosOperationConstants["VPN_OPERATION_CODE"]: - operationType = operationTypeConstants["PROFILE"]; - var ppp = {}; - var ipSec = {}; - var ikev2 = {}; - var pulseSecure = {}; - - if (operationData["vpnType"] == "PPTP") { - ppp = { - "authName": operationData["pptpAuthName"], - "tokenCard": operationData["pptpTokenCard"], - "authPassword": operationData["pptpAuthPassword"], - "commRemoteAddress": operationData["pptpCommRemoteAddress"], - "RSASecureID": operationData["pptpRSASecureID"], - "CCPEnabled": operationData["pptpCCPEnabled"], - "CCPMPPE40Enabled": operationData["pptpCCPMPPE40Enabled"], - "CCPMPPE128Enabled": operationData["pptpCCPMPPE128Enabled"] - }; - } else if (operationData["vpnType"] == "L2TP") { - ppp = { - "authName": operationData["l2tpAuthName"], - "tokenCard": operationData["l2tpTokenCard"], - "authPassword": operationData["l2tpAuthPassword"], - "commRemoteAddress": operationData["l2tpCommRemoteAddress"], - "RSASecureID": operationData["l2tpRSASecureID"] - }; - } else if (operationData["vpnType"] == "IPSec") { - ipSec = { - "remoteAddress": operationData["ipsecRemoteAddress"], - "authenticationMethod": operationData["ipsecAuthenticationMethod"], - "localIdentifier": operationData["ipsecLocalIdentifier"], - "sharedSecret": operationData["ipsecSharedSecret"], - "payloadCertificateUUID": operationData["ipsecPayloadCertificateUUID"], - "XAuthEnabled": operationData["ipsecXAuthEnabled"], - "XAuthName": operationData["ipsecXAuthName"], - "promptForVPNPIN": operationData["ipsecPromptForVPNPIN"] - }; - } else if (operationData["vpnType"] == "IKEv2") { - ikev2 = { - "remoteAddress": operationData["ikev2RemoteAddress"], - "localIdentifier": operationData["ikev2LocalIdentifier"], - "remoteIdentifier": operationData["ikev2RemoteIdentifier"], - "authenticationMethod": operationData["ikev2AuthenticationMethod"], - "sharedSecret": operationData["ikev2SharedSecret"], - "payloadCertificateUUID": operationData["ikev2PayloadCertificateUUID"], - "extendedAuthEnabled": operationData["ikev2ExtendedAuthEnabled"], - "authName": operationData["ikev2AuthName"], - "authPassword": operationData["ikev2AuthPassword"], - "deadPeerDetectionInterval": operationData["ikev2DeadPeerDetectionInterval"], - "serverCertificateIssuerCommonName": operationData["ikev2ServerCertificateIssuerCommonName"], - "serverCertificateCommonName": operationData["ikev2ServerCertificateCommonName"] - }; - } else if (operationData["vpnType"] == "PulseSecure") { - pulseSecure = { - "remoteAddress": operationData["pulsesecureRemoteAddress"], - "userName": operationData["pulsesecureName"], - "sharedSecret": operationData["pulsesecureSharedSecret"] - }; - } - - var domainsAlways = new Array(); - for (var i = 0; i < operationData["onDemandMatchDomainsAlways"].length; i++) { - domainsAlways.push(operationData["onDemandMatchDomainsAlways"][i].domain); - } - - var domainsNever = new Array(); - for (var i = 0; i < operationData["onDemandMatchDomainsNever"].length; i++) { - domainsNever.push(operationData["onDemandMatchDomainsNever"][i].domain); - } - - var domainsRetry = new Array(); - for (var i = 0; i < operationData["onDemandMatchDomainsOnRetry"].length; i++) { - domainsRetry.push(operationData["onDemandMatchDomainsOnRetry"][i].domain); - } - - payload = { - "operation": { - "userDefinedName": operationData["userDefinedName"], - "overridePrimary": operationData["overridePrimary"], - "onDemandEnabled": operationData["onDemandEnabled"], - "onDemandMatchDomainsAlways": domainsAlways, - "onDemandMatchDomainsNever": domainsNever, - "onDemandMatchDomainsOnRetry": domainsRetry, - "onDemandRules": operationData["onDemandRules"], - "vendorConfigs": operationData["vendorConfigs"], - "vpnType": operationData["vpnType"], - "ppp": ppp, - "ipSec": ipSec, - "ikEv2": ikev2, - "pulseSecure": pulseSecure - } - }; - break; - case iosOperationConstants["PER_APP_VPN_OPERATION_CODE"]: - operationType = operationTypeConstants["PROFILE"]; - var domains = new Array(); - for (var i = 0; i < operationData["safariDomains"].length; i++) { - domains.push(operationData["safariDomains"][i].domain); - } - payload = { - "operation": { - "VPNUUID": operationData["VPNUUID"], - "safariDomains": domains, - "onDemandMatchAppEnabled": operationData["onDemandMatchAppEnabled"] - } - }; - break; - case iosOperationConstants["APP_TO_PER_APP_VPN_MAPPING_OPERATION_CODE"]: - operationType = operationTypeConstants["PROFILE"]; - payload = { - "operation": { - "appLayerVPNMappings": operationData["appLayerVPNMappings"] - } - }; - break; - case iosOperationConstants["RESTRICTIONS_OPERATION_CODE"]: - operationType = operationTypeConstants["PROFILE"]; - payload = { - "operation": { - "allowAccountModification": operationData["restrictionsAllowAccountModification"], - "allowAddingGameCenterFriends": operationData["restrictionsAllowAddingGameCenterFriends"], - "allowAirDrop": operationData["restrictionsAllowAirDrop"], - "allowAppCellularDataModification": operationData["restrictionsAllowAppCellularDataModification"], - "allowAppInstallation": operationData["restrictionsAllowAppInstallation"], - "allowAppRemoval": operationData["restrictionsAllowAppRemoval"], - "allowAssistant": operationData["restrictionsAllowAssistant"], - "allowAssistantUserGeneratedContent": operationData["restrictionsAllowAssistantUserGeneratedContent"], - "allowAssistantWhileLocked": operationData["restrictionsAllowAssistantWhileLocked"], - "allowBookstore": operationData["restrictionsAllowBookstore"], - "allowBookstoreErotica": operationData["restrictionsAllowBookstoreErotica"], - "allowCamera": operationData["restrictionsAllowCamera"], - "allowChat": operationData["restrictionsAllowChat"], - "allowCloudBackup": operationData["restrictionsAllowCloudBackup"], - "allowCloudDocumentSync": operationData["restrictionsAllowCloudDocumentSync"], - "allowCloudKeychainSync": operationData["restrictionsAllowCloudKeychainSync"], - "allowDiagnosticSubmission": operationData["restrictionsAllowDiagnosticSubmission"], - "allowExplicitContent": operationData["restrictionsAllowExplicitContent"], - "allowFindMyFriendsModification": operationData["restrictionsAllowFindMyFriendsModification"], - "allowFingerprintForUnlock": operationData["restrictionsAllowFingerprintForUnlock"], - "allowGameCenter": operationData["restrictionsAllowGameCenter"], - "allowGlobalBackgroundFetchWhenRoaming": operationData["restrictionsAllowGlobalBackgroundFetchWhenRoaming"], - "allowInAppPurchases": operationData["restrictionsAllowInAppPurchases"], - "allowLockScreenControlCenter": operationData["restrictionsAllowLockScreenControlCenter"], - "allowHostPairing": operationData["restrictionsAllowHostPairing"], - "allowLockScreenNotificationsView": operationData["restrictionsAllowLockScreenNotificationsView"], - "allowLockScreenTodayView": operationData["restrictionsAllowLockScreenTodayView"], - "allowMultiplayerGaming": operationData["restrictionsAllowMultiplayerGaming"], - "allowOpenFromManagedToUnmanaged": operationData["restrictionsAllowOpenFromManagedToUnmanaged"], - "allowOpenFromUnmanagedToManaged": operationData["restrictionsAllowOpenFromUnmanagedToManaged"], - "allowOTAPKIUpdates": operationData["restrictionsAllowOTAPKIUpdates"], - "allowPassbookWhileLocked": operationData["restrictionsAllowPassbookWhileLocked"], - "allowPhotoStream": operationData["restrictionsAllowPhotoStream"], - "allowSafari": operationData["restrictionsAllowSafari"], - "safariAllowAutoFill": operationData["restrictionsSafariAllowAutoFill"], - "safariForceFraudWarning": operationData["restrictionsSafariForceFraudWarning"], - "safariAllowJavaScript": operationData["restrictionsSafariAllowJavaScript"], - "safariAllowPopups": operationData["restrictionsSafariAllowPopups"], - "allowScreenShot": operationData["restrictionsAllowScreenShot"], - "allowSharedStream": operationData["restrictionsAllowSharedStream"], - "allowUIConfigurationProfileInstallation": operationData["restrictionsAllowUIConfigurationProfileInstallation"], - "allowUntrustedTLSPrompt": operationData["restrictionsAllowUntrustedTLSPrompt"], - "allowVideoConferencing": operationData["restrictionsAllowVideoConferencing"], - "allowVoiceDialing": operationData["restrictionsAllowVoiceDialing"], - "allowYouTube": operationData["restrictionsAllowYouTube"], - "allowiTunes": operationData["restrictionsAllowITunes"], - "forceAssistantProfanityFilter": operationData["restrictionsForceAssistantProfanityFilter"], - "forceEncryptedBackup": operationData["restrictionsForceEncryptedBackup"], - "forceITunesStorePasswordEntry": operationData["restrictionsForceITunesStorePasswordEntry"], - "forceLimitAdTracking": operationData["restrictionsForceLimitAdTracking"], - "forceAirPlayOutgoingRequestsPairingPassword": operationData["restrictionsForceAirPlayOutgoingRequestsPairingPassword"], - "forceAirPlayIncomingRequestsPairingPassword": operationData["restrictionsForceAirPlayIncomingRequestsPairingPassword"], - "allowManagedAppsCloudSync": operationData["restrictionsAllowManagedAppsCloudSync"], - "allowEraseContentAndSettings": operationData["restrictionsAllowEraseContentAndSettings"], - "allowSpotlightInternetResults": operationData["restrictionsAllowSpotlightInternetResults"], - "allowEnablingRestrictions": operationData["restrictionsAllowEnablingRestrictions"], - "allowActivityContinuation": operationData["restrictionsAllowActivityContinuation"], - "allowEnterpriseBookBackup": operationData["restrictionsAllowEnterpriseBookBackup"], - "allowEnterpriseBookMetadataSync": operationData["restrictionsAllowEnterpriseBookMetadataSync"], - "allowPodcasts": operationData["restrictionsAllowPodcasts"], - "allowDefinitionLookup": operationData["restrictionsAllowDefinitionLookup"], - "allowPredictiveKeyboard": operationData["restrictionsAllowPredictiveKeyboard"], - "allowAutoCorrection": operationData["restrictionsAllowAutoCorrection"], - "allowSpellCheck": operationData["restrictionsAllowSpellCheck"], - "safariAcceptCookies": operationData["restrictionsSafariAcceptCookies"], - "autonomousSingleAppModePermittedAppIDs": operationData["restrictionsAutonomousSingleAppModePermittedAppIDs"] - } - }; - break; - case iosOperationConstants["EMAIL_OPERATION_CODE"]: - operationType = operationTypeConstants["PROFILE"]; - payload = { - "operation": { - "emailAccountDescription": operationData["emailAccountDescription"], - "emailAccountName": operationData["emailAccountName"], - "emailAccountType": operationData["emailAccountType"], - "emailAddress": operationData["emailAddress"], - "incomingMailServerAuthentication": operationData["emailIncomingMailServerAuthentication"], - "incomingMailServerHostName": operationData["emailIncomingMailServerHostname"], - "incomingMailServerPortNumber": operationData["emailIncomingMailServerPort"], - "incomingMailServerUseSSL": operationData["emailIncomingUseSSL"], - "incomingMailServerUsername": operationData["emailIncomingMailServerUsername"], - "incomingPassword": operationData["emailIncomingMailServerPassword"], - "outgoingPassword": operationData["emailOutgoingMailServerPassword"], - "outgoingPasswordSameAsIncomingPassword": operationData["emailOutgoingPasswordSameAsIncomingPassword"], - "outgoingMailServerAuthentication": operationData["emailOutgoingMailServerAuthentication"], - "outgoingMailServerHostName": operationData["emailOutgoingMailServerHostname"], - "outgoingMailServerPortNumber": operationData["emailOutgoingMailServerPort"], - "outgoingMailServerUseSSL": operationData["emailOutgoingUseSSL"], - "outgoingMailServerUsername": operationData["emailOutgoingMailServerUsername"], - "preventMove": operationData["emailPreventMove"], - "preventAppSheet": operationData["emailPreventAppSheet"], - "disableMailRecentsSyncing": operationData["emailDisableMailRecentsSyncing"], - "incomingMailServerIMAPPathPrefix": operationData["emailIncomingMailServerIMAPPathPrefix"], - "smimeenabled": operationData["emailSMIMEEnabled"], - "smimesigningCertificateUUID": operationData["emailSMIMESigningCertificateUUID"], - "smimeencryptionCertificateUUID": operationData["emailSMIMEEncryptionCertificateUUID"], - "smimeenablePerMessageSwitch": operationData["emailSMIMEEnablePerMessageSwitch"] - } - }; - break; - case iosOperationConstants["AIRPLAY_OPERATION_CODE"]: - operationType = operationTypeConstants["PROFILE"]; - payload = { - "operation": { - "airPlayDestinations": operationData["airplayDestinations"], - "airPlayCredentials": operationData["airplayCredentials"] - } - }; - break; - case iosOperationConstants["LDAP_OPERATION_CODE"]: - operationType = operationTypeConstants["PROFILE"]; - payload = { - "operation": { - "accountDescription": operationData["ldapAccountDescription"], - "accountHostName": operationData["ldapAccountHostname"], - "accountUseSSL": operationData["ldapUseSSL"], - "accountUsername": operationData["ldapAccountUsername"], - "accountPassword": operationData["ldapAccountPassword"], - "ldapSearchSettings": operationData["ldapSearchSettings"] - } - }; - break; - case iosOperationConstants["CALENDAR_OPERATION_CODE"]: - operationType = operationTypeConstants["PROFILE"]; - payload = { - "operation": { - "accountDescription": operationData["calendarAccountDescription"], - "hostName": operationData["calendarAccountHostname"], - "username": operationData["calendarAccountUsername"], - "password": operationData["calendarAccountPassword"], - "useSSL": operationData["calendarUseSSL"], - "port": operationData["calendarAccountPort"], - "principalURL": operationData["calendarPrincipalURL"] - } - }; - break; - case iosOperationConstants["CALENDAR_SUBSCRIPTION_OPERATION_CODE"]: - operationType = operationTypeConstants["PROFILE"]; - payload = { - "operation": { - "accountDescription": operationData["calendarSubscriptionDescription"], - "hostName": operationData["calendarSubscriptionHostname"], - "username": operationData["calendarSubscriptionUsername"], - "password": operationData["calendarSubscriptionPassword"], - "useSSL": operationData["calendarSubscriptionUseSSL"] - } - }; - break; - case iosOperationConstants["APN_OPERATION_CODE"]: - operationType = operationTypeConstants["PROFILE"]; - payload = { - "operation": { - "apnConfigurations": operationData["apnConfigurations"] - } - }; - break; - case iosOperationConstants["DOMAIN_OPERATION_CODE"]: - operationType = operationTypeConstants["PROFILE"]; - payload = { - "operation": { - "emailDomains": operationData["emailDomains"], - "webDomains": operationData["webDomains"] - } - }; - break; - case - iosOperationConstants["CELLULAR_OPERATION_CODE"] - : - operationType = operationTypeConstants["PROFILE"]; - payload = { - "operation": { - "attachAPNName": operationData["cellularAttachAPNName"], - "authenticationType": operationData["cellularAuthenticationType"], - "username": operationData["cellularUsername"], - "password": operationData["cellularPassword"], - "apnConfigurations": operationData["cellularAPNConfigurations"] - } - }; - break; - case - iosOperationConstants["NOTIFICATION_OPERATION_CODE"] - : - operationType = operationTypeConstants["PROFILE"]; - payload = { - "operation": { - "messageTitle": operationData["messageTitle"], - "messageText": operationData["messageText"] - } - }; - break; - default: - // If the operation is neither of above, it is a command operation - operationType = operationTypeConstants["COMMAND"]; - // Operation payload of a command operation is simply an array of device IDs - payload = deviceList; - } - - if (operationType == operationTypeConstants["PROFILE"] && deviceList) { - payload["deviceIDs"] = deviceList; - } - return payload; - } - ; - - /** - * Convert the android platform specific code to the generic payload. - * TODO: think of the possibility to follow a pattern to the key name (namespace?) - * @param operationCode - * @param operationPayload - * @returns {{}} - */ - privateMethods.generateGenericPayloadFromAndroidPayload = function (operationCode, operationPayload) { - var payload = {}; - operationPayload = JSON.parse(operationPayload); - switch (operationCode) { - case androidOperationConstants["PASSCODE_POLICY_OPERATION_CODE"]: - payload = { - "passcodePolicyAllowSimple": operationPayload["allowSimple"], - "passcodePolicyRequireAlphanumeric": operationPayload["requireAlphanumeric"], - "passcodePolicyMinLength": operationPayload["minLength"], - "passcodePolicyMinComplexChars": operationPayload["minComplexChars"], - "passcodePolicyMaxPasscodeAgeInDays": operationPayload["maxPINAgeInDays"], - "passcodePolicyPasscodeHistory": operationPayload["pinHistory"], - "passcodePolicyMaxFailedAttempts": operationPayload["maxFailedAttempts"] - }; - break; - case androidOperationConstants["CAMERA_OPERATION_CODE"]: - payload = operationPayload; - break; - case androidOperationConstants["ENCRYPT_STORAGE_OPERATION_CODE"]: - payload = { - "encryptStorageEnabled": operationPayload["encrypted"] - }; - break; - case androidOperationConstants["WORK_PROFILE_CODE"]: - payload = { - "workProfilePolicyProfileName": operationPayload["profileName"], - "workProfilePolicyEnableSystemApps": operationPayload["enableSystemApps"], - "workProfilePolicyHideSystemApps": operationPayload["hideSystemApps"], - "workProfilePolicyUnhideSystemApps": operationPayload["unhideSystemApps"], - "workProfilePolicyEnablePlaystoreApps": operationPayload["enablePlaystoreApps"] - }; - break; - case androidOperationConstants["WIFI_OPERATION_CODE"]: - payload = { - "wifiSSID": operationPayload["ssid"], - "wifiPassword": operationPayload["password"], - "wifiType": operationPayload["type"], - "wifiEAP": operationPayload["eap"], - "wifiPhase2": operationPayload["phase2"], - "wifiProvisioning": operationPayload["provisioning"], - "wifiIdentity": operationPayload["identity"], - "wifiAnoIdentity": operationPayload["anonymousIdentity"], - "wifiCaCert": operationPayload["cacert"], - "wifiCaCertName": operationPayload["cacertName"] - }; - break; - case androidOperationConstants["VPN_OPERATION_CODE"]: - payload = { - "serverAddress": operationPayload["serverAddress"], - "serverPort": operationPayload["serverPort"], - "sharedSecret": operationPayload["sharedSecret"], - "dnsServer": operationPayload["dnsServer"] - }; - break; - case androidOperationConstants["APPLICATION_OPERATION_CODE"]: - payload = { - "restrictionType": operationPayload["restriction-type"], - "restrictedApplications": operationPayload["restricted-applications"] - }; - break; - case androidOperationConstants["SYSTEM_UPDATE_POLICY_CODE"]: - if (operationPayload["type"] != "window") { - payload = { - "cosuSystemUpdatePolicyType": operationPayload["type"] - }; - } else { - payload = { - "cosuSystemUpdatePolicyType": operationPayload["type"], - "cosuSystemUpdatePolicyWindowStartTime": operationPayload["startTime"], - "cosuSystemUpdatePolicyWindowEndTime": operationPayload["endTime"] - }; - } - break; - case androidOperationConstants["KIOSK_APPS_CODE"]: - payload = { - "cosuWhitelistedApplications": operationPayload["whitelistedApplications"] - }; - break; - } - return payload; - }; - - privateMethods.generateAndroidOperationPayload = function (operationCode, operationData, deviceList) { - var payload; - var operationType; - switch (operationCode) { - case androidOperationConstants["CAMERA_OPERATION_CODE"]: - operationType = operationTypeConstants["PROFILE"]; - payload = { - "operation": { - "CAMERA": operationData["cameraEnabled"], - "DISALLOW_ADJUST_VOLUME": operationData["disallowAdjustVolumeEnabled"], - "DISALLOW_CONFIG_BLUETOOTH": operationData["disallowConfigBluetooth"], - "DISALLOW_CONFIG_CELL_BROADCASTS": operationData["disallowConfigCellBroadcasts"], - "DISALLOW_CONFIG_CREDENTIALS": operationData["disallowConfigCredentials"], - "DISALLOW_CONFIG_MOBILE_NETWORKS": operationData["disallowConfigMobileNetworks"], - "DISALLOW_CONFIG_TETHERING": operationData["disallowConfigTethering"], - "DISALLOW_CONFIG_VPN": operationData["disallowConfigVpn"], - "DISALLOW_CONFIG_WIFI": operationData["disallowConfigWifi"], - "DISALLOW_APPS_CONTROL": operationData["disallowAppControl"], - "DISALLOW_CREATE_WINDOWS": operationData["disallowCreateWindows"], - "DISALLOW_CROSS_PROFILE_COPY_PASTE": operationData["disallowCrossProfileCopyPaste"], - "DISALLOW_DEBUGGING_FEATURES": operationData["disallowDebugging"], - "DISALLOW_FACTORY_RESET": operationData["disallowFactoryReset"], - "DISALLOW_ADD_USER": operationData["disallowAddUser"], - "DISALLOW_INSTALL_APPS": operationData["disallowInstallApps"], - "DISALLOW_INSTALL_UNKNOWN_SOURCES": operationData["disallowInstallUnknownSources"], - "DISALLOW_MODIFY_ACCOUNTS": operationData["disallowModifyAccounts"], - "DISALLOW_MOUNT_PHYSICAL_MEDIA": operationData["disallowMountPhysicalMedia"], - "DISALLOW_NETWORK_RESET": operationData["disallowNetworkReset"], - "DISALLOW_OUTGOING_BEAM": operationData["disallowOutgoingBeam"], - "DISALLOW_OUTGOING_CALLS": operationData["disallowOutgoingCalls"], - "DISALLOW_REMOVE_USER": operationData["disallowRemoveUser"], - "DISALLOW_SAFE_BOOT": operationData["disallowSafeBoot"], - "DISALLOW_SHARE_LOCATION": operationData["disallowLocationSharing"], - "DISALLOW_SMS": operationData["disallowSMS"], - "DISALLOW_UNINSTALL_APPS": operationData["disallowUninstallApps"], - "DISALLOW_UNMUTE_MICROPHONE": operationData["disallowUnmuteMicrophone"], - "DISALLOW_USB_FILE_TRANSFER": operationData["disallowUSBFileTransfer"], - "ALLOW_PARENT_PROFILE_APP_LINKING": operationData["disallowParentProfileAppLinking"], - "ENSURE_VERIFY_APPS": operationData["ensureVerifyApps"], - "AUTO_TIME": operationData["enableAutoTime"], - "SET_SCREEN_CAPTURE_DISABLED": operationData["disableScreenCapture"], - "SET_STATUS_BAR_DISABLED": operationData["disableStatusBar"] - } - }; - break; - case androidOperationConstants["CHANGE_LOCK_CODE_OPERATION_CODE"]: - operationType = operationTypeConstants["PROFILE"]; - payload = { - "operation": { - "lockCode": operationData["lockCode"] - } - }; - break; - case androidOperationConstants["ENCRYPT_STORAGE_OPERATION_CODE"]: - operationType = operationTypeConstants["PROFILE"]; - payload = { - "operation": { - "encrypted": operationData["encryptStorageEnabled"] - } - }; - break; - case androidOperationConstants["NOTIFICATION_OPERATION_CODE"]: - operationType = operationTypeConstants["PROFILE"]; - payload = { - "operation": { - //"message" : operationData["message"] - "messageText": operationData["messageText"], - "messageTitle": operationData["messageTitle"] - } - }; - break; - case androidOperationConstants["UPGRADE_FIRMWARE"]: - operationType = operationTypeConstants["PROFILE"]; - payload = { - "operation": { - "schedule": operationData["schedule"], - "server": operationData["server"] - } - }; - break; - case androidOperationConstants["WIPE_OPERATION_CODE"]: - operationType = operationTypeConstants["PROFILE"]; - payload = { - "operation": { - "pin": operationData["pin"] - } - }; - break; - case androidOperationConstants["WIFI_OPERATION_CODE"]: - operationType = operationTypeConstants["PROFILE"]; - payload = { - "operation": { - "ssid": operationData["wifiSSID"], - "type": operationData["wifiType"], - "password": operationData["wifiPassword"], - "eap": operationData["wifiEAP"], - "phase2": operationData["wifiPhase2"], - "provisioning": operationData["wifiProvisioning"], - "identity": operationData["wifiIdentity"], - "anonymousIdentity": operationData["wifiAnoIdentity"], - "cacert": operationData["wifiCaCert"], - "cacertName": operationData["wifiCaCertName"] - } - }; - break; - case androidOperationConstants["VPN_OPERATION_CODE"]: - operationType = operationTypeConstants["PROFILE"]; - payload = { - "operation": { - "serverAddress": operationData["serverAddress"], - "serverPort": operationData["serverPort"], - "sharedSecret": operationData["sharedSecret"], - "dnsServer": operationData["dnsServer"] - } - }; - break; - case androidOperationConstants["LOCK_OPERATION_CODE"]: - operationType = operationTypeConstants["PROFILE"]; - payload = { - "operation": { - "message": operationData["lock-message"], - "isHardLockEnabled": operationData["hard-lock"] - } - }; - break; - case androidOperationConstants["WORK_PROFILE_CODE"]: - operationType = operationTypeConstants["PROFILE"]; - payload = { - "operation": { - "profileName": operationData["workProfilePolicyProfileName"], - "enableSystemApps": operationData["workProfilePolicyEnableSystemApps"], - "hideSystemApps": operationData["workProfilePolicyHideSystemApps"], - "unhideSystemApps": operationData["workProfilePolicyUnhideSystemApps"], - "enablePlaystoreApps": operationData["workProfilePolicyEnablePlaystoreApps"] - } - }; - break; - case androidOperationConstants["PASSCODE_POLICY_OPERATION_CODE"]: - operationType = operationTypeConstants["PROFILE"]; - payload = { - "operation": { - "allowSimple": operationData["passcodePolicyAllowSimple"], - "requireAlphanumeric": operationData["passcodePolicyRequireAlphanumeric"], - "minLength": operationData["passcodePolicyMinLength"], - "minComplexChars": operationData["passcodePolicyMinComplexChars"], - "maxPINAgeInDays": operationData["passcodePolicyMaxPasscodeAgeInDays"], - "pinHistory": operationData["passcodePolicyPasscodeHistory"], - "maxFailedAttempts": operationData["passcodePolicyMaxFailedAttempts"] - } - }; - break; - case androidOperationConstants["APPLICATION_OPERATION_CODE"]: - payload = { - "operation": { - "restriction-type": operationData["restrictionType"], - "restricted-applications": operationData["restrictedApplications"] - } - }; - break; - case androidOperationConstants["SYSTEM_UPDATE_POLICY_CODE"]: - operationType = operationTypeConstants["PROFILE"]; - if (operationData["cosuSystemUpdatePolicyType"] != "window") { - payload = { - "operation": { - "type": operationData["cosuSystemUpdatePolicyType"] - } - }; - } else { - payload = { - "operation": { - "type": operationData["cosuSystemUpdatePolicyType"], - "startTime": operationData["cosuSystemUpdatePolicyWindowStartTime"], - "endTime": operationData["cosuSystemUpdatePolicyWindowEndTime"] - } - }; - } - break; - case androidOperationConstants["KIOSK_APPS_CODE"]: - operationType = operationTypeConstants["PROFILE"]; - payload = { - "operation": { - "whitelistedApplications": operationData["cosuWhitelistedApplications"] - } - }; - break; - default: - // If the operation is neither of above, it is a command operation - operationType = operationTypeConstants["COMMAND"]; - // Operation payload of a command operation is simply an array of device IDs - payload = deviceList; - } - - if (operationType == operationTypeConstants["PROFILE"] && deviceList) { - payload["deviceIDs"] = deviceList; - } - - return payload; - }; - - publicMethods.getAndroidServiceEndpoint = function (operationCode) { - var featureMap = { - "WIFI": "configure-wifi", - "CAMERA": "control-camera", - "VPN": "configure-vpn", - "DEVICE_LOCK": "lock-devices", - "DEVICE_UNLOCK": "unlock-devices", - "DEVICE_LOCATION": "location", - "CLEAR_PASSWORD": "clear-password", - "APPLICATION_LIST": "get-application-list", - "DEVICE_RING": "ring", - "DEVICE_REBOOT": "reboot", - "UPGRADE_FIRMWARE": "upgrade-firmware", - "DEVICE_MUTE": "mute", - "NOTIFICATION": "send-notification", - "ENCRYPT_STORAGE": "encrypt-storage", - "CHANGE_LOCK_CODE": "change-lock-code", - "WEBCLIP": "set-webclip", - "INSTALL_APPLICATION": "install-application", - "UNINSTALL_APPLICATION": "uninstall-application", - "BLACKLIST_APPLICATIONS": "blacklist-applications", - "PASSCODE_POLICY": "set-password-policy", - "ENTERPRISE_WIPE": "enterprise-wipe", - "WIPE_DATA": "wipe" - }; - //return "/mdm-android-agent/operation/" + featureMap[operationCode]; - return "/api/device-mgt/android/v1.0/admin/devices/" + featureMap[operationCode]; - }; - /** * Convert the windows platform specific code to the generic payload. * TODO: think of the possibility to follow a pattern to the key name (namespace?) @@ -1236,28 +148,6 @@ var operationModule = function () { //return "/mdm-windows-agent/services/windows/operation/" + featureMap[operationCode]; return "/api/device-mgt/windows/v1.0/services/windows/admin/devices/" + featureMap[operationCode]; }; - /** - * Get the icon for the featureCode - * @param operationCode - * @returns icon class - */ - publicMethods.getAndroidIconForFeature = function (operationCode) { - var featureMap = { - "DEVICE_LOCK": "fw-lock", - "DEVICE_LOCATION": "fw-map-location", - "CLEAR_PASSWORD": "fw-clear", - "ENTERPRISE_WIPE": "fw-block", - "WIPE_DATA": "fw-delete", - "DEVICE_RING": "fw-dial-up", - "DEVICE_REBOOT": "fw-refresh", - "UPGRADE_FIRMWARE": "fw-hardware", - "DEVICE_MUTE": "fw-mute", - "NOTIFICATION": "fw-message", - "CHANGE_LOCK_CODE": "fw-security", - "DEVICE_UNLOCK": "fw-key" - }; - return featureMap[operationCode]; - }; /** * Get the icon for the featureCode @@ -1275,22 +165,6 @@ var operationModule = function () { return featureMap[operationCode]; }; - /** - * Get the icon for the featureCode - * @param operationCode - * @returns icon class - */ - publicMethods.getIOSIconForFeature = function (operationCode) { - var featureMap = { - "DEVICE_LOCK": "fw-lock", - "LOCATION": "fw-map-location", - "ENTERPRISE_WIPE": "fw-block", - "NOTIFICATION": "fw-message", - "RING": "fw-dial-up" - }; - return featureMap[operationCode]; - }; - /** * Filter a list by a data attribute. * @param prop @@ -1308,12 +182,11 @@ var operationModule = function () { /** * Method to generate Platform specific operation payload. * - * @param platformType Platform Type of the profile * @param operationCode Operation Codes to generate the profile from * @param deviceList Optional device list to include in payload body for operations * @returns {*} */ - publicMethods.generatePayload = function (platformType, operationCode, deviceList) { + publicMethods.generatePayload = function (operationCode, deviceList) { var payload; var operationData = {}; // capturing form input data designated by .operationDataKeys @@ -1430,47 +303,23 @@ var operationModule = function () { } } ); - - switch (platformType) { - case platformTypeConstants["ANDROID"]: - payload = privateMethods.generateAndroidOperationPayload(operationCode, operationData, deviceList); - break; - case platformTypeConstants["IOS"]: - payload = privateMethods.generateIOSOperationPayload(operationCode, operationData, deviceList); - break; - case platformTypeConstants["WINDOWS"]: - payload = privateMethods.generateWindowsOperationPayload(operationCode, operationData, deviceList); - break; - } + payload = privateMethods.generateWindowsOperationPayload(operationCode, operationData, deviceList); return payload; }; /** * Method to populate the Platform specific operation payload. * - * @param platformType Platform Type of the profile * @param operationCode Operation Codes to generate the profile from * @param operationPayload payload * @returns {*} */ - publicMethods.populateUI = function (platformType, operationCode, operationPayload) { - var uiPayload; - switch (platformType) { - case platformTypeConstants["ANDROID"]: - uiPayload = privateMethods.generateGenericPayloadFromAndroidPayload(operationCode, operationPayload); - break; - case platformTypeConstants["IOS"]: - uiPayload = privateMethods.generateGenericPayloadFromIOSPayload(operationCode, operationPayload); - break; - case platformTypeConstants["WINDOWS"]: - uiPayload = privateMethods.generateGenericPayloadFromWindowsPayload(operationCode, operationPayload); - break; - } + publicMethods.populateUI = function (operationCode, operationPayload) { + var uiPayload = privateMethods.generateGenericPayloadFromWindowsPayload(operationCode, operationPayload); // capturing form input data designated by .operationDataKeys $(".operation-data").filterByData("operation-code", operationCode).find(".operationDataKeys").each( function () { var operationDataObj = $(this); - //TODO :remove //operationDataObj.prop('disabled', true) var key = operationDataObj.data("key"); // retrieve corresponding input value associated with the key @@ -1612,36 +461,15 @@ var operationModule = function () { /** * generateProfile method is only used for policy-creation UIs. * - * @param platformType Platform Type of the profile * @param operationCodes Operation codes to generate the profile from * @returns {{}} */ - publicMethods.generateProfile = function (platformType, operationCodes) { + publicMethods.generateProfile = function (operationCodes) { var generatedProfile = {}; for (var i = 0; i < operationCodes.length; ++i) { var operationCode = operationCodes[i]; - var payload = publicMethods.generatePayload(platformType, operationCode, null); - - if (platformType == platformTypeConstants["ANDROID"] && - operationCodes[i] == androidOperationConstants["CAMERA_OPERATION_CODE"]) { - var operations = payload["operation"]; - for (var key in operations) { - operationCode = key; - var restriction = false; - if (operations[key]) { - restriction = true; - } - var payloadResult = { - "operation": { - "enabled": restriction - } - }; - generatedProfile[operationCode] = payloadResult["operation"]; - } - - } else { - generatedProfile[operationCode] = payload["operation"]; - } + var payload = publicMethods.generatePayload(operationCode, null); + generatedProfile[operationCode] = payload["operation"]; } return generatedProfile; }; @@ -1649,133 +477,21 @@ var operationModule = function () { /** * populateProfile method is used to populate the html ui with saved payload. * - * @param platformType Platform Type of the profile * @param payload List of profileFeatures * @returns [] configuredOperations array */ - publicMethods.populateProfile = function (platformType, payload) { + publicMethods.populateProfile = function (payload) { var i, configuredOperations = []; - var restrictions = {}; for (i = 0; i < payload.length; ++i) { var configuredFeature = payload[i]; var featureCode = configuredFeature["featureCode"]; var operationPayload = configuredFeature["content"]; - if (platformType == platformTypeConstants["ANDROID"]) { - var restriction = JSON.parse(operationPayload); - if (featureCode == androidOperationConstants["CAMERA_OPERATION_CODE"]) { - restrictions["cameraEnabled"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["DISALLOW_ADJUST_VOLUME"]) { - restrictions["disallowAdjustVolumeEnabled"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["DISALLOW_CONFIG_BLUETOOTH"]) { - restrictions["disallowConfigBluetooth"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["DISALLOW_CONFIG_CELL_BROADCASTS"]) { - restrictions["disallowConfigCellBroadcasts"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["DISALLOW_CONFIG_CREDENTIALS"]) { - restrictions["disallowConfigCredentials"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["DISALLOW_CONFIG_MOBILE_NETWORKS"]) { - restrictions["disallowConfigMobileNetworks"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["DISALLOW_CONFIG_TETHERING"]) { - restrictions["disallowConfigTethering"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["DISALLOW_CONFIG_VPN"]) { - restrictions["disallowConfigVpn"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["DISALLOW_CONFIG_WIFI"]) { - restrictions["disallowConfigWifi"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["DISALLOW_APPS_CONTROL"]) { - restrictions["disallowAppControl"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["DISALLOW_CREATE_WINDOWS"]) { - restrictions["disallowCreateWindows"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["DISALLOW_CROSS_PROFILE_COPY_PASTE"]) { - restrictions["disallowCrossProfileCopyPaste"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["DISALLOW_DEBUGGING_FEATURES"]) { - restrictions["disallowDebugging"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["DISALLOW_FACTORY_RESET"]) { - restrictions["disallowFactoryReset"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["DISALLOW_ADD_USER"]) { - restrictions["disallowAddUser"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["DISALLOW_INSTALL_APPS"]) { - restrictions["disallowInstallApps"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["DISALLOW_INSTALL_UNKNOWN_SOURCES"]) { - restrictions["disallowInstallUnknownSources"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["DISALLOW_MODIFY_ACCOUNTS"]) { - restrictions["disallowModifyAccounts"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["DISALLOW_MOUNT_PHYSICAL_MEDIA"]) { - restrictions["disallowMountPhysicalMedia"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["DISALLOW_NETWORK_RESET"]) { - restrictions["disallowNetworkReset"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["DISALLOW_OUTGOING_BEAM"]) { - restrictions["disallowOutgoingBeam"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["DISALLOW_OUTGOING_CALLS"]) { - restrictions["disallowOutgoingCalls"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["DISALLOW_REMOVE_USER"]) { - restrictions["disallowRemoveUser"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["DISALLOW_SAFE_BOOT"]) { - restrictions["disallowSafeBoot"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["DISALLOW_SHARE_LOCATION"]) { - restrictions["disallowLocationSharing"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["DISALLOW_SMS"]) { - restrictions["disallowSMS"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["DISALLOW_UNINSTALL_APPS"]) { - restrictions["disallowUninstallApps"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["DISALLOW_UNMUTE_MICROPHONE"]) { - restrictions["disallowUnmuteMicrophone"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["DISALLOW_USB_FILE_TRANSFER"]) { - restrictions["disallowUSBFileTransfer"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["ALLOW_PARENT_PROFILE_APP_LINKING"]) { - restrictions["disallowParentProfileAppLinking"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["ENSURE_VERIFY_APPS"]) { - restrictions["ensureVerifyApps"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["AUTO_TIME"]) { - restrictions["enableAutoTime"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["SET_SCREEN_CAPTURE_DISABLED"]) { - restrictions["disableScreenCapture"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["SET_STATUS_BAR_DISABLED"]) { - restrictions["disableStatusBar"] = restriction["enabled"]; - continue; - } - } //push the feature-code to the configuration array configuredOperations.push(featureCode); - publicMethods.populateUI(platformType, featureCode, operationPayload); - } - if (typeof restrictions.cameraEnabled !== 'undefined') { - configuredOperations.push(androidOperationConstants["CAMERA_OPERATION_CODE"]); - publicMethods.populateUI(platformType, androidOperationConstants["CAMERA_OPERATION_CODE"], JSON.stringify(restrictions)); + publicMethods.populateUI(featureCode, operationPayload); } return configuredOperations; }; return publicMethods; -}(); +}(); \ No newline at end of file diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.policy-edit/public/js/windows-policy-edit.js b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.policy-edit/public/js/windows-policy-edit.js index 573760c438..ec7ae00035 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.policy-edit/public/js/windows-policy-edit.js +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.policy-edit/public/js/windows-policy-edit.js @@ -16,6 +16,8 @@ * under the License. */ +var configuredOperations = []; + var windowsOperationConstants = { "PASSCODE_POLICY_OPERATION": "passcode-policy", "PASSCODE_POLICY_OPERATION_CODE": "PASSCODE_POLICY", @@ -52,21 +54,60 @@ var updateGroupedInputVisibility = function (domElement) { * * This method will be invoked from the relevant cdmf unit when the edit page gets loaded. * - * @param configuredOperations selected configurations. + * @param profileFeatureList saved feature list */ -var polulateProfileOperations = function (configuredOperations) { +var polulateProfileOperations = function (profileFeatureList) { + var selectedOperations = windowsOperationModule.populateProfile(profileFeatureList); $(".wr-advance-operations li.grouped-input").each(function () { updateGroupedInputVisibility(this); }); - for (var i = 0; i < configuredOperations.length; ++i) { - var configuredOperation = configuredOperations[i]; - $(".operation-data").filterByData("operation-code", configuredOperation) + for (var i = 0; i < selectedOperations.length; ++i) { + var selectedOperation = selectedOperations[i]; + $(".operation-data").filterByData("operation-code", selectedOperation) .find(".panel-title .wr-input-control.switch input[type=checkbox]").each(function () { $(this).click(); }); } }; +/** + * Generates policy profile feature list which will be saved with the profile. + * + * This function will be invoked from the relevant cdmf unit at the time of policy creation. + * + * @returns {Array} profile payloads + */ +var generateProfileFeaturesList = function () { + var profilePayloads = []; + // traverses key by key in policy["profile"] + var key; + for (key in policy["profile"]) { + if (policy["profile"].hasOwnProperty(key)) { + if (key == windowsOperationConstants["PASSCODE_POLICY_OPERATION_CODE"]) { + policy["profile"][key].enablePassword = true; + } + profilePayloads.push({ + "featureCode": key, + "deviceType": policy["platform"], + "content": policy["profile"][key] + }); + } + } + return profilePayloads; +}; + +/** + * Generates policy profile object which will be saved with the profile. + * + * This function will be invoked from the relevant cdmf unit at the time of policy creation. + * + * @returns {object} generated profile. + */ +var generatePolicyProfile = function () { + return windowsOperationModule.generateProfile(configuredOperations); +}; + + /** * Checks if provided number is valid against a range. * @@ -256,33 +297,6 @@ var validatePolicyProfile = function () { return wizardIsToBeContinued; }; -/** - * Generates policy profile object which will be saved with the profile. - * - * This function will be invoked from the relevant cdmf unit at the time of policy creation. - * - * @returns {Array} profile payloads - */ -var generatePolicyProfile = function () { - var profilePayloads = []; - // traverses key by key in policy["profile"] - var key; - for (key in policy["profile"]) { - if (key == windowsOperationConstants["PASSCODE_POLICY_OPERATION_CODE"]) { - policy["profile"][key].enablePassword = true; - } - if (policy["profile"].hasOwnProperty(key)) { - profilePayloads.push({ - "featureCode": key, - "deviceType": policy["platform"], - "content": policy["profile"][key] - }); - } - } - - return profilePayloads; -}; - // Start of HTML embedded invoke methods var showAdvanceOperation = function (operation, button) { $(button).addClass('selected'); diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.policy-view/public/js/windows-policy-view.js b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.policy-view/public/js/windows-policy-view.js index 0b39e45404..9280bec146 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.policy-view/public/js/windows-policy-view.js +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.policy-view/public/js/windows-policy-view.js @@ -16,8 +16,6 @@ * under the License. */ -var configuredOperations = []; - /** * Method to update the visibility (i.e. disabled or enabled view) * of grouped input according to the values @@ -47,9 +45,10 @@ var updateGroupedInputVisibility = function (domElement) { * * This method will be invoked from the relevant cdmf unit when the edit page gets loaded. * - * @param selectedConfigurations selected configurations. + * @param profileFeatureList selected configurations. */ -var polulateProfileOperations = function (selectedConfigurations) { +var polulateProfileOperations = function (profileFeatureList) { + var selectedConfigurations = windowsOperationModule.populateProfile(profileFeatureList); $(".wr-advance-operations li.grouped-input").each(function () { updateGroupedInputVisibility(this); }); @@ -168,208 +167,20 @@ var slideDownPaneAgainstValueSetForRadioButtons = function (selectElement, paneI }; // End of HTML embedded invoke methods - -// Start of functions related to grid-input-view - -/** - * Method to set count id to cloned elements. - * @param {object} addFormContainer - */ -var setId = function (addFormContainer) { - $(addFormContainer).find("[data-add-form-clone]").each(function (i) { - $(this).attr("id", $(this).attr("data-add-form-clone").slice(1) + "-" + (i + 1)); - if ($(this).find(".index").length > 0) { - $(this).find(".index").html(i + 1); - } - }); -}; - -/** - * Method to set count id to cloned elements. - * @param {object} addFormContainer - */ -var showHideHelpText = function (addFormContainer) { - var helpText = "[data-help-text=add-form]"; - if ($(addFormContainer).find("[data-add-form-clone]").length > 0) { - $(addFormContainer).find(helpText).hide(); - } else { - $(addFormContainer).find(helpText).show(); - } -}; - -/** - * This method will display appropriate fields based on wifi type - * @param {object} wifi type select object - */ -var changeAndroidWifiPolicy = function (select) { - slideDownPaneAgainstValueSet(select, 'control-wifi-password', ['wep', 'wpa', '802eap']); - slideDownPaneAgainstValueSet(select, 'control-wifi-eap', ['802eap']); - slideDownPaneAgainstValueSet(select, 'control-wifi-phase2', ['802eap']); - slideDownPaneAgainstValueSet(select, 'control-wifi-identity', ['802eap']); - slideDownPaneAgainstValueSet(select, 'control-wifi-anoidentity', ['802eap']); - slideDownPaneAgainstValueSet(select, 'control-wifi-cacert', ['802eap']); -}; - -/** - * This method will display appropriate fields based on wifi EAP type - * @param {object} wifi eap select object - * @param {object} wifi type select object - */ -var changeAndroidWifiPolicyEAP = function (select, superSelect) { - slideDownPaneAgainstValueSet(select, 'control-wifi-password', ['peap', 'ttls', 'pwd', 'fast', 'leap']); - slideDownPaneAgainstValueSet(select, 'control-wifi-phase2', ['peap', 'ttls', 'fast']); - slideDownPaneAgainstValueSet(select, 'control-wifi-provisioning', ['fast']); - slideDownPaneAgainstValueSet(select, 'control-wifi-identity', ['peap', 'tls', 'ttls', 'pwd', 'fast', 'leap']); - slideDownPaneAgainstValueSet(select, 'control-wifi-anoidentity', ['peap', 'ttls']); - slideDownPaneAgainstValueSet(select, 'control-wifi-cacert', ['peap', 'tls', 'ttls']); - if (superSelect.value != '802eap') { - changeAndroidWifiPolicy(superSelect); - } -}; - $(document).ready(function () { - // Maintains an array of configured features of the profile var advanceOperations = ".wr-advance-operations"; $(advanceOperations).on("click", ".wr-input-control.switch", function (event) { - var operationCode = $(this).parents(".operation-data").data("operation-code"); var operation = $(this).parents(".operation-data").data("operation"); - var operationDataWrapper = $(this).data("target"); // prevents event bubbling by figuring out what element it's being called from. if (event.target.tagName == "INPUT") { var featureConfiguredIcon; if ($("input[type='checkbox']", this).is(":checked")) { - configuredOperations.push(operationCode); - // when a feature is enabled, if "zero-configured-features" msg is available, hide that. - var zeroConfiguredOperationsErrorMsg = "#policy-profile-main-error-msg"; - if (!$(zeroConfiguredOperationsErrorMsg).hasClass("hidden")) { - $(zeroConfiguredOperationsErrorMsg).addClass("hidden"); - } // add configured-state-icon to the feature featureConfiguredIcon = "#" + operation + "-configured"; if ($(featureConfiguredIcon).hasClass("hidden")) { $(featureConfiguredIcon).removeClass("hidden"); } - } else { - //splicing the array if operation is present. - var index = $.inArray(operationCode, configuredOperations); - if (index != -1) { - configuredOperations.splice(index, 1); - } - // when a feature is disabled, clearing all its current configured, error or success states - var subErrorMsgWrapper = "#" + operation + "-feature-error-msg"; - var subErrorIcon = "#" + operation + "-error"; - var subOkIcon = "#" + operation + "-ok"; - featureConfiguredIcon = "#" + operation + "-configured"; - - if (!$(subErrorMsgWrapper).hasClass("hidden")) { - $(subErrorMsgWrapper).addClass("hidden"); - } - if (!$(subErrorIcon).hasClass("hidden")) { - $(subErrorIcon).addClass("hidden"); - } - if (!$(subOkIcon).hasClass("hidden")) { - $(subOkIcon).addClass("hidden"); - } - if (!$(featureConfiguredIcon).hasClass("hidden")) { - $(featureConfiguredIcon).addClass("hidden"); - } - // reinitializing input fields into the defaults - $(operationDataWrapper + " input").each( - function () { - if ($(this).is("input:text")) { - $(this).val($(this).data("default")); - } else if ($(this).is("input:password")) { - $(this).val(""); - } else if ($(this).is("input:checkbox")) { - $(this).prop("checked", $(this).data("default")); - // if this checkbox is the parent input of a grouped-input - if ($(this).hasClass("parent-input")) { - var groupedInput = $(this).parent().parent().parent(); - updateGroupedInputVisibility(groupedInput); - } - } - } - ); - // reinitializing select fields into the defaults - $(operationDataWrapper + " select").each( - function () { - var defaultOption = $(this).data("default"); - $("option:eq(" + defaultOption + ")", this).prop("selected", "selected"); - } - ); - // collapsing expanded-panes (upon the selection of html-select-options) if any - $(operationDataWrapper + " .expanded").each( - function () { - if ($(this).hasClass("expanded")) { - $(this).removeClass("expanded"); - } - $(this).slideUp(); - } - ); - // removing all entries of grid-input elements if exist - $(operationDataWrapper + " .grouped-array-input").each( - function () { - var gridInputs = $(this).find("[data-add-form-clone]"); - if (gridInputs.length > 0) { - gridInputs.remove(); - } - var helpTexts = $(this).find("[data-help-text=add-form]"); - if (helpTexts.length > 0) { - helpTexts.show(); - } - } - ); } } }); - - // adding support for cloning multiple profiles per feature with cloneable class definitions - $(advanceOperations).on("click", ".multi-view.add.enabled", function () { - // get a copy of .cloneable and create new .cloned div element - var cloned = "

" + $(".cloneable", $(this).parent().parent()).html() + "
"; - // append newly created .cloned div element to panel-body - $(this).parent().parent().append(cloned); - // enable remove action of newly cloned div element - $(".cloned", $(this).parent().parent()).each( - function () { - if ($(".multi-view.remove", this).hasClass("disabled")) { - $(".multi-view.remove", this).removeClass("disabled"); - } - if (!$(".multi-view.remove", this).hasClass("enabled")) { - $(".multi-view.remove", this).addClass("enabled"); - } - } - ); - }); - - $(advanceOperations).on("click", ".multi-view.remove.enabled", function () { - $(this).parent().remove(); - }); - - // enabling or disabling grouped-input based on the status of a parent check-box - $(advanceOperations).on("click", ".grouped-input", function () { - updateGroupedInputVisibility(this); - }); - - // add form entry click function for grid inputs - $(advanceOperations).on("click", "[data-click-event=add-form]", function () { - var addFormContainer = $("[data-add-form-container=" + $(this).attr("href") + "]"); - var clonedForm = $("[data-add-form=" + $(this).attr("href") + "]").clone().find("[data-add-form-element=clone]").attr("data-add-form-clone", $(this).attr("href")); - - // adding class .child-input to capture text-input-array-values - $("input, select", clonedForm).addClass("child-input"); - - $(addFormContainer).append(clonedForm); - setId(addFormContainer); - showHideHelpText(addFormContainer); - }); - - // remove form entry click function for grid inputs - $(advanceOperations).on("click", "[data-click-event=remove-form]", function () { - var addFormContainer = $("[data-add-form-container=" + $(this).attr("href") + "]"); - - $(this).closest("[data-add-form-element=clone]").remove(); - setId(addFormContainer); - showHideHelpText(addFormContainer); - }); }); \ No newline at end of file diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.policy-wizard/public/js/windows-policy-operations.js b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.policy-wizard/public/js/windows-policy-operations.js index 3a149ee88e..4f8c121d03 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.policy-wizard/public/js/windows-policy-operations.js +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.policy-wizard/public/js/windows-policy-operations.js @@ -16,6 +16,8 @@ * under the License. */ +var configuredOperations = []; + var windowsOperationConstants = { "PASSCODE_POLICY_OPERATION": "passcode-policy", "PASSCODE_POLICY_OPERATION_CODE": "PASSCODE_POLICY", @@ -237,21 +239,21 @@ var validatePolicyProfile = function () { }; /** - * Generates policy profile object which will be saved with the profile. + * Generates policy profile feature list which will be saved with the profile. * * This function will be invoked from the relevant cdmf unit at the time of policy creation. * * @returns {Array} profile payloads */ -var generatePolicyProfile = function () { +var generateProfileFeaturesList = function () { var profilePayloads = []; // traverses key by key in policy["profile"] var key; for (key in policy["profile"]) { - if (key == windowsOperationConstants["PASSCODE_POLICY_OPERATION_CODE"]) { - policy["profile"][key].enablePassword = true; - } if (policy["profile"].hasOwnProperty(key)) { + if (key == windowsOperationConstants["PASSCODE_POLICY_OPERATION_CODE"]) { + policy["profile"][key].enablePassword = true; + } profilePayloads.push({ "featureCode": key, "deviceType": policy["platform"], @@ -259,10 +261,27 @@ var generatePolicyProfile = function () { }); } } - return profilePayloads; }; +/** + * Generates policy profile object which will be saved with the profile. + * + * This function will be invoked from the relevant cdmf unit at the time of policy creation. + * + * @returns {object} generated profile. + */ +var generatePolicyProfile = function () { + return windowsOperationModule.generateProfile(configuredOperations); +}; + +/** + * Resets policy profile configurations. + */ +var resetPolicyProfile = function () { + configuredOperations = []; +}; + // Start of HTML embedded invoke methods var showAdvanceOperation = function (operation, button) { $(button).addClass('selected'); @@ -272,37 +291,6 @@ var showAdvanceOperation = function (operation, button) { $(hiddenOperation + '[data-operation="' + operation + '"]').siblings().hide(); }; - -/** - * This method will display appropriate fields based on wifi type - * @param select - */ -var changeAndroidWifiPolicy = function (select) { - slideDownPaneAgainstValueSet(select, 'control-wifi-password', ['wep', 'wpa', '802eap']); - slideDownPaneAgainstValueSet(select, 'control-wifi-eap', ['802eap']); - slideDownPaneAgainstValueSet(select, 'control-wifi-phase2', ['802eap']); - slideDownPaneAgainstValueSet(select, 'control-wifi-identity', ['802eap']); - slideDownPaneAgainstValueSet(select, 'control-wifi-anoidentity', ['802eap']); - slideDownPaneAgainstValueSet(select, 'control-wifi-cacert', ['802eap']); -}; - -/** - * This method will display appropriate fields based on wifi EAP type - * @param select - * @param superSelect - */ -var changeAndroidWifiPolicyEAP = function (select, superSelect) { - slideDownPaneAgainstValueSet(select, 'control-wifi-password', ['peap', 'ttls', 'pwd', 'fast', 'leap']); - slideDownPaneAgainstValueSet(select, 'control-wifi-phase2', ['peap', 'ttls', 'fast']); - slideDownPaneAgainstValueSet(select, 'control-wifi-provisioning', ['fast']); - slideDownPaneAgainstValueSet(select, 'control-wifi-identity', ['peap', 'tls', 'ttls', 'pwd', 'fast', 'leap']); - slideDownPaneAgainstValueSet(select, 'control-wifi-anoidentity', ['peap', 'ttls']); - slideDownPaneAgainstValueSet(select, 'control-wifi-cacert', ['peap', 'tls', 'ttls']); - if (superSelect.value != '802eap') { - changeAndroidWifiPolicy(superSelect); - } -}; - /** * Method to slide down a provided pane upon provided value set. * diff --git a/features/extensions-feature/org.wso2.extension.siddhi.execution.json.feature/pom.xml b/features/extensions-feature/org.wso2.extension.siddhi.execution.json.feature/pom.xml new file mode 100644 index 0000000000..09380ecf42 --- /dev/null +++ b/features/extensions-feature/org.wso2.extension.siddhi.execution.json.feature/pom.xml @@ -0,0 +1,75 @@ + + + + 4.0.0 + + + org.wso2.carbon.devicemgt-plugins + extensions-feature + 3.0.3-SNAPSHOT + ../pom.xml + + + org.wso2.extension.siddhi.execution.json.feature + pom + 3.0.3-SNAPSHOT + WSO2 Siddhi Execution Extension - Json Feature + http://wso2.org + This feature contains Siddhi extension feature for changing a json string to individual properties. + + + + org.wso2.carbon.devicemgt-plugins + org.wso2.extension.siddhi.execution.json + + + + + + + org.wso2.maven + carbon-p2-plugin + ${carbon.p2.plugin.version} + + + p2-feature-generation + package + + p2-feature-gen + + + org.wso2.extension.siddhi.execution.json + ../../etc/feature.properties + + + org.wso2.carbon.p2.category.type:server + org.eclipse.equinox.p2.type.group:true + + + + + org.wso2.carbon.devicemgt-plugins:org.wso2.extension.siddhi.execution.json:${carbon.devicemgt.plugins.version} + + + + + + + + + \ No newline at end of file diff --git a/features/extensions-feature/pom.xml b/features/extensions-feature/pom.xml index b6afa7982e..3df8280605 100644 --- a/features/extensions-feature/pom.xml +++ b/features/extensions-feature/pom.xml @@ -37,6 +37,7 @@ org.wso2.carbon.appmgt.mdm.osgiconnector.feature org.wso2.carbon.device.mgt.adapter.feature org.wso2.carbon.andes.extensions.device.mgt.mqtt.authorization.feature + org.wso2.extension.siddhi.execution.json.feature diff --git a/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/pom.xml b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/pom.xml index 5b79edefde..97b1674501 100644 --- a/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/pom.xml +++ b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/pom.xml @@ -117,6 +117,18 @@ **/* + + org.wso2.carbon.devicemgt-plugins + org.wso2.carbon.device.mgt.mobile.android.analytics + + ${project.version} + zip + true + + ${project.build.directory}/maven-shared-archive-resources/carbonapps + + **/* +
diff --git a/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/p2.inf b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/p2.inf index 2b8eaf5dd0..3ef1823484 100644 --- a/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/p2.inf +++ b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/p2.inf @@ -1,5 +1,7 @@ instructions.configure = \ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.android_${feature.version}/webapps/api#device-mgt#android#v1.0.war,target:${installFolder}/../../deployment/server/webapps/api#device-mgt#android#v1.0.war,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/carbonapps/);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.android_${feature.version}/carbonapps/,target:${installFolder}/../../deployment/server/carbonapps/,overwrite:true);\ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.android_${feature.version}/jaggeryapps/devicemgt,target:${installFolder}/../../deployment/server/jaggeryapps/devicemgt,overwrite:true);\ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.android_${feature.version}/jaggeryapps/android-web-agent,target:${installFolder}/../../deployment/server/jaggeryapps/android-web-agent,overwrite:true);\ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.android_${feature.version}/datasources/,target:${installFolder}/../../conf/datasources/,overwrite:true);\ @@ -28,4 +30,5 @@ org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../dep org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../../dbscripts/cdm/plugins/android);\ org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../database/WSO2MobileAndroid_DB.h2.db);\ +org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/carbonapps/android_agent_analytics-1.0.0.car);\ org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/devicetypes/android.xml);\ \ No newline at end of file diff --git a/pom.xml b/pom.xml index 1b4bea258e..f6181f3235 100644 --- a/pom.xml +++ b/pom.xml @@ -382,6 +382,11 @@ + + org.wso2.carbon.devicemgt-plugins + org.wso2.extension.siddhi.execution.json + ${carbon.devicemgt.plugins.version} + org.wso2.carbon.devicemgt-plugins org.wso2.carbon.device.mgt.output.adapter.mqtt @@ -851,7 +856,6 @@ gcm-server ${gcm.server.version} - org.json.wso2 json @@ -1185,6 +1189,24 @@ feign-gson ${io.github.openfeign.version} + + + + org.wso2.siddhi + siddhi-core + ${siddhi.version} + + + org.wso2.siddhi + siddhi-query-api + ${siddhi.version} + + + junit + junit + ${junit.version} + test + @@ -1352,6 +1374,9 @@ 9.3.1 [1.1.0, 2.0.0) 1.7 + 3.1.2 + 1.7.2 + 2.0.0.wso2v1