diff --git a/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/pom.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/pom.xml index 9adf7afb5..925456dbc 100644 --- a/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/pom.xml +++ b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.devicemgt-plugins iot-analytics - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT ../pom.xml diff --git a/components/analytics/iot-analytics/org.wso2.carbon.iot.das.rest.api/pom.xml b/components/analytics/iot-analytics/org.wso2.carbon.iot.das.rest.api/pom.xml deleted file mode 100644 index 5deaf0ae2..000000000 --- a/components/analytics/iot-analytics/org.wso2.carbon.iot.das.rest.api/pom.xml +++ /dev/null @@ -1,72 +0,0 @@ - - - - - - org.wso2.carbon.devicemgt-plugins - iot-analytics - 3.0.3-SNAPSHOT - ../pom.xml - - - 4.0.0 - org.wso2.carbon.iot.das.rest.api - WSO2 Carbon - IoT Server REST API - pom - - - - - org.apache.felix - maven-scr-plugin - - - generate-scr-descriptor - - scr - - - - - - org.apache.maven.plugins - maven-surefire-plugin - - - org.apache.felix - maven-bundle-plugin - true - - - ${project.artifactId} - ${project.artifactId} - - - - - - - * - - - - - - - \ No newline at end of file diff --git a/components/analytics/iot-analytics/org.wso2.carbon.iot.device.statistics.dashboard/pom.xml b/components/analytics/iot-analytics/org.wso2.carbon.iot.device.statistics.dashboard/pom.xml index 9aa36b192..a2d9c0f6b 100644 --- a/components/analytics/iot-analytics/org.wso2.carbon.iot.device.statistics.dashboard/pom.xml +++ b/components/analytics/iot-analytics/org.wso2.carbon.iot.device.statistics.dashboard/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.devicemgt-plugins iot-analytics - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT ../pom.xml diff --git a/components/analytics/iot-analytics/org.wso2.carbon.iot.device.statistics.dashboard/src/main/resources/carbonapps/Dashboard_1.0.0/device-statistics-dashboard.json b/components/analytics/iot-analytics/org.wso2.carbon.iot.device.statistics.dashboard/src/main/resources/carbonapps/Dashboard_1.0.0/device-statistics-dashboard.json index bb57e0bc0..b30859faa 100644 --- a/components/analytics/iot-analytics/org.wso2.carbon.iot.device.statistics.dashboard/src/main/resources/carbonapps/Dashboard_1.0.0/device-statistics-dashboard.json +++ b/components/analytics/iot-analytics/org.wso2.carbon.iot.device.statistics.dashboard/src/main/resources/carbonapps/Dashboard_1.0.0/device-statistics-dashboard.json @@ -3,9 +3,9 @@ "title": "Device Statistics Dashboard", "description": "", "permissions": { - "viewers": ["admin"], - "editors": ["admin"], - "owners": ["admin"] + "viewers": ["Internal/everyone"], + "editors": ["Internal/everyone"], + "owners": ["Internal/everyone"] }, "pages": [{ "id": "landing", diff --git a/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/pom.xml b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/pom.xml index 988223499..581c07c33 100644 --- a/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/pom.xml +++ b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.devicemgt-plugins iot-analytics - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT ../pom.xml diff --git a/components/analytics/iot-analytics/pom.xml b/components/analytics/iot-analytics/pom.xml index ac8a3c9b0..92ad61b0b 100644 --- a/components/analytics/iot-analytics/pom.xml +++ b/components/analytics/iot-analytics/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt-plugins analytics - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT ../pom.xml diff --git a/components/analytics/pom.xml b/components/analytics/pom.xml index d228e42c0..60cd864f2 100644 --- a/components/analytics/pom.xml +++ b/components/analytics/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt-plugins carbon-device-mgt-plugins-parent - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT ../../pom.xml diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/pom.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/pom.xml index 56f608416..951be22be 100644 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/pom.xml +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/pom.xml @@ -21,7 +21,7 @@ androidsense-plugin org.wso2.carbon.devicemgt-plugins - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT ../pom.xml diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_sense_receiver/android_sense_receiver.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_sense_receiver/android_sense_receiver.xml index e94bf47ca..706610654 100644 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_sense_receiver/android_sense_receiver.xml +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_sense_receiver/android_sense_receiver.xml @@ -19,10 +19,8 @@ - carbon.super/android_sense/+/data - admin - admin - org.wso2.carbon.device.mgt.input.adapter.mqtt.util.MQTTContentValidator + ${tenant-domain}/android_sense/+/data + iot-mqtt true diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/pom.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/pom.xml index 993349f35..fc1a18732 100644 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/pom.xml +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/pom.xml @@ -3,7 +3,7 @@ androidsense-plugin org.wso2.carbon.devicemgt-plugins - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT ../pom.xml diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/pom.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/pom.xml index 248d64651..03816ecd9 100644 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/pom.xml +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/pom.xml @@ -22,7 +22,7 @@ androidsense-plugin org.wso2.carbon.devicemgt-plugins - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT ../pom.xml diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/public/js/download.js b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/public/js/download.js index 082cc1586..fcb3c3754 100644 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/public/js/download.js +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/public/js/download.js @@ -21,6 +21,8 @@ var modalPopupContainer = modalPopup + " .modal-content"; var modalPopupContent = modalPopup + " .modal-content"; var body = "body"; +var backendEndBasePath = "/api/device-mgt/v1.0"; + /* * set popup maximum height function. */ @@ -69,4 +71,32 @@ function attachEvents() { generateQRCode(modalPopupContent + " .qr-code"); modalDialog.show(); } -} \ No newline at end of file +} + +function artifactUpload() { + var contentType = "application/json"; + + var urix = backendEndBasePath + "/admin/devicetype/deploy/android_sense"; + var defaultStatusClasses = "fw fw-stack-1x"; + var content = $("#androidsense-statistic-response-template").find(".content"); + var title = content.find("#title"); + var statusIcon = content.find("#status-icon"); + var data = {} + invokerUtil.post(urix, data, function (data) { + title.html("Deploying statistic artifacts. Please wait..."); + statusIcon.attr("class", defaultStatusClasses + " fw-check"); + $(modalPopupContent).html(content.html()); + showPopup(); + setTimeout(function () { + hidePopup(); + location.reload(true); + }, 5000); + + }, function (jqXHR) { + title.html("Failed to deploy artifacts, Please contact administrator."); + statusIcon.attr("class", defaultStatusClasses + " fw-error"); + $(modalPopupContent).html(content.html()); + showPopup(); + }, contentType); +} + diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/type-view.hbs b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/type-view.hbs index fdccd55d5..9c08451e9 100644 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/type-view.hbs +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/type-view.hbs @@ -41,7 +41,9 @@ Enroll Device Download APK Invite by Email - + {{#if displayStatus}} + Deploy Analytics Artifacts + {{/if}} @@ -240,7 +242,26 @@ {{unit "cdmf.unit.device.type.email.invite-modal" deviceTypeView="androidSense"}} - + diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/type-view.js b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/type-view.js index 8c8260405..adb857567 100644 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/type-view.js +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/type-view.js @@ -19,6 +19,20 @@ function onRequest(context){ var viewModel = {}; var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"]; + var serviceInvokers = require("/app/modules/oauth/token-protected-service-invokers.js")["invokers"]; + var url = devicemgtProps["httpsURL"] + "/api/device-mgt/v1.0/admin/devicetype/deploy/android_sense/status"; + serviceInvokers.XMLHttp.get( + url, function (responsePayload) { + var responseContent = responsePayload.status; + new Log().error(responseContent); + if ("204" == responsePayload.status) { + viewModel["displayStatus"] = "Display"; + } + }, + function (responsePayload) { + //do nothing. + } + ); viewModel["hostName"] = devicemgtProps["generalConfig"]["host"]; viewModel["enrollmentURL"] = viewModel["hostName"] + context.unit.publicUri + "/asset/androidsense.apk"; return viewModel; diff --git a/components/device-types/androidsense-plugin/pom.xml b/components/device-types/androidsense-plugin/pom.xml index f4c271aaa..f25886b19 100644 --- a/components/device-types/androidsense-plugin/pom.xml +++ b/components/device-types/androidsense-plugin/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt-plugins device-types - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT ../pom.xml diff --git a/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.analytics/pom.xml b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.analytics/pom.xml index 45fc93fad..6b9ca04e0 100644 --- a/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.analytics/pom.xml +++ b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.analytics/pom.xml @@ -21,7 +21,7 @@ arduino-plugin org.wso2.carbon.devicemgt-plugins - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT ../pom.xml diff --git a/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.analytics/src/main/resources/carbonapps/Arduino/arduino_receiver/arduino_receiver.xml b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.analytics/src/main/resources/carbonapps/Arduino/arduino_receiver/arduino_receiver.xml index c8c306ef9..31a060893 100644 --- a/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.analytics/src/main/resources/carbonapps/Arduino/arduino_receiver/arduino_receiver.xml +++ b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.analytics/src/main/resources/carbonapps/Arduino/arduino_receiver/arduino_receiver.xml @@ -18,7 +18,7 @@ --> - org.wso2.carbon.device.mgt.input.adapter.http.util.HTTPContentValidator + iot-http diff --git a/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/pom.xml b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/pom.xml index 19e0e3606..532f22f17 100644 --- a/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/pom.xml +++ b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/pom.xml @@ -21,7 +21,7 @@ arduino-plugin org.wso2.carbon.devicemgt-plugins - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT ../pom.xml diff --git a/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/ArduinoServiceImpl.java b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/ArduinoServiceImpl.java index b5c6b10d9..54c82f12b 100644 --- a/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/ArduinoServiceImpl.java +++ b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/ArduinoServiceImpl.java @@ -179,7 +179,9 @@ public class ArduinoServiceImpl implements ArduinoService { @Produces("application/zip") public Response downloadSketch(@QueryParam("deviceName") String deviceName) { try { - ZipArchive zipFile = createDownloadFile(APIUtil.getAuthenticatedUser(), deviceName); + String username = APIUtil.getAuthenticatedUser() + "@" + PrivilegedCarbonContext + .getThreadLocalCarbonContext().getTenantDomain(); + ZipArchive zipFile = createDownloadFile(username, deviceName); Response.ResponseBuilder response = Response.ok(FileUtils.readFileToByteArray(zipFile.getZipFile())); response.status(Response.Status.OK); response.type("application/zip"); @@ -221,7 +223,8 @@ public class ArduinoServiceImpl implements ArduinoService { throw new DeviceManagementException(msg); } String applicationUsername = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm() - .getRealmConfiguration().getAdminUserName(); + .getRealmConfiguration().getAdminUserName() + "@" + PrivilegedCarbonContext + .getThreadLocalCarbonContext().getTenantDomain();; if (apiApplicationKey == null) { APIManagementProviderService apiManagementProviderService = APIUtil.getAPIManagementProviderService(); String[] tags = {ArduinoConstants.DEVICE_TYPE}; diff --git a/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/pom.xml b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/pom.xml index 5b917581e..385570c29 100644 --- a/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/pom.xml +++ b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/pom.xml @@ -23,7 +23,7 @@ arduino-plugin org.wso2.carbon.devicemgt-plugins - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT ../pom.xml diff --git a/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.type-view/public/js/download.js b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.type-view/public/js/download.js index 3b104cd53..26706014a 100644 --- a/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.type-view/public/js/download.js +++ b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.type-view/public/js/download.js @@ -21,6 +21,8 @@ var modalPopupContainer = modalPopup + " .modal-content"; var modalPopupContent = modalPopup + " .modal-content"; var body = "body"; +var backendEndBasePath = "/api/device-mgt/v1.0"; + /* * set popup maximum height function. */ @@ -181,4 +183,31 @@ function doAction(data) { hidePopup(); }); } +} + +function artifactUpload() { + var contentType = "application/json"; + + var urix = backendEndBasePath + "/admin/devicetype/deploy/arduino"; + var defaultStatusClasses = "fw fw-stack-1x"; + var content = $("#arduino-statistic-response-template").find(".content"); + var title = content.find("#title"); + var statusIcon = content.find("#status-icon"); + var data = {} + invokerUtil.post(urix, data, function (data) { + title.html("Deploying statistic artifacts. Please wait..."); + statusIcon.attr("class", defaultStatusClasses + " fw-check"); + $(modalPopupContent).html(content.html()); + showPopup(); + setTimeout(function () { + hidePopup(); + location.reload(true); + }, 5000); + + }, function (jqXHR) { + title.html("Failed to deploy artifacts, Please contact administrator."); + statusIcon.attr("class", defaultStatusClasses + " fw-error"); + $(modalPopupContent).html(content.html()); + showPopup(); + }, contentType); } \ No newline at end of file diff --git a/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.type-view/type-view.hbs b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.type-view/type-view.hbs index 437d5400a..5aefca356 100644 --- a/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.type-view/type-view.hbs +++ b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.type-view/type-view.hbs @@ -66,6 +66,10 @@ Download Sketch + {{#if displayStatus}} + Deploy Analytics Artifacts + {{/if}} + @@ -291,6 +295,27 @@ + + {{#zone "topCss"}} {{css "css/styles.css"}} {{/zone}} diff --git a/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.type-view/type-view.js b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.type-view/type-view.js new file mode 100644 index 000000000..2800d8f23 --- /dev/null +++ b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.type-view/type-view.js @@ -0,0 +1,37 @@ +/* + * 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. + */ + +function onRequest(context){ + var viewModel = {}; + var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"]; + var serviceInvokers = require("/app/modules/oauth/token-protected-service-invokers.js")["invokers"]; + var url = devicemgtProps["httpsURL"] + "/api/device-mgt/v1.0/admin/devicetype/deploy/arduino/status"; + serviceInvokers.XMLHttp.get( + url, function (responsePayload) { + var responseContent = responsePayload.status; + new Log().error(responseContent); + if ("204" == responsePayload.status) { + viewModel["displayStatus"] = "Display"; + } + }, + function (responsePayload) { + //do nothing. + } + ); + return viewModel; +} \ No newline at end of file diff --git a/components/device-types/arduino-plugin/pom.xml b/components/device-types/arduino-plugin/pom.xml index 9a1e801bd..f37fdec2a 100644 --- a/components/device-types/arduino-plugin/pom.xml +++ b/components/device-types/arduino-plugin/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt-plugins device-types - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT ../pom.xml diff --git a/components/device-types/pom.xml b/components/device-types/pom.xml index 16d10bd66..f64171e44 100644 --- a/components/device-types/pom.xml +++ b/components/device-types/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt-plugins carbon-device-mgt-plugins-parent - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT ../../pom.xml diff --git a/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.analytics/pom.xml b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.analytics/pom.xml index c4d33c93e..ec0649181 100644 --- a/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.analytics/pom.xml +++ b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.analytics/pom.xml @@ -21,7 +21,7 @@ raspberrypi-plugin org.wso2.carbon.devicemgt-plugins - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT ../pom.xml diff --git a/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.analytics/src/main/resources/carbonapps/raspberrypi/raspberrypi_receiver/raspberrypi_receiver.xml b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.analytics/src/main/resources/carbonapps/raspberrypi/raspberrypi_receiver/raspberrypi_receiver.xml index 9cd4a9eb4..1424b737e 100644 --- a/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.analytics/src/main/resources/carbonapps/raspberrypi/raspberrypi_receiver/raspberrypi_receiver.xml +++ b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.analytics/src/main/resources/carbonapps/raspberrypi/raspberrypi_receiver/raspberrypi_receiver.xml @@ -18,10 +18,8 @@ --> - carbon.super/raspberrypi/+/temperature - admin - admin - org.wso2.carbon.device.mgt.input.adapter.mqtt.util.MQTTContentValidator + ${tenant-domain}/raspberrypi/+/temperature + iot-mqtt true diff --git a/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/pom.xml b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/pom.xml index ddd00264e..a80de0fad 100644 --- a/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/pom.xml +++ b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/pom.xml @@ -21,7 +21,7 @@ raspberrypi-plugin org.wso2.carbon.devicemgt-plugins - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT ../pom.xml diff --git a/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/RaspberryPiServiceImpl.java b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/RaspberryPiServiceImpl.java index c0dec9973..f87439123 100644 --- a/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/RaspberryPiServiceImpl.java +++ b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/RaspberryPiServiceImpl.java @@ -141,7 +141,9 @@ public class RaspberryPiServiceImpl implements RaspberryPiService { @Produces("application/zip") public Response downloadSketch(@QueryParam("deviceName") String deviceName, @QueryParam("sketchType") String sketchType) { try { - ZipArchive zipFile = createDownloadFile(APIUtil.getAuthenticatedUser(), deviceName, sketchType); + String username = APIUtil.getAuthenticatedUser() + "@" + PrivilegedCarbonContext + .getThreadLocalCarbonContext().getTenantDomain(); + ZipArchive zipFile = createDownloadFile(username, deviceName, sketchType); Response.ResponseBuilder response = Response.ok(FileUtils.readFileToByteArray(zipFile.getZipFile())); response.status(Response.Status.OK); response.type("application/zip"); @@ -206,7 +208,8 @@ public class RaspberryPiServiceImpl implements RaspberryPiService { } if (apiApplicationKey == null) { String applicationUsername = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm() - .getRealmConfiguration().getAdminUserName(); + .getRealmConfiguration().getAdminUserName() + "@" + PrivilegedCarbonContext + .getThreadLocalCarbonContext().getTenantDomain(); APIManagementProviderService apiManagementProviderService = APIUtil.getAPIManagementProviderService(); String[] tags = {RaspberrypiConstants.DEVICE_TYPE}; apiApplicationKey = apiManagementProviderService.generateAndRetrieveApplicationKeys( diff --git a/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/pom.xml b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/pom.xml index 9d1da3d84..8c832bbf3 100644 --- a/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/pom.xml +++ b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/pom.xml @@ -23,7 +23,7 @@ raspberrypi-plugin org.wso2.carbon.devicemgt-plugins - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT ../pom.xml diff --git a/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.type-view/public/js/download.js b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.type-view/public/js/download.js index f6b9f1e64..abd0a49f5 100644 --- a/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.type-view/public/js/download.js +++ b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.type-view/public/js/download.js @@ -21,6 +21,8 @@ var modalPopupContainer = modalPopup + " .modal-content"; var modalPopupContent = modalPopup + " .modal-content"; var body = "body"; +var backendEndBasePath = "/api/device-mgt/v1.0"; + /* * set popup maximum height function. */ @@ -180,4 +182,31 @@ function doAction(data) { hidePopup(); }); } +} + +function artifactUpload() { + var contentType = "application/json"; + + var urix = backendEndBasePath + "/admin/devicetype/deploy/raspberrypi"; + var defaultStatusClasses = "fw fw-stack-1x"; + var content = $("#raspberrypi-statistic-response-template").find(".content"); + var title = content.find("#title"); + var statusIcon = content.find("#status-icon"); + var data = {} + invokerUtil.post(urix, data, function (data) { + title.html("Deploying statistic artifacts. Please wait..."); + statusIcon.attr("class", defaultStatusClasses + " fw-check"); + $(modalPopupContent).html(content.html()); + showPopup(); + setTimeout(function () { + hidePopup(); + location.reload(true); + }, 5000); + + }, function (jqXHR) { + title.html("Failed to deploy artifacts, Please contact administrator."); + statusIcon.attr("class", defaultStatusClasses + " fw-error"); + $(modalPopupContent).html(content.html()); + showPopup(); + }, contentType); } \ No newline at end of file diff --git a/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.type-view/type-view.hbs b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.type-view/type-view.hbs index 8b645b36a..000e232a4 100644 --- a/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.type-view/type-view.hbs +++ b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.type-view/type-view.hbs @@ -61,6 +61,10 @@ Download Agent + {{#if displayStatus}} + Deploy Analytics Artifacts + {{/if}} + @@ -275,6 +279,27 @@ + + {{#zone "topCss"}} {{css "css/styles.css"}} {{/zone}} diff --git a/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.type-view/type-view.js b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.type-view/type-view.js new file mode 100644 index 000000000..ef40e6ebe --- /dev/null +++ b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.type-view/type-view.js @@ -0,0 +1,37 @@ +/* + * 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. + */ + +function onRequest(context){ + var viewModel = {}; + var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"]; + var serviceInvokers = require("/app/modules/oauth/token-protected-service-invokers.js")["invokers"]; + var url = devicemgtProps["httpsURL"] + "/api/device-mgt/v1.0/admin/devicetype/deploy/raspberrypi/status"; + serviceInvokers.XMLHttp.get( + url, function (responsePayload) { + var responseContent = responsePayload.status; + new Log().error(responseContent); + if ("204" == responsePayload.status) { + viewModel["displayStatus"] = "Display"; + } + }, + function (responsePayload) { + //do nothing. + } + ); + return viewModel; +} \ No newline at end of file diff --git a/components/device-types/raspberrypi-plugin/pom.xml b/components/device-types/raspberrypi-plugin/pom.xml index 1c2399971..15fec876b 100644 --- a/components/device-types/raspberrypi-plugin/pom.xml +++ b/components/device-types/raspberrypi-plugin/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt-plugins device-types - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT ../pom.xml diff --git a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/pom.xml b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/pom.xml index f4dea9291..d739f8d11 100644 --- a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/pom.xml +++ b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/pom.xml @@ -23,7 +23,7 @@ virtual-fire-alarm-plugin org.wso2.carbon.devicemgt-plugins - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT ../pom.xml diff --git a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/pom.xml b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/pom.xml index dd0913181..ec91a2e5d 100644 --- a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/pom.xml +++ b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/pom.xml @@ -23,7 +23,7 @@ virtual-fire-alarm-plugin org.wso2.carbon.devicemgt-plugins - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT ../pom.xml diff --git a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.analytics/pom.xml b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.analytics/pom.xml index 07c3cc970..436d77892 100644 --- a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.analytics/pom.xml +++ b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.analytics/pom.xml @@ -21,7 +21,7 @@ virtual-fire-alarm-plugin org.wso2.carbon.devicemgt-plugins - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT ../pom.xml diff --git a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.analytics/src/main/resources/carbonapps/virtualfirealarm/virtualfirealarm_receiver/virtualfirealarm_receiver.xml b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.analytics/src/main/resources/carbonapps/virtualfirealarm/virtualfirealarm_receiver/virtualfirealarm_receiver.xml index 7f7b3cf7f..d46fc1a56 100644 --- a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.analytics/src/main/resources/carbonapps/virtualfirealarm/virtualfirealarm_receiver/virtualfirealarm_receiver.xml +++ b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.analytics/src/main/resources/carbonapps/virtualfirealarm/virtualfirealarm_receiver/virtualfirealarm_receiver.xml @@ -18,10 +18,8 @@ --> - carbon.super/virtual_firealarm/+/temperature - admin - admin - org.wso2.carbon.device.mgt.input.adapter.mqtt.util.MQTTContentValidator + ${tenant-domain}/virtual_firealarm/+/temperature + iot-mqtt true diff --git a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/pom.xml b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/pom.xml index 890431608..024ef6b57 100644 --- a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/pom.xml +++ b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/pom.xml @@ -21,7 +21,7 @@ virtual-fire-alarm-plugin org.wso2.carbon.devicemgt-plugins - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT ../pom.xml diff --git a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/VirtualFireAlarmServiceImpl.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/VirtualFireAlarmServiceImpl.java index b283bcb3d..fbebe12f9 100644 --- a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/VirtualFireAlarmServiceImpl.java +++ b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/VirtualFireAlarmServiceImpl.java @@ -172,7 +172,9 @@ public class VirtualFireAlarmServiceImpl implements VirtualFireAlarmService { public Response downloadSketch(@QueryParam("deviceName") String deviceName, @QueryParam("sketchType") String sketchType) { try { - ZipArchive zipFile = createDownloadFile(APIUtil.getAuthenticatedUser(), deviceName, sketchType); + String user = APIUtil.getAuthenticatedUser() + "@" + PrivilegedCarbonContext.getThreadLocalCarbonContext() + .getTenantDomain(); + ZipArchive zipFile = createDownloadFile(user, deviceName, sketchType); Response.ResponseBuilder response = Response.ok(FileUtils.readFileToByteArray(zipFile.getZipFile())); response.status(Response.Status.OK); response.type("application/zip"); @@ -242,7 +244,8 @@ public class VirtualFireAlarmServiceImpl implements VirtualFireAlarmService { if (apiApplicationKey == null) { String applicationUsername = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm().getRealmConfiguration() - .getAdminUserName(); + .getAdminUserName() + "@" + PrivilegedCarbonContext.getThreadLocalCarbonContext() + .getTenantDomain(); APIManagementProviderService apiManagementProviderService = APIUtil.getAPIManagementProviderService(); String[] tags = {VirtualFireAlarmConstants.DEVICE_TYPE}; apiApplicationKey = apiManagementProviderService.generateAndRetrieveApplicationKeys( diff --git a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/pom.xml b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/pom.xml index 61d0a7ce1..7fbe10a02 100644 --- a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/pom.xml +++ b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/pom.xml @@ -23,7 +23,7 @@ virtual-fire-alarm-plugin org.wso2.carbon.devicemgt-plugins - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT ../pom.xml diff --git a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.type-view/public/js/download.js b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.type-view/public/js/download.js index 991796825..a667ef4cc 100644 --- a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.type-view/public/js/download.js +++ b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.type-view/public/js/download.js @@ -21,6 +21,8 @@ var modalPopupContainer = modalPopup + " .modal-content"; var modalPopupContent = modalPopup + " .modal-content"; var body = "body"; +var backendEndBasePath = "/api/device-mgt/v1.0"; + /* * Set popup maximum height function. */ @@ -132,4 +134,31 @@ function doAction(data) { hideAgentDownloadPopup(); }); } +} + +function artifactUpload() { + var contentType = "application/json"; + + var urix = backendEndBasePath + "/admin/devicetype/deploy/virtual_firealarm"; + var defaultStatusClasses = "fw fw-stack-1x"; + var content = $("#virtualfirealarm-statistic-response-template").find(".content"); + var title = content.find("#title"); + var statusIcon = content.find("#status-icon"); + var data = {} + invokerUtil.post(urix, data, function (data) { + title.html("Deploying statistic artifacts. Please wait..."); + statusIcon.attr("class", defaultStatusClasses + " fw-check"); + $(modalPopupContent).html(content.html()); + showPopup(); + setTimeout(function () { + hidePopup(); + location.reload(true); + }, 5000); + + }, function (jqXHR) { + title.html("Failed to deploy artifacts, Please contact administrator."); + statusIcon.attr("class", defaultStatusClasses + " fw-error"); + $(modalPopupContent).html(content.html()); + showPopup(); + }, contentType); } \ No newline at end of file diff --git a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.type-view/type-view.hbs b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.type-view/type-view.hbs index c37a9b9c0..922ace659 100644 --- a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.type-view/type-view.hbs +++ b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.type-view/type-view.hbs @@ -54,6 +54,10 @@ Download Agent + {{#if displayStatus}} + Deploy Analytics Artifacts + {{/if}} + @@ -260,6 +264,27 @@ + + {{#zone "topCss"}} {{css "css/styles.css"}} {{/zone}} diff --git a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.type-view/type-view.js b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.type-view/type-view.js new file mode 100644 index 000000000..ea24f499c --- /dev/null +++ b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.type-view/type-view.js @@ -0,0 +1,37 @@ +/* + * 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. + */ + +function onRequest(context){ + var viewModel = {}; + var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"]; + var serviceInvokers = require("/app/modules/oauth/token-protected-service-invokers.js")["invokers"]; + var url = devicemgtProps["httpsURL"] + "/api/device-mgt/v1.0/admin/devicetype/deploy/virtual_firealarm/status"; + serviceInvokers.XMLHttp.get( + url, function (responsePayload) { + var responseContent = responsePayload.status; + new Log().error(responseContent); + if ("204" == responsePayload.status) { + viewModel["displayStatus"] = "Display"; + } + }, + function (responsePayload) { + //do nothing. + } + ); + return viewModel; +} \ No newline at end of file diff --git a/components/device-types/virtual-fire-alarm-plugin/pom.xml b/components/device-types/virtual-fire-alarm-plugin/pom.xml index 46079dba4..935d73e49 100644 --- a/components/device-types/virtual-fire-alarm-plugin/pom.xml +++ b/components/device-types/virtual-fire-alarm-plugin/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt-plugins device-types - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT ../pom.xml diff --git a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/pom.xml b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/pom.xml index 7f9dfbd45..f81aedf64 100644 --- a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/pom.xml +++ b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/pom.xml @@ -18,7 +18,7 @@ org.wso2.carbon.devicemgt-plugins appm-connector - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT ../pom.xml diff --git a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/pom.xml b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/pom.xml new file mode 100644 index 000000000..f36fdd337 --- /dev/null +++ b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/pom.xml @@ -0,0 +1,125 @@ + + + + + org.wso2.carbon.devicemgt-plugins + appm-connector + 3.0.12-SNAPSHOT + ../pom.xml + + + 4.0.0 + org.wso2.carbon.appmgt.mdm.restconnector + bundle + WSO2 Carbon - App Manager WSO2 MDM REST Connector Component + http://maven.apache.org + + + + + org.apache.felix + maven-scr-plugin + + + generate-scr-scrdescriptor + + scr + + + + + + org.apache.felix + maven-bundle-plugin + true + + + ${project.artifactId} + ${project.artifactId} + org.wso2.carbon.appmgt.mdm.restconnector.internal + + org.osgi.framework, + org.osgi.service.component, + org.wso2.carbon.appmgt.mobile.utils.*, + org.wso2.carbon.appmgt.mobile.mdm.*, + org.wso2.carbon.appmgt.mobile.interfaces.*, + org.apache.commons.*, + org.wso2.carbon.user.core.service, + org.wso2.carbon.user.core.tenant, + org.wso2.carbon.user.api, + feign, + feign.auth, + feign.codec, + feign.gson, + org.json.simple.*, + org.wso2.carbon.appmgt.mobile.beans, + org.wso2.carbon.context + + + !org.wso2.carbon.appmgt.mdm.restconnector.internal, + org.wso2.carbon.appmgt.mdm.restconnector.* + + + jsr311-api, + feign-jaxrs + + + + + + + + + + com.googlecode.json-simple.wso2 + json-simple + + + org.wso2.carbon + org.wso2.carbon.logging + + + org.wso2.carbon.devicemgt + org.wso2.carbon.identity.jwt.client.extension + + + io.github.openfeign + feign-core + + + io.github.openfeign + feign-jaxrs + + + io.github.openfeign + feign-gson + + + javax.ws.rs + jsr311-api + + + io.swagger + swagger-jaxrs + + + org.wso2.carbon.appmgt + org.wso2.carbon.appmgt.mobile + + + + diff --git a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/ApplicationOperationsImpl.java b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/ApplicationOperationsImpl.java new file mode 100644 index 000000000..949407f02 --- /dev/null +++ b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/ApplicationOperationsImpl.java @@ -0,0 +1,274 @@ +/* + * Copyright (c) 2017, 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.appmgt.mdm.restconnector; + +import feign.Feign; +import feign.gson.GsonDecoder; +import feign.gson.GsonEncoder; +import feign.jaxrs.JAXRSContract; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.json.simple.JSONObject; +import org.json.simple.parser.JSONParser; +import org.json.simple.parser.ParseException; +import org.wso2.carbon.appmgt.mdm.restconnector.authorization.client.OAuthRequestInterceptor; +import org.wso2.carbon.appmgt.mdm.restconnector.authorization.client.dto.Activity; +import org.wso2.carbon.appmgt.mdm.restconnector.authorization.client.dto.ApplicationManagementAdminService; +import org.wso2.carbon.appmgt.mdm.restconnector.authorization.client.dto.ApplicationWrapper; +import org.wso2.carbon.appmgt.mdm.restconnector.authorization.client.dto.DeviceManagementAdminService; +import org.wso2.carbon.appmgt.mdm.restconnector.authorization.client.dto.MobileApp; +import org.wso2.carbon.appmgt.mdm.restconnector.authorization.client.dto.MobileAppTypes; +import org.wso2.carbon.appmgt.mdm.restconnector.config.AuthorizationConfigurationManager; +import org.wso2.carbon.appmgt.mobile.beans.ApplicationOperationAction; +import org.wso2.carbon.appmgt.mobile.beans.ApplicationOperationDevice; +import org.wso2.carbon.appmgt.mobile.beans.DeviceIdentifier; +import org.wso2.carbon.appmgt.mobile.interfaces.ApplicationOperations; +import org.wso2.carbon.appmgt.mobile.mdm.App; +import org.wso2.carbon.appmgt.mobile.mdm.Device; +import org.wso2.carbon.appmgt.mobile.utils.MobileApplicationException; +import org.wso2.carbon.appmgt.mobile.utils.MobileConfigurations; +import org.wso2.carbon.context.PrivilegedCarbonContext; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Properties; + +public class ApplicationOperationsImpl implements ApplicationOperations { + private static final String CDMF_SERVER_BASE_CONTEXT = "/api/device-mgt/v1.0"; + private static DeviceManagementAdminService deviceManagementAdminService; + private static final Log log = LogFactory.getLog(ApplicationOperationsImpl.class); + private static ApplicationManagementAdminService applicationManagementAdminService; + + /** + * Constructor. + */ + public ApplicationOperationsImpl() { + String authorizationConfigManagerServerURL = AuthorizationConfigurationManager.getInstance().getServerURL(); + OAuthRequestInterceptor oAuthRequestInterceptor = new OAuthRequestInterceptor(); + deviceManagementAdminService = Feign.builder() + .requestInterceptor(oAuthRequestInterceptor) + .contract(new JAXRSContract()).encoder(new GsonEncoder()).decoder(new GsonDecoder()) + .target(DeviceManagementAdminService.class, + authorizationConfigManagerServerURL + CDMF_SERVER_BASE_CONTEXT); + applicationManagementAdminService = Feign.builder() + .requestInterceptor(oAuthRequestInterceptor) + .contract(new JAXRSContract()).encoder(new GsonEncoder()).decoder(new GsonDecoder()) + .target(ApplicationManagementAdminService.class, + authorizationConfigManagerServerURL + CDMF_SERVER_BASE_CONTEXT); + } + + /** + * Install, uninstall, reinstall application in devices. + * + * @param applicationOperationAction {@link ApplicationOperationAction} object + * @return Activity id + * @throws MobileApplicationException on errors while trying to perform action in devices + */ + @Override + public String performAction(ApplicationOperationAction applicationOperationAction) + throws MobileApplicationException { + ApplicationWrapper applicationWrapper = new ApplicationWrapper(); + MobileApp mobileApp = new MobileApp(); + + String type = applicationOperationAction.getType(); + String[] params = applicationOperationAction.getParams(); + int tenantId = applicationOperationAction.getTenantId(); + + PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(tenantId); + + List deviceIdentifiers = new ArrayList<>(); + List deviceList; + if (Constants.USER.equals(type)) { + String platform = applicationOperationAction.getApp().getPlatform(); + String userName; + for (String param : params) { + userName = param; + deviceList = deviceManagementAdminService.getDevices(userName, null).getList(); + + for (org.wso2.carbon.appmgt.mdm.restconnector.authorization.client.dto.Device device : deviceList) { + if (Constants.WEBAPP.equals(platform) || platform.equalsIgnoreCase(device.getType())) { + if (Constants.ACTIVE.equalsIgnoreCase(device.getEnrolmentInfo().getStatus().toString())) { + deviceIdentifiers.add(getDeviceIdentifierByDevice(device)); + } + } + } + } + } else if (Constants.ROLE.equals(type)) { + String userRole; + for (String param : applicationOperationAction.getParams()) { + userRole = param; + deviceList = deviceManagementAdminService.getDevices(null, userRole).getList(); + for (org.wso2.carbon.appmgt.mdm.restconnector.authorization.client.dto.Device device : deviceList) { + if (Constants.ACTIVE.equalsIgnoreCase(device.getEnrolmentInfo().getStatus().toString())) { + deviceIdentifiers.add(getDeviceIdentifierByDevice(device)); + } + } + } + } else if (Constants.DEVICE.equals(type)) { + DeviceIdentifier deviceIdentifier; + for (String param : params) { + deviceIdentifier = new DeviceIdentifier(); + if (isValidJSON(param)) { + JSONParser parser = new JSONParser(); + try { + JSONObject parsedObj = (JSONObject) parser.parse(param); + deviceIdentifier.setId((String) parsedObj.get(Constants.ID)); + String deviceType = (String) parsedObj.get(Constants.TYPE); + deviceIdentifier.setType(deviceType); + deviceIdentifiers.add(deviceIdentifier); + } catch (ParseException e) { + throw new MobileApplicationException("Device Identifier is not valid json object.", e); + } + } + } + } else { + throw new IllegalStateException("Invalid type is received from app store."); + } + + App app = applicationOperationAction.getApp(); + mobileApp.setId(app.getId()); + mobileApp.setType(MobileAppTypes.valueOf(app.getType().toUpperCase())); + mobileApp.setAppIdentifier(app.getAppIdentifier()); + mobileApp.setIconImage(app.getIconImage()); + mobileApp.setIdentifier(app.getIdentifier()); + mobileApp.setLocation(app.getLocation()); + mobileApp.setName(app.getName()); + mobileApp.setPackageName(app.getPackageName()); + mobileApp.setPlatform(app.getPlatform()); + mobileApp.setVersion(app.getVersion()); + Properties mobileAppProperties = new Properties(); + + if (Constants.IOS.equals(app.getPlatform())) { + if (Constants.ENTERPRISE.equals(app.getType())) { + mobileAppProperties.put(Constants.IOSConstants.IS_REMOVE_APP, true); + mobileAppProperties.put(Constants.IOSConstants.IS_PREVENT_BACKUP, true); + } else if (Constants.IOSConstants.PUBLIC.equals(app.getType())) { + mobileAppProperties.put(Constants.IOSConstants.I_TUNES_ID, app.getIdentifier()); + mobileAppProperties.put(Constants.IOSConstants.IS_REMOVE_APP, true); + mobileAppProperties.put(Constants.IOSConstants.IS_PREVENT_BACKUP, true); + } else if (Constants.WEBAPP.equals(app.getType())) { + mobileAppProperties.put(Constants.IOSConstants.LABEL, app.getName()); + mobileAppProperties.put(Constants.IOSConstants.IS_REMOVE_APP, true); + } + } else if (Constants.WEBAPP.equals(app.getPlatform())) { + mobileAppProperties.put(Constants.IOSConstants.LABEL, app.getName()); + mobileAppProperties.put(Constants.IOSConstants.IS_REMOVE_APP, true); + } + mobileApp.setProperties(mobileAppProperties); + applicationWrapper.setApplication(mobileApp); + Activity activity = null; + + if (deviceIdentifiers.size() > 0) { + applicationWrapper.setDeviceIdentifiers(deviceIdentifiers); + if (Constants.INSTALL.equals(applicationOperationAction.getAction())) { + activity = applicationManagementAdminService.installApplication(applicationWrapper); + } else if (Constants.UPDATE.equals(applicationOperationAction.getAction())) { + activity = applicationManagementAdminService.installApplication(applicationWrapper); + } else { + activity = applicationManagementAdminService.uninstallApplication(applicationWrapper); + } + } + + if (activity != null) { + return activity.getActivityId(); + } + return null; + } + + /** + * Get devices. + * + * @param applicationOperationDevice {@link ApplicationOperationAction} object + * @return list of {@link Device} objects + * @throws MobileApplicationException on errors while trying to get devices list + */ + @Override + public List getDevices(ApplicationOperationDevice applicationOperationDevice) + throws MobileApplicationException { + Map queryParamsMap = new HashMap<>(); + String platform = applicationOperationDevice.getPlatform(); + String platformVersion = applicationOperationDevice.getPlatformVersion(); + String userName = applicationOperationDevice.getCurrentUser().getUsername(); + queryParamsMap.put(Constants.PLATFORM, platform); + queryParamsMap.put(Constants.PLATFORM_VERSION, platformVersion); + queryParamsMap.put(Constants.USER, userName); + String type = applicationOperationDevice.getType(); + queryParamsMap.put(Constants.TYPE, type); + List deviceList = + deviceManagementAdminService.getDevices(userName, null).getList(); + + List processedDevices = new ArrayList<>(); + for (org.wso2.carbon.appmgt.mdm.restconnector.authorization.client.dto.Device device : deviceList) { + Device processedDevice = new Device(); + DeviceIdentifier deviceIdentifier = new DeviceIdentifier(); + deviceIdentifier.setId(device.getDeviceIdentifier().toString()); + deviceIdentifier.setType(device.getType().toString()); + processedDevice.setDeviceIdentifier(deviceIdentifier); + processedDevice.setName(device.getName()); + processedDevice.setModel(device.getName()); + processedDevice.setType(device.getType()); + String imgUrl; + if (Constants.ANDROID.equalsIgnoreCase((device.getType().toString()))) { + imgUrl = String.format(getActiveMDMProperties().get(Constants.PROPERTY_IMAGE_URL), Constants.NEXUS); + } else if (Constants.IOS.equalsIgnoreCase((device.getType().toString()))) { + imgUrl = String.format(getActiveMDMProperties().get(Constants.PROPERTY_IMAGE_URL), Constants.IPHONE); + } else { + imgUrl = String.format(getActiveMDMProperties().get(Constants.PROPERTY_IMAGE_URL), Constants.NONE); + } + processedDevice.setImage(imgUrl); + processedDevice.setPlatform(device.getType().toString()); + processedDevices.add(processedDevice); + } + return processedDevices; + + } + + private HashMap getActiveMDMProperties() { + MobileConfigurations configurations = MobileConfigurations.getInstance(); + return configurations.getActiveMDMProperties(); + } + + private static DeviceIdentifier getDeviceIdentifierByDevice( + org.wso2.carbon.appmgt.mdm.restconnector.authorization.client.dto.Device device) { + DeviceIdentifier deviceIdentifier = new DeviceIdentifier(); + deviceIdentifier.setId(device.getDeviceIdentifier()); + deviceIdentifier.setType(device.getType()); + + return deviceIdentifier; + } + + private boolean isValidJSON(String json) { + JSONParser parser = new JSONParser(); + try { + parser.parse(json); + } catch (ParseException e) { + return false; + } + return true; + } + + private void logError(String errorMessage, Throwable e) { + if (log.isDebugEnabled()) { + log.error(errorMessage, e); + } else { + log.error(errorMessage); + } + } +} \ No newline at end of file diff --git a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/Constants.java b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/Constants.java new file mode 100644 index 000000000..1721fc1a7 --- /dev/null +++ b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/Constants.java @@ -0,0 +1,108 @@ +/* + * Copyright (c) 2017, 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.appmgt.mdm.restconnector; + +public class Constants { + public static final String PROPERTY_SERVER_URL = "ServerURL"; + public static final String PROPERTY_TOKEN_API_URL = "TokenApiURL"; + public static final String PROPERTY_IMAGE_URL = "ImageURL"; + public static final String PROPERTY_TOKEN_REFRESH_TIME_OFFSET = "TokenRefreshTimeOffset"; + public static final String PROPERTY_USERNAME = "Username"; + public static final String PROPERTY_PASSWORD = "Password"; + + public static final String USER = "user"; + public static final String ROLE = "role"; + public static final String USERS = USER + "s"; + public static final String ROLES = ROLE + "s"; + public static final String ANDROID = "android"; + public static final String IOS = "ios"; + public static final String WEBAPP = "webapp"; + public static final String PLATFORM = "platform"; + public static final String PLATFORM_VERSION = "platformVersion"; + public static final String PROPERTIES = "properties"; + public static final String TYPE = "type"; + public static final String TYPES = TYPE + "s"; + public static final String ID = "id"; + public static final String NAME = "name"; + public static final String USER_LIST = "userList"; + public static final String DEVICE_IDENTIFIER = "deviceIdentifier"; + public static final String DEVICE_IDENTIFIERS = DEVICE_IDENTIFIER + "s"; + public static final String DEVICES = "devices"; + public static final String APPLICATION = "application"; + public static final String NEXUS = "nexus"; + public static final String IPHONE = "iphone"; + public static final String NONE = "none"; + public static final String INSTALL = "install"; + public static final String UPDATE = "update"; + public static final String MOBILE_DEVICE = "mobileDevice"; + public static final String ENTERPRISE = "enterprise"; + public static final String ACTIVE = "active"; + public static final String DEVICE = "device"; + + + public class IOSConstants { + + private IOSConstants() { + throw new AssertionError(); + } + + public static final String IS_REMOVE_APP = "isRemoveApp"; + public static final String IS_PREVENT_BACKUP = "isPreventBackup"; + public static final String I_TUNES_ID = "iTunesId"; + public static final String LABEL = "label"; + public static final String PUBLIC = "public"; + public static final String OPCODE_INSTALL_ENTERPRISE_APPLICATION = + "INSTALL_ENTERPRISE_APPLICATION"; + public static final String OPCODE_INSTALL_STORE_APPLICATION = "INSTALL_STORE_APPLICATION"; + public static final String OPCODE_INSTALL_WEB_APPLICATION = "WEB_CLIP"; + public static final String OPCODE_REMOVE_APPLICATION = "REMOVE_APPLICATION"; + } + + public class AndroidConstants { + private AndroidConstants() { + throw new AssertionError(); + } + + public static final String OPCODE_INSTALL_APPLICATION = "INSTALL_APPLICATION"; + public static final String OPCODE_UPDATE_APPLICATION = "UPDATE_APPLICATION"; + public static final String OPCODE_UNINSTALL_APPLICATION = "UNINSTALL_APPLICATION"; + } + + public class WebAppConstants { + public static final String WEBAPP = "webapp"; + public static final String LABEL = "label"; + public static final String IS_REMOVE_APP = "isRemoveApp"; + public static final String NAME = "name"; + } + + public class RestConstants { + public static final String USERNAME = "username"; + public static final String PASSWORD = "password"; + public static final String AUTHORIZATION = "Authorization"; + public static final String BEARER = "Bearer "; + public static final String BASIC = "Basic "; + public static final String COLON = ":"; + public static final String GRANT_TYPE = "grant_type"; + public static final String CONTENT_TYPE = "Content-Type"; + public static final String ACCESS_TOKEN = "accessToken"; + public static final String ACCEPT = "Accept"; + public static final String APPLICATION_JSON = "application/json"; + public static final String APPLICATION_FORM_URL_ENCODED = "application/x-www-form-urlencoded"; + } + +} diff --git a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/OAuthRequestInterceptor.java b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/OAuthRequestInterceptor.java new file mode 100755 index 000000000..48bf79df8 --- /dev/null +++ b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/OAuthRequestInterceptor.java @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2017, 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.appmgt.mdm.restconnector.authorization.client; + +import feign.Feign; +import feign.RequestInterceptor; +import feign.RequestTemplate; +import feign.auth.BasicAuthRequestInterceptor; +import feign.gson.GsonDecoder; +import feign.gson.GsonEncoder; +import feign.jaxrs.JAXRSContract; +import org.wso2.carbon.appmgt.mdm.restconnector.Constants; +import org.wso2.carbon.appmgt.mdm.restconnector.authorization.client.dto.AccessTokenInfo; +import org.wso2.carbon.appmgt.mdm.restconnector.authorization.client.dto.ApiApplicationKey; +import org.wso2.carbon.appmgt.mdm.restconnector.authorization.client.dto.ApiApplicationRegistrationService; +import org.wso2.carbon.appmgt.mdm.restconnector.authorization.client.dto.ApiRegistrationProfile; +import org.wso2.carbon.appmgt.mdm.restconnector.authorization.client.dto.TokenIssuerService; +import org.wso2.carbon.appmgt.mdm.restconnector.config.AuthorizationConfigurationManager; +import org.wso2.carbon.appmgt.mdm.restconnector.internal.AuthorizationDataHolder; + +/** + * This is a request interceptor to add oauth token header. + */ +public class OAuthRequestInterceptor implements RequestInterceptor { + private AccessTokenInfo tokenInfo; + private String refreshTimeOffset; + private static final String API_APPLICATION_REGISTRATION_CONTEXT = "/api-application-registration"; + private static final String DEVICE_MANAGEMENT_SERVICE_TAG[] = {"device_management"}; + private static final String APPLICATION_NAME = "appm_restconnector_application"; + private static final String PASSWORD_GRANT_TYPE = "password"; + private static final String REFRESH_GRANT_TYPE = "refresh_token"; + private ApiApplicationRegistrationService apiApplicationRegistrationService; + private TokenIssuerService tokenIssuerService; + + /** + * Creates an interceptor that authenticates all requests. + */ + public OAuthRequestInterceptor() { + refreshTimeOffset = AuthorizationConfigurationManager.getInstance().getTokenRefreshTimeOffset(); + String username = AuthorizationConfigurationManager.getInstance().getUserName(); + String password = AuthorizationConfigurationManager.getInstance().getPassword(); + apiApplicationRegistrationService = Feign.builder().requestInterceptor( + new BasicAuthRequestInterceptor(username, password)) + .contract(new JAXRSContract()).encoder(new GsonEncoder()).decoder(new GsonDecoder()) + .target(ApiApplicationRegistrationService.class, + AuthorizationConfigurationManager.getInstance().getServerURL() + + API_APPLICATION_REGISTRATION_CONTEXT); + AuthorizationDataHolder.getInstance().setApiApplicationRegistrationService(apiApplicationRegistrationService); + + } + + /** + * Api create. + * + * @param template {@link RequestTemplate} object + */ + @Override + public void apply(RequestTemplate template) { + if (tokenInfo == null) { + ApiRegistrationProfile apiRegistrationProfile = new ApiRegistrationProfile(); + apiRegistrationProfile.setApplicationName(APPLICATION_NAME); + apiRegistrationProfile.setIsAllowedToAllDomains(false); + apiRegistrationProfile.setIsMappingAnExistingOAuthApp(false); + apiRegistrationProfile.setTags(DEVICE_MANAGEMENT_SERVICE_TAG); + ApiApplicationKey apiApplicationKey = apiApplicationRegistrationService.register(apiRegistrationProfile); + String consumerKey = apiApplicationKey.getConsumerKey(); + String consumerSecret = apiApplicationKey.getConsumerSecret(); + String username = AuthorizationConfigurationManager.getInstance().getUserName(); + String password = AuthorizationConfigurationManager.getInstance().getPassword(); + tokenIssuerService = Feign.builder().requestInterceptor( + new BasicAuthRequestInterceptor(consumerKey, consumerSecret)) + .contract(new JAXRSContract()).encoder(new GsonEncoder()).decoder(new GsonDecoder()) + .target(TokenIssuerService.class, AuthorizationConfigurationManager.getInstance().getTokenApiURL()); + tokenInfo = tokenIssuerService.getToken(PASSWORD_GRANT_TYPE, username, password); + tokenInfo.setExpires_in(System.currentTimeMillis() + tokenInfo.getExpires_in()); + } + synchronized (this) { + if (System.currentTimeMillis() + Long.parseLong(refreshTimeOffset) > tokenInfo.getExpires_in()) { + tokenInfo = tokenIssuerService.getToken(REFRESH_GRANT_TYPE, tokenInfo.getRefresh_token()); + tokenInfo.setExpires_in(System.currentTimeMillis() + tokenInfo.getExpires_in()); + } + } + String headerValue = Constants.RestConstants.BEARER + tokenInfo.getAccess_token(); + template.header(Constants.RestConstants.AUTHORIZATION, headerValue); + } +} diff --git a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/dto/AccessTokenInfo.java b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/dto/AccessTokenInfo.java new file mode 100755 index 000000000..f315ae116 --- /dev/null +++ b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/dto/AccessTokenInfo.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2017, 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.appmgt.mdm.restconnector.authorization.client.dto; + +/** + * This hold access token info that returned from the api call. + */ +public class AccessTokenInfo { + public String token_type; + public long expires_in; + public String refresh_token; + public String access_token; + + public String getToken_type() { + return token_type; + } + + public void setToken_type(String token_type) { + this.token_type = token_type; + } + + public long getExpires_in() { + return expires_in; + } + + public void setExpires_in(long expires_in) { + this.expires_in = expires_in; + } + + public String getRefresh_token() { + return refresh_token; + } + + public void setRefresh_token(String refresh_token) { + this.refresh_token = refresh_token; + } + + public String getAccess_token() { + return access_token; + } + + public void setAccess_token(String access_token) { + this.access_token = access_token; + } +} diff --git a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/dto/Activity.java b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/dto/Activity.java new file mode 100644 index 000000000..b373a1c63 --- /dev/null +++ b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/dto/Activity.java @@ -0,0 +1,63 @@ +/* + * 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.appmgt.mdm.restconnector.authorization.client.dto; + + +public class Activity { + + public enum Type { + CONFIG, MESSAGE, INFO, COMMAND, PROFILE, POLICY + } + private String activityId; + private String code; + private Type type; + private String createdTimeStamp; + + public String getActivityId() { + return activityId; + } + + public void setActivityId(String activityId) { + this.activityId = activityId; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public Type getType() { + return type; + } + + public void setType(Type type) { + this.type = type; + } + + public String getCreatedTimeStamp() { + return createdTimeStamp; + } + + public void setCreatedTimeStamp(String createdTimeStamp) { + this.createdTimeStamp = createdTimeStamp; + } +} + diff --git a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/dto/ApiApplicationKey.java b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/dto/ApiApplicationKey.java new file mode 100644 index 000000000..0c34147e2 --- /dev/null +++ b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/dto/ApiApplicationKey.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2017, 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.appmgt.mdm.restconnector.authorization.client.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/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/dto/ApiApplicationRegistrationService.java b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/dto/ApiApplicationRegistrationService.java new file mode 100755 index 000000000..65f5db187 --- /dev/null +++ b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/dto/ApiApplicationRegistrationService.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2017, 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.appmgt.mdm.restconnector.authorization.client.dto; + +import javax.ws.rs.Consumes; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; + +/** + * This is the application registration service that exposed for apimApplicationRegistration. + */ + +@Path("/register") +public interface ApiApplicationRegistrationService { + + /** + * This method is used to register api application. + * + * @param registrationProfile contains the necessary attributes that are needed in order to register an app + */ + @POST + @Produces(MediaType.APPLICATION_JSON) + @Consumes(MediaType.APPLICATION_JSON) + ApiApplicationKey register(ApiRegistrationProfile registrationProfile); +} diff --git a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/dto/ApiRegistrationProfile.java b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/dto/ApiRegistrationProfile.java new file mode 100755 index 000000000..15179e1a9 --- /dev/null +++ b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/dto/ApiRegistrationProfile.java @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2017, 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.appmgt.mdm.restconnector.authorization.client.dto; + + +/** + * This class represents the data that are required to register the oauth application. + */ +public class ApiRegistrationProfile { + public String applicationName; + public String tags[]; + public boolean isAllowedToAllDomains; + public String consumerKey; + public String consumerSecret; + public boolean isMappingAnExistingOAuthApp; + + public String getApplicationName() { + return applicationName; + } + + public void setApplicationName(String applicationName) { + this.applicationName = applicationName; + } + + public String[] getTags() { + return tags; + } + + public void setTags(String[] tags) { + this.tags = tags; + } + + public boolean isAllowedToAllDomains() { + return isAllowedToAllDomains; + } + + public void setIsAllowedToAllDomains(boolean isAllowedToAllDomains) { + this.isAllowedToAllDomains = isAllowedToAllDomains; + } + + public boolean isMappingAnExistingOAuthApp() { + return isMappingAnExistingOAuthApp; + } + + public void setIsMappingAnExistingOAuthApp(boolean isMappingAnExistingOAuthApp) { + this.isMappingAnExistingOAuthApp = isMappingAnExistingOAuthApp; + } + + public String getConsumerKey() { + return consumerKey; + } + + public void setConsumerKey(String consumerKey) { + this.consumerKey = consumerKey; + } + + public String getConsumerSecret() { + return consumerSecret; + } + + public void setConsumerSecret(String consumerSecret) { + this.consumerSecret = consumerSecret; + } +} \ No newline at end of file diff --git a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/dto/ApplicationManagementAdminService.java b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/dto/ApplicationManagementAdminService.java new file mode 100644 index 000000000..e48e8e5c1 --- /dev/null +++ b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/dto/ApplicationManagementAdminService.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2017, 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.appmgt.mdm.restconnector.authorization.client.dto; + + +import javax.ws.rs.Consumes; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; + +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +@Path("/admin/applications") + +/** + * This interface provided the definition of the application management service. + */ +public interface ApplicationManagementAdminService { + + /** + * Install application. + * + * @param applicationWrapper {@link ApplicationWrapper} object + * @return {@link Activity} object + */ + @POST + @Path("/install-application") + @Produces(MediaType.APPLICATION_JSON) + @Consumes(MediaType.APPLICATION_JSON) + Activity installApplication(ApplicationWrapper applicationWrapper); + + /** + * Uninstall application. + * + * @param applicationWrapper {@link ApplicationWrapper} object + * @return {@link Activity} object + */ + @POST + @Path("/uninstall-application") + @Produces(MediaType.APPLICATION_JSON) + @Consumes(MediaType.APPLICATION_JSON) + Activity uninstallApplication(ApplicationWrapper applicationWrapper); +} \ No newline at end of file diff --git a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/dto/ApplicationWrapper.java b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/dto/ApplicationWrapper.java new file mode 100644 index 000000000..4e0d497d1 --- /dev/null +++ b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/dto/ApplicationWrapper.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2017, 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.appmgt.mdm.restconnector.authorization.client.dto; + +import org.wso2.carbon.appmgt.mobile.beans.DeviceIdentifier; + +import java.util.List; + +/** + * This DTO class is used to send application details and devices details to installation/uninstallation service. + */ +public class ApplicationWrapper { + private List userNameList; + private List roleNameList; + private List deviceIdentifiers; + private MobileApp application; + + public List getUserNameList() { + return userNameList; + } + + public void setUserNameList(List userNameList) { + this.userNameList = userNameList; + } + + public List getDeviceIdentifiers() { + return deviceIdentifiers; + } + + public void setDeviceIdentifiers( + List deviceIdentifiers) { + this.deviceIdentifiers = deviceIdentifiers; + } + + public List getRoleNameList() { + return roleNameList; + } + + public void setRoleNameList(List roleNameList) { + this.roleNameList = roleNameList; + } + + public MobileApp getApplication() { + return application; + } + + public void setApplication(MobileApp application) { + this.application = application; + } +} diff --git a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/dto/Device.java b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/dto/Device.java new file mode 100644 index 000000000..96af8865a --- /dev/null +++ b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/dto/Device.java @@ -0,0 +1,121 @@ +/* + * Copyright (c) 2017, 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.appmgt.mdm.restconnector.authorization.client.dto; + +import java.io.Serializable; + +/** + * The DTO class of device. + */ +public class Device implements Serializable { + private static final long serialVersionUID = 1998101711L; + private int id; + private String name; + private String type; + private String description; + private String deviceIdentifier; + private EnrolmentInfo enrolmentInfo; + + public Device() { + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getDeviceIdentifier() { + return deviceIdentifier; + } + + public void setDeviceIdentifier(String deviceIdentifier) { + this.deviceIdentifier = deviceIdentifier; + } + + public EnrolmentInfo getEnrolmentInfo() { + return enrolmentInfo; + } + + public void setEnrolmentInfo(EnrolmentInfo enrolmentInfo) { + this.enrolmentInfo = enrolmentInfo; + } + + public static class Property { + + private String name; + private String value; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + } + + @Override + public String toString() { + return "device [" + + "name=" + name + ";" + + "type=" + type + ";" + + "description=" + description + ";" + + "identifier=" + deviceIdentifier + ";" + + "EnrolmentInfo[" + + "owner=" + enrolmentInfo.getOwner() + ";" + + "ownership=" + enrolmentInfo.getOwnership() + ";" + + "status=" + enrolmentInfo.getStatus() + ";" + + "]" + + "]"; + } +} diff --git a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/dto/DeviceList.java b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/dto/DeviceList.java new file mode 100644 index 000000000..6470910c2 --- /dev/null +++ b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/dto/DeviceList.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2017, 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.appmgt.mdm.restconnector.authorization.client.dto; + +import java.util.ArrayList; +import java.util.List; + +public class DeviceList { + private List devices = new ArrayList<>(); + private int count; + + public int getCount() { + return count; + } + + public void setCount(int count) { + this.count = count; + } + + public List getList() { + return devices; + } + + public void setList(List devices) { + this.devices = devices; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{\n"); + + sb.append(" count: ").append(getCount()).append(",\n"); + sb.append(" devices: [").append(devices).append("\n"); + sb.append("]}\n"); + return sb.toString(); + } +} \ No newline at end of file diff --git a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/dto/DeviceManagementAdminService.java b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/dto/DeviceManagementAdminService.java new file mode 100644 index 000000000..0bed67b3a --- /dev/null +++ b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/dto/DeviceManagementAdminService.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2017, 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.appmgt.mdm.restconnector.authorization.client.dto; + + +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; + + +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +@Path("/devices") + +/** + * This interface provided the definition of the device management service. + */ +public interface DeviceManagementAdminService { + /** + * Get devices. + * + * @param user Username + * @param role Role of the user + * @return {@link DeviceList} object + */ + @GET + @Produces(MediaType.APPLICATION_JSON) + DeviceList getDevices(@QueryParam("user") String user, @QueryParam("role") String role); +} diff --git a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/dto/EnrolmentInfo.java b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/dto/EnrolmentInfo.java new file mode 100644 index 000000000..66cd08304 --- /dev/null +++ b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/dto/EnrolmentInfo.java @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2017, 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.appmgt.mdm.restconnector.authorization.client.dto; + +import java.io.Serializable; + +/** + * The DTO class for enrollment information. + */ +public class EnrolmentInfo implements Serializable { + private static final long serialVersionUID = 1998101712L; + + public enum Status { + CREATED, ACTIVE, INACTIVE, UNREACHABLE, UNCLAIMED, SUSPENDED, BLOCKED, REMOVED, DISENROLLMENT_REQUESTED + } + + public enum OwnerShip { + BYOD, COPE + } + + private int id; + private OwnerShip ownership; + private Status status; + private String owner; + private Long dateOfEnrolment; + private Long dateOfLastUpdate; + + public EnrolmentInfo() { + } + + public EnrolmentInfo(String owner, OwnerShip ownership, Status status) { + this.owner = owner; + this.ownership = ownership; + this.status = status; + } + + public Long getDateOfEnrolment() { + return dateOfEnrolment; + } + + public void setDateOfEnrolment(Long dateOfEnrolment) { + this.dateOfEnrolment = dateOfEnrolment; + } + + public Long getDateOfLastUpdate() { + return dateOfLastUpdate; + } + + public void setDateOfLastUpdate(Long dateOfLastUpdate) { + this.dateOfLastUpdate = dateOfLastUpdate; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + + public OwnerShip getOwnership() { + return ownership; + } + + public void setOwnership(OwnerShip ownership) { + this.ownership = ownership; + } + + public Status getStatus() { + return status; + } + + public void setStatus(Status status) { + this.status = status; + } + + public String getOwner() { + return owner; + } + + public void setOwner(String owner) { + this.owner = owner; + } + + @Override + public boolean equals(Object obj) { + if (obj instanceof EnrolmentInfo) { + EnrolmentInfo tempInfo = (EnrolmentInfo) obj; + if (this.owner != null && this.ownership != null) { + if (this.owner.equals(tempInfo.getOwner()) && this.ownership.equals(tempInfo.getOwnership())) { + return true; + } + } + } + return false; + } + + @Override + public int hashCode() { + return owner.hashCode() ^ ownership.hashCode(); + } +} diff --git a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/dto/MobileApp.java b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/dto/MobileApp.java new file mode 100644 index 000000000..18a7b853f --- /dev/null +++ b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/dto/MobileApp.java @@ -0,0 +1,126 @@ +/* + * Copyright (c) 2017, 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.appmgt.mdm.restconnector.authorization.client.dto; + +import java.util.Properties; + +/** + * This class represents the generic mobile Application information which is used by AppM. + */ +public class MobileApp { + + private String id; + private String name; + private MobileAppTypes type; + private String platform; + private String version; + private String identifier; + private String iconImage; + private String packageName; + private String appIdentifier; + private String location; + private Properties properties; + + public MobileAppTypes getType() { + return type; + } + + public void setType(MobileAppTypes type) { + this.type = type; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getPlatform() { + return platform; + } + + public void setPlatform(String platform) { + this.platform = platform; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getIdentifier() { + return identifier; + } + + public void setIdentifier(String identifier) { + this.identifier = identifier; + } + + public String getIconImage() { + return iconImage; + } + + public void setIconImage(String iconImage) { + this.iconImage = iconImage; + } + + public String getPackageName() { + return packageName; + } + + public void setPackageName(String packageName) { + this.packageName = packageName; + } + + public String getAppIdentifier() { + return appIdentifier; + } + + public void setAppIdentifier(String appIdentifier) { + this.appIdentifier = appIdentifier; + } + + public String getLocation() { + return location; + } + + public void setLocation(String location) { + this.location = location; + } + + public Properties getProperties() { + return properties; + } + + public void setProperties(Properties properties) { + this.properties = properties; + } +} diff --git a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/dto/MobileAppTypes.java b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/dto/MobileAppTypes.java new file mode 100644 index 000000000..f3127ab25 --- /dev/null +++ b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/dto/MobileAppTypes.java @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2017, 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.appmgt.mdm.restconnector.authorization.client.dto; + +/** + * This enum contains the mobile app types. + */ +public enum MobileAppTypes { + ENTERPRISE, WEBAPP, PUBLIC +} diff --git a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/dto/TokenIssuerService.java b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/dto/TokenIssuerService.java new file mode 100755 index 000000000..81e44bb2c --- /dev/null +++ b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/dto/TokenIssuerService.java @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2017, 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.appmgt.mdm.restconnector.authorization.client.dto; + +import javax.ws.rs.Consumes; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; + +/** + * This hold the api definition that is used as a contract with netflix feign. + */ +@Path("/token") +public interface TokenIssuerService { + + /** + * Get a token for password grant type. + * @param grant Token grant type + * @param username Username + * @param password Password + * @return {@link AccessTokenInfo} object + */ + @POST + @Produces(MediaType.APPLICATION_JSON) + @Consumes(MediaType.APPLICATION_FORM_URLENCODED) + AccessTokenInfo getToken(@QueryParam("grant_type") String grant, @QueryParam("username") String username, + @QueryParam("password") String password); + + /** + * Get a token for refresh grant type. + * @param grant Token grant type + * @param refreshToken Refresh token + * @return {@link AccessTokenInfo} object + */ + @POST + @Produces(MediaType.APPLICATION_JSON) + @Consumes(MediaType.APPLICATION_FORM_URLENCODED) + AccessTokenInfo getToken(@QueryParam("grant_type") String grant, @QueryParam("refreshToken") String refreshToken); +} diff --git a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/config/AuthorizationConfigurationManager.java b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/config/AuthorizationConfigurationManager.java new file mode 100644 index 000000000..707ef50fa --- /dev/null +++ b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/config/AuthorizationConfigurationManager.java @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2017, 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.appmgt.mdm.restconnector.config; + +import org.wso2.carbon.appmgt.mdm.restconnector.Constants; +import org.wso2.carbon.appmgt.mobile.utils.MobileConfigurations; + +import java.util.HashMap; + +/** + * The DTO class to AuthorizationConfigurationManager. + */ +public class AuthorizationConfigurationManager { + private String tokenApiURL; + private String imageURL; + private String serverURL; + private String userName; + private String password; + private String tokenRefreshTimeOffset; + + private static AuthorizationConfigurationManager authorizationConfigurationManager = new + AuthorizationConfigurationManager(); + + private AuthorizationConfigurationManager() { + MobileConfigurations configurations = MobileConfigurations.getInstance(); + HashMap configProperties = configurations.getActiveMDMProperties(); + setTokenApiURL(configProperties.get(Constants.PROPERTY_TOKEN_API_URL)); + setImageURL(configProperties.get(Constants.PROPERTY_IMAGE_URL)); + setServerURL(configProperties.get(Constants.PROPERTY_SERVER_URL)); + setUserName(configProperties.get(Constants.PROPERTY_USERNAME)); + setPassword(configProperties.get(Constants.PROPERTY_PASSWORD)); + setTokenRefreshTimeOffset(configProperties.get(Constants.PROPERTY_TOKEN_REFRESH_TIME_OFFSET)); + } + + public static AuthorizationConfigurationManager getInstance() { + return authorizationConfigurationManager; + } + + public String getTokenApiURL() { + return tokenApiURL; + } + + public void setTokenApiURL(String tokenApiURL) { + this.tokenApiURL = tokenApiURL; + } + + public String getImageURL() { + return imageURL; + } + + public void setImageURL(String imageURL) { + this.imageURL = imageURL; + } + + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + public String getServerURL() { + return serverURL; + } + + public void setServerURL(String serverURL) { + this.serverURL = serverURL; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public static AuthorizationConfigurationManager getAuthorizationConfigurationManager() { + return authorizationConfigurationManager; + } + + public static void setAuthorizationConfigurationManager( + AuthorizationConfigurationManager authorizationConfigurationManager) { + AuthorizationConfigurationManager.authorizationConfigurationManager = authorizationConfigurationManager; + } + + public String getTokenRefreshTimeOffset() { + return tokenRefreshTimeOffset; + } + + public void setTokenRefreshTimeOffset(String tokenRefreshTimeOffset) { + this.tokenRefreshTimeOffset = tokenRefreshTimeOffset; + } +} \ No newline at end of file diff --git a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/internal/AuthorizationDataHolder.java b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/internal/AuthorizationDataHolder.java new file mode 100644 index 000000000..15a53b7ff --- /dev/null +++ b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/internal/AuthorizationDataHolder.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2017, 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.appmgt.mdm.restconnector.internal; + +import org.wso2.carbon.appmgt.mdm.restconnector.authorization.client.dto.ApiApplicationRegistrationService; + +public class AuthorizationDataHolder { + private static AuthorizationDataHolder thisInstance = new AuthorizationDataHolder(); + + private ApiApplicationRegistrationService apiApplicationRegistrationService; + + private AuthorizationDataHolder() { + } + + public static AuthorizationDataHolder getInstance() { + return thisInstance; + } + + public ApiApplicationRegistrationService getApiApplicationRegistrationService() { + return apiApplicationRegistrationService; + } + + public void setApiApplicationRegistrationService( + ApiApplicationRegistrationService apiApplicationRegistrationService) { + this.apiApplicationRegistrationService = apiApplicationRegistrationService; + } +} diff --git a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/internal/MDMComponent.java b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/internal/MDMComponent.java new file mode 100644 index 000000000..c75ed0981 --- /dev/null +++ b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/internal/MDMComponent.java @@ -0,0 +1,61 @@ +/* + * + * Copyright (c) 2017, 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.appmgt.mdm.restconnector.internal; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.osgi.framework.BundleContext; +import org.osgi.framework.ServiceRegistration; +import org.osgi.service.component.ComponentContext; +import org.wso2.carbon.appmgt.mdm.restconnector.ApplicationOperationsImpl; +import org.wso2.carbon.appmgt.mobile.interfaces.ApplicationOperations; + +/** + * @scr.component name="org.wso2.carbon.appmgt.mdm.restconnector" immediate="true" + */ +public class MDMComponent { + private static final Log log = LogFactory.getLog(MDMComponent.class); + private ServiceRegistration mdmServiceRegistration; + + protected void activate(ComponentContext context) { + BundleContext bundleContext = context.getBundleContext(); + if (log.isDebugEnabled()) { + log.debug("WSO2MDM MDM Component activated"); + } + try { + mdmServiceRegistration = bundleContext.registerService(ApplicationOperations.class.getName(), new + ApplicationOperationsImpl(), null); + } catch (Throwable e) { + log.error("Failed to activate org.wso2.carbon.appmgt.mdm.restconnector.internal." + + "MDMComponent : " + e); + } + } + + protected void deactivate(ComponentContext context) { + if (mdmServiceRegistration != null) { + mdmServiceRegistration.unregister(); + mdmServiceRegistration = null; + } + if (log.isDebugEnabled()) { + log.debug("WSO2MDM MDM Component deactivated"); + } + } +} \ No newline at end of file diff --git a/components/extensions/appm-connector/pom.xml b/components/extensions/appm-connector/pom.xml index 2e5b0ed9a..2cba956a1 100644 --- a/components/extensions/appm-connector/pom.xml +++ b/components/extensions/appm-connector/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt-plugins extensions - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT ../pom.xml @@ -34,6 +34,7 @@ org.wso2.carbon.appmgt.mdm.osgiconnector + org.wso2.carbon.appmgt.mdm.restconnector diff --git a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.extension/pom.xml b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.extension/pom.xml index c5779f116..5e929b0f2 100644 --- a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.extension/pom.xml +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.extension/pom.xml @@ -20,7 +20,7 @@ org.wso2.carbon.devicemgt-plugins cdmf-transport-adapters - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT ../../pom.xml 4.0.0 @@ -33,6 +33,18 @@ + + org.apache.felix + maven-scr-plugin + + + generate-scr-descriptor + + scr + + + + org.apache.maven.plugins maven-surefire-plugin @@ -45,12 +57,48 @@ ${project.artifactId} ${project.artifactId} + + org.wso2.carbon.device.mgt.input.adapter.extension.internal, + org.wso2.carbon.device.mgt.input.adapter.extension.internal.* + - org.wso2.carbon.device.mgt.input.adapter.extension.* + org.wso2.carbon.device.mgt.input.adapter.extension.*, + !org.wso2.carbon.device.mgt.input.adapter.extension.internal, + + org.osgi.framework, + org.osgi.service.component, + com.jayway.jsonpath, + org.apache.commons.logging, + org.json.simple, + org.json.simple.parser + + + + + org.wso2.carbon + org.wso2.carbon.logging + + + com.googlecode.json-simple.wso2 + json-simple + + + com.jayway.jsonpath + json-path + + + org.eclipse.osgi + org.eclipse.osgi + + + org.eclipse.osgi + org.eclipse.osgi.services + + \ No newline at end of file diff --git a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.extension/src/main/java/org/wso2/carbon/device/mgt/input/adapter/extension/ContentTransformer.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.extension/src/main/java/org/wso2/carbon/device/mgt/input/adapter/extension/ContentTransformer.java index d86aaaab5..8c3b3033f 100644 --- a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.extension/src/main/java/org/wso2/carbon/device/mgt/input/adapter/extension/ContentTransformer.java +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.extension/src/main/java/org/wso2/carbon/device/mgt/input/adapter/extension/ContentTransformer.java @@ -25,6 +25,11 @@ import java.util.Map; */ public interface ContentTransformer { + /** + * This returns the type of ContentTransformer. + */ + String getType(); + /** * This is used to transform the receiver content * @param message message to be format diff --git a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.extension/src/main/java/org/wso2/carbon/device/mgt/input/adapter/extension/ContentValidator.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.extension/src/main/java/org/wso2/carbon/device/mgt/input/adapter/extension/ContentValidator.java index d01536c5a..e3e81c471 100644 --- a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.extension/src/main/java/org/wso2/carbon/device/mgt/input/adapter/extension/ContentValidator.java +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.extension/src/main/java/org/wso2/carbon/device/mgt/input/adapter/extension/ContentValidator.java @@ -24,6 +24,13 @@ import java.util.Map; * This interface will be triggered to validate the stream content before publishing. */ public interface ContentValidator { + + /** + * this returns the unique name of ContentValidatorType. + * @return + */ + String getType(); + /** * @param dynamicParameter that message. * @return ContentInfo. diff --git a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.extension/src/main/java/org/wso2/carbon/device/mgt/input/adapter/extension/InputAdapterExtensionService.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.extension/src/main/java/org/wso2/carbon/device/mgt/input/adapter/extension/InputAdapterExtensionService.java new file mode 100644 index 000000000..28046b73b --- /dev/null +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.extension/src/main/java/org/wso2/carbon/device/mgt/input/adapter/extension/InputAdapterExtensionService.java @@ -0,0 +1,34 @@ +package org.wso2.carbon.device.mgt.input.adapter.extension; + +/** + * This hold the input adapter extension service. + */ +public interface InputAdapterExtensionService { + + /** + * return content validator for the given type. + * @param type type of the content validator + * @return content validator for the given type. + */ + ContentValidator getContentValidator(String type); + + /** + * return default content validator for the given type. + * @return default content validator for the given type. + */ + ContentValidator getDefaultContentValidator(); + + /** + * return content transformer for the given type. + * @param type of the content transfomer + * @return content transformer for the given type. + */ + ContentTransformer getContentTransformer(String type); + + /** + * return default content transformer for the given type. + * @return default content transformer for the given type. + */ + ContentTransformer getDefaultContentTransformer(); + +} diff --git a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.extension/src/main/java/org/wso2/carbon/device/mgt/input/adapter/extension/InputAdapterExtensionServiceImpl.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.extension/src/main/java/org/wso2/carbon/device/mgt/input/adapter/extension/InputAdapterExtensionServiceImpl.java new file mode 100644 index 000000000..5d1d33448 --- /dev/null +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.extension/src/main/java/org/wso2/carbon/device/mgt/input/adapter/extension/InputAdapterExtensionServiceImpl.java @@ -0,0 +1,31 @@ +package org.wso2.carbon.device.mgt.input.adapter.extension; + +import org.wso2.carbon.device.mgt.input.adapter.extension.internal.InputAdapterServiceDataHolder; + +/** + * This hold the input adapter extension service implementation. + */ +public class InputAdapterExtensionServiceImpl implements InputAdapterExtensionService { + private static final String DEFAULT = "default"; + + + @Override + public ContentValidator getContentValidator(String type) { + return InputAdapterServiceDataHolder.getInstance().getContentValidatorMap().get(type); + } + + @Override + public ContentValidator getDefaultContentValidator() { + return InputAdapterServiceDataHolder.getInstance().getContentValidatorMap().get(DEFAULT); + } + + @Override + public ContentTransformer getContentTransformer(String type) { + return InputAdapterServiceDataHolder.getInstance().getContentTransformerMap().get(type); + } + + @Override + public ContentTransformer getDefaultContentTransformer() { + return InputAdapterServiceDataHolder.getInstance().getContentTransformerMap().get(DEFAULT); + } +} diff --git a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.extension/src/main/java/org/wso2/carbon/device/mgt/input/adapter/extension/internal/InputAdapterServiceComponent.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.extension/src/main/java/org/wso2/carbon/device/mgt/input/adapter/extension/internal/InputAdapterServiceComponent.java new file mode 100644 index 000000000..b7370fa3a --- /dev/null +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.extension/src/main/java/org/wso2/carbon/device/mgt/input/adapter/extension/internal/InputAdapterServiceComponent.java @@ -0,0 +1,96 @@ +/* +* 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. +*/ +package org.wso2.carbon.device.mgt.input.adapter.extension.internal; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.osgi.service.component.ComponentContext; +import org.wso2.carbon.device.mgt.input.adapter.extension.ContentTransformer; +import org.wso2.carbon.device.mgt.input.adapter.extension.ContentValidator; +import org.wso2.carbon.device.mgt.input.adapter.extension.InputAdapterExtensionService; +import org.wso2.carbon.device.mgt.input.adapter.extension.InputAdapterExtensionServiceImpl; +import org.wso2.carbon.device.mgt.input.adapter.extension.transformer.DefaultContentTransformer; +import org.wso2.carbon.device.mgt.input.adapter.extension.validator.DefaultContentValidator; +import org.wso2.carbon.device.mgt.input.adapter.extension.validator.HTTPContentValidator; +import org.wso2.carbon.device.mgt.input.adapter.extension.validator.MQTTContentValidator; + +/** + * @scr.component name="input.adapter.extension.adapterService.component" immediate="true" + * @scr.reference name="InputAdapterServiceComponent.service" + * interface="org.wso2.carbon.device.mgt.input.adapter.extension.ContentValidator" + * cardinality="0..n" + * policy="dynamic" + * bind="setContentValidator" + * unbind="unsetContentValidator" + * * @scr.reference name="InputAdapterServiceComponent.service" + * interface="org.wso2.carbon.device.mgt.input.adapter.extension.ContentTransformer" + * cardinality="0..n" + * policy="dynamic" + * bind="setContentTransformer" + * unbind="unsetContentTransformer" + */ +public class InputAdapterServiceComponent { + + private static final Log log = LogFactory.getLog( + InputAdapterServiceComponent.class); + + protected void activate(ComponentContext context) { + try { + if (log.isDebugEnabled()) { + log.debug("Successfully deployed the input adapter extension service"); + } + + InputAdapterServiceDataHolder.getInstance().addContentTransformer(new DefaultContentTransformer()); + InputAdapterServiceDataHolder.getInstance().addContentValidator(new DefaultContentValidator()); + InputAdapterServiceDataHolder.getInstance().addContentValidator(new HTTPContentValidator()); + InputAdapterServiceDataHolder.getInstance().addContentValidator(new MQTTContentValidator()); + + context.getBundleContext().registerService(InputAdapterExtensionService.class, + new InputAdapterExtensionServiceImpl(), null); + } catch (RuntimeException e) { + log.error("Can not create the input adapter service ", e); + } + } + + protected void setContentValidator(ContentValidator contentValidator) { + if (log.isDebugEnabled()) { + log.debug("Setting ContentValidator Service"); + } + InputAdapterServiceDataHolder.getInstance().addContentValidator(contentValidator); + } + + protected void unsetContentValidator(ContentValidator contentValidator) { + if (log.isDebugEnabled()) { + log.debug("Un-setting ContentValidator Service"); + } + } + + protected void setContentTransformer(ContentTransformer contentTransformer) { + if (log.isDebugEnabled()) { + log.debug("Setting contentTransformer Service"); + } + InputAdapterServiceDataHolder.getInstance().addContentTransformer(contentTransformer); + } + + protected void unsetContentValidator(ContentTransformer contentTransformer) { + if (log.isDebugEnabled()) { + log.debug("Un-setting ContentTransformer Service"); + } + } + +} diff --git a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.extension/src/main/java/org/wso2/carbon/device/mgt/input/adapter/extension/internal/InputAdapterServiceDataHolder.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.extension/src/main/java/org/wso2/carbon/device/mgt/input/adapter/extension/internal/InputAdapterServiceDataHolder.java new file mode 100644 index 000000000..fc299ae26 --- /dev/null +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.extension/src/main/java/org/wso2/carbon/device/mgt/input/adapter/extension/internal/InputAdapterServiceDataHolder.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * Licensed 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.device.mgt.input.adapter.extension.internal; + +import org.wso2.carbon.device.mgt.input.adapter.extension.ContentTransformer; +import org.wso2.carbon.device.mgt.input.adapter.extension.ContentValidator; + +import java.util.HashMap; +import java.util.Map; + +/** + * common place to hold some OSGI service references. + */ +public class InputAdapterServiceDataHolder { + + private static InputAdapterServiceDataHolder inputAdapterServiceDataHolder = new InputAdapterServiceDataHolder(); + private static Map contentValidatorMap = new HashMap<>(); + private static Map contentTransformerMap = new HashMap<>(); + + private InputAdapterServiceDataHolder() { + } + + public static InputAdapterServiceDataHolder getInstance() { + return inputAdapterServiceDataHolder; + } + + public Map getContentValidatorMap() { + return contentValidatorMap; + } + + public void addContentValidator(ContentValidator contentValidator) { + InputAdapterServiceDataHolder.contentValidatorMap.put(contentValidator.getType(), contentValidator); + } + + public Map getContentTransformerMap() { + return contentTransformerMap; + } + + public void addContentTransformer(ContentTransformer contentTransformer) { + InputAdapterServiceDataHolder.contentTransformerMap.put(contentTransformer.getType(), contentTransformer); + } +} diff --git a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.extension/src/main/java/org/wso2/carbon/device/mgt/input/adapter/extension/DefaultContentTransformer.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.extension/src/main/java/org/wso2/carbon/device/mgt/input/adapter/extension/transformer/DefaultContentTransformer.java similarity index 74% rename from components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.extension/src/main/java/org/wso2/carbon/device/mgt/input/adapter/extension/DefaultContentTransformer.java rename to components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.extension/src/main/java/org/wso2/carbon/device/mgt/input/adapter/extension/transformer/DefaultContentTransformer.java index 9e0f5f256..fe73bd37f 100644 --- a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.extension/src/main/java/org/wso2/carbon/device/mgt/input/adapter/extension/DefaultContentTransformer.java +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.extension/src/main/java/org/wso2/carbon/device/mgt/input/adapter/extension/transformer/DefaultContentTransformer.java @@ -16,14 +16,22 @@ * under the License. */ -package org.wso2.carbon.device.mgt.input.adapter.extension; +package org.wso2.carbon.device.mgt.input.adapter.extension.transformer; + +import org.wso2.carbon.device.mgt.input.adapter.extension.ContentTransformer; import java.util.Map; /** * This holds the default implementation of ContentTransformer */ -public class DefaultContentTransformer implements ContentTransformer{ +public class DefaultContentTransformer implements ContentTransformer { + private static final String DEFAULT_CONTENT_VALIDATOR = "default"; + + @Override + public String getType() { + return DEFAULT_CONTENT_VALIDATOR; + } @Override public Object transform(Object message, Map dynamicProperties) { diff --git a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.extension/src/main/java/org/wso2/carbon/device/mgt/input/adapter/extension/DefaultContentValidator.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.extension/src/main/java/org/wso2/carbon/device/mgt/input/adapter/extension/validator/DefaultContentValidator.java similarity index 73% rename from components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.extension/src/main/java/org/wso2/carbon/device/mgt/input/adapter/extension/DefaultContentValidator.java rename to components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.extension/src/main/java/org/wso2/carbon/device/mgt/input/adapter/extension/validator/DefaultContentValidator.java index 3e507b10d..2493c0dd8 100644 --- a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.extension/src/main/java/org/wso2/carbon/device/mgt/input/adapter/extension/DefaultContentValidator.java +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.extension/src/main/java/org/wso2/carbon/device/mgt/input/adapter/extension/validator/DefaultContentValidator.java @@ -16,7 +16,10 @@ * under the License. */ -package org.wso2.carbon.device.mgt.input.adapter.extension; +package org.wso2.carbon.device.mgt.input.adapter.extension.validator; + +import org.wso2.carbon.device.mgt.input.adapter.extension.ContentInfo; +import org.wso2.carbon.device.mgt.input.adapter.extension.ContentValidator; import java.util.Map; @@ -24,6 +27,12 @@ import java.util.Map; * This holds the default implementation of content validator interface. */ public class DefaultContentValidator implements ContentValidator { + private static final String DEFAULT_TYPE = "default"; + + @Override + public String getType() { + return DEFAULT_TYPE; + } @Override public ContentInfo validate(Object message, Map dynamicParams) { diff --git a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.extension/src/main/java/org/wso2/carbon/device/mgt/input/adapter/extension/validator/HTTPContentValidator.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.extension/src/main/java/org/wso2/carbon/device/mgt/input/adapter/extension/validator/HTTPContentValidator.java new file mode 100644 index 000000000..fe548099a --- /dev/null +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.extension/src/main/java/org/wso2/carbon/device/mgt/input/adapter/extension/validator/HTTPContentValidator.java @@ -0,0 +1,87 @@ +/* +* 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.device.mgt.input.adapter.extension.validator; + +import com.jayway.jsonpath.JsonPath; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.json.simple.JSONArray; +import org.json.simple.parser.JSONParser; +import org.json.simple.parser.ParseException; +import org.wso2.carbon.device.mgt.input.adapter.extension.ContentInfo; +import org.wso2.carbon.device.mgt.input.adapter.extension.ContentValidator; + +import java.util.List; +import java.util.Map; + +public class HTTPContentValidator implements ContentValidator { + private static final Log log = LogFactory.getLog(HTTPContentValidator.class); + private static String JSON_ARRAY_START_CHAR = "["; + private static String CDMF_SCOPE_PREFIX = "cdmf"; + private static String CDMF_SCOPE_SEPERATOR = "/"; + private static String CDMF_HTTP_CONTENT_VALIDATOR = "iot-http"; + public static final String DEVICE_ID_JSON_PATH = "event.metaData.deviceId"; + + @Override + public String getType() { + return CDMF_HTTP_CONTENT_VALIDATOR; + } + + @Override + public ContentInfo validate(Object msgPayload, Map dynamicParams) { + String deviceId = (String) dynamicParams.get("deviceId"); + String msg = (String) msgPayload; + String deviceIdJsonPath = DEVICE_ID_JSON_PATH; + boolean status; + if (msg.startsWith(JSON_ARRAY_START_CHAR)) { + status = processMultipleEvents(msg, deviceId, deviceIdJsonPath); + } else { + status = processSingleEvent(msg, deviceId, deviceIdJsonPath); + } + return new ContentInfo(status, msg); + } + + private boolean processSingleEvent(String msg, String deviceIdFromTopic, String deviceIdJsonPath) { + Object res = JsonPath.read(msg, deviceIdJsonPath); + String deviceIdFromContent = (res != null) ? res.toString() : ""; + if (deviceIdFromContent.equals(deviceIdFromTopic)) { + return true; + } + return false; + } + + private boolean processMultipleEvents(String msg, String deviceIdFromTopic, String deviceIdJsonPath) { + try { + JSONParser jsonParser = new JSONParser(); + JSONArray jsonArray = (JSONArray) jsonParser.parse(msg); + boolean status = false; + for (int i = 0; i < jsonArray.size(); i++) { + status = processSingleEvent(jsonArray.get(i).toString(), deviceIdFromTopic, deviceIdJsonPath); + if (!status) { + return status; + } + } + return status; + } catch (ParseException e) { + log.error("Invalid input " + msg, e); + return false; + } + } + +} diff --git a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/util/MQTTContentValidator.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.extension/src/main/java/org/wso2/carbon/device/mgt/input/adapter/extension/validator/MQTTContentValidator.java similarity index 81% rename from components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/util/MQTTContentValidator.java rename to components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.extension/src/main/java/org/wso2/carbon/device/mgt/input/adapter/extension/validator/MQTTContentValidator.java index a3de8ffa9..fdd4c34cf 100644 --- a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/util/MQTTContentValidator.java +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.extension/src/main/java/org/wso2/carbon/device/mgt/input/adapter/extension/validator/MQTTContentValidator.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.device.mgt.input.adapter.mqtt.util; +package org.wso2.carbon.device.mgt.input.adapter.extension.validator; import com.jayway.jsonpath.JsonPath; import org.apache.commons.logging.Log; @@ -32,13 +32,23 @@ import java.util.Map; public class MQTTContentValidator implements ContentValidator { private static final String JSON_ARRAY_START_CHAR = "["; private static final Log log = LogFactory.getLog(MQTTContentValidator.class); + private static final String CDMF_MQTT_CONTENT_VALIDATOR = "iot-mqtt"; + public static final String DEVICE_ID_JSON_PATH = "event.metaData.deviceId"; + public static final String DEVICE_TYPE_JSON_PATH = "event.metaData.deviceId"; + public static final String TOPIC = "topic"; + public static final int DEVICE_ID_TOPIC_HIERARCHY_INDEX = 2; + + @Override + public String getType() { + return null; + } @Override public ContentInfo validate(Object msgPayload, Map dynamicParams) { - String topic = (String) dynamicParams.get(MQTTEventAdapterConstants.TOPIC); + String topic = (String) dynamicParams.get(TOPIC); String topics[] = topic.split("/"); - String deviceIdJsonPath = MQTTEventAdapterConstants.DEVICE_ID_JSON_PATH; - int deviceIdInTopicHierarchyLevelIndex = MQTTEventAdapterConstants.DEVICE_ID_TOPIC_HIERARCHY_INDEX; + String deviceIdJsonPath = DEVICE_ID_JSON_PATH; + int deviceIdInTopicHierarchyLevelIndex = DEVICE_ID_TOPIC_HIERARCHY_INDEX; String deviceIdFromTopic = topics[deviceIdInTopicHierarchyLevelIndex]; boolean status; String message = (String) msgPayload; diff --git a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/pom.xml b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/pom.xml index a7ab24ef5..52ecb5acd 100644 --- a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/pom.xml +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/pom.xml @@ -20,7 +20,7 @@ org.wso2.carbon.devicemgt-plugins cdmf-transport-adapters - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT ../../pom.xml @@ -76,6 +76,22 @@ commons-pool.wso2 commons-pool + + io.github.openfeign + feign-core + + + io.github.openfeign + feign-jaxrs + + + io.github.openfeign + feign-gson + + + javax.ws.rs + jsr311-api + @@ -117,7 +133,6 @@ org.wso2.carbon.event.input.adapter.core, org.wso2.carbon.event.input.adapter.core.*, javax.xml.namespace; version=0.0.0, - com.jayway.jsonpath.*, com.nimbusds.jose, com.nimbusds.jose.crypto, com.nimbusds.jwt, @@ -130,9 +145,27 @@ org.wso2.carbon.user.core.service, org.wso2.carbon.user.core.tenant, org.apache.commons.pool, - org.apache.commons.pool.impl + org.apache.commons.pool.impl, + feign, + feign.auth, + feign.codec, + feign.gson, + org.wso2.carbon.device.mgt.input.adapter.extension, + org.apache.axiom.util.base64, + org.apache.axis2.*, + org.apache.commons.httpclient.*, + org.apache.commons.logging, + org.apache.log4j, + org.wso2.carbon.context, + org.wso2.carbon.core.util, + org.wso2.carbon.identity.oauth2.*, + org.wso2.carbon.utils, + org.wso2.carbon.utils.multitenancy - * + + jsr311-api, + feign-jaxrs + diff --git a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/HTTPEventAdapterFactory.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/HTTPEventAdapterFactory.java index b46117f65..c12e24a6a 100644 --- a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/HTTPEventAdapterFactory.java +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/HTTPEventAdapterFactory.java @@ -76,12 +76,12 @@ public class HTTPEventAdapterFactory extends InputEventAdapterFactory { propertyList.add(exposedTransportsProperty); //Content Validator details - Property contentValidator = new Property(HTTPEventAdapterConstants.ADAPTER_CONF_CONTENT_VALIDATOR_CLASSNAME); + Property contentValidator = new Property(HTTPEventAdapterConstants.ADAPTER_CONF_CONTENT_VALIDATOR_TYPE); contentValidator.setDisplayName( - resourceBundle.getString(HTTPEventAdapterConstants.ADAPTER_CONF_CONTENT_VALIDATOR_CLASSNAME)); + resourceBundle.getString(HTTPEventAdapterConstants.ADAPTER_CONF_CONTENT_VALIDATOR_TYPE)); contentValidator.setRequired(false); contentValidator.setHint( - resourceBundle.getString(HTTPEventAdapterConstants.ADAPTER_CONF_CONTENT_VALIDATOR_CLASSNAME_HINT)); + resourceBundle.getString(HTTPEventAdapterConstants.ADAPTER_CONF_CONTENT_VALIDATOR_TYPE_HINT)); contentValidator.setDefaultValue(HTTPEventAdapterConstants.DEFAULT); propertyList.add(contentValidator); diff --git a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/HTTPMessageServlet.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/HTTPMessageServlet.java index 3d5351b30..afda05edf 100644 --- a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/HTTPMessageServlet.java +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/HTTPMessageServlet.java @@ -18,11 +18,13 @@ package org.wso2.carbon.device.mgt.input.adapter.http; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.context.PrivilegedCarbonContext; +import org.wso2.carbon.device.mgt.input.adapter.http.authorization.DeviceAuthorizer; +import org.wso2.carbon.device.mgt.input.adapter.http.internal.InputAdapterServiceDataHolder; import org.wso2.carbon.device.mgt.input.adapter.http.oauth.OAuthAuthenticator; import org.wso2.carbon.device.mgt.input.adapter.extension.ContentInfo; import org.wso2.carbon.device.mgt.input.adapter.extension.ContentTransformer; -import org.wso2.carbon.device.mgt.input.adapter.extension.DefaultContentTransformer; -import org.wso2.carbon.device.mgt.input.adapter.extension.DefaultContentValidator; +import org.wso2.carbon.device.mgt.input.adapter.extension.transformer.DefaultContentTransformer; +import org.wso2.carbon.device.mgt.input.adapter.extension.validator.DefaultContentValidator; import org.wso2.carbon.device.mgt.input.adapter.http.exception.HTTPContentInitializationException; import org.wso2.carbon.device.mgt.input.adapter.http.jwt.JWTAuthenticator; import org.wso2.carbon.device.mgt.input.adapter.http.util.AuthenticationInfo; @@ -58,6 +60,7 @@ public class HTTPMessageServlet extends HttpServlet { private String exposedTransports; private static JWTAuthenticator jwtAuthenticator; private static OAuthAuthenticator oAuthAuthenticator; + private static DeviceAuthorizer deviceAuthorizer; public HTTPMessageServlet(InputEventAdapterListener eventAdaptorListener, int tenantId, InputEventAdapterConfiguration eventAdapterConfiguration, @@ -67,48 +70,29 @@ public class HTTPMessageServlet extends HttpServlet { this.exposedTransports = eventAdapterConfiguration.getProperties().get( HTTPEventAdapterConstants.EXPOSED_TRANSPORTS); - String className = eventAdapterConfiguration.getProperties().get( - HTTPEventAdapterConstants.ADAPTER_CONF_CONTENT_VALIDATOR_CLASSNAME); - if (HTTPEventAdapterConstants.DEFAULT.equals(className)) { - contentValidator = new DefaultContentValidator(); + String contentValidatorType = eventAdapterConfiguration.getProperties().get( + HTTPEventAdapterConstants.ADAPTER_CONF_CONTENT_VALIDATOR_TYPE); + if (contentValidatorType == null || HTTPEventAdapterConstants.DEFAULT.equals(contentValidatorType)) { + contentValidator = InputAdapterServiceDataHolder.getInputAdapterExtensionService() + .getDefaultContentValidator(); } else { - try { - Class contentValidatorClass = Class.forName(className) - .asSubclass(ContentValidator.class); - contentValidator = contentValidatorClass.newInstance(); - } catch (ClassNotFoundException e) { - throw new HTTPContentInitializationException( - "Unable to find the class validator: " + className, e); - } catch (InstantiationException e) { - throw new HTTPContentInitializationException( - "Unable to create an instance of :" + className, e); - } catch (IllegalAccessException e) { - throw new HTTPContentInitializationException("Access of the instance in not allowed.", e); - } + contentValidator = InputAdapterServiceDataHolder.getInputAdapterExtensionService() + .getContentValidator(contentValidatorType); } String contentTransformerClassName = eventAdapterConfiguration.getProperties().get( HTTPEventAdapterConstants.ADAPTER_CONF_CONTENT_TRANSFORMER_CLASSNAME); - if (contentTransformerClassName != null && contentTransformerClassName.equals(HTTPEventAdapterConstants.DEFAULT)) { - contentTransformer = new DefaultContentTransformer(); - } else if (contentTransformerClassName != null && !contentTransformerClassName.isEmpty()) { - try { - Class contentTransformerClass = Class.forName(contentTransformerClassName) - .asSubclass(ContentTransformer.class); - contentTransformer = contentTransformerClass.newInstance(); - } catch (ClassNotFoundException e) { - throw new HTTPContentInitializationException( - "Unable to find the class transformer: " + contentTransformerClassName, e); - } catch (InstantiationException e) { - throw new HTTPContentInitializationException( - "Unable to create an instance of :" + contentTransformerClassName, e); - } catch (IllegalAccessException e) { - throw new HTTPContentInitializationException("Access of the instance in not allowed.", e); - } + if (contentTransformerClassName == null || contentTransformerClassName.equals(HTTPEventAdapterConstants.DEFAULT)) { + contentTransformer = InputAdapterServiceDataHolder.getInputAdapterExtensionService() + .getDefaultContentTransformer(); + } else { + contentTransformer = InputAdapterServiceDataHolder.getInputAdapterExtensionService() + .getContentTransformer(contentValidatorType); } jwtAuthenticator = new JWTAuthenticator(); oAuthAuthenticator = new OAuthAuthenticator(globalProperties); + deviceAuthorizer = new DeviceAuthorizer(globalProperties); } @Override @@ -177,14 +161,24 @@ public class HTTPMessageServlet extends HttpServlet { paramMap.put(HTTPEventAdapterConstants.USERNAME_TAG, authenticationInfo.getUsername()); paramMap.put(HTTPEventAdapterConstants.TENANT_DOMAIN_TAG, authenticationInfo.getTenantDomain()); paramMap.put(HTTPEventAdapterConstants.SCOPE_TAG, authenticationInfo.getScopes()); - if (contentValidator != null && contentTransformer != null) { - data = (String) contentTransformer.transform(data, paramMap); - ContentInfo contentInfo = contentValidator.validate(data, paramMap); - if (contentInfo != null && contentInfo.isValidContent()) { - HTTPEventAdapter.executorService.submit(new HTTPRequestProcessor(eventAdaptorListener, - (String) contentInfo.getMessage(), tenantId)); - } - } + String deviceId = (String) paramMap.get("deviceId"); + String deviceType = (String) paramMap.get("deviceType"); + if (deviceAuthorizer.isAuthorized(authenticationInfo, deviceId, deviceType)) { + if (contentValidator != null && contentTransformer != null) { + data = (String) contentTransformer.transform(data, paramMap); + ContentInfo contentInfo = contentValidator.validate(data, paramMap); + if (contentInfo != null && contentInfo.isValidContent()) { + HTTPEventAdapter.executorService.submit(new HTTPRequestProcessor(eventAdaptorListener, + (String) contentInfo + .getMessage(), + tenantId)); + } + } + } else { + if (log.isDebugEnabled()) { + log.debug("Unauthorized device with device id" + deviceId + " and device type" + deviceType); + } + } } } diff --git a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/authorization/DeviceAuthorizer.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/authorization/DeviceAuthorizer.java new file mode 100644 index 000000000..2eab72cfb --- /dev/null +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/authorization/DeviceAuthorizer.java @@ -0,0 +1,101 @@ +/* + * 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.device.mgt.input.adapter.http.authorization; + +import feign.Feign; +import feign.FeignException; +import feign.gson.GsonDecoder; +import feign.gson.GsonEncoder; +import feign.jaxrs.JAXRSContract; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.device.mgt.input.adapter.http.authorization.client.OAuthRequestInterceptor; +import org.wso2.carbon.device.mgt.input.adapter.http.authorization.client.dto.AuthorizationRequest; +import org.wso2.carbon.device.mgt.input.adapter.http.authorization.client.dto.DeviceAccessAuthorizationAdminService; +import org.wso2.carbon.device.mgt.input.adapter.http.authorization.client.dto.DeviceAuthorizationResult; +import org.wso2.carbon.device.mgt.input.adapter.http.authorization.client.dto.DeviceIdentifier; +import org.wso2.carbon.device.mgt.input.adapter.http.util.AuthenticationInfo; +import org.wso2.carbon.device.mgt.input.adapter.http.util.PropertyUtils; +import org.wso2.carbon.event.input.adapter.core.exception.InputEventAdapterException; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * This authorizer crossvalidates the request with device id and device type. + */ +public class DeviceAuthorizer { + + private static DeviceAccessAuthorizationAdminService deviceAccessAuthorizationAdminService; + private static final String CDMF_SERVER_BASE_CONTEXT = "/api/device-mgt/v1.0"; + private static final String DEVICE_MGT_SERVER_URL = "deviceMgtServerUrl"; + private static Log logger = LogFactory.getLog(DeviceAuthorizer.class); + + public DeviceAuthorizer(Map globalProperties) { + try { + deviceAccessAuthorizationAdminService = Feign.builder() + .requestInterceptor(new OAuthRequestInterceptor(globalProperties)) + .contract(new JAXRSContract()).encoder(new GsonEncoder()).decoder(new GsonDecoder()) + .target(DeviceAccessAuthorizationAdminService.class, getDeviceMgtServerUrl(globalProperties) + + CDMF_SERVER_BASE_CONTEXT); + } catch (InputEventAdapterException e) { + logger.error("Invalid value for deviceMgtServerUrl in globalProperties."); + } + } + + + public boolean isAuthorized(AuthenticationInfo authenticationInfo, String deviceId, String deviceType) { + + if (deviceId != null && !deviceId.isEmpty() && deviceType != null && !deviceType.isEmpty()) { + + AuthorizationRequest authorizationRequest = new AuthorizationRequest(); + authorizationRequest.setTenantDomain(authenticationInfo.getTenantDomain()); + authorizationRequest.setUsername(authenticationInfo.getUsername()); + DeviceIdentifier deviceIdentifier = new DeviceIdentifier(); + deviceIdentifier.setId(deviceId); + deviceIdentifier.setType(deviceType); + List deviceIdentifiers = new ArrayList<>(); + deviceIdentifiers.add(deviceIdentifier); + authorizationRequest.setDeviceIdentifiers(deviceIdentifiers); + try { + DeviceAuthorizationResult deviceAuthorizationResult = + deviceAccessAuthorizationAdminService.isAuthorized(authorizationRequest); + List devices = deviceAuthorizationResult.getAuthorizedDevices(); + if (devices != null && devices.size() > 0) { + DeviceIdentifier authorizedDevice = devices.get(0); + if (authorizedDevice.getId().equals(deviceId) && authorizedDevice.getType().equals(deviceType)) { + return true; + } + } + } catch (FeignException e) { + logger.error(e.getMessage(), e); + } + } + return false; + } + + private String getDeviceMgtServerUrl(Map properties) throws InputEventAdapterException { + String deviceMgtServerUrl = PropertyUtils.replaceProperty(properties.get(DEVICE_MGT_SERVER_URL)); + if (deviceMgtServerUrl == null || deviceMgtServerUrl.isEmpty()) { + logger.error("deviceMgtServerUrl can't be empty "); + } + return deviceMgtServerUrl; + } +} \ No newline at end of file diff --git a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/authorization/client/OAuthRequestInterceptor.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/authorization/client/OAuthRequestInterceptor.java new file mode 100755 index 000000000..9b2ea93ae --- /dev/null +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/authorization/client/OAuthRequestInterceptor.java @@ -0,0 +1,161 @@ +/* + * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * Licensed 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.device.mgt.input.adapter.http.authorization.client; + +import feign.Feign; +import feign.RequestInterceptor; +import feign.RequestTemplate; +import feign.auth.BasicAuthRequestInterceptor; +import feign.gson.GsonDecoder; +import feign.gson.GsonEncoder; +import feign.jaxrs.JAXRSContract; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.device.mgt.input.adapter.http.authorization.client.dto.AccessTokenInfo; +import org.wso2.carbon.device.mgt.input.adapter.http.authorization.client.dto.ApiApplicationKey; +import org.wso2.carbon.device.mgt.input.adapter.http.authorization.client.dto.ApiApplicationRegistrationService; +import org.wso2.carbon.device.mgt.input.adapter.http.authorization.client.dto.ApiRegistrationProfile; +import org.wso2.carbon.device.mgt.input.adapter.http.authorization.client.dto.TokenIssuerService; +import org.wso2.carbon.device.mgt.input.adapter.http.util.PropertyUtils; +import org.wso2.carbon.event.input.adapter.core.exception.InputEventAdapterException; + +import java.util.Map; + +/** + * This is a request interceptor to add oauth token header. + */ +public class OAuthRequestInterceptor implements RequestInterceptor { + + private AccessTokenInfo tokenInfo; + private long refreshTimeOffset; + private static final String API_APPLICATION_REGISTRATION_CONTEXT = "/api-application-registration"; + private static final String DEVICE_MANAGEMENT_SERVICE_TAG[] = {"device_management"}; + private static final String APPLICATION_NAME = "websocket-app"; + private static final String PASSWORD_GRANT_TYPE = "password"; + private static final String REFRESH_GRANT_TYPE = "refresh_token"; + private static final String REQUIRED_SCOPE = "perm:authorization:verify"; + private ApiApplicationRegistrationService apiApplicationRegistrationService; + private TokenIssuerService tokenIssuerService; + + private static Log logger = LogFactory.getLog(OAuthRequestInterceptor.class); + + private static final String CONNECTION_USERNAME = "username"; + private static final String CONNECTION_PASSWORD = "password"; + private static final String TOKEN_REFRESH_TIME_OFFSET = "tokenRefreshTimeOffset"; + private static final String TOKEN_SCOPES = "scopes"; + private static final String DEVICE_MGT_SERVER_URL = "deviceMgtServerUrl"; + private static final String TOKEN_ENDPOINT_CONTEXT = "tokenUrl"; + private static String username; + private static String password; + private static String tokenEndpoint; + private static String deviceMgtServerUrl; + private static String scopes; + private static Map globalProperties; + + + /** + * Creates an interceptor that authenticates all requests. + */ + public OAuthRequestInterceptor(Map globalProperties) { + this.globalProperties = globalProperties; + try { + deviceMgtServerUrl = getDeviceMgtServerUrl(globalProperties); + refreshTimeOffset = getRefreshTimeOffset(globalProperties) * 1000; + username = getUsername(globalProperties); + password = getPassword(globalProperties); + tokenEndpoint = getTokenEndpoint(globalProperties); + apiApplicationRegistrationService = Feign.builder().requestInterceptor( + new BasicAuthRequestInterceptor(username, password)) + .contract(new JAXRSContract()).encoder(new GsonEncoder()).decoder(new GsonDecoder()) + .target(ApiApplicationRegistrationService.class, + deviceMgtServerUrl + API_APPLICATION_REGISTRATION_CONTEXT); + } catch (InputEventAdapterException e) { + logger.error("Invalid url: deviceMgtServerUrl" + deviceMgtServerUrl + " or tokenEndpoint:" + tokenEndpoint, + e); + } + } + + @Override + public void apply(RequestTemplate template) { + if (tokenInfo == null) { + //had to do on demand initialization due to start up error. + ApiRegistrationProfile apiRegistrationProfile = new ApiRegistrationProfile(); + apiRegistrationProfile.setApplicationName(APPLICATION_NAME); + apiRegistrationProfile.setIsAllowedToAllDomains(false); + apiRegistrationProfile.setIsMappingAnExistingOAuthApp(false); + apiRegistrationProfile.setTags(DEVICE_MANAGEMENT_SERVICE_TAG); + ApiApplicationKey apiApplicationKey = apiApplicationRegistrationService.register(apiRegistrationProfile); + String consumerKey = apiApplicationKey.getConsumerKey(); + String consumerSecret = apiApplicationKey.getConsumerSecret(); + tokenIssuerService = Feign.builder().requestInterceptor( + new BasicAuthRequestInterceptor(consumerKey, consumerSecret)) + .contract(new JAXRSContract()).encoder(new GsonEncoder()).decoder(new GsonDecoder()) + .target(TokenIssuerService.class, tokenEndpoint); + tokenInfo = tokenIssuerService.getToken(PASSWORD_GRANT_TYPE, username, password, REQUIRED_SCOPE); + tokenInfo.setExpires_in(System.currentTimeMillis() + (tokenInfo.getExpires_in() * 1000)); + } + synchronized(this) { + if (System.currentTimeMillis() + refreshTimeOffset > tokenInfo.getExpires_in()) { + tokenInfo = tokenIssuerService.getToken(REFRESH_GRANT_TYPE, tokenInfo.getRefresh_token()); + tokenInfo.setExpires_in(System.currentTimeMillis() + tokenInfo.getExpires_in()); + } + } + String headerValue = "Bearer " + tokenInfo.getAccess_token(); + template.header("Authorization", headerValue); + } + + private String getUsername(Map globalProperties) { + String username = globalProperties.get(CONNECTION_USERNAME); + if (username == null || username.isEmpty()) { + logger.error("username can't be empty "); + } + return username; + } + + private String getPassword(Map globalProperties) { + String password = globalProperties.get(CONNECTION_PASSWORD);; + if (password == null || password.isEmpty()) { + logger.error("password can't be empty "); + } + return password; + } + + private String getDeviceMgtServerUrl(Map globalProperties) throws InputEventAdapterException { + String deviceMgtServerUrl = globalProperties.get(DEVICE_MGT_SERVER_URL); + if (deviceMgtServerUrl == null || deviceMgtServerUrl.isEmpty()) { + logger.error("deviceMgtServerUrl can't be empty "); + } + return PropertyUtils.replaceProperty(deviceMgtServerUrl); + } + + private String getTokenEndpoint(Map globalProperties) throws InputEventAdapterException { + String tokenEndpoint = globalProperties.get(TOKEN_ENDPOINT_CONTEXT); + if ( tokenEndpoint.isEmpty()) { + logger.error("tokenEndpoint can't be empty "); + } + return PropertyUtils.replaceProperty(tokenEndpoint); + } + + private long getRefreshTimeOffset(Map globalProperties) { + long refreshTimeOffset = 100; + try { + refreshTimeOffset = Long.parseLong(globalProperties.get(TOKEN_REFRESH_TIME_OFFSET)); + } catch (NumberFormatException e) { + logger.error("refreshTimeOffset should be a number", e); + } + return refreshTimeOffset; + } + +} diff --git a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/authorization/client/dto/AccessTokenInfo.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/authorization/client/dto/AccessTokenInfo.java new file mode 100755 index 000000000..a935d8587 --- /dev/null +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/authorization/client/dto/AccessTokenInfo.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * Licensed 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.device.mgt.input.adapter.http.authorization.client.dto; + +/** + * This hold access token info that returned from the api call + */ +public class AccessTokenInfo { + public String token_type; + public long expires_in; + public String refresh_token; + public String access_token; + + public String getToken_type() { + return token_type; + } + + public void setToken_type(String token_type) { + this.token_type = token_type; + } + + public long getExpires_in() { + return expires_in; + } + + public void setExpires_in(long expires_in) { + this.expires_in = expires_in; + } + + public String getRefresh_token() { + return refresh_token; + } + + public void setRefresh_token(String refresh_token) { + this.refresh_token = refresh_token; + } + + public String getAccess_token() { + return access_token; + } + + public void setAccess_token(String access_token) { + this.access_token = access_token; + } +} diff --git a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/authorization/client/dto/ApiApplicationKey.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/authorization/client/dto/ApiApplicationKey.java new file mode 100644 index 000000000..cfc32a4be --- /dev/null +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/authorization/client/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.device.mgt.input.adapter.http.authorization.client.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/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/authorization/client/dto/ApiApplicationRegistrationService.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/authorization/client/dto/ApiApplicationRegistrationService.java new file mode 100755 index 000000000..b8e216305 --- /dev/null +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/authorization/client/dto/ApiApplicationRegistrationService.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * Licensed 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.device.mgt.input.adapter.http.authorization.client.dto; + +import javax.ws.rs.Consumes; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; + +/** + * This is the application registration service that exposed for apimApplicationRegistration + */ + +@Path("/register") +public interface ApiApplicationRegistrationService { + + /** + * This method is used to register api application + * + * @param registrationProfile contains the necessary attributes that are needed in order to register an app. + */ + @POST + @Produces(MediaType.APPLICATION_JSON) + @Consumes(MediaType.APPLICATION_JSON) + ApiApplicationKey register(ApiRegistrationProfile registrationProfile); +} diff --git a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/authorization/client/dto/ApiRegistrationProfile.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/authorization/client/dto/ApiRegistrationProfile.java new file mode 100755 index 000000000..51748f4a3 --- /dev/null +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/authorization/client/dto/ApiRegistrationProfile.java @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * Licensed 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.device.mgt.input.adapter.http.authorization.client.dto; + + +/** + * This class represents the data that are required to register + * the oauth application. + */ +public class ApiRegistrationProfile { + + public String applicationName; + public String tags[]; + public boolean isAllowedToAllDomains; + public String consumerKey; + public String consumerSecret; + public boolean isMappingAnExistingOAuthApp; + + public String getApplicationName() { + return applicationName; + } + + public void setApplicationName(String applicationName) { + this.applicationName = applicationName; + } + + public String[] getTags() { + return tags; + } + + public void setTags(String[] tags) { + this.tags = tags; + } + + public boolean isAllowedToAllDomains() { + return isAllowedToAllDomains; + } + + public void setIsAllowedToAllDomains(boolean isAllowedToAllDomains) { + this.isAllowedToAllDomains = isAllowedToAllDomains; + } + + public boolean isMappingAnExistingOAuthApp() { + return isMappingAnExistingOAuthApp; + } + + public void setIsMappingAnExistingOAuthApp(boolean isMappingAnExistingOAuthApp) { + this.isMappingAnExistingOAuthApp = isMappingAnExistingOAuthApp; + } + + public String getConsumerKey() { + return consumerKey; + } + + public void setConsumerKey(String consumerKey) { + this.consumerKey = consumerKey; + } + + public String getConsumerSecret() { + return consumerSecret; + } + + public void setConsumerSecret(String consumerSecret) { + this.consumerSecret = consumerSecret; + } +} \ No newline at end of file diff --git a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/authorization/client/dto/AuthorizationRequest.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/authorization/client/dto/AuthorizationRequest.java new file mode 100644 index 000000000..8703e6d1a --- /dev/null +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/authorization/client/dto/AuthorizationRequest.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * Licensed 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.device.mgt.input.adapter.http.authorization.client.dto; + +import java.util.List; + +/** + * DTO of the authorization request + */ +public class AuthorizationRequest { + + String tenantDomain; + String username; + List deviceIdentifiers; + List permissions; + + public String getTenantDomain() { + return tenantDomain; + } + + public void setTenantDomain(String tenantDomain) { + this.tenantDomain = tenantDomain; + } + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public List getDeviceIdentifiers() { + return deviceIdentifiers; + } + + public void setDeviceIdentifiers(List deviceIdentifiers) { + this.deviceIdentifiers = deviceIdentifiers; + } + + public List getPermissions() { + return permissions; + } + + public void setPermissions(List permissions) { + this.permissions = permissions; + } +} diff --git a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/authorization/client/dto/DeviceAccessAuthorizationAdminService.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/authorization/client/dto/DeviceAccessAuthorizationAdminService.java new file mode 100644 index 000000000..9c4c74140 --- /dev/null +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/authorization/client/dto/DeviceAccessAuthorizationAdminService.java @@ -0,0 +1,41 @@ +/* + * 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.device.mgt.input.adapter.http.authorization.client.dto; + + +import javax.ws.rs.Consumes; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; + + +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +@Path("/admin/authorization") +/** + * This interface provided the definition of the device - user access verification service. + */ +public interface DeviceAccessAuthorizationAdminService { + + @POST + @Produces(MediaType.APPLICATION_JSON) + @Consumes(MediaType.APPLICATION_JSON) + DeviceAuthorizationResult isAuthorized(AuthorizationRequest authorizationRequest); +} diff --git a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/authorization/client/dto/DeviceAuthorizationResult.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/authorization/client/dto/DeviceAuthorizationResult.java new file mode 100644 index 000000000..2a27ba6b1 --- /dev/null +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/authorization/client/dto/DeviceAuthorizationResult.java @@ -0,0 +1,56 @@ +/* + * 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. + */ + +package org.wso2.carbon.device.mgt.input.adapter.http.authorization.client.dto; + +import java.util.ArrayList; +import java.util.List; + +/** + * Represents a DeviceAuthorizationResult including a list of authorized devices and a list of unauthorized devices. + */ +public class DeviceAuthorizationResult { + + private List authorizedDevices = new ArrayList<>(); + private List unauthorizedDevices = new ArrayList<>(); + + public List getAuthorizedDevices() { + return authorizedDevices; + } + + public void setAuthorizedDevices(List authorizedDevices) { + this.authorizedDevices = authorizedDevices; + } + + public void setUnauthorizedDevices( + List unauthorizedDevices) { + this.unauthorizedDevices = unauthorizedDevices; + } + + public void addAuthorizedDevice(DeviceIdentifier deviceIdentifier) { + authorizedDevices.add(deviceIdentifier); + } + + public List getUnauthorizedDevices() { + return unauthorizedDevices; + } + + public void addUnauthorizedDevice(DeviceIdentifier deviceIdentifier) { + unauthorizedDevices.add(deviceIdentifier); + } +} diff --git a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/authorization/client/dto/DeviceIdentifier.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/authorization/client/dto/DeviceIdentifier.java new file mode 100644 index 000000000..872af37f9 --- /dev/null +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/authorization/client/dto/DeviceIdentifier.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2014, 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.device.mgt.input.adapter.http.authorization.client.dto; + +import java.io.Serializable; + +/** + * DTO of the device identifier + */ +public class DeviceIdentifier implements Serializable{ + + private String id; + private String type; + + public DeviceIdentifier() {} + + public DeviceIdentifier(String id, String type) { + this.id = id; + this.type = type; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type.toLowerCase(); + } + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } +} diff --git a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/authorization/client/dto/OAuthApplicationInfo.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/authorization/client/dto/OAuthApplicationInfo.java new file mode 100755 index 000000000..b396c863d --- /dev/null +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/authorization/client/dto/OAuthApplicationInfo.java @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * Licensed 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.device.mgt.input.adapter.http.authorization.client.dto; + +/** + * This class represents an OAuth application populated with necessary data. + */ +public class OAuthApplicationInfo { + + public String client_id; + public String client_name; + public String callback_url; + public String client_secret; + + public String getClient_id() { + return client_id; + } + + public void setClient_id(String client_id) { + this.client_id = client_id; + } + + public String getClient_name() { + return client_name; + } + + public void setClient_name(String client_name) { + this.client_name = client_name; + } + + public String getCallback_url() { + return callback_url; + } + + public void setCallback_url(String callback_url) { + this.callback_url = callback_url; + } + + public String getClient_secret() { + return client_secret; + } + + public void setClient_secret(String client_secret) { + this.client_secret = client_secret; + } +} diff --git a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/authorization/client/dto/RegisterInfo.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/authorization/client/dto/RegisterInfo.java new file mode 100755 index 000000000..4bb046b48 --- /dev/null +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/authorization/client/dto/RegisterInfo.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * Licensed 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.device.mgt.input.adapter.http.authorization.client.dto; + +/** + * This holds the data related to registration. + */ +public class RegisterInfo { + + private boolean isRegistered; + private String msg; + + public boolean isRegistered() { + return isRegistered; + } + + public void setIsRegistered(boolean isRegistered) { + this.isRegistered = isRegistered; + } + + public String getMsg() { + return msg; + } + + public void setMsg(String msg) { + this.msg = msg; + } +} diff --git a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/authorization/client/dto/RegistrationProfile.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/authorization/client/dto/RegistrationProfile.java new file mode 100755 index 000000000..0ed5cfbe3 --- /dev/null +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/authorization/client/dto/RegistrationProfile.java @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * Licensed 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.device.mgt.input.adapter.http.authorization.client.dto; + + +/** + * This class represents the data that are required to register + * the oauth application. + */ +public class RegistrationProfile { + + public String callbackUrl; + public String clientName; + public String tokenScope; + public String owner; + public String grantType; + public String applicationType; + + public String getCallbackUrl() { + return callbackUrl; + } + + public void setCallbackUrl(String callBackUrl) { + this.callbackUrl = callBackUrl; + } + + public String getClientName() { + return clientName; + } + + public void setClientName(String clientName) { + this.clientName = clientName; + } + + public String getTokenScope() { + return tokenScope; + } + + public void setTokenScope(String tokenScope) { + this.tokenScope = tokenScope; + } + + public String getOwner() { + return owner; + } + + public void setOwner(String owner) { + this.owner = owner; + } + + public String getGrantType() { + return grantType; + } + + public void setGrantType(String grantType) { + this.grantType = grantType; + } + + public String getApplicationType() { + return applicationType; + } + + public void setApplicationType(String applicationType) { + this.applicationType = applicationType; + } + +} \ No newline at end of file diff --git a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/authorization/client/dto/TokenIssuerService.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/authorization/client/dto/TokenIssuerService.java new file mode 100755 index 000000000..950d05291 --- /dev/null +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/authorization/client/dto/TokenIssuerService.java @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * Licensed 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. + * + */ +/* + * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * Licensed 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.device.mgt.input.adapter.http.authorization.client.dto; + +import javax.ws.rs.Consumes; +import javax.ws.rs.POST; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; + +/** + * This hold the api defintion that is used as a contract with netflix feign. + */ +public interface TokenIssuerService { + + @POST + @Produces(MediaType.APPLICATION_JSON) + @Consumes(MediaType.APPLICATION_FORM_URLENCODED) + AccessTokenInfo getToken(@QueryParam("grant_type") String grant, @QueryParam("username") String username, + @QueryParam("password") String password); + + @POST + @Produces(MediaType.APPLICATION_JSON) + @Consumes(MediaType.APPLICATION_FORM_URLENCODED) + AccessTokenInfo getToken(@QueryParam("grant_type") String grant, @QueryParam("username") String username, + @QueryParam("password") String password, @QueryParam("scope") String scopes); + + @POST + @Produces(MediaType.APPLICATION_JSON) + @Consumes(MediaType.APPLICATION_FORM_URLENCODED) + AccessTokenInfo getToken(@QueryParam("grant_type") String grant, @QueryParam("refresh_token") String refreshToken); +} \ No newline at end of file diff --git a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/internal/InputAdapterServiceComponent.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/internal/InputAdapterServiceComponent.java index 7e5688838..cd3876c8f 100644 --- a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/internal/InputAdapterServiceComponent.java +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/internal/InputAdapterServiceComponent.java @@ -21,6 +21,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.osgi.service.component.ComponentContext; import org.osgi.service.http.HttpService; +import org.wso2.carbon.device.mgt.input.adapter.extension.InputAdapterExtensionService; import org.wso2.carbon.device.mgt.input.adapter.http.HTTPEventAdapterFactory; import org.wso2.carbon.event.input.adapter.core.InputEventAdapterFactory; import org.wso2.carbon.user.core.service.RealmService; @@ -29,9 +30,19 @@ import org.wso2.carbon.user.core.service.RealmService; * @scr.component name="input.iot.http.AdapterService.component" immediate="true" * @scr.reference name="user.realmservice.default" * interface="org.wso2.carbon.user.core.service.RealmService" cardinality="1..1" - * policy="dynamic" bind="setRealmService" unbind="unsetRealmService" + * policy="dynamic" + * bind="setRealmService" + * unbind="unsetRealmService" * @scr.reference name="http.service" interface="org.osgi.service.http.HttpService" - * cardinality="1..1" policy="dynamic" bind="setHttpService" unbind="unsetHttpService" + * cardinality="1..1" + * policy="dynamic" + * bind="setHttpService" + * unbind="unsetHttpService" + * @scr.reference name="input.extension.service" interface="org.wso2.carbon.device.mgt.input.adapter.extension.InputAdapterExtensionService" + * cardinality="1..1" + * policy="dynamic" + * bind="setInputAdapterExtensionService" + * unbind="unsetInputAdapterExtensionService" */ public class InputAdapterServiceComponent { @@ -67,4 +78,12 @@ public class InputAdapterServiceComponent { InputAdapterServiceDataHolder.registerHTTPService(null); } + protected void setInputAdapterExtensionService(InputAdapterExtensionService inputAdapterExtensionService) { + InputAdapterServiceDataHolder.setInputAdapterExtensionService(inputAdapterExtensionService); + } + + protected void unsetInputAdapterExtensionService(InputAdapterExtensionService inputAdapterExtensionService) { + InputAdapterServiceDataHolder.setInputAdapterExtensionService(null); + } + } diff --git a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/internal/InputAdapterServiceDataHolder.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/internal/InputAdapterServiceDataHolder.java index 6f1969e6d..e521f2c3c 100644 --- a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/internal/InputAdapterServiceDataHolder.java +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/internal/InputAdapterServiceDataHolder.java @@ -15,6 +15,7 @@ package org.wso2.carbon.device.mgt.input.adapter.http.internal; import org.osgi.service.http.HttpService; +import org.wso2.carbon.device.mgt.input.adapter.extension.InputAdapterExtensionService; import org.wso2.carbon.user.core.service.RealmService; /** @@ -24,6 +25,7 @@ public final class InputAdapterServiceDataHolder { private static RealmService realmService; private static HttpService httpService; + private static InputAdapterExtensionService inputAdapterExtensionService; private InputAdapterServiceDataHolder() { } @@ -46,5 +48,12 @@ public final class InputAdapterServiceDataHolder { return httpService; } + public static void setInputAdapterExtensionService(InputAdapterExtensionService inputAdapterExtensionService) { + InputAdapterServiceDataHolder.inputAdapterExtensionService = inputAdapterExtensionService; + } + + public static InputAdapterExtensionService getInputAdapterExtensionService() { + return inputAdapterExtensionService; + } } diff --git a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/util/HTTPContentValidator.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/util/HTTPContentValidator.java deleted file mode 100644 index d8085d5b5..000000000 --- a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/util/HTTPContentValidator.java +++ /dev/null @@ -1,99 +0,0 @@ -/* -* 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.device.mgt.input.adapter.http.util; - -import com.jayway.jsonpath.JsonPath; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.json.simple.JSONArray; -import org.json.simple.parser.JSONParser; -import org.json.simple.parser.ParseException; -import org.wso2.carbon.device.mgt.input.adapter.extension.ContentInfo; -import org.wso2.carbon.device.mgt.input.adapter.extension.ContentValidator; - -import java.util.List; -import java.util.Map; - -public class HTTPContentValidator implements ContentValidator { - private static final Log log = LogFactory.getLog(HTTPContentValidator.class); - private static String JSON_ARRAY_START_CHAR = "["; - private static String CDMF_SCOPE_PREFIX = "cdmf"; - private static String CDMF_SCOPE_SEPERATOR = "/"; - - @Override - public ContentInfo validate(Object msgPayload, Map dynamicParams) { - String deviceId = (String) dynamicParams.get("deviceId"); - String deviceType = (String) dynamicParams.get("deviceType"); - String msg = (String) msgPayload; - String deviceIdJsonPath = HTTPEventAdapterConstants.DEVICE_ID_JSON_PATH; - boolean status; - if (status = isValidDevice(deviceId, deviceType, dynamicParams)) { - if (msg.startsWith(JSON_ARRAY_START_CHAR)) { - status = processMultipleEvents(msg, deviceId, deviceIdJsonPath); - } else { - status = processSingleEvent(msg, deviceId, deviceIdJsonPath); - } - } - return new ContentInfo(status, msg); - } - - private boolean processSingleEvent(String msg, String deviceIdFromTopic, String deviceIdJsonPath) { - Object res = JsonPath.read(msg, deviceIdJsonPath); - String deviceIdFromContent = (res != null) ? res.toString() : ""; - if (deviceIdFromContent.equals(deviceIdFromTopic)) { - return true; - } - return false; - } - - private boolean processMultipleEvents(String msg, String deviceIdFromTopic, String deviceIdJsonPath) { - try { - JSONParser jsonParser = new JSONParser(); - JSONArray jsonArray = (JSONArray) jsonParser.parse(msg); - boolean status = false; - for (int i = 0; i < jsonArray.size(); i++) { - status = processSingleEvent(jsonArray.get(i).toString(), deviceIdFromTopic, deviceIdJsonPath); - if (!status) { - return status; - } - } - return status; - } catch (ParseException e) { - log.error("Invalid input " + msg, e); - return false; - } - } - - private boolean isValidDevice(String deviceId, String deviceType, Map dynamicParams) { - List scopes = (List) dynamicParams.get(HTTPEventAdapterConstants.SCOPE_TAG); - if (scopes != null) { - for (String scope : scopes) { - if (scope.startsWith(CDMF_SCOPE_PREFIX)) { - String deviceIdInfo[] = scope.split(CDMF_SCOPE_SEPERATOR); - if (deviceIdInfo.length == 3) { - if (deviceId.equals(deviceIdInfo[2]) && deviceType.equals(deviceIdInfo[1])) { - return true; - } - } - } - } - } - return false; - } -} diff --git a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/util/HTTPEventAdapterConstants.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/util/HTTPEventAdapterConstants.java index c5d88a975..7fe46450a 100644 --- a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/util/HTTPEventAdapterConstants.java +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/util/HTTPEventAdapterConstants.java @@ -48,27 +48,17 @@ public final class HTTPEventAdapterConstants { public static final int DEFAULT_HTTP_PORT = 9763; public static final int DEFAULT_HTTPS_PORT = 9443; public static final String MAXIMUM_TOTAL_HTTP_CONNECTION = "maximumTotalHttpConnection"; - public static final String MAXIMUM_TOTAL_HTTP_CONNECTION_HINT = "maximumTotalHttpConnection.hint"; public static final String MAXIMUM_HTTP_CONNECTION_PER_HOST = "maximumHttpConnectionPerHost"; - public static final String MAXIMUM_HTTP_CONNECTION_PER_HOST_HINT = "maximumHttpConnectionPerHost.hint"; - public static final String TOKEN_VALIDATION_ENDPOINT_URL = "keymanagerUrl"; + public static final String TOKEN_VALIDATION_ENDPOINT_URL = "tokenValidationUrl"; public static final String TOKEN_VALIDATION_POST_FIX = "/services/OAuth2TokenValidationService"; public static final String USERNAME = "username"; - public static final String USERNAME_HINT = "username.hint"; public static final String PASSWORD = "password"; - public static final String PASSWORD_HINT = "password.hint"; - public static final String DEFAULT_STRING = "default"; - public static final String MAX_HTTP_CONNECTION = "2"; - public static final String MAX_TOTAL_HTTP_CONNECTION = "100"; public static final String TENANT_DOMAIN_TAG = "tenantDomain"; public static final String USERNAME_TAG = "username"; public static final String SCOPE_TAG = "scopes"; - public static final String PAYLOAD_TAG = "payload"; - public static final String DEVICE_ID_JSON_PATH = "event.metaData.deviceId"; - public static final String ADAPTER_CONF_CONTENT_VALIDATOR_CLASSNAME = "contentValidator"; - public static final String ADAPTER_CONF_CONTENT_VALIDATOR_CLASSNAME_HINT = "contentValidator.hint"; + public static final String ADAPTER_CONF_CONTENT_VALIDATOR_TYPE = "contentValidator"; + public static final String ADAPTER_CONF_CONTENT_VALIDATOR_TYPE_HINT = "contentValidator.hint"; public static final String DEFAULT = "default"; - public static final String HTTP_CONTENT_VALIDATION_DEFAULT_PARAMETERS = ""; public static final String ADAPTER_CONF_CONTENT_TRANSFORMER_CLASSNAME = "contentTransformer"; public static final String ADAPTER_CONF_CONTENT_TRANSFORMER_CLASSNAME_HINT = "contentTransformer.hint"; } diff --git a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/util/PropertyUtils.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/util/PropertyUtils.java new file mode 100644 index 000000000..d6f442cdd --- /dev/null +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/util/PropertyUtils.java @@ -0,0 +1,45 @@ +/* +* 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.device.mgt.input.adapter.http.util; + +import org.wso2.carbon.event.input.adapter.core.exception.InputEventAdapterException; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class PropertyUtils { + + //This method is only used if the mb features are within DAS. + public static String replaceProperty(String urlWithPlaceholders) throws InputEventAdapterException { + String regex = "\\$\\{(.*?)\\}"; + Pattern pattern = Pattern.compile(regex); + Matcher matchPattern = pattern.matcher(urlWithPlaceholders); + while (matchPattern.find()) { + String sysPropertyName = matchPattern.group(1); + String sysPropertyValue = System.getProperty(sysPropertyName); + if (sysPropertyValue != null && !sysPropertyName.isEmpty()) { + urlWithPlaceholders = urlWithPlaceholders.replaceAll("\\$\\{(" + sysPropertyName + ")\\}", sysPropertyValue); + } else { + throw new InputEventAdapterException("System property - " + sysPropertyName + + " is not defined, hence cannot resolve : " + urlWithPlaceholders); + } + } + return urlWithPlaceholders; + } +} diff --git a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/resources/org/wso2/carbon/device/mgt/input/adapter/http/i18n/Resources.properties b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/resources/org/wso2/carbon/device/mgt/input/adapter/http/i18n/Resources.properties index d21d20917..0b17e3b53 100644 --- a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/resources/org/wso2/carbon/device/mgt/input/adapter/http/i18n/Resources.properties +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/resources/org/wso2/carbon/device/mgt/input/adapter/http/i18n/Resources.properties @@ -23,6 +23,6 @@ http.usage.tips_mid2=/endpoints/<event_receiver_name>

For oth http.usage.tips_mid3=/endpoints/t/<tenant_domain>/<event_receiver_name>
  https://localhost: http.usage.tips_postfix=/endpoints/t/<tenant_domain>/<event_receiver_name> contentValidator=contentValidator -contentValidator.hint=Class Name of the content Validation or 'default' to set default class, required to implement (if required) +contentValidator.hint=Type of the content Validation or 'default' to set default impl, required to implement (if required) contentTransformer=contentTransformer -contentTransformer.hint=Class Name of the content transformer or 'default' to set default class, required to implement (if required) \ No newline at end of file +contentTransformer.hint=Type of the content transformer or 'default' to set default type, required to implement (if required) \ No newline at end of file diff --git a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/pom.xml b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/pom.xml index 8b0d5a287..728d4622c 100644 --- a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/pom.xml +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/pom.xml @@ -20,7 +20,7 @@ org.wso2.carbon.devicemgt-plugins cdmf-transport-adapters - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT ../../pom.xml 4.0.0 @@ -32,6 +32,10 @@ http://wso2.org + + commons-codec.wso2 + commons-codec + org.wso2.carbon.analytics-common org.wso2.carbon.event.input.adapter.core @@ -72,6 +76,10 @@ org.wso2.carbon.devicemgt-plugins org.wso2.carbon.device.mgt.input.adapter.extension + + org.wso2.carbon.devicemgt + org.wso2.carbon.identity.jwt.client.extension + @@ -124,9 +132,20 @@ org.apache.http.client.methods;version="${httpclient.version.range}", org.apache.http.impl.client;version="${httpclient.version.range}", org.json.simple.*, - com.jayway.jsonpath.* + com.jayway.jsonpath.*, + org.wso2.carbon.identity.jwt.client.extension.*, + javax.net.ssl, + org.apache.commons.codec.binary, + org.apache.commons.logging, + org.apache.http.entity, + org.osgi.framework, + org.osgi.service.component, + org.osgi.service.http, + org.wso2.carbon.context, + org.wso2.carbon.core, + org.wso2.carbon.device.mgt.input.adapter.extension, + org.wso2.carbon.user.api - * diff --git a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/MQTTEventAdapter.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/MQTTEventAdapter.java index a2ddfd446..f6b80dc79 100644 --- a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/MQTTEventAdapter.java +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/MQTTEventAdapter.java @@ -42,7 +42,6 @@ public class MQTTEventAdapter implements InputEventAdapter { private MQTTAdapterListener mqttAdapterListener; private MQTTBrokerConnectionConfiguration mqttBrokerConnectionConfiguration; - public MQTTEventAdapter(InputEventAdapterConfiguration eventAdapterConfiguration, Map globalProperties) { this.eventAdapterConfiguration = eventAdapterConfiguration; @@ -53,7 +52,6 @@ public class MQTTEventAdapter implements InputEventAdapter { public void init(InputEventAdapterListener eventAdapterListener) throws InputEventAdapterException { this.eventAdapterListener = eventAdapterListener; try { - mqttBrokerConnectionConfiguration = new MQTTBrokerConnectionConfiguration(eventAdapterConfiguration ,globalProperties); mqttAdapterListener = new MQTTAdapterListener(mqttBrokerConnectionConfiguration diff --git a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/MQTTEventAdapterFactory.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/MQTTEventAdapterFactory.java index 5212b029d..f5f93b17a 100644 --- a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/MQTTEventAdapterFactory.java +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/MQTTEventAdapterFactory.java @@ -65,12 +65,12 @@ public class MQTTEventAdapterFactory extends InputEventAdapterFactory { //Content Validator details - Property contentValidator = new Property(MQTTEventAdapterConstants.ADAPTER_CONF_CONTENT_VALIDATOR_CLASSNAME); + Property contentValidator = new Property(MQTTEventAdapterConstants.ADAPTER_CONF_CONTENT_VALIDATOR_TYPE); contentValidator.setDisplayName( - resourceBundle.getString(MQTTEventAdapterConstants.ADAPTER_CONF_CONTENT_VALIDATOR_CLASSNAME)); + resourceBundle.getString(MQTTEventAdapterConstants.ADAPTER_CONF_CONTENT_VALIDATOR_TYPE)); contentValidator.setRequired(false); contentValidator.setHint( - resourceBundle.getString(MQTTEventAdapterConstants.ADAPTER_CONF_CONTENT_VALIDATOR_CLASSNAME_HINT)); + resourceBundle.getString(MQTTEventAdapterConstants.ADAPTER_CONF_CONTENT_VALIDATOR_TYPE_HINT)); contentValidator.setDefaultValue(MQTTEventAdapterConstants.DEFAULT); propertyList.add(contentValidator); @@ -78,7 +78,7 @@ public class MQTTEventAdapterFactory extends InputEventAdapterFactory { Property userName = new Property(MQTTEventAdapterConstants.ADAPTER_CONF_USERNAME); userName.setDisplayName( resourceBundle.getString(MQTTEventAdapterConstants.ADAPTER_CONF_USERNAME)); - userName.setRequired(true); + userName.setRequired(false); userName.setHint(resourceBundle.getString(MQTTEventAdapterConstants.ADAPTER_CONF_USERNAME_HINT)); propertyList.add(userName); @@ -86,7 +86,7 @@ public class MQTTEventAdapterFactory extends InputEventAdapterFactory { Property password = new Property(MQTTEventAdapterConstants.ADAPTER_CONF_PASSWORD); userName.setDisplayName( resourceBundle.getString(MQTTEventAdapterConstants.ADAPTER_CONF_PASSWORD)); - userName.setRequired(true); + userName.setRequired(false); userName.setHint(resourceBundle.getString(MQTTEventAdapterConstants.ADAPTER_CONF_PASSWORD_HINT)); propertyList.add(password); @@ -108,12 +108,12 @@ public class MQTTEventAdapterFactory extends InputEventAdapterFactory { propertyList.add(clearSession); //Content Transformer details - Property contentTransformer = new Property(MQTTEventAdapterConstants.ADAPTER_CONF_CONTENT_TRANSFORMER_CLASSNAME); + Property contentTransformer = new Property(MQTTEventAdapterConstants.ADAPTER_CONF_CONTENT_TRANSFORMER_TYPE); contentTransformer.setDisplayName( - resourceBundle.getString(MQTTEventAdapterConstants.ADAPTER_CONF_CONTENT_TRANSFORMER_CLASSNAME)); + resourceBundle.getString(MQTTEventAdapterConstants.ADAPTER_CONF_CONTENT_TRANSFORMER_TYPE)); contentTransformer.setRequired(false); contentTransformer.setHint( - resourceBundle.getString(MQTTEventAdapterConstants.ADAPTER_CONF_CONTENT_TRANSFORMER_CLASSNAME_HINT)); + resourceBundle.getString(MQTTEventAdapterConstants.ADAPTER_CONF_CONTENT_TRANSFORMER_TYPE_HINT)); contentTransformer.setDefaultValue(MQTTEventAdapterConstants.DEFAULT); propertyList.add(contentTransformer); diff --git a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/internal/InputAdapterServiceComponent.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/internal/InputAdapterServiceComponent.java index d02b8d356..e281a7dae 100644 --- a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/internal/InputAdapterServiceComponent.java +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/internal/InputAdapterServiceComponent.java @@ -21,11 +21,23 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.osgi.service.component.ComponentContext; import org.osgi.service.http.HttpService; +import org.wso2.carbon.device.mgt.input.adapter.extension.InputAdapterExtensionService; import org.wso2.carbon.device.mgt.input.adapter.mqtt.MQTTEventAdapterFactory; import org.wso2.carbon.event.input.adapter.core.InputEventAdapterFactory; +import org.wso2.carbon.identity.jwt.client.extension.service.JWTClientManagerService; /** * @scr.component name="input.iot.mqtt.AdapterService.component" immediate="true" + * @scr.reference name="input.extension.service" interface="org.wso2.carbon.device.mgt.input.adapter.extension.InputAdapterExtensionService" + * cardinality="1..1" + * policy="dynamic" + * bind="setInputAdapterExtensionService" + * unbind="unsetInputAdapterExtensionService" + * @scr.reference name="jwt.client.service" interface="org.wso2.carbon.identity.jwt.client.extension.service.JWTClientManagerService" + * cardinality="1..1" + * policy="dynamic" + * bind="setJWTClientManagerService" + * unbind="unsetJWTClientManagerService" */ public class InputAdapterServiceComponent { @@ -52,4 +64,20 @@ public class InputAdapterServiceComponent { InputAdapterServiceDataHolder.registerHTTPService(null); } + protected void setInputAdapterExtensionService(InputAdapterExtensionService inputAdapterExtensionService) { + InputAdapterServiceDataHolder.setInputAdapterExtensionService(inputAdapterExtensionService); + } + + protected void unsetInputAdapterExtensionService(InputAdapterExtensionService inputAdapterExtensionService) { + InputAdapterServiceDataHolder.setInputAdapterExtensionService(null); + } + + protected void setJWTClientManagerService(JWTClientManagerService jwtClientManagerService) { + InputAdapterServiceDataHolder.setJwtClientManagerService(jwtClientManagerService); + } + + protected void unsetJWTClientManagerService(JWTClientManagerService jwtClientManagerService) { + InputAdapterServiceDataHolder.setJwtClientManagerService(null); + } + } diff --git a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/internal/InputAdapterServiceDataHolder.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/internal/InputAdapterServiceDataHolder.java index 5335ddfb4..72fdbe245 100644 --- a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/internal/InputAdapterServiceDataHolder.java +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/internal/InputAdapterServiceDataHolder.java @@ -15,6 +15,8 @@ package org.wso2.carbon.device.mgt.input.adapter.mqtt.internal; import org.osgi.service.http.HttpService; +import org.wso2.carbon.device.mgt.input.adapter.extension.InputAdapterExtensionService; +import org.wso2.carbon.identity.jwt.client.extension.service.JWTClientManagerService; /** * common place to hold some OSGI service references. @@ -22,6 +24,8 @@ import org.osgi.service.http.HttpService; public final class InputAdapterServiceDataHolder { private static HttpService httpService; + private static InputAdapterExtensionService inputAdapterExtensionService; + private static JWTClientManagerService jwtClientManagerService; private InputAdapterServiceDataHolder() { } @@ -35,5 +39,20 @@ public final class InputAdapterServiceDataHolder { return httpService; } + public static void setInputAdapterExtensionService(InputAdapterExtensionService inputAdapterExtensionService) { + InputAdapterServiceDataHolder.inputAdapterExtensionService = inputAdapterExtensionService; + } + public static InputAdapterExtensionService getInputAdapterExtensionService() { + return inputAdapterExtensionService; + } + + public static JWTClientManagerService getJwtClientManagerService() { + return jwtClientManagerService; + } + + public static void setJwtClientManagerService( + JWTClientManagerService jwtClientManagerService) { + InputAdapterServiceDataHolder.jwtClientManagerService = jwtClientManagerService; + } } diff --git a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/util/MQTTAdapterListener.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/util/MQTTAdapterListener.java index 96546c3ad..dbfc79c9c 100644 --- a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/util/MQTTAdapterListener.java +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/util/MQTTAdapterListener.java @@ -21,14 +21,11 @@ import org.apache.commons.codec.binary.Base64; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.http.HttpResponse; -import org.apache.http.NameValuePair; import org.apache.http.client.HttpClient; -import org.apache.http.client.entity.UrlEncodedFormEntity; import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.ContentType; import org.apache.http.entity.StringEntity; import org.apache.http.message.BasicHeader; -import org.apache.http.message.BasicNameValuePair; import org.eclipse.paho.client.mqttv3.*; import org.eclipse.paho.client.mqttv3.persist.MqttDefaultFilePersistence; import org.json.simple.JSONObject; @@ -39,11 +36,13 @@ import org.wso2.carbon.core.ServerStatus; import org.wso2.carbon.device.mgt.input.adapter.extension.ContentInfo; import org.wso2.carbon.device.mgt.input.adapter.extension.ContentTransformer; import org.wso2.carbon.device.mgt.input.adapter.extension.ContentValidator; -import org.wso2.carbon.device.mgt.input.adapter.extension.DefaultContentTransformer; -import org.wso2.carbon.device.mgt.input.adapter.extension.DefaultContentValidator; +import org.wso2.carbon.device.mgt.input.adapter.mqtt.internal.InputAdapterServiceDataHolder; import org.wso2.carbon.event.input.adapter.core.InputEventAdapterListener; import org.wso2.carbon.event.input.adapter.core.exception.InputEventAdapterRuntimeException; -import org.wso2.carbon.device.mgt.input.adapter.mqtt.exception.MQTTContentInitializationException; +import org.wso2.carbon.identity.jwt.client.extension.dto.AccessTokenInfo; +import org.wso2.carbon.identity.jwt.client.extension.exception.JWTClientException; +import org.wso2.carbon.identity.jwt.client.extension.service.JWTClientManagerService; +import org.wso2.carbon.user.api.UserStoreException; import java.io.IOException; import java.net.MalformedURLException; @@ -51,9 +50,7 @@ import java.net.URL; import java.security.KeyManagementException; import java.security.KeyStoreException; import java.security.NoSuchAlgorithmException; -import java.util.ArrayList; import java.util.HashMap; -import java.util.List; import java.util.Map; public class MQTTAdapterListener implements MqttCallback, Runnable { @@ -83,7 +80,7 @@ public class MQTTAdapterListener implements MqttCallback, Runnable { this.mqttBrokerConnectionConfiguration = mqttBrokerConnectionConfiguration; this.cleanSession = mqttBrokerConnectionConfiguration.isCleanSession(); int keepAlive = mqttBrokerConnectionConfiguration.getKeepAlive(); - this.topic = topic; + this.topic = PropertyUtils.replaceTenantDomainProperty(topic); this.eventAdapterListener = inputEventAdapterListener; this.tenantId = tenantId; @@ -102,43 +99,23 @@ public class MQTTAdapterListener implements MqttCallback, Runnable { // Set this wrapper as the callback handler mqttClient.setCallback(this); - String contentValidatorClassName = this.mqttBrokerConnectionConfiguration.getContentValidatorClassName(); + String contentValidatorType = this.mqttBrokerConnectionConfiguration.getContentValidatorType(); - if (contentValidatorClassName != null && contentValidatorClassName.equals(MQTTEventAdapterConstants.DEFAULT)) { - contentValidator = new DefaultContentValidator(); - } else if (contentValidatorClassName != null && !contentValidatorClassName.isEmpty()) { - try { - Class contentValidatorClass = Class.forName(contentValidatorClassName) - .asSubclass(ContentValidator.class); - contentValidator = contentValidatorClass.newInstance(); - } catch (ClassNotFoundException e) { - throw new MQTTContentInitializationException( - "Unable to find the class validator: " + contentValidatorClassName, e); - } catch (InstantiationException e) { - throw new MQTTContentInitializationException( - "Unable to create an instance of :" + contentValidatorClassName, e); - } catch (IllegalAccessException e) { - throw new MQTTContentInitializationException("Access of the instance in not allowed.", e); - } + if (contentValidatorType == null || contentValidatorType.equals(MQTTEventAdapterConstants.DEFAULT)) { + contentValidator = InputAdapterServiceDataHolder.getInputAdapterExtensionService() + .getDefaultContentValidator(); + } else { + contentValidator = InputAdapterServiceDataHolder.getInputAdapterExtensionService() + .getContentValidator(contentValidatorType); } - String contentTransformerClassName = this.mqttBrokerConnectionConfiguration.getContentTransformerClassName(); - if (contentTransformerClassName != null && contentTransformerClassName.equals(MQTTEventAdapterConstants.DEFAULT)) { - contentTransformer = new DefaultContentTransformer(); - } else if (contentTransformerClassName != null && !contentTransformerClassName.isEmpty()) { - try { - Class contentTransformerClass = Class.forName(contentTransformerClassName) - .asSubclass(ContentTransformer.class); - contentTransformer = contentTransformerClass.newInstance(); - } catch (ClassNotFoundException e) { - throw new MQTTContentInitializationException( - "Unable to find the class transfoer: " + contentTransformerClassName, e); - } catch (InstantiationException e) { - throw new MQTTContentInitializationException( - "Unable to create an instance of :" + contentTransformerClassName, e); - } catch (IllegalAccessException e) { - throw new MQTTContentInitializationException("Access of the instance in not allowed.", e); - } + String contentTransformerType = this.mqttBrokerConnectionConfiguration.getContentTransformerType(); + if (contentTransformerType == null || contentTransformerType.equals(MQTTEventAdapterConstants.DEFAULT)) { + contentTransformer = InputAdapterServiceDataHolder.getInputAdapterExtensionService() + .getDefaultContentTransformer(); + } else { + contentTransformer = InputAdapterServiceDataHolder.getInputAdapterExtensionService() + .getContentTransformer(contentTransformerType); } } catch (MqttException e) { log.error("Exception occurred while subscribing to MQTT broker at " @@ -165,8 +142,16 @@ public class MQTTAdapterListener implements MqttCallback, Runnable { registrationProfile.setGrantType(MQTTEventAdapterConstants.GRANT_TYPE); registrationProfile.setOwner(username); registrationProfile.setTokenScope(MQTTEventAdapterConstants.TOKEN_SCOPE); - registrationProfile.setClientName(MQTTEventAdapterConstants.APPLICATION_NAME_PREFIX - + mqttBrokerConnectionConfiguration.getAdapterName() + "_" + tenantId); + if (!mqttBrokerConnectionConfiguration.isGlobalCredentailSet()) { + registrationProfile.setClientName(MQTTEventAdapterConstants.APPLICATION_NAME_PREFIX + + mqttBrokerConnectionConfiguration.getAdapterName() + + "_" + tenantId); + registrationProfile.setIsSaasApp(false); + } else { + registrationProfile.setClientName(MQTTEventAdapterConstants.APPLICATION_NAME_PREFIX + + mqttBrokerConnectionConfiguration.getAdapterName()); + registrationProfile.setIsSaasApp(true); + } String jsonString = registrationProfile.toJSON(); StringEntity requestEntity = new StringEntity(jsonString, ContentType.APPLICATION_JSON); postMethod.setEntity(requestEntity); @@ -192,8 +177,10 @@ public class MQTTAdapterListener implements MqttCallback, Runnable { } } catch (MalformedURLException e) { log.error("Invalid dcrUrl : " + dcrUrlString); - } catch (KeyManagementException | NoSuchAlgorithmException | KeyStoreException | IOException e) { - log.error("Failed to create an https connection.", e); + } catch (JWTClientException | UserStoreException e) { + log.error("Failed to create an oauth token with jwt grant type.", e); + } catch (NoSuchAlgorithmException |KeyManagementException |KeyStoreException | IOException e) { + log.error("Failed to create a http connection.", e); } } } @@ -287,34 +274,26 @@ public class MQTTAdapterListener implements MqttCallback, Runnable { } private String getToken(String clientId, String clientSecret) - throws IOException, NoSuchAlgorithmException, KeyStoreException, KeyManagementException, ParseException { - URL tokenEndpoint = new URL(mqttBrokerConnectionConfiguration.getTokenUrl()); - HttpClient httpClient = MQTTUtil.getHttpClient(tokenEndpoint.getProtocol()); - HttpPost postMethod = new HttpPost(tokenEndpoint.toString()); - - List nameValuePairs = new ArrayList<>(); - nameValuePairs.add(new BasicNameValuePair(MQTTEventAdapterConstants.GRANT_TYPE_PARAM_NAME, - MQTTEventAdapterConstants.PASSWORD_GRANT_TYPE)); - nameValuePairs.add(new BasicNameValuePair(MQTTEventAdapterConstants.PASSWORD_GRANT_TYPE_USERNAME, - mqttBrokerConnectionConfiguration.getUsername())); - nameValuePairs.add(new BasicNameValuePair(MQTTEventAdapterConstants.PASSWORD_GRANT_TYPE_PASSWORD, - mqttBrokerConnectionConfiguration.getPassword())); - String scopes = mqttBrokerConnectionConfiguration.getBrokerScopes(); - if (scopes != null && !scopes.isEmpty()) { - nameValuePairs.add(new BasicNameValuePair(MQTTEventAdapterConstants.PASSWORD_GRANT_TYPE_SCOPES, scopes)); - } + throws UserStoreException, JWTClientException { + PrivilegedCarbonContext.startTenantFlow(); + PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(tenantId, true); + try { + String scopes = mqttBrokerConnectionConfiguration.getBrokerScopes(); + String username = mqttBrokerConnectionConfiguration.getUsername(); + if (mqttBrokerConnectionConfiguration.isGlobalCredentailSet()) { + username = PrivilegedCarbonContext.getThreadLocalCarbonContext() + .getUserRealm().getRealmConfiguration().getAdminUserName() + "@" + PrivilegedCarbonContext + .getThreadLocalCarbonContext().getTenantDomain(true); + } - postMethod.setEntity(new UrlEncodedFormEntity(nameValuePairs)); - postMethod.addHeader("Authorization", "Basic " + getBase64Encode(clientId, clientSecret)); - postMethod.addHeader("Content-Type", "application/x-www-form-urlencoded"); - HttpResponse httpResponse = httpClient.execute(postMethod); - String response = MQTTUtil.getResponseString(httpResponse); - if (log.isDebugEnabled()) { - log.debug(response); + JWTClientManagerService jwtClientManagerService = + InputAdapterServiceDataHolder.getJwtClientManagerService(); + AccessTokenInfo accessTokenInfo = jwtClientManagerService.getJWTClient().getAccessToken( + clientId, clientSecret, username, scopes); + return accessTokenInfo.getAccessToken(); + } finally { + PrivilegedCarbonContext.endTenantFlow(); } - JSONParser jsonParser = new JSONParser(); - JSONObject jsonObject = (JSONObject) jsonParser.parse(response); - return (String) jsonObject.get(MQTTEventAdapterConstants.ACCESS_TOKEN_GRANT_TYPE_PARAM_NAME); } private String getBase64Encode(String key, String value) { diff --git a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/util/MQTTBrokerConnectionConfiguration.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/util/MQTTBrokerConnectionConfiguration.java index 59ef8a3b4..3685c245f 100644 --- a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/util/MQTTBrokerConnectionConfiguration.java +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/util/MQTTBrokerConnectionConfiguration.java @@ -34,10 +34,10 @@ public class MQTTBrokerConnectionConfiguration { private int keepAlive; private String brokerUrl; private String dcrUrl; - private String tokenUrl; - private String contentValidatorClassName; - private String contentTransformerClassName; + private String contentValidatorType; + private String contentTransformerType; private String adapterName; + private boolean globalCredentailSet; public String getBrokerScopes() { return brokerScopes; @@ -67,16 +67,16 @@ public class MQTTBrokerConnectionConfiguration { return keepAlive; } - public String getContentValidatorClassName() { - return contentValidatorClassName; + public String getContentValidatorType() { + return contentValidatorType; } - public String getContentTransformerClassName() { - return contentTransformerClassName; + public String getContentTransformerType() { + return contentTransformerType; } - public String getTokenUrl() { - return tokenUrl; + public boolean isGlobalCredentailSet() { + return globalCredentailSet; } public String getAdapterName() { @@ -89,6 +89,11 @@ public class MQTTBrokerConnectionConfiguration { adapterName = eventAdapterConfiguration.getName(); this.username = eventAdapterConfiguration.getProperties().get(MQTTEventAdapterConstants.ADAPTER_CONF_USERNAME); this.password = eventAdapterConfiguration.getProperties().get(MQTTEventAdapterConstants.ADAPTER_CONF_PASSWORD); + if ((username == null || username.isEmpty()) && (password == null || password.isEmpty())) { + username = globalProperties.get(MQTTEventAdapterConstants.ADAPTER_CONF_USERNAME); + password = globalProperties.get(MQTTEventAdapterConstants.ADAPTER_CONF_PASSWORD); + globalCredentailSet = true; + } this.brokerScopes = eventAdapterConfiguration.getProperties().get(MQTTEventAdapterConstants.ADAPTER_CONF_SCOPES); if (brokerScopes == null) { this.brokerScopes = MQTTEventAdapterConstants.EMPTY_STRING; @@ -100,10 +105,8 @@ public class MQTTBrokerConnectionConfiguration { this.brokerUrl = PropertyUtils.replaceMqttProperty(url); this.dcrUrl = PropertyUtils .replaceMqttProperty(globalProperties.get(MQTTEventAdapterConstants.ADAPTER_CONF_DCR_URL)); - this.tokenUrl = PropertyUtils - .replaceMqttProperty(globalProperties.get(MQTTEventAdapterConstants.ADAPTER_CONF_TOKEN_URL)); - this.contentValidatorClassName = eventAdapterConfiguration.getProperties() - .get(MQTTEventAdapterConstants.ADAPTER_CONF_CONTENT_VALIDATOR_CLASSNAME); + this.contentValidatorType = eventAdapterConfiguration.getProperties() + .get(MQTTEventAdapterConstants.ADAPTER_CONF_CONTENT_VALIDATOR_TYPE); this.cleanSession = Boolean.parseBoolean(eventAdapterConfiguration.getProperties() .get(MQTTEventAdapterConstants.ADAPTER_CONF_CLEAN_SESSION)); //If global properties are available those will be assigned else constant values will be assigned @@ -112,7 +115,7 @@ public class MQTTBrokerConnectionConfiguration { } else { keepAlive = MQTTEventAdapterConstants.ADAPTER_CONF_DEFAULT_KEEP_ALIVE; } - this.contentTransformerClassName = eventAdapterConfiguration.getProperties() - .get(MQTTEventAdapterConstants.ADAPTER_CONF_CONTENT_TRANSFORMER_CLASSNAME); + this.contentTransformerType = eventAdapterConfiguration.getProperties() + .get(MQTTEventAdapterConstants.ADAPTER_CONF_CONTENT_TRANSFORMER_TYPE); } } diff --git a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/util/MQTTEventAdapterConstants.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/util/MQTTEventAdapterConstants.java index f21abd29b..dc0e45413 100644 --- a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/util/MQTTEventAdapterConstants.java +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/util/MQTTEventAdapterConstants.java @@ -35,10 +35,10 @@ public class MQTTEventAdapterConstants { public static final String ADAPTER_CONF_DCR_URL = "dcrUrl"; public static final String ADAPTER_CONF_TOKEN_URL = "tokenUrl"; public static final String ADAPTER_CONF_DCR_URL_HINT = "dcrUrl.hint"; - public static final String ADAPTER_CONF_CONTENT_VALIDATOR_CLASSNAME = "contentValidator"; - public static final String ADAPTER_CONF_CONTENT_VALIDATOR_CLASSNAME_HINT = "contentValidator.hint"; - public static final String ADAPTER_CONF_CONTENT_TRANSFORMER_CLASSNAME = "contentTransformer"; - public static final String ADAPTER_CONF_CONTENT_TRANSFORMER_CLASSNAME_HINT = "contentTransformer.hint"; + public static final String ADAPTER_CONF_CONTENT_VALIDATOR_TYPE = "contentValidator"; + public static final String ADAPTER_CONF_CONTENT_VALIDATOR_TYPE_HINT = "contentValidator.hint"; + public static final String ADAPTER_CONF_CONTENT_TRANSFORMER_TYPE = "contentTransformer"; + public static final String ADAPTER_CONF_CONTENT_TRANSFORMER_TYPE_HINT = "contentTransformer.hint"; public static final String ADAPTER_MESSAGE_TOPIC = "topic"; public static final String ADAPTER_MESSAGE_TOPIC_HINT = "topic.hint"; public static final String ADAPTER_CONF_CLIENTID = "clientId"; @@ -53,7 +53,7 @@ public class MQTTEventAdapterConstants { public static final String EMPTY_STRING = ""; public static final String GRANT_TYPE_PARAM_NAME = "grant_type"; - public static final String GRANT_TYPE = "password refresh_token"; + public static final String GRANT_TYPE = "password refresh_token urn:ietf:params:oauth:grant-type:jwt-bearer"; public static final String TOKEN_SCOPE = "production"; public static final String APPLICATION_NAME_PREFIX = "InputAdapter_"; public static final String CLIENT_ID = "clientId"; @@ -63,15 +63,7 @@ public class MQTTEventAdapterConstants { public static final String MQTT_CONTENT_VALIDATION_DEFAULT_PARAMETERS = ""; public static final String TOPIC = "topic"; public static final String PAYLOAD = "payload"; - public static final String DEVICE_ID_JSON_PATH = "event.metaData.deviceId"; - public static final String DEVICE_TYPE_JSON_PATH = "event.metaData.deviceId"; - public static final int DEVICE_ID_TOPIC_HIERARCHY_INDEX = 2; public static final String AUTHORIZATION_HEADER_NAME = "Authorization"; public static final String AUTHORIZATION_HEADER_VALUE_PREFIX = "Basic "; - public static final String PASSWORD_GRANT_TYPE = "password"; - public static final String PASSWORD_GRANT_TYPE_USERNAME = "username"; - public static final String PASSWORD_GRANT_TYPE_PASSWORD = "password"; - public static final String PASSWORD_GRANT_TYPE_SCOPES = "scopes"; - public static final String ACCESS_TOKEN_GRANT_TYPE_PARAM_NAME = "access_token"; } diff --git a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/util/PropertyUtils.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/util/PropertyUtils.java index 91a512b79..682a292f7 100644 --- a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/util/PropertyUtils.java +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/util/PropertyUtils.java @@ -18,12 +18,14 @@ package org.wso2.carbon.device.mgt.input.adapter.mqtt.util; +import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.event.input.adapter.core.exception.InputEventAdapterException; import java.util.regex.Matcher; import java.util.regex.Pattern; class PropertyUtils { + private static final String TENANT_DOMAIN_PROPERTY = "\\$\\{tenant-domain\\}"; //This method is only used if the mb features are within DAS. static String replaceMqttProperty(String urlWithPlaceholders) throws InputEventAdapterException { @@ -42,4 +44,10 @@ class PropertyUtils { } return urlWithPlaceholders; } + + public static String replaceTenantDomainProperty (String urlWithPlaceholders) { + urlWithPlaceholders = urlWithPlaceholders.replaceAll(TENANT_DOMAIN_PROPERTY, PrivilegedCarbonContext + .getThreadLocalCarbonContext().getTenantDomain(true)); + return urlWithPlaceholders; + } } diff --git a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/util/RegistrationProfile.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/util/RegistrationProfile.java index f5445f170..fddc8e534 100644 --- a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/util/RegistrationProfile.java +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/util/RegistrationProfile.java @@ -12,6 +12,7 @@ public class RegistrationProfile { private String owner; private String grantType; private String applicationType; + private boolean isSaasApp; private static final String TAG = RegistrationProfile.class.getSimpleName(); @@ -63,11 +64,19 @@ public class RegistrationProfile { this.applicationType = applicationType; } - public String toJSON() { + public boolean isSaasApp() { + return isSaasApp; + } + + public void setIsSaasApp(boolean isSaasApp) { + this.isSaasApp = isSaasApp; + } + + public String toJSON() { String jsonString = "{\"callbackUrl\": \"" + callbackUrl + "\",\"clientName\": \"" + clientName + "\", \"tokenScope\": " + "\"" + tokenScope + "\", \"owner\": \"" + owner + "\"," + "\"grantType\": \"" + grantType + - "\", \"saasApp\" :false }\n"; + "\", \"saasApp\" :" + isSaasApp + " }\n"; return jsonString; } } \ No newline at end of file diff --git a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/resources/org/wso2/carbon/device/mgt/input/adapter/mqtt/i18n/Resources.properties b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/resources/org/wso2/carbon/device/mgt/input/adapter/mqtt/i18n/Resources.properties index 38cfcf7c6..aee8d9a4c 100644 --- a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/resources/org/wso2/carbon/device/mgt/input/adapter/mqtt/i18n/Resources.properties +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/resources/org/wso2/carbon/device/mgt/input/adapter/mqtt/i18n/Resources.properties @@ -27,14 +27,12 @@ password=Password password.hint=Password of the user for the broker (if required) scopes=Scopes scopes.hint=Scopes required to connect to broker (if required) -dcrUrl=dcrUrl -dcrUrl.hint=dynamic client registration endpoint URL to create application (if required) eg: https://localhost:9443/dynamic-client-web/register contentValidator=contentValidation -contentValidator.hint=Class Name of the content Validation or 'default' to set default class, required to implement (if required) +contentValidator.hint=Type of the content Validation or 'default' to set default type, required to implement (if required) url.hint=MQTT broker url tcp://localhost:1883 cleanSession=Clean Session cleanSession.hint=Persist topic subscriptions and ack positions across client sessions keepAlive=Keep Alive (In seconds) events.duplicated.in.cluster=Is events duplicated in cluster contentTransformer=contentTransformer -contentTransformer.hint=Class Name of the content transformer or 'default' to set default class, required to implement (if required) \ No newline at end of file +contentTransformer.hint=Type of the content transformer or 'default' to set default type, required to implement (if required) \ No newline at end of file diff --git a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.xmpp/pom.xml b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.xmpp/pom.xml index 9d292edc4..c1786e995 100644 --- a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.xmpp/pom.xml +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.xmpp/pom.xml @@ -20,7 +20,7 @@ org.wso2.carbon.devicemgt-plugins cdmf-transport-adapters - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT ../../pom.xml 4.0.0 @@ -116,9 +116,16 @@ org.jivesoftware.smack.*, org.apache.log4j, org.wso2.carbon.base, - org.wso2.carbon.core.util + org.wso2.carbon.core.util, + org.apache.commons.logging, + org.osgi.framework, + org.osgi.service.component, + org.osgi.service.http, + org.wso2.carbon.context, + org.wso2.carbon.core, + org.wso2.carbon.device.mgt.input.adapter.extension, + org.wso2.carbon.user.core.service - * diff --git a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/input/adapter/xmpp/internal/InputAdapterServiceComponent.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/input/adapter/xmpp/internal/InputAdapterServiceComponent.java index 32db2049b..4099c23f3 100644 --- a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/input/adapter/xmpp/internal/InputAdapterServiceComponent.java +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/input/adapter/xmpp/internal/InputAdapterServiceComponent.java @@ -21,6 +21,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.osgi.service.component.ComponentContext; import org.osgi.service.http.HttpService; +import org.wso2.carbon.device.mgt.input.adapter.extension.InputAdapterExtensionService; import org.wso2.carbon.device.mgt.input.adapter.xmpp.XMPPEventAdapterFactory; import org.wso2.carbon.event.input.adapter.core.InputEventAdapterFactory; import org.wso2.carbon.user.core.service.RealmService; @@ -30,6 +31,11 @@ import org.wso2.carbon.user.core.service.RealmService; * @scr.reference name="user.realmservice.default" * interface="org.wso2.carbon.user.core.service.RealmService" cardinality="1..1" * policy="dynamic" bind="setRealmService" unbind="unsetRealmService" + * @scr.reference name="input.extension.service" interface="org.wso2.carbon.device.mgt.input.adapter.extension.InputAdapterExtensionService" + * cardinality="1..1" + * policy="dynamic" + * bind="setInputAdapterExtensionService" + * unbind="unsetInputAdapterExtensionService" */ public class InputAdapterServiceComponent { @@ -64,4 +70,12 @@ public class InputAdapterServiceComponent { InputAdapterServiceDataHolder.registerHTTPService(null); } + protected void setInputAdapterExtensionService(InputAdapterExtensionService inputAdapterExtensionService) { + InputAdapterServiceDataHolder.setInputAdapterExtensionService(inputAdapterExtensionService); + } + + protected void unsetInputAdapterExtensionService(InputAdapterExtensionService inputAdapterExtensionService) { + InputAdapterServiceDataHolder.setInputAdapterExtensionService(null); + } + } diff --git a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/input/adapter/xmpp/internal/InputAdapterServiceDataHolder.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/input/adapter/xmpp/internal/InputAdapterServiceDataHolder.java index 38296aea8..f2c92c898 100644 --- a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/input/adapter/xmpp/internal/InputAdapterServiceDataHolder.java +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/input/adapter/xmpp/internal/InputAdapterServiceDataHolder.java @@ -15,6 +15,7 @@ package org.wso2.carbon.device.mgt.input.adapter.xmpp.internal; import org.osgi.service.http.HttpService; +import org.wso2.carbon.device.mgt.input.adapter.extension.InputAdapterExtensionService; import org.wso2.carbon.user.core.service.RealmService; /** @@ -24,6 +25,7 @@ public final class InputAdapterServiceDataHolder { private static RealmService realmService; private static HttpService httpService; + private static InputAdapterExtensionService inputAdapterExtensionService; private InputAdapterServiceDataHolder() { } @@ -46,5 +48,12 @@ public final class InputAdapterServiceDataHolder { return httpService; } + public static void setInputAdapterExtensionService(InputAdapterExtensionService inputAdapterExtensionService) { + InputAdapterServiceDataHolder.inputAdapterExtensionService = inputAdapterExtensionService; + } + + public static InputAdapterExtensionService getInputAdapterExtensionService() { + return inputAdapterExtensionService; + } } diff --git a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/input/adapter/xmpp/util/XMPPAdapterListener.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/input/adapter/xmpp/util/XMPPAdapterListener.java index 2dd10098a..3203ba586 100644 --- a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/input/adapter/xmpp/util/XMPPAdapterListener.java +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/input/adapter/xmpp/util/XMPPAdapterListener.java @@ -21,7 +21,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.jivesoftware.smack.ConnectionConfiguration; import org.jivesoftware.smack.PacketListener; -import org.jivesoftware.smack.ReconnectionManager; import org.jivesoftware.smack.SmackConfiguration; import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPException; @@ -36,9 +35,10 @@ import org.wso2.carbon.core.ServerStatus; import org.wso2.carbon.device.mgt.input.adapter.extension.ContentInfo; import org.wso2.carbon.device.mgt.input.adapter.extension.ContentTransformer; import org.wso2.carbon.device.mgt.input.adapter.extension.ContentValidator; -import org.wso2.carbon.device.mgt.input.adapter.extension.DefaultContentTransformer; -import org.wso2.carbon.device.mgt.input.adapter.extension.DefaultContentValidator; +import org.wso2.carbon.device.mgt.input.adapter.extension.transformer.DefaultContentTransformer; +import org.wso2.carbon.device.mgt.input.adapter.extension.validator.DefaultContentValidator; import org.wso2.carbon.device.mgt.input.adapter.xmpp.exception.XMPPContentInitializationException; +import org.wso2.carbon.device.mgt.input.adapter.xmpp.internal.InputAdapterServiceDataHolder; import org.wso2.carbon.event.input.adapter.core.InputEventAdapterListener; import org.wso2.carbon.event.input.adapter.core.exception.InputEventAdapterRuntimeException; import java.util.HashMap; @@ -58,55 +58,27 @@ public class XMPPAdapterListener implements Runnable { private InputEventAdapterListener eventAdapterListener = null; - public XMPPAdapterListener(XMPPServerConnectionConfiguration xmppServerConnectionConfiguration, InputEventAdapterListener inputEventAdapterListener, int tenantId) { this.xmppServerConnectionConfiguration = xmppServerConnectionConfiguration; this.eventAdapterListener = inputEventAdapterListener; this.tenantId = tenantId; - try { - String contentValidatorClassName = this.xmppServerConnectionConfiguration.getContentValidatorClassName(); - if (contentValidatorClassName != null && contentValidatorClassName.equals(XMPPEventAdapterConstants.DEFAULT)) { - contentValidator = new DefaultContentValidator(); - } else if (contentValidatorClassName != null && !contentValidatorClassName.isEmpty()) { - try { - Class contentValidatorClass = Class.forName(contentValidatorClassName) - .asSubclass(ContentValidator.class); - contentValidator = contentValidatorClass.newInstance(); - } catch (ClassNotFoundException e) { - throw new XMPPContentInitializationException( - "Unable to find the class validator: " + contentValidatorClassName, e); - } catch (InstantiationException e) { - throw new XMPPContentInitializationException( - "Unable to create an instance of :" + contentValidatorClassName, e); - } catch (IllegalAccessException e) { - throw new XMPPContentInitializationException("Access of the instance in not allowed.", e); - } - } + String contentValidatorType = this.xmppServerConnectionConfiguration.getContentValidatorClassName(); + if (contentValidatorType == null || contentValidatorType.equals(XMPPEventAdapterConstants.DEFAULT)) { + contentValidator = InputAdapterServiceDataHolder.getInputAdapterExtensionService().getDefaultContentValidator(); + } else { + contentValidator = InputAdapterServiceDataHolder.getInputAdapterExtensionService() + .getContentValidator(contentValidatorType); + } - String contentTransformerClassName = this.xmppServerConnectionConfiguration.getContentTransformerClassName(); - if (contentTransformerClassName != null && contentTransformerClassName.equals(XMPPEventAdapterConstants.DEFAULT)) { - contentTransformer = new DefaultContentTransformer(); - } else if (contentTransformerClassName != null && !contentTransformerClassName.isEmpty()) { - try { - Class contentTransformerClass = Class.forName(contentTransformerClassName) - .asSubclass(ContentTransformer.class); - contentTransformer = contentTransformerClass.newInstance(); - } catch (ClassNotFoundException e) { - throw new XMPPContentInitializationException( - "Unable to find the class transformer: " + contentTransformerClassName, e); - } catch (InstantiationException e) { - throw new XMPPContentInitializationException( - "Unable to create an instance of :" + contentTransformerClassName, e); - } catch (IllegalAccessException e) { - throw new XMPPContentInitializationException("Access of the instance in not allowed.", e); - } - } - } catch (Throwable e) { - log.error("Exception occurred while subscribing to MQTT broker at " - + xmppServerConnectionConfiguration.getHost()); - throw new InputEventAdapterRuntimeException(e); + String contentTransformerType = this.xmppServerConnectionConfiguration.getContentTransformerClassName(); + if (contentTransformer == null || contentTransformerType.equals(XMPPEventAdapterConstants.DEFAULT)) { + this.contentTransformer = InputAdapterServiceDataHolder.getInputAdapterExtensionService() + .getDefaultContentTransformer(); + } else { + this.contentTransformer = InputAdapterServiceDataHolder.getInputAdapterExtensionService() + .getContentTransformer(contentTransformerType); } } diff --git a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.xmpp/src/main/resources/org/wso2/carbon/device/mgt/input/adapter/xmpp/i18n/Resources.properties b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.xmpp/src/main/resources/org/wso2/carbon/device/mgt/input/adapter/xmpp/i18n/Resources.properties index ac6b7f1e1..7c63ed55d 100644 --- a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.xmpp/src/main/resources/org/wso2/carbon/device/mgt/input/adapter/xmpp/i18n/Resources.properties +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.xmpp/src/main/resources/org/wso2/carbon/device/mgt/input/adapter/xmpp/i18n/Resources.properties @@ -29,8 +29,8 @@ timeoutInterval.hint=used by listeners to the server and for reconnection schedu resource=Resource resource.hint=specific to the XMPP-Account to which the login is made to. contentValidator=contentValidation -contentValidator.hint=Class Name of the content Validation or 'default' to set default class, required to implement (if required) +contentValidator.hint=Type of the content Validation or 'default' to set default type, required to implement (if required) jid=jid jid.hint=JID - XMPP Account Name. contentTransformer=contentTransformer -contentTransformer.hint=Class Name of the content transformer or 'default' to set default class, required to implement (if required) \ No newline at end of file +contentTransformer.hint=Type of the content transformer or 'default' to set default type, required to implement (if required) \ No newline at end of file diff --git a/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.mqtt/pom.xml b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.mqtt/pom.xml index 74b142399..8842867d9 100644 --- a/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.mqtt/pom.xml +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.mqtt/pom.xml @@ -20,7 +20,7 @@ org.wso2.carbon.devicemgt-plugins cdmf-transport-adapters - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT ../../pom.xml 4.0.0 @@ -33,6 +33,10 @@ http://wso2.org + + commons-codec.wso2 + commons-codec + org.wso2.carbon.analytics-common org.wso2.carbon.event.output.adapter.core @@ -61,6 +65,10 @@ com.googlecode.json-simple.wso2 json-simple + + org.wso2.carbon.devicemgt + org.wso2.carbon.identity.jwt.client.extension + @@ -121,7 +129,9 @@ org.apache.commons.codec.binary, org.apache.http.client.entity, org.apache.http.message, - org.apache.commons.ssl + org.apache.commons.ssl, + org.wso2.carbon.identity.jwt.client.extension.*, + org.wso2.carbon.user.api diff --git a/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/output/adapter/mqtt/MQTTEventAdapter.java b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/output/adapter/mqtt/MQTTEventAdapter.java index a87fddf58..fbc9c015d 100644 --- a/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/output/adapter/mqtt/MQTTEventAdapter.java +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/output/adapter/mqtt/MQTTEventAdapter.java @@ -122,7 +122,7 @@ public class MQTTEventAdapter implements OutputEventAdapter { String clientId = eventAdapterConfiguration.getStaticProperties().get( MQTTEventAdapterConstants.ADAPTER_CONF_CLIENTID); qos = eventAdapterConfiguration.getStaticProperties().get(MQTTEventAdapterConstants.ADAPTER_MESSAGE_QOS); - mqttAdapterPublisher = new MQTTAdapterPublisher(mqttBrokerConnectionConfiguration, clientId); + mqttAdapterPublisher = new MQTTAdapterPublisher(mqttBrokerConnectionConfiguration, clientId, tenantId); } @Override diff --git a/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/output/adapter/mqtt/MQTTEventAdapterFactory.java b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/output/adapter/mqtt/MQTTEventAdapterFactory.java index 9275ec20d..1c8cd43de 100644 --- a/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/output/adapter/mqtt/MQTTEventAdapterFactory.java +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/output/adapter/mqtt/MQTTEventAdapterFactory.java @@ -56,19 +56,20 @@ public class MQTTEventAdapterFactory extends OutputEventAdapterFactory { //Broker Username Property userName = new Property(MQTTEventAdapterConstants.ADAPTER_CONF_USERNAME); userName.setDisplayName(resourceBundle.getString(MQTTEventAdapterConstants.ADAPTER_CONF_USERNAME)); - userName.setRequired(true); + userName.setRequired(false); userName.setHint(resourceBundle.getString(MQTTEventAdapterConstants.ADAPTER_CONF_USERNAME_HINT)); //Broker Password Property password = new Property(MQTTEventAdapterConstants.ADAPTER_CONF_PASSWORD); password.setDisplayName(resourceBundle.getString(MQTTEventAdapterConstants.ADAPTER_CONF_PASSWORD)); - password.setRequired(true); + password.setRequired(false); password.setHint(resourceBundle.getString(MQTTEventAdapterConstants.ADAPTER_CONF_PASSWORD_HINT)); //Broker Connection Scopes Property scopes = new Property(MQTTEventAdapterConstants.ADAPTER_CONF_SCOPES); scopes.setDisplayName(resourceBundle.getString(MQTTEventAdapterConstants.ADAPTER_CONF_SCOPES)); - scopes.setRequired(true); + scopes.setRequired(false); + scopes.setDefaultValue("default"); scopes.setHint(resourceBundle.getString(MQTTEventAdapterConstants.ADAPTER_CONF_SCOPES_HINT)); // set clientId diff --git a/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/output/adapter/mqtt/internal/MQTTEventAdapterServiceComponent.java b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/output/adapter/mqtt/internal/MQTTEventAdapterServiceComponent.java index 80784a4ce..d7ff9d9ed 100644 --- a/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/output/adapter/mqtt/internal/MQTTEventAdapterServiceComponent.java +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/output/adapter/mqtt/internal/MQTTEventAdapterServiceComponent.java @@ -22,10 +22,15 @@ import org.apache.commons.logging.LogFactory; import org.osgi.service.component.ComponentContext; import org.wso2.carbon.device.mgt.output.adapter.mqtt.MQTTEventAdapterFactory; import org.wso2.carbon.event.output.adapter.core.OutputEventAdapterFactory; - +import org.wso2.carbon.identity.jwt.client.extension.service.JWTClientManagerService; /** * @scr.component component.name="output.Mqtt.AdapterService.component" immediate="true" + * @scr.reference name="jwt.client.service" interface="org.wso2.carbon.identity.jwt.client.extension.service.JWTClientManagerService" + * cardinality="1..1" + * policy="dynamic" + * bind="setJWTClientManagerService" + * unbind="unsetJWTClientManagerService" */ public class MQTTEventAdapterServiceComponent { @@ -48,4 +53,12 @@ public class MQTTEventAdapterServiceComponent { } } + protected void setJWTClientManagerService(JWTClientManagerService jwtClientManagerService) { + OutputAdapterServiceDataHolder.setJwtClientManagerService(jwtClientManagerService); + } + + protected void unsetJWTClientManagerService(JWTClientManagerService jwtClientManagerService) { + OutputAdapterServiceDataHolder.setJwtClientManagerService(null); + } + } diff --git a/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/output/adapter/mqtt/internal/OutputAdapterServiceDataHolder.java b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/output/adapter/mqtt/internal/OutputAdapterServiceDataHolder.java new file mode 100644 index 000000000..9cda29113 --- /dev/null +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/output/adapter/mqtt/internal/OutputAdapterServiceDataHolder.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * Licensed 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.device.mgt.output.adapter.mqtt.internal; + +import org.wso2.carbon.identity.jwt.client.extension.service.JWTClientManagerService; + +/** + * common place to hold some OSGI service references. + */ +public final class OutputAdapterServiceDataHolder { + + private static JWTClientManagerService jwtClientManagerService; + + public static JWTClientManagerService getJwtClientManagerService() { + return jwtClientManagerService; + } + + public static void setJwtClientManagerService( + JWTClientManagerService jwtClientManagerService) { + OutputAdapterServiceDataHolder.jwtClientManagerService = jwtClientManagerService; + } +} diff --git a/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/output/adapter/mqtt/util/MQTTAdapterPublisher.java b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/output/adapter/mqtt/util/MQTTAdapterPublisher.java index 79188e840..38f078ff7 100644 --- a/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/output/adapter/mqtt/util/MQTTAdapterPublisher.java +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/output/adapter/mqtt/util/MQTTAdapterPublisher.java @@ -21,14 +21,11 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.commons.ssl.Base64; import org.apache.http.HttpResponse; -import org.apache.http.NameValuePair; import org.apache.http.client.HttpClient; -import org.apache.http.client.entity.UrlEncodedFormEntity; import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.ContentType; import org.apache.http.entity.StringEntity; import org.apache.http.message.BasicHeader; -import org.apache.http.message.BasicNameValuePair; import org.eclipse.paho.client.mqttv3.MqttClient; import org.eclipse.paho.client.mqttv3.MqttConnectOptions; import org.eclipse.paho.client.mqttv3.MqttException; @@ -38,9 +35,14 @@ import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; import org.json.simple.parser.ParseException; import org.wso2.carbon.context.PrivilegedCarbonContext; +import org.wso2.carbon.device.mgt.output.adapter.mqtt.internal.OutputAdapterServiceDataHolder; import org.wso2.carbon.event.output.adapter.core.exception.ConnectionUnavailableException; import org.wso2.carbon.event.output.adapter.core.exception.OutputEventAdapterException; import org.wso2.carbon.event.output.adapter.core.exception.OutputEventAdapterRuntimeException; +import org.wso2.carbon.identity.jwt.client.extension.dto.AccessTokenInfo; +import org.wso2.carbon.identity.jwt.client.extension.exception.JWTClientException; +import org.wso2.carbon.identity.jwt.client.extension.service.JWTClientManagerService; +import org.wso2.carbon.user.api.UserStoreException; import java.io.IOException; import java.net.MalformedURLException; @@ -48,8 +50,6 @@ import java.net.URL; import java.security.KeyManagementException; import java.security.KeyStoreException; import java.security.NoSuchAlgorithmException; -import java.util.ArrayList; -import java.util.List; /** * MQTT publisher related configuration initialization and publishing capabilties are implemented here. @@ -60,8 +60,11 @@ public class MQTTAdapterPublisher { private MqttClient mqttClient; private MQTTBrokerConnectionConfiguration mqttBrokerConnectionConfiguration; String clientId; + int tenantId; - public MQTTAdapterPublisher(MQTTBrokerConnectionConfiguration mqttBrokerConnectionConfiguration, String clientId) { + public MQTTAdapterPublisher(MQTTBrokerConnectionConfiguration mqttBrokerConnectionConfiguration, String clientId + , int tenantId) { + this.tenantId = tenantId; if (clientId == null || clientId.trim().isEmpty()) { this.clientId = MqttClient.generateClientId(); } @@ -146,7 +149,6 @@ public class MQTTAdapterPublisher { String password = this.mqttBrokerConnectionConfiguration.getPassword(); String dcrUrlString = this.mqttBrokerConnectionConfiguration.getDcrUrl(); - int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); if (dcrUrlString != null && !dcrUrlString.isEmpty()) { try { URL dcrUrl = new URL(dcrUrlString); @@ -157,8 +159,16 @@ public class MQTTAdapterPublisher { registrationProfile.setGrantType(MQTTEventAdapterConstants.GRANT_TYPE); registrationProfile.setOwner(username); registrationProfile.setTokenScope(MQTTEventAdapterConstants.TOKEN_SCOPE); - registrationProfile.setClientName(MQTTEventAdapterConstants.APPLICATION_NAME_PREFIX - + mqttBrokerConnectionConfiguration.getAdapterName() + "_" + tenantId); + if (!mqttBrokerConnectionConfiguration.isGlobalCredentailSet()) { + registrationProfile.setClientName(MQTTEventAdapterConstants.APPLICATION_NAME_PREFIX + + mqttBrokerConnectionConfiguration.getAdapterName() + + "_" + tenantId); + registrationProfile.setIsSaasApp(false); + } else { + registrationProfile.setClientName(MQTTEventAdapterConstants.APPLICATION_NAME_PREFIX + + mqttBrokerConnectionConfiguration.getAdapterName()); + registrationProfile.setIsSaasApp(true); + } String jsonString = registrationProfile.toJSON(); StringEntity requestEntity = new StringEntity(jsonString, ContentType.APPLICATION_JSON); postMethod.setEntity(requestEntity); @@ -186,40 +196,34 @@ public class MQTTAdapterPublisher { throw new OutputEventAdapterRuntimeException("Invalid dcrUrl : " + dcrUrlString); } catch (KeyManagementException | NoSuchAlgorithmException | KeyStoreException | IOException e) { throw new OutputEventAdapterRuntimeException("Failed to create an https connection.", e); + } catch (JWTClientException | UserStoreException e) { + log.error("Failed to create an oauth token with jwt grant type.", e); } } throw new OutputEventAdapterRuntimeException("Invalid configuration for mqtt publisher"); } private String getToken(String clientId, String clientSecret) - throws IOException, NoSuchAlgorithmException, KeyStoreException, KeyManagementException, ParseException { - URL tokenEndpoint = new URL(mqttBrokerConnectionConfiguration.getTokenUrl()); - HttpClient httpClient = MQTTUtil.getHttpClient(tokenEndpoint.getProtocol()); - HttpPost postMethod = new HttpPost(tokenEndpoint.toString()); - - List nameValuePairs = new ArrayList<>(); - nameValuePairs.add(new BasicNameValuePair(MQTTEventAdapterConstants.GRANT_TYPE_PARAM_NAME, - MQTTEventAdapterConstants.PASSWORD_GRANT_TYPE)); - nameValuePairs.add(new BasicNameValuePair(MQTTEventAdapterConstants.PASSWORD_GRANT_TYPE_USERNAME, - mqttBrokerConnectionConfiguration.getUsername())); - nameValuePairs.add(new BasicNameValuePair(MQTTEventAdapterConstants.PASSWORD_GRANT_TYPE_PASSWORD, - mqttBrokerConnectionConfiguration.getPassword())); - String scopes = mqttBrokerConnectionConfiguration.getScopes(); - if (scopes != null && !scopes.isEmpty()) { - nameValuePairs.add(new BasicNameValuePair(MQTTEventAdapterConstants.PASSWORD_GRANT_TYPE_SCOPES, scopes)); - } + throws UserStoreException, JWTClientException { + PrivilegedCarbonContext.startTenantFlow(); + PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(tenantId, true); + try { + String scopes = mqttBrokerConnectionConfiguration.getScopes(); + String username = mqttBrokerConnectionConfiguration.getUsername(); + if (mqttBrokerConnectionConfiguration.isGlobalCredentailSet()) { + username = PrivilegedCarbonContext.getThreadLocalCarbonContext() + .getUserRealm().getRealmConfiguration().getAdminUserName() + "@" + PrivilegedCarbonContext + .getThreadLocalCarbonContext().getTenantDomain(true); + } - postMethod.setEntity(new UrlEncodedFormEntity(nameValuePairs)); - postMethod.addHeader("Authorization", "Basic " + getBase64Encode(clientId, clientSecret)); - postMethod.addHeader("Content-Type", "application/x-www-form-urlencoded"); - HttpResponse httpResponse = httpClient.execute(postMethod); - String response = MQTTUtil.getResponseString(httpResponse); - if (log.isDebugEnabled()) { - log.debug(response); + JWTClientManagerService jwtClientManagerService = + OutputAdapterServiceDataHolder.getJwtClientManagerService(); + AccessTokenInfo accessTokenInfo = jwtClientManagerService.getJWTClient().getAccessToken( + clientId, clientSecret, username, scopes); + return accessTokenInfo.getAccessToken(); + } finally { + PrivilegedCarbonContext.endTenantFlow(); } - JSONParser jsonParser = new JSONParser(); - JSONObject jsonObject = (JSONObject) jsonParser.parse(response); - return (String) jsonObject.get(MQTTEventAdapterConstants.ACCESS_TOKEN_GRANT_TYPE_PARAM_NAME); } private String getBase64Encode(String key, String value) { diff --git a/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/output/adapter/mqtt/util/MQTTBrokerConnectionConfiguration.java b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/output/adapter/mqtt/util/MQTTBrokerConnectionConfiguration.java index b88d9d18b..2bbd394ab 100644 --- a/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/output/adapter/mqtt/util/MQTTBrokerConnectionConfiguration.java +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/output/adapter/mqtt/util/MQTTBrokerConnectionConfiguration.java @@ -33,6 +33,8 @@ public class MQTTBrokerConnectionConfiguration { private String tokenUrl; private boolean cleanSession = true; private int keepAlive; + private boolean globalCredentailSet; + public String getTokenUrl() { return tokenUrl; } @@ -69,11 +71,20 @@ public class MQTTBrokerConnectionConfiguration { return adapterName; } + public boolean isGlobalCredentailSet() { + return globalCredentailSet; + } + public MQTTBrokerConnectionConfiguration(OutputEventAdapterConfiguration eventAdapterConfiguration, Map globalProperties) { adapterName = eventAdapterConfiguration.getName(); this.username = eventAdapterConfiguration.getStaticProperties().get(MQTTEventAdapterConstants.ADAPTER_CONF_USERNAME); this.password = eventAdapterConfiguration.getStaticProperties().get(MQTTEventAdapterConstants.ADAPTER_CONF_PASSWORD); + if ((username == null || username.isEmpty()) && (password == null || password.isEmpty())) { + username = globalProperties.get(MQTTEventAdapterConstants.ADAPTER_CONF_USERNAME); + password = globalProperties.get(MQTTEventAdapterConstants.ADAPTER_CONF_PASSWORD); + globalCredentailSet = true; + } String url = eventAdapterConfiguration .getStaticProperties().get(MQTTEventAdapterConstants.ADAPTER_CONF_URL); if (url == null || url.isEmpty()) { url = globalProperties.get(MQTTEventAdapterConstants.ADAPTER_CONF_URL); diff --git a/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/output/adapter/mqtt/util/MQTTEventAdapterConstants.java b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/output/adapter/mqtt/util/MQTTEventAdapterConstants.java index 732af141c..1f2bbdd38 100644 --- a/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/output/adapter/mqtt/util/MQTTEventAdapterConstants.java +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/output/adapter/mqtt/util/MQTTEventAdapterConstants.java @@ -58,7 +58,7 @@ public final class MQTTEventAdapterConstants { public static final String DEFAULT_CALLBACK = ""; public static final String DEFAULT_PASSWORD = ""; - public static final String GRANT_TYPE = "password"; + public static final String GRANT_TYPE = "urn:ietf:params:oauth:grant-type:jwt-bearer"; public static final String TOKEN_SCOPE = "production"; public static final String APPLICATION_NAME_PREFIX = "OutputAdapter_"; public static final String CLIENT_ID = "clientId"; diff --git a/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/output/adapter/mqtt/util/PropertyUtils.java b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/output/adapter/mqtt/util/PropertyUtils.java index deda48085..f77279934 100644 --- a/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/output/adapter/mqtt/util/PropertyUtils.java +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/output/adapter/mqtt/util/PropertyUtils.java @@ -21,10 +21,10 @@ package org.wso2.carbon.device.mgt.output.adapter.mqtt.util; import java.util.regex.Matcher; import java.util.regex.Pattern; -class PropertyUtils { +public class PropertyUtils { //This method is only used if the mb features are within DAS. - static String replaceMqttProperty(String urlWithPlaceholders) { + public static String replaceMqttProperty(String urlWithPlaceholders) { String regex = "\\$\\{(.*?)\\}"; Pattern pattern = Pattern.compile(regex); Matcher matchPattern = pattern.matcher(urlWithPlaceholders); diff --git a/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/output/adapter/mqtt/util/RegistrationProfile.java b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/output/adapter/mqtt/util/RegistrationProfile.java index 0a4d93125..ef9249bd6 100644 --- a/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/output/adapter/mqtt/util/RegistrationProfile.java +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/output/adapter/mqtt/util/RegistrationProfile.java @@ -12,6 +12,7 @@ public class RegistrationProfile { private String owner; private String grantType; private String applicationType; + private boolean isSaasApp; private static final String TAG = RegistrationProfile.class.getSimpleName(); @@ -63,11 +64,19 @@ public class RegistrationProfile { this.applicationType = applicationType; } - public String toJSON() { + public boolean isSaasApp() { + return isSaasApp; + } + + public void setIsSaasApp(boolean isSaasApp) { + this.isSaasApp = isSaasApp; + } + + public String toJSON() { String jsonString = "{\"callbackUrl\": \"" + callbackUrl + "\",\"clientName\": \"" + clientName + "\", \"tokenScope\": " + "\"" + tokenScope + "\", \"owner\": \"" + owner + "\"," + "\"grantType\": \"" + grantType + - "\", \"saasApp\" :false }\n"; + "\", \"saasApp\" : " + isSaasApp + " }\n"; return jsonString; } } \ No newline at end of file diff --git a/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket.endpoint/pom.xml b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket.endpoint/pom.xml index 5e964725c..a4246e7d4 100644 --- a/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket.endpoint/pom.xml +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket.endpoint/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt-plugins cdmf-transport-adapters - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT ../../pom.xml diff --git a/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/pom.xml b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/pom.xml index 8e3b97b31..b86ab8f08 100644 --- a/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/pom.xml +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.devicemgt-plugins cdmf-transport-adapters - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT ../../pom.xml diff --git a/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/constants/WebsocketConstants.java b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/constants/WebsocketConstants.java index 6391fa07d..c5c3c01f2 100644 --- a/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/constants/WebsocketConstants.java +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/constants/WebsocketConstants.java @@ -29,7 +29,7 @@ public class WebsocketConstants { public static final String SCOPE_IDENTIFIER = "scopes"; public static final String MAXIMUM_TOTAL_HTTP_CONNECTION = "maximumTotalHttpConnection"; public static final String MAXIMUM_HTTP_CONNECTION_PER_HOST = "maximumHttpConnectionPerHost"; - public static final String TOKEN_VALIDATION_ENDPOINT_URL = "keymanagerUrl"; + public static final String TOKEN_VALIDATION_ENDPOINT_URL = "tokenValidationUrl"; public static final String TOKEN_VALIDATION_CONTEX = "/services/OAuth2TokenValidationService"; public static final String USERNAME = "username"; public static final String PASSWORD = "password"; diff --git a/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.xmpp/pom.xml b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.xmpp/pom.xml index 5c68ba086..3029e8abd 100644 --- a/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.xmpp/pom.xml +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.xmpp/pom.xml @@ -20,7 +20,7 @@ org.wso2.carbon.devicemgt-plugins cdmf-transport-adapters - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT ../../pom.xml diff --git a/components/extensions/cdmf-transport-adapters/pom.xml b/components/extensions/cdmf-transport-adapters/pom.xml index 45f732cab..bf715c897 100644 --- a/components/extensions/cdmf-transport-adapters/pom.xml +++ b/components/extensions/cdmf-transport-adapters/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt-plugins extensions - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT ../pom.xml diff --git a/components/extensions/mb-extensions/org.wso2.carbon.andes.extensions.device.mgt.mqtt.authorization/pom.xml b/components/extensions/mb-extensions/org.wso2.carbon.andes.extensions.device.mgt.mqtt.authorization/pom.xml index 39aa9b75a..7885a389a 100644 --- a/components/extensions/mb-extensions/org.wso2.carbon.andes.extensions.device.mgt.mqtt.authorization/pom.xml +++ b/components/extensions/mb-extensions/org.wso2.carbon.andes.extensions.device.mgt.mqtt.authorization/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt-plugins mb-extensions - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT ../pom.xml diff --git a/components/extensions/mb-extensions/pom.xml b/components/extensions/mb-extensions/pom.xml index 9f65b62b8..e920fde00 100644 --- a/components/extensions/mb-extensions/pom.xml +++ b/components/extensions/mb-extensions/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt-plugins extensions - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT ../pom.xml diff --git a/components/extensions/pom.xml b/components/extensions/pom.xml index f14672d08..7c1457b78 100644 --- a/components/extensions/pom.xml +++ b/components/extensions/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt-plugins carbon-device-mgt-plugins-parent - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT ../../pom.xml 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 index 13f96e631..c90a2dabb 100644 --- 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 @@ -20,7 +20,7 @@ org.wso2.carbon.devicemgt-plugins siddhi-extensions - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT ../pom.xml diff --git a/components/extensions/siddhi-extensions/pom.xml b/components/extensions/siddhi-extensions/pom.xml index b60fae671..25332b34f 100644 --- a/components/extensions/siddhi-extensions/pom.xml +++ b/components/extensions/siddhi-extensions/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt-plugins extensions - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT ../pom.xml 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 index 827c0d084..99cb9be3b 100644 --- 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 @@ -21,7 +21,7 @@ org.wso2.carbon.devicemgt-plugins android-plugin - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT ../pom.xml diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/pom.xml b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/pom.xml index fcde56fc9..b21b40149 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/pom.xml +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/pom.xml @@ -21,7 +21,7 @@ android-plugin org.wso2.carbon.devicemgt-plugins - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT ../pom.xml 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/DeviceManagementAdminService.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/DeviceManagementAdminService.java index db795dcd8..78bb83361 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/DeviceManagementAdminService.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/DeviceManagementAdminService.java @@ -415,7 +415,7 @@ public interface DeviceManagementAdminService { value = "Clearing the Password on Android Devices", notes = "Clear the password on Android devices", response = Activity.class, - tags = "Android Device Management Administrative Service.", + tags = "Android Device Management Administrative Service", extensions = { @Extension(properties = { @ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:clear-password") diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/pom.xml b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/pom.xml index 2f967751f..027b1a800 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/pom.xml +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/pom.xml @@ -23,13 +23,13 @@ android-plugin org.wso2.carbon.devicemgt-plugins - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.device.mgt.mobile.android.ui - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT WSO2 Carbon - Mobile Android UI pom diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/android-web-agent/app/pages/mdm.page.enrollments.android.download-agent/public/asset/android-agent.apk b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/android-web-agent/app/pages/mdm.page.enrollments.android.download-agent/public/asset/android-agent.apk index 6f5ead8bc..a9e3481a4 100644 Binary files a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/android-web-agent/app/pages/mdm.page.enrollments.android.download-agent/public/asset/android-agent.apk and b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/android-web-agent/app/pages/mdm.page.enrollments.android.download-agent/public/asset/android-agent.apk differ 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.device-view/public/js/load-map.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.device-view/public/js/load-map.js index 4a7361e27..10c4ec453 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.device-view/public/js/load-map.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.device-view/public/js/load-map.js @@ -19,8 +19,11 @@ var map; function loadLeafletMap() { + var deviceLocationID = "#device-location", locations = $(deviceLocationID).data("locations"), + location_lat = $(deviceLocationID).data("lat"), + location_long = $(deviceLocationID).data("long"), container = "device-location", zoomLevel = 13, tileSet = "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", @@ -46,6 +49,19 @@ function loadLeafletMap() { $("#map-error").hide(); $("#device-location").show(); + } else if (location_long && location_lat) { + + map = L.map(container).setView([location_lat, location_long], zoomLevel); + L.tileLayer(tileSet, {attribution: attribution}).addTo(map); + + var m = L.marker([location_lat, location_long], {"opacity": opacVal}).addTo(map).bindPopup("Your device is here"); + m.on('mouseover', function (e) { + this.openPopup(); + }); + m.on('mouseout', function (e) { + this.closePopup(); + }); + } else { $("#device-location").hide(); $("#map-error").show(); @@ -56,4 +72,4 @@ $(document).ready(function () { $(".location_tab").on("click", function () { loadLeafletMap(); }); -}); \ 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.type-view/public/js/type-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.type-view/public/js/type-view.js index 7d9c77921..e6a79d11b 100755 --- 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.type-view/public/js/type-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.type-view/public/js/type-view.js @@ -20,7 +20,7 @@ var modalPopup = ".modal", modalPopupContainer = modalPopup + " .modal-content", modalPopupContent = modalPopup + " .modal-content"; -var emmAdminBasePath = "/api/device-mgt/v1.0"; +var backendEndBasePath = "/api/device-mgt/v1.0"; //function openCollapsedNav() { // $(".wr-hidden-nav-toggle-btn").addClass("active"); @@ -102,7 +102,7 @@ function loadNewNotificationsOnSideViewPanel() { if ($("#right-sidebar").attr("is-authorized") == "false") { $("#notification-bubble-wrapper").remove(); } else { - var serviceURL = emmAdminBasePath + "/notifications?status=NEW"; + var serviceURL = backendEndBasePath + "/notifications?status=NEW"; invokerUtil.get(serviceURL, updateNotificationCountOnSuccess, updateNotificationCountOnError); loadNewNotifications(); } @@ -117,7 +117,7 @@ function loadNewNotifications() { var currentUser = notifications.data("currentUser"); $.template("notification-listing", notifications.attr("src"), function (template) { - var serviceURL = emmAdminBasePath + "/notifications?offset=0&limit=5&status=NEW"; + var serviceURL = backendEndBasePath + "/notifications?offset=0&limit=5&status=NEW"; invokerUtil.get( serviceURL, // on success @@ -359,7 +359,7 @@ $(document).ready(function () { $("#right-sidebar").on("click", ".new-notification", function () { var notificationId = $(this).data("id"); var redirectUrl = $(this).data("url"); - var markAsReadNotificationsEpr = emmAdminBasePath + "/notifications/" + notificationId + "/mark-checked"; + var markAsReadNotificationsEpr = backendEndBasePath + "/notifications/" + notificationId + "/mark-checked"; var messageSideBar = ".sidebar-messages"; invokerUtil.put( @@ -382,3 +382,30 @@ $(document).ready(function () { ); }); }); + +function artifactUpload() { + var contentType = "application/json"; + + var urix = backendEndBasePath + "/admin/devicetype/deploy/android"; + var defaultStatusClasses = "fw fw-stack-1x"; + var content = $("#android-statistic-response-template").find(".content"); + var title = content.find("#title"); + var statusIcon = content.find("#status-icon"); + var data = {} + invokerUtil.post(urix, data, function (data) { + title.html("Deploying statistic artifacts. Please wait..."); + statusIcon.attr("class", defaultStatusClasses + " fw-check"); + $(modalPopupContent).html(content.html()); + showPopup(); + setTimeout(function () { + hidePopup(); + location.reload(true); + }, 5000); + + }, function (jqXHR) { + title.html("Failed to deploy artifacts, Please contact administrator."); + statusIcon.attr("class", defaultStatusClasses + " fw-error"); + $(modalPopupContent).html(content.html()); + showPopup(); + }, contentType); +} \ 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.type-view/type-view.hbs 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.type-view/type-view.hbs index a5a93a803..a0c4e15a9 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.type-view/type-view.hbs +++ 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.type-view/type-view.hbs @@ -20,6 +20,9 @@ Enroll Device Download APK Invite by Email + {{#if displayStatus}} + Deploy Analytics Artifacts + {{/if}} @@ -41,6 +44,28 @@ + + +

Prepare


    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.type-view/type-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.type-view/type-view.js index a5c2a32bb..3d0d430b1 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.type-view/type-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.type-view/type-view.js @@ -19,6 +19,21 @@ function onRequest(context){ var viewModel = {}; var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"]; + //uncomment this to enable analytics artifact deployment + //var serviceInvokers = require("/app/modules/oauth/token-protected-service-invokers.js")["invokers"]; + //var url = devicemgtProps["httpsURL"] + "/api/device-mgt/v1.0/admin/devicetype/deploy/android/status"; + //serviceInvokers.XMLHttp.get( + // url, function (responsePayload) { + // var responseContent = responsePayload.status; + // new Log().error(responseContent); + // if ("204" == responsePayload.status) { + // viewModel["displayStatus"] = "Display"; + // } + // }, + // function (responsePayload) { + // //do nothing. + // } + //); viewModel["hostName"] = devicemgtProps["httpsURL"]; viewModel["enrollmentURL"] = devicemgtProps["generalConfig"]["host"] + devicemgtProps["androidEnrollmentDir"]; return viewModel; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/pom.xml b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/pom.xml index 8eaddf080..bd97bd6eb 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/pom.xml +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/pom.xml @@ -22,7 +22,7 @@ android-plugin org.wso2.carbon.devicemgt-plugins - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT ../pom.xml diff --git a/components/mobile-plugins/android-plugin/pom.xml b/components/mobile-plugins/android-plugin/pom.xml index f716ad2a4..2493fdc14 100644 --- a/components/mobile-plugins/android-plugin/pom.xml +++ b/components/mobile-plugins/android-plugin/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt-plugins mobile-plugins - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT ../pom.xml diff --git a/components/mobile-plugins/pom.xml b/components/mobile-plugins/pom.xml index 4ac356bb6..4ce34b0f5 100644 --- a/components/mobile-plugins/pom.xml +++ b/components/mobile-plugins/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt-plugins carbon-device-mgt-plugins-parent - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT ../../pom.xml diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/pom.xml b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/pom.xml index 247eaf3fc..f8537e1f9 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/pom.xml +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/pom.xml @@ -21,7 +21,7 @@ windows-plugin org.wso2.carbon.devicemgt-plugins - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT ../pom.xml diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/DeviceManagementAdminService.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/DeviceManagementAdminService.java index 936b353ac..b97f0e6dc 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/DeviceManagementAdminService.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/DeviceManagementAdminService.java @@ -179,7 +179,7 @@ public interface DeviceManagementAdminService { value = "Dis-enrol the windows Devices", notes = "Dis-enroll on Android devices", response = Activity.class, - tags = "Windows Device Management Administrative Service.", + tags = "Windows Device Management Administrative Service", extensions = { @Extension(properties = { @ExtensionProperty(name = Constants.SCOPE, value = "perm:windows:disenroll") diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/DeviceManagementService.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/DeviceManagementService.java index bbfda4355..73cc46b88 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/DeviceManagementService.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/DeviceManagementService.java @@ -18,8 +18,6 @@ package org.wso2.carbon.device.mgt.mobile.windows.api.services; - -import io.swagger.annotations.*; import org.w3c.dom.Document; import org.wso2.carbon.apimgt.annotations.api.Scope; import org.wso2.carbon.apimgt.annotations.api.Scopes; @@ -28,7 +26,6 @@ import org.wso2.carbon.device.mgt.mobile.windows.api.common.PluginConstants; import org.wso2.carbon.device.mgt.mobile.windows.api.common.exceptions.WindowsConfigurationException; import org.wso2.carbon.device.mgt.mobile.windows.api.common.exceptions.WindowsDeviceEnrolmentException; import org.wso2.carbon.device.mgt.mobile.windows.api.operations.WindowsOperationException; -import org.wso2.carbon.device.mgt.mobile.windows.api.operations.util.Constants; import javax.ws.rs.Consumes; import javax.ws.rs.POST; @@ -57,55 +54,6 @@ public interface DeviceManagementService { @POST @Consumes({PluginConstants.SYNCML_MEDIA_TYPE, MediaType.APPLICATION_XML}) @Produces(PluginConstants.SYNCML_MEDIA_TYPE) - @ApiOperation( - httpMethod = "POST", - value = "Getting pending operations for Windows device.", - notes = "Using this API to fetching more information to enroll the Device and " + - "getting pending operations.", - tags = "Windows Device Management Administrative Service", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = Constants.SCOPE, value = "perm:android:enroll") - }) - } - ) - @ApiResponses(value = { - @ApiResponse( - code = 201, - message = "Ok. \n Successfully getting pending operations.", - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "URL of the activity instance that refers to the scheduled operation."), - @ResponseHeader( - name = "Content-Type", - description = "Content type of the body"), - @ResponseHeader( - name = "ETag", - description = "Entity Tag of the response resource.\n" + - "Used by caches, or in conditional requests."), - @ResponseHeader( - name = "Last-Modified", - description = "Date and time the resource was last modified. \n" + - "Used by caches, or in conditional requests.")}), - @ApiResponse( - code = 303, - message = "See Other. \n The source can be retrieved from the URL specified in the location header.", - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "The Source URL of the document.")}), - @ApiResponse( - code = 400, - message = "Bad Request. \n Invalid request or validation error."), - @ApiResponse( - code = 415, - message = "Unsupported media type. \n The format of the requested entity was not supported.\n"), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n " + - "Server error occurred while getting pending operations.") - }) Response getResponse(Document request) throws WindowsDeviceEnrolmentException, WindowsOperationException, NotificationManagementException, WindowsConfigurationException; diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/discovery/DiscoveryService.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/discovery/DiscoveryService.java index 2b856cb85..d271d9892 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/discovery/DiscoveryService.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/discovery/DiscoveryService.java @@ -18,8 +18,6 @@ package org.wso2.carbon.device.mgt.mobile.windows.api.services.discovery; -import io.swagger.annotations.*; -import org.wso2.carbon.device.mgt.common.operation.mgt.Activity; import org.wso2.carbon.device.mgt.mobile.windows.api.common.PluginConstants; import org.wso2.carbon.device.mgt.mobile.windows.api.common.exceptions.WindowsDeviceEnrolmentException; import org.wso2.carbon.device.mgt.mobile.windows.api.services.discovery.beans.DiscoveryRequest; @@ -27,13 +25,8 @@ import org.wso2.carbon.device.mgt.mobile.windows.api.services.discovery.beans.Di import javax.jws.WebMethod; import javax.jws.WebParam; -import javax.jws.WebResult; import javax.jws.WebService; -import javax.ws.rs.GET; import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; import javax.xml.ws.BindingType; import javax.xml.ws.RequestWrapper; import javax.xml.ws.ResponseWrapper; @@ -48,68 +41,12 @@ import javax.xml.ws.soap.SOAPBinding; @BindingType(value = SOAPBinding.SOAP12HTTP_BINDING) public interface DiscoveryService { @POST - @ApiOperation( - httpMethod = "POST", - value = "Discovering the server Enrollment policy and Enrollment service Endpoints.", - notes = "Using this API to discover the Enrollment policy,Enrollment service and " + - "federated login page server endpoints in the server. ", - response = DiscoveryResponse.class, - tags = "Windows Device Enrollment.", - authorizations = { - @Authorization( - value = "permission", - scopes = {@AuthorizationScope( - scope = "/device-mgt/devices/enroll/windows", - description = "Discover the service endpoints.")} - ) - } - ) - @ApiResponses(value = { - @ApiResponse( - code = 200, - message = "Ok. \n Accepted and getting server endpoints.", - response = DiscoveryResponse.class, - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "URL of the activity instance."), - @ResponseHeader( - name = "Content-Type", - description = "Content type of the body"), - @ResponseHeader( - name = "ETag", - description = "Entity Tag of the response resource.\n" + - "Used by caches, or in conditional requests."), - @ResponseHeader( - name = "Last-Modified", - description = "Date and time the resource was last modified. \n" + - "Used by caches, or in conditional requests.")}), - @ApiResponse( - code = 303, - message = "See Other. \n The source can be retrieved from the URLr.", - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "The Source URL of the document.")}), - @ApiResponse( - code = 400, - message = "Bad Request. \n Invalid request or validation error."), - @ApiResponse( - code = 415, - message = "Unsupported media type. \n The format of the requested entity was not supported.\n"), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n " + - "Server error occurred while fetching the server endpoints.") - }) + @RequestWrapper(localName = "Discover", targetNamespace = PluginConstants.DISCOVERY_SERVICE_TARGET_NAMESPACE) @WebMethod(operationName = "Discover") @ResponseWrapper(localName = "DiscoverResponse", targetNamespace = PluginConstants.DISCOVERY_SERVICE_TARGET_NAMESPACE) void discover( @WebParam(name = "request", targetNamespace = PluginConstants.DISCOVERY_SERVICE_TARGET_NAMESPACE) - @ApiParam( - name = "DiscoveryRequest", - value = "Discovery service SOAP request.") DiscoveryRequest request, @WebParam(mode = WebParam.Mode.OUT, name = "DiscoverResult", targetNamespace = PluginConstants.DISCOVERY_SERVICE_TARGET_NAMESPACE) diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/enrollment/EnrollmentService.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/enrollment/EnrollmentService.java index cb3e38091..5f4f14573 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/enrollment/EnrollmentService.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/enrollment/EnrollmentService.java @@ -18,7 +18,6 @@ package org.wso2.carbon.device.mgt.mobile.windows.api.services.enrollment; -import io.swagger.annotations.*; import org.wso2.carbon.device.mgt.mobile.windows.api.common.PluginConstants; import org.wso2.carbon.device.mgt.mobile.windows.api.common.exceptions.WAPProvisioningException; import org.wso2.carbon.device.mgt.mobile.windows.api.common.exceptions.WindowsDeviceEnrolmentException; @@ -45,59 +44,6 @@ public interface EnrollmentService { @ResponseWrapper(localName = "RequestSecurityTokenResponseCollection", targetNamespace = PluginConstants.WS_TRUST_TARGET_NAMESPACE) @POST - @ApiOperation( - httpMethod = "POST", - value = "Signing the certificate signing request(CSR) and provide request security token response.", - notes = "Using this API to fetching more information to enroll the Device and " + - "getting pending operations.", - tags = "Windows 10 Device Enrollment Service.", - authorizations = { - @Authorization( - value = "permission", - scopes = {@AuthorizationScope( - scope = "/device-mgt/devices/enroll/windows", - description = "Signing the certificate signing request(CSR) " + - "and provide request security token response")} - ) - } - ) - @ApiResponses(value = { - @ApiResponse( - code = 200, - message = "Ok.Successfully signed the CSR.", - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "URL of the activity instance that refers to the scheduled operation."), - @ResponseHeader( - name = "Content-Type", - description = "Content type of the body"), - @ResponseHeader( - name = "ETag", - description = "Entity Tag of the response resource.\n" + - "Used by caches, or in conditional requests."), - @ResponseHeader( - name = "Last-Modified", - description = "Date and time the resource was last modified. \n" + - "Used by caches, or in conditional requests.")}), - @ApiResponse( - code = 303, - message = "See Other. \n The source can be retrieved from the URL specified in the location header.", - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "The Source URL of the document.")}), - @ApiResponse( - code = 400, - message = "Bad Request. \n Invalid request or validation error."), - @ApiResponse( - code = 415, - message = "Unsupported media type. \n The format of the requested entity was not supported.\n"), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n " + - "Server error occurred while Signing the CSR.") - }) void requestSecurityToken( @WebParam(name = "TokenType", targetNamespace = PluginConstants.WS_TRUST_TARGET_NAMESPACE) String tokenType, diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/syncml/SyncmlService.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/syncml/SyncmlService.java index d92b52e65..b666e3f22 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/syncml/SyncmlService.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/syncml/SyncmlService.java @@ -18,12 +18,10 @@ package org.wso2.carbon.device.mgt.mobile.windows.api.services.syncml; -import io.swagger.annotations.*; import org.w3c.dom.Document; import org.wso2.carbon.apimgt.annotations.api.Scope; import org.wso2.carbon.apimgt.annotations.api.Scopes; import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagementException; -import org.wso2.carbon.device.mgt.common.operation.mgt.Activity; import org.wso2.carbon.device.mgt.mobile.windows.api.common.PluginConstants; import org.wso2.carbon.device.mgt.mobile.windows.api.common.exceptions.WindowsConfigurationException; import org.wso2.carbon.device.mgt.mobile.windows.api.common.exceptions.WindowsDeviceEnrolmentException; @@ -57,59 +55,6 @@ public interface SyncmlService { @POST @Consumes({PluginConstants.SYNCML_MEDIA_TYPE, MediaType.APPLICATION_XML}) @Produces(PluginConstants.SYNCML_MEDIA_TYPE) - @ApiOperation( - httpMethod = "POST", - value = "Getting pending operations for Windows device.", - notes = "Using this API to fetching more information to enroll the Device and " + - "getting pending operations.", - tags = "Windows Device Management Administrative Service", - authorizations = { - @Authorization( - value = "permission", - scopes = {@AuthorizationScope( - scope = "/device-mgt/devices/enroll/windows", - description = "Getting pending operations and " + - "device information to enroll the device")} - ) - } - ) - @ApiResponses(value = { - @ApiResponse( - code = 201, - message = "Ok. \n Successfully getting pending operations.", - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "URL of the activity instance that refers to the scheduled operation."), - @ResponseHeader( - name = "Content-Type", - description = "Content type of the body"), - @ResponseHeader( - name = "ETag", - description = "Entity Tag of the response resource.\n" + - "Used by caches, or in conditional requests."), - @ResponseHeader( - name = "Last-Modified", - description = "Date and time the resource was last modified. \n" + - "Used by caches, or in conditional requests.")}), - @ApiResponse( - code = 303, - message = "See Other. \n The source can be retrieved from the URL specified in the location header.", - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "The Source URL of the document.")}), - @ApiResponse( - code = 400, - message = "Bad Request. \n Invalid request or validation error."), - @ApiResponse( - code = 415, - message = "Unsupported media type. \n The format of the requested entity was not supported.\n"), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n " + - "Server error occurred while getting pending operations.") - }) Response getResponse(Document request) throws WindowsDeviceEnrolmentException, WindowsOperationException, NotificationManagementException, WindowsConfigurationException; diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/wstep/CertificateEnrollmentService.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/wstep/CertificateEnrollmentService.java index 1b29298b3..8c6569861 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/wstep/CertificateEnrollmentService.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/wstep/CertificateEnrollmentService.java @@ -52,59 +52,6 @@ public interface CertificateEnrollmentService { @ResponseWrapper(localName = "RequestSecurityTokenResponseCollection", targetNamespace = PluginConstants.WS_TRUST_TARGET_NAMESPACE) @POST - @ApiOperation( - httpMethod = "POST", - value = "Signing the certificate signing request(CSR) and provide request security token response.", - notes = "Using this API to fetching more information to enroll the Device and " + - "getting pending operations.", - tags = "Windows Device Enrollment Service.", - authorizations = { - @Authorization( - value = "permission", - scopes = {@AuthorizationScope( - scope = "/device-mgt/devices/enroll/windows", - description = "GSigning the certificate signing request(CSR) " + - "and provide request security token response")} - ) - } - ) - @ApiResponses(value = { - @ApiResponse( - code = 200, - message = "Ok.Successfully signed the CSR.", - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "URL of the activity instance that refers to the scheduled operation."), - @ResponseHeader( - name = "Content-Type", - description = "Content type of the body"), - @ResponseHeader( - name = "ETag", - description = "Entity Tag of the response resource.\n" + - "Used by caches, or in conditional requests."), - @ResponseHeader( - name = "Last-Modified", - description = "Date and time the resource was last modified. \n" + - "Used by caches, or in conditional requests.")}), - @ApiResponse( - code = 303, - message = "See Other. \n The source can be retrieved from the URL specified in the location header.", - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "The Source URL of the document.")}), - @ApiResponse( - code = 400, - message = "Bad Request. \n Invalid request or validation error."), - @ApiResponse( - code = 415, - message = "Unsupported media type. \n The format of the requested entity was not supported.\n"), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n " + - "Server error occurred while Signing the CSR.") - }) void requestSecurityToken( @WebParam(name = "TokenType", targetNamespace = PluginConstants.WS_TRUST_TARGET_NAMESPACE) String tokenType, diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/xcep/CertificateEnrollmentPolicyService.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/xcep/CertificateEnrollmentPolicyService.java index 91cb4de1c..9b91ef75d 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/xcep/CertificateEnrollmentPolicyService.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/xcep/CertificateEnrollmentPolicyService.java @@ -18,7 +18,6 @@ package org.wso2.carbon.device.mgt.mobile.windows.api.services.xcep; -import io.swagger.annotations.*; import org.wso2.carbon.device.mgt.mobile.windows.api.common.PluginConstants; import org.wso2.carbon.device.mgt.mobile.windows.api.services.xcep.beans.*; @@ -27,7 +26,6 @@ import javax.jws.WebParam; import javax.jws.WebService; import javax.ws.rs.Consumes; import javax.ws.rs.POST; -import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import javax.xml.bind.annotation.XmlSeeAlso; @@ -56,59 +54,6 @@ public interface CertificateEnrollmentPolicyService { @POST @Consumes({PluginConstants.SYNCML_MEDIA_TYPE, MediaType.APPLICATION_XML}) @Produces(PluginConstants.SYNCML_MEDIA_TYPE) - @ApiOperation( - httpMethod = "POST", - value = "Getting pending operations for Windows device.", - notes = "Using this API to fetching more information to enroll the Device and " + - "getting pending operations.", - tags = "Windows Device Management Administrative Service", - authorizations = { - @Authorization( - value = "permission", - scopes = {@AuthorizationScope( - scope = "/device-mgt/devices/enroll/windows", - description = "Getting pending operations and " + - "device information to enroll the device")} - ) - } - ) - @ApiResponses(value = { - @ApiResponse( - code = 201, - message = "Ok. \n Successfully getting pending operations.", - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "URL of the activity instance that refers to the scheduled operation."), - @ResponseHeader( - name = "Content-Type", - description = "Content type of the body"), - @ResponseHeader( - name = "ETag", - description = "Entity Tag of the response resource.\n" + - "Used by caches, or in conditional requests."), - @ResponseHeader( - name = "Last-Modified", - description = "Date and time the resource was last modified. \n" + - "Used by caches, or in conditional requests.")}), - @ApiResponse( - code = 303, - message = "See Other. \n The source can be retrieved from the URL specified in the location header.", - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "The Source URL of the document.")}), - @ApiResponse( - code = 400, - message = "Bad Request. \n Invalid request or validation error."), - @ApiResponse( - code = 415, - message = "Unsupported media type. \n The format of the requested entity was not supported.\n"), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n " + - "Server error occurred while getting pending operations.") - }) void getPolicies( @WebParam(name = "client", targetNamespace = PluginConstants. ENROLLMENT_POLICY_TARGET_NAMESPACE) diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/pom.xml b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/pom.xml index 0f6e02311..e979e3af3 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/pom.xml +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/pom.xml @@ -23,13 +23,13 @@ windows-plugin org.wso2.carbon.devicemgt-plugins - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.device.mgt.mobile.windows.ui - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT WSO2 Carbon - Mobile Windows UI pom diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/pom.xml b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/pom.xml index 11ac24d32..e33b5b18d 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/pom.xml +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/pom.xml @@ -22,7 +22,7 @@ windows-plugin org.wso2.carbon.devicemgt-plugins - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT ../pom.xml diff --git a/components/mobile-plugins/windows-plugin/pom.xml b/components/mobile-plugins/windows-plugin/pom.xml index 3523f2d1f..aaecc79ad 100644 --- a/components/mobile-plugins/windows-plugin/pom.xml +++ b/components/mobile-plugins/windows-plugin/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt-plugins mobile-plugins - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT ../pom.xml diff --git a/features/analytics-feature/org.wso2.carbon.device.mgt.iot.analytics.feature/pom.xml b/features/analytics-feature/org.wso2.carbon.device.mgt.iot.analytics.feature/pom.xml index 8b4571a36..a6679fcce 100644 --- a/features/analytics-feature/org.wso2.carbon.device.mgt.iot.analytics.feature/pom.xml +++ b/features/analytics-feature/org.wso2.carbon.device.mgt.iot.analytics.feature/pom.xml @@ -23,13 +23,13 @@ org.wso2.carbon.devicemgt-plugins analytics-feature - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.device.mgt.iot.analytics.feature - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT pom WSO2 Carbon - IoT Server Analytics Feature http://wso2.org @@ -63,7 +63,6 @@ - diff --git a/features/analytics-feature/org.wso2.carbon.device.mgt.iot.analytics.feature/src/main/resources/p2.inf b/features/analytics-feature/org.wso2.carbon.device.mgt.iot.analytics.feature/src/main/resources/p2.inf index 1245989d7..ea5525436 100644 --- a/features/analytics-feature/org.wso2.carbon.device.mgt.iot.analytics.feature/src/main/resources/p2.inf +++ b/features/analytics-feature/org.wso2.carbon.device.mgt.iot.analytics.feature/src/main/resources/p2.inf @@ -1,6 +1,5 @@ instructions.configure = \ -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.iot.analytics_${feature.version}/carbonapps/,target:${installFolder}/../../deployment/server/carbonapps/,overwrite:true);\ - -instructions.unconfigure = \ -org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/carbonapps/);\ \ No newline at end of file +org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../resources/);\ +org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../resources/devicetypes/);\ +org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../resources/devicetypes/device_management/);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.analytics_${feature.version}/carbonapps/,target:${installFolder}/../../resources/devicetypes/device_management/,overwrite:true);\ diff --git a/features/analytics-feature/org.wso2.carbon.iot.device.statistics.dashboard.feature/pom.xml b/features/analytics-feature/org.wso2.carbon.iot.device.statistics.dashboard.feature/pom.xml index 66cd6d05f..8a3c12b30 100644 --- a/features/analytics-feature/org.wso2.carbon.iot.device.statistics.dashboard.feature/pom.xml +++ b/features/analytics-feature/org.wso2.carbon.iot.device.statistics.dashboard.feature/pom.xml @@ -23,13 +23,13 @@ org.wso2.carbon.devicemgt-plugins analytics-feature - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.iot.device.statistics.dashboard.feature - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT pom WSO2 Carbon - IoT Server Analytics Feature http://wso2.org diff --git a/features/analytics-feature/org.wso2.carbon.iot.device.statistics.dashboard.feature/src/main/resources/p2.inf b/features/analytics-feature/org.wso2.carbon.iot.device.statistics.dashboard.feature/src/main/resources/p2.inf index 451e26141..7af677462 100644 --- a/features/analytics-feature/org.wso2.carbon.iot.device.statistics.dashboard.feature/src/main/resources/p2.inf +++ b/features/analytics-feature/org.wso2.carbon.iot.device.statistics.dashboard.feature/src/main/resources/p2.inf @@ -1,6 +1,5 @@ instructions.configure = \ -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.iot.device.statistics.dashboard_${feature.version}/carbonapps/,target:${installFolder}/../../deployment/server/carbonapps/,overwrite:true);\ - -instructions.unconfigure = \ -org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/carbonapps/);\ \ No newline at end of file +org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../resources/);\ +org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../resources/devicetypes/);\ +org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../resources/devicetypes/device_management/);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.iot.device.statistics.dashboard_${feature.version}/carbonapps/,target:${installFolder}/../../resources/devicetypes/device_management/,overwrite:true);\ diff --git a/features/analytics-feature/org.wso2.carbon.iot.geo.dashboard.feature/pom.xml b/features/analytics-feature/org.wso2.carbon.iot.geo.dashboard.feature/pom.xml index 5cd7c6205..fc3aa7b15 100644 --- a/features/analytics-feature/org.wso2.carbon.iot.geo.dashboard.feature/pom.xml +++ b/features/analytics-feature/org.wso2.carbon.iot.geo.dashboard.feature/pom.xml @@ -23,7 +23,7 @@ org.wso2.carbon.devicemgt-plugins analytics-feature - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT ../pom.xml diff --git a/features/analytics-feature/pom.xml b/features/analytics-feature/pom.xml index e15740474..9836a4b77 100644 --- a/features/analytics-feature/pom.xml +++ b/features/analytics-feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt-plugins carbon-device-mgt-plugins-parent - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT ../../pom.xml diff --git a/features/device-types-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/pom.xml b/features/device-types-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/pom.xml index 13e414a6d..ace48d60c 100644 --- a/features/device-types-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/pom.xml +++ b/features/device-types-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/pom.xml @@ -23,13 +23,13 @@ org.wso2.carbon.devicemgt-plugins androidsense-plugin-feature - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.device.mgt.iot.androidsense.feature - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT pom WSO2 Carbon - IoT Server Android Sense Feature http://wso2.org @@ -110,6 +110,50 @@ + + unpack-analytics + package + + unpack + + + + + org.wso2.carbon.devicemgt-plugins + org.wso2.carbon.device.mgt.iot.analytics + ${project.version} + zip + true + + ${project.build.directory}/maven-shared-archive-resources/carbonapps + + **/* + + + + + + unpack-geo + package + + unpack + + + + + org.wso2.carbon.devicemgt-plugins + org.wso2.carbon.iot.geo.dashboard + ${project.version} + zip + true + + ${project.build.directory}/maven-shared-archive-resources/carbonapps + + **/* + + + + copy-jaxrs-war package diff --git a/features/device-types-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/devicetypes/android_sense.xml b/features/device-types-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/devicetypes/android_sense.xml index 33cb2a7d2..764aa311a 100644 --- a/features/device-types-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/devicetypes/android_sense.xml +++ b/features/device-types-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/devicetypes/android_sense.xml @@ -57,10 +57,7 @@ androidsense.mqtt.adapter - admin - admin 0 - true diff --git a/features/device-types-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/p2.inf b/features/device-types-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/p2.inf index a14a4d13e..565901c76 100644 --- a/features/device-types-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/p2.inf +++ b/features/device-types-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/p2.inf @@ -1,8 +1,11 @@ instructions.configure = \ +org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../resources/);\ +org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../resources/devicetypes/);\ +org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../resources/devicetypes/android_sense/);\ org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/webapps/);\ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.androidsense_${feature.version}/webapps/,target:${installFolder}/../../deployment/server/webapps/,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.iot.androidsense_${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.iot.androidsense_${feature.version}/carbonapps/,target:${installFolder}/../../resources/devicetypes/android_sense/,overwrite:true);\ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.androidsense_${feature.version}/dbscripts/,target:${installFolder}/../../../dbscripts/cdm/plugins/android_sense,overwrite:true);\ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.androidsense_${feature.version}/datasources/,target:${installFolder}/../../conf/datasources/,overwrite:true);\ org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/jaggeryapps/);\ diff --git a/features/device-types-feature/androidsense-plugin-feature/pom.xml b/features/device-types-feature/androidsense-plugin-feature/pom.xml index d618db37e..f539e272b 100644 --- a/features/device-types-feature/androidsense-plugin-feature/pom.xml +++ b/features/device-types-feature/androidsense-plugin-feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt-plugins device-types-feature - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT ../pom.xml diff --git a/features/device-types-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/pom.xml b/features/device-types-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/pom.xml index c1e6e1c3e..87fb81ed0 100644 --- a/features/device-types-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/pom.xml +++ b/features/device-types-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/pom.xml @@ -23,7 +23,7 @@ org.wso2.carbon.devicemgt-plugins arduino-plugin-feature - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT ../pom.xml @@ -113,6 +113,28 @@ + + unpack-analytics + package + + unpack + + + + + org.wso2.carbon.devicemgt-plugins + org.wso2.carbon.device.mgt.iot.analytics + ${project.version} + zip + true + + ${project.build.directory}/maven-shared-archive-resources/carbonapps + + **/* + + + + copy-jaxrs-war package diff --git a/features/device-types-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/p2.inf b/features/device-types-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/p2.inf index 5164aa76d..6ca5d2df7 100644 --- a/features/device-types-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/p2.inf +++ b/features/device-types-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/p2.inf @@ -1,4 +1,7 @@ instructions.configure = \ +org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../resources/);\ +org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../resources/devicetypes/);\ +org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../resources/devicetypes/arduino/);\ org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/webapps/);\ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.arduino_${feature.version}/webapps/,target:${installFolder}/../../deployment/server/webapps/,overwrite:true);\ org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../resources/sketches/);\ @@ -7,7 +10,7 @@ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../featur org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/jaggeryapps/);\ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.arduino_${feature.version}/jaggeryapps/,target:${installFolder}/../../deployment/server/jaggeryapps/,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.iot.arduino_${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.iot.arduino_${feature.version}/carbonapps/,target:${installFolder}/../../resources/devicetypes/arduino/,overwrite:true);\ org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/devicetypes/);\ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.arduino_${feature.version}/devicetypes/,target:${installFolder}/../../deployment/server/devicetypes/,overwrite:true);\ diff --git a/features/device-types-feature/arduino-plugin-feature/pom.xml b/features/device-types-feature/arduino-plugin-feature/pom.xml index 199b9aa7c..d491fc821 100644 --- a/features/device-types-feature/arduino-plugin-feature/pom.xml +++ b/features/device-types-feature/arduino-plugin-feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt-plugins device-types-feature - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT ../pom.xml diff --git a/features/device-types-feature/pom.xml b/features/device-types-feature/pom.xml index 811dadf15..17c67605f 100644 --- a/features/device-types-feature/pom.xml +++ b/features/device-types-feature/pom.xml @@ -22,13 +22,13 @@ org.wso2.carbon.devicemgt-plugins carbon-device-mgt-plugins-parent - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT ../../pom.xml 4.0.0 device-types-feature - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT pom WSO2 Carbon - Device Management IoT Plugins Feature http://wso2.org diff --git a/features/device-types-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/pom.xml b/features/device-types-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/pom.xml index 5c436d0da..02541412d 100644 --- a/features/device-types-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/pom.xml +++ b/features/device-types-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/pom.xml @@ -23,7 +23,7 @@ org.wso2.carbon.devicemgt-plugins raspberrypi-plugin-feature - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT ../pom.xml @@ -133,6 +133,28 @@ + + unpack-analytics + package + + unpack + + + + + org.wso2.carbon.devicemgt-plugins + org.wso2.carbon.device.mgt.iot.analytics + ${project.version} + zip + true + + ${project.build.directory}/maven-shared-archive-resources/carbonapps + + **/* + + + + diff --git a/features/device-types-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/devicetypes/raspberrypi.xml b/features/device-types-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/devicetypes/raspberrypi.xml index 60bbfa162..85db147c6 100644 --- a/features/device-types-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/devicetypes/raspberrypi.xml +++ b/features/device-types-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/devicetypes/raspberrypi.xml @@ -39,10 +39,7 @@ raspberrypi.mqtt.adapter - admin - admin 0 - true diff --git a/features/device-types-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/p2.inf b/features/device-types-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/p2.inf index a5582cdd1..6c5fec5f5 100644 --- a/features/device-types-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/p2.inf +++ b/features/device-types-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/p2.inf @@ -1,4 +1,7 @@ instructions.configure = \ +org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../resources/);\ +org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../resources/devicetypes/);\ +org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../resources/devicetypes/raspberrypi/);\ org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/webapps/);\ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.raspberrypi_${feature.version}/webapps/,target:${installFolder}/../../deployment/server/webapps/,overwrite:true);\ org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../resources/sketches/);\ @@ -11,7 +14,7 @@ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../featur org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../database/);\ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.raspberrypi_${feature.version}/database/,target:${installFolder}/../../database/,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.iot.raspberrypi_${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.iot.raspberrypi_${feature.version}/carbonapps/,target:${installFolder}/../../resources/devicetypes/raspberrypi/,overwrite:true);\ org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/devicetypes/);\ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.raspberrypi_${feature.version}/devicetypes/,target:${installFolder}/../../deployment/server/devicetypes/,overwrite:true);\ diff --git a/features/device-types-feature/raspberrypi-plugin-feature/pom.xml b/features/device-types-feature/raspberrypi-plugin-feature/pom.xml index e0a4451a3..92626ddee 100644 --- a/features/device-types-feature/raspberrypi-plugin-feature/pom.xml +++ b/features/device-types-feature/raspberrypi-plugin-feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt-plugins device-types-feature - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT ../pom.xml diff --git a/features/device-types-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/pom.xml b/features/device-types-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/pom.xml index cca3d7e29..0459e1eb1 100644 --- a/features/device-types-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/pom.xml +++ b/features/device-types-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/pom.xml @@ -23,7 +23,7 @@ org.wso2.carbon.devicemgt-plugins virtual-fire-alarm-plugin-feature - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT ../pom.xml @@ -36,10 +36,6 @@ - - - - org.wso2.carbon.devicemgt-plugins org.wso2.carbon.device.mgt.iot.virtualfirealarm.api @@ -166,6 +162,28 @@ + + unpack-analytics + package + + unpack + + + + + org.wso2.carbon.devicemgt-plugins + org.wso2.carbon.device.mgt.iot.analytics + ${project.version} + zip + true + + ${project.build.directory}/maven-shared-archive-resources/carbonapps + + **/* + + + + diff --git a/features/device-types-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/conf/virtual_firealarm.xml b/features/device-types-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/conf/virtual_firealarm.xml deleted file mode 100644 index b4a9a64a9..000000000 --- a/features/device-types-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/conf/virtual_firealarm.xml +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - MQTT - - virtualfirealarm.mqtt.adapter - admin - admin - 0 - - true - - - - - diff --git a/features/device-types-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/devicetypes/virtual_firealarm.xml b/features/device-types-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/devicetypes/virtual_firealarm.xml index e88e4f03d..1fcfec4c6 100644 --- a/features/device-types-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/devicetypes/virtual_firealarm.xml +++ b/features/device-types-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/devicetypes/virtual_firealarm.xml @@ -31,7 +31,7 @@ - false + true @@ -39,10 +39,7 @@ virtualfirealarm.mqtt.adapter - admin - admin 0 - true diff --git a/features/device-types-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/p2.inf b/features/device-types-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/p2.inf index f88a8eb2d..9ebe160d9 100644 --- a/features/device-types-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/p2.inf +++ b/features/device-types-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/p2.inf @@ -1,4 +1,7 @@ instructions.configure = \ +org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../resources/);\ +org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../resources/devicetypes/);\ +org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../resources/devicetypes/virtual_firealarm/);\ org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/webapps/);\ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.virtualfirealarm_${feature.version}/webapps/,target:${installFolder}/../../deployment/server/webapps/,overwrite:true);\ org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../resources/sketches/);\ @@ -17,9 +20,8 @@ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../featur org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../resources/device-types/);\ org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/devicetypes/);\ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.virtualfirealarm_${feature.version}/devicetypes/,target:${installFolder}/../../deployment/server/devicetypes/,overwrite:true);\ -org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../conf/etc/device-mgt-plugins/);\ 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.iot.virtualfirealarm_${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.iot.virtualfirealarm_${feature.version}/carbonapps/,target:${installFolder}/../../resources/devicetypes/virtual_firealarm/,overwrite:true);\ instructions.unconfigure = \ diff --git a/features/device-types-feature/virtual-fire-alarm-plugin-feature/pom.xml b/features/device-types-feature/virtual-fire-alarm-plugin-feature/pom.xml index b8eeb5c61..e11e61d2f 100644 --- a/features/device-types-feature/virtual-fire-alarm-plugin-feature/pom.xml +++ b/features/device-types-feature/virtual-fire-alarm-plugin-feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt-plugins device-types-feature - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT ../pom.xml diff --git a/features/extensions-feature/org.wso2.carbon.andes.extensions.device.mgt.mqtt.authorization.feature/pom.xml b/features/extensions-feature/org.wso2.carbon.andes.extensions.device.mgt.mqtt.authorization.feature/pom.xml index e8be410b6..a8be9fc35 100644 --- a/features/extensions-feature/org.wso2.carbon.andes.extensions.device.mgt.mqtt.authorization.feature/pom.xml +++ b/features/extensions-feature/org.wso2.carbon.andes.extensions.device.mgt.mqtt.authorization.feature/pom.xml @@ -23,7 +23,7 @@ org.wso2.carbon.devicemgt-plugins extensions-feature - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT ../pom.xml diff --git a/features/extensions-feature/org.wso2.carbon.appmgt.mdm.osgiconnector.feature/pom.xml b/features/extensions-feature/org.wso2.carbon.appmgt.mdm.osgiconnector.feature/pom.xml index 7cc59dd05..b9c0d4c09 100644 --- a/features/extensions-feature/org.wso2.carbon.appmgt.mdm.osgiconnector.feature/pom.xml +++ b/features/extensions-feature/org.wso2.carbon.appmgt.mdm.osgiconnector.feature/pom.xml @@ -20,13 +20,13 @@ org.wso2.carbon.devicemgt-plugins extensions-feature - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT ../pom.xml org.wso2.carbon.appmgt.mdm.osgiconnector.feature pom - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT WSO2 Carbon - App management MDM OSGI Connector http://wso2.org This feature contains the core bundles required for APP management OSGI MDM connection @@ -36,7 +36,7 @@ org.wso2.carbon.devicemgt-plugins org.wso2.carbon.appmgt.mdm.osgiconnector - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT org.apache.ws.commons.axiom diff --git a/features/extensions-feature/org.wso2.carbon.appmgt.mdm.restconnector.feature/pom.xml b/features/extensions-feature/org.wso2.carbon.appmgt.mdm.restconnector.feature/pom.xml new file mode 100644 index 000000000..83728f311 --- /dev/null +++ b/features/extensions-feature/org.wso2.carbon.appmgt.mdm.restconnector.feature/pom.xml @@ -0,0 +1,96 @@ + + + + 4.0.0 + + + org.wso2.carbon.devicemgt-plugins + extensions-feature + 3.0.12-SNAPSHOT + ../pom.xml + + + org.wso2.carbon.appmgt.mdm.restconnector.feature + pom + 3.0.12-SNAPSHOT + WSO2 Carbon - App management MDM REST Connector + http://wso2.org + This feature contains the core bundles required for APP management MDM REST connection + + + + + org.wso2.carbon.devicemgt-plugins + org.wso2.carbon.appmgt.mdm.restconnector + 3.0.12-SNAPSHOT + + + org.apache.ws.commons.axiom + axiom-api + + + org.apache.ws.commons.axiom + axiom-impl + + + + + com.googlecode.plist + dd-plist + + + + + + + org.wso2.maven + carbon-p2-plugin + ${carbon.p2.plugin.version} + + + 4-p2-feature-generation + package + + p2-feature-gen + + + org.wso2.carbon.appmgt.mdm.restconnector + ../etc/feature.properties + + + org.wso2.carbon.p2.category.type:server + + org.eclipse.equinox.p2.type.group:false + + + + + + org.wso2.carbon.devicemgt-plugins:org.wso2.carbon.appmgt.mdm.restconnector:${carbon.devicemgt.plugins.version} + + com.googlecode.plist:dd-plist:${googlecode.plist.version} + + + + + + + + + + + diff --git a/features/extensions-feature/org.wso2.carbon.device.mgt.adapter.feature/pom.xml b/features/extensions-feature/org.wso2.carbon.device.mgt.adapter.feature/pom.xml index d0b9f7ebe..65d06ffea 100644 --- a/features/extensions-feature/org.wso2.carbon.device.mgt.adapter.feature/pom.xml +++ b/features/extensions-feature/org.wso2.carbon.device.mgt.adapter.feature/pom.xml @@ -23,14 +23,14 @@ org.wso2.carbon.devicemgt-plugins extensions-feature - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.device.mgt.adapter.feature pom - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT WSO2 Carbon - Device Management Adapters Feature http://wso2.org This feature contains the adapter bundles required for IoT Server @@ -78,6 +78,11 @@ feign-gson ${io.github.openfeign.version} + + org.wso2.carbon.identity.carbon.auth.jwt + org.wso2.carbon.identity.authenticator.signedjwt + ${identity.carbon.auth.jwt.version} + @@ -196,6 +201,9 @@ io.github.openfeign:feign-gson:${io.github.openfeign.version} + + org.wso2.carbon.identity.carbon.auth.jwt:org.wso2.carbon.identity.authenticator.signedjwt:${identity.carbon.auth.jwt.version} + 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 index 0d4a90652..b1623498e 100644 --- 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 @@ -20,13 +20,13 @@ org.wso2.carbon.devicemgt-plugins extensions-feature - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT ../pom.xml org.wso2.extension.siddhi.execution.json.feature pom - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT WSO2 Siddhi Execution Extension - Json Feature http://wso2.org This feature contains Siddhi extension feature for changing a json string to individual properties. diff --git a/features/extensions-feature/pom.xml b/features/extensions-feature/pom.xml index 253b52d26..20b5b1da2 100644 --- a/features/extensions-feature/pom.xml +++ b/features/extensions-feature/pom.xml @@ -22,19 +22,20 @@ org.wso2.carbon.devicemgt-plugins carbon-device-mgt-plugins-parent - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT ../../pom.xml 4.0.0 extensions-feature - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT pom WSO2 Carbon - Device Management Extensions http://wso2.org org.wso2.carbon.appmgt.mdm.osgiconnector.feature + org.wso2.carbon.appmgt.mdm.restconnector.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 50360308a..a97ecd32b 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 @@ -22,14 +22,14 @@ org.wso2.carbon.devicemgt-plugins android-plugin-feature - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.device.mgt.mobile.android.feature pom - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT WSO2 Carbon - Android Device Management Feature http://wso2.org This feature contains the core bundles required for Android Device Management @@ -132,6 +132,28 @@ + + unpack-geo + package + + unpack + + + + + org.wso2.carbon.devicemgt-plugins + org.wso2.carbon.iot.geo.dashboard + ${project.version} + zip + true + + ${project.build.directory}/maven-shared-archive-resources/carbonapps + + **/* + + + + copy-jaxrs-war package 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 ffd5fd2c6..847d0eee9 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,7 +1,9 @@ instructions.configure = \ +org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../resources/);\ +org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../resources/devicetypes/);\ +org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../resources/devicetypes/android/);\ 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}/carbonapps/,target:${installFolder}/../../resources/devicetypes/android/,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);\ @@ -31,5 +33,5 @@ org.eclipse.equinox.p2.touchpoint.natives.remove(path:$${installFolder}/../../.. 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}/../../resources/devicetypes/android/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/features/mobile-plugins-feature/android-plugin-feature/pom.xml b/features/mobile-plugins-feature/android-plugin-feature/pom.xml index 8e89dea67..b8c5c34a3 100644 --- a/features/mobile-plugins-feature/android-plugin-feature/pom.xml +++ b/features/mobile-plugins-feature/android-plugin-feature/pom.xml @@ -22,13 +22,13 @@ org.wso2.carbon.devicemgt-plugins mobile-plugins-feature - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT ../pom.xml 4.0.0 android-plugin-feature - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT pom WSO2 Carbon - Device Management Android Plugin Feature http://wso2.org diff --git a/features/mobile-plugins-feature/pom.xml b/features/mobile-plugins-feature/pom.xml index 38850f069..0a16bf3fb 100644 --- a/features/mobile-plugins-feature/pom.xml +++ b/features/mobile-plugins-feature/pom.xml @@ -22,13 +22,13 @@ org.wso2.carbon.devicemgt-plugins carbon-device-mgt-plugins-parent - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT ../../pom.xml 4.0.0 mobile-plugins-feature - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT pom WSO2 Carbon - Device Management EMM Plugins Feature http://wso2.org diff --git a/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/pom.xml b/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/pom.xml index 4bd99ad93..ef7f85eb1 100644 --- a/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/pom.xml +++ b/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/pom.xml @@ -22,14 +22,14 @@ org.wso2.carbon.devicemgt-plugins windows-plugin-feature - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.device.mgt.mobile.windows.feature pom - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT WSO2 Carbon - Windows Device Management Feature http://wso2.org This feature contains the core bundles required for Windows Device Management diff --git a/features/mobile-plugins-feature/windows-plugin-feature/pom.xml b/features/mobile-plugins-feature/windows-plugin-feature/pom.xml index 97710d5ee..9c001ac8f 100644 --- a/features/mobile-plugins-feature/windows-plugin-feature/pom.xml +++ b/features/mobile-plugins-feature/windows-plugin-feature/pom.xml @@ -22,13 +22,13 @@ org.wso2.carbon.devicemgt-plugins mobile-plugins-feature - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT ../pom.xml 4.0.0 windows-plugin-feature - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT pom WSO2 Carbon - Device Management Windows Plugin Feature http://wso2.org diff --git a/pom.xml b/pom.xml index 4f63cfca6..37b7e0741 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ org.wso2.carbon.devicemgt-plugins carbon-device-mgt-plugins-parent pom - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT WSO2 Carbon - Device Management Plugins Parent http://wso2.org WSO2 Carbon - Device Management Plugins Parent @@ -528,6 +528,16 @@ org.wso2.carbon.appmgt org.wso2.carbon.appmgt.mobile ${carbon.appmgt.version} + + + org.apache.ws.commons.axiom + axiom-api + + + org.apache.ws.commons.axiom + axiom-impl + + @@ -793,6 +803,11 @@ + + commons-codec.wso2 + commons-codec + ${commons-codec.version.wso2} + commons-codec commons-codec @@ -953,6 +968,11 @@ ${identity.inbound.auth.oauth.version} provided + + org.wso2.carbon.identity.carbon.auth.jwt + org.wso2.carbon.identity.authenticator.signedjwt + ${identity.carbon.auth.jwt.version} + org.apache.httpcomponents.wso2 httpcore @@ -1113,14 +1133,14 @@ 1.1.1 - 2.0.11 + 2.0.13 [2.0.0, 3.0.0) - 1.2.13 + 1.2.15 - 3.0.9-SNAPSHOT + 3.0.12-SNAPSHOT 4.4.8 @@ -1132,6 +1152,7 @@ 5.6.89 5.3.1 [5.2.0, 6.0.0) + 5.1.2 4.6.1 @@ -1143,7 +1164,7 @@ 4.7.0 - 6.1.35 + 6.1.64 3.0.4.wso2v1 @@ -1179,7 +1200,7 @@ 3.1.0.wso2v2 - + 1.4.0.wso2v1 1.7 6.0