From bdfb816ffc246edb0ab6f99af6c12fb95b6e94ed Mon Sep 17 00:00:00 2001 From: Imesh Chandrasiri Date: Wed, 18 Jan 2017 11:43:49 +0530 Subject: [PATCH 1/7] Fix for issue where list item operations getting fired even after cancelling list item selection --- .../public/js/dataTables.extended.serversidepaging.js | 1 + 1 file changed, 1 insertion(+) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.data-tables-extended/public/js/dataTables.extended.serversidepaging.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.data-tables-extended/public/js/dataTables.extended.serversidepaging.js index 243df02a4d..9ca788dc43 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.data-tables-extended/public/js/dataTables.extended.serversidepaging.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.data-tables-extended/public/js/dataTables.extended.serversidepaging.js @@ -273,6 +273,7 @@ $.fn.datatables_extended_serverside_paging = function (settings, url, dataFilter thisTable.removeClass("table-selectable"); $(button).addClass("active").html('Select'); $(button).parent().next().children().addClass("disabled"); + $('.DTTT_selected.selected').removeClass(rowSelectedClass); // EMM related function $(document).on('click', '.viewEnabledIcon', InitiateViewOption); //--- End of EMM related codes From 1f5448c2a0d22874e2b247b60950709462aec7e9 Mon Sep 17 00:00:00 2001 From: Maninda Date: Wed, 18 Jan 2017 12:36:11 +0530 Subject: [PATCH 2/7] Corrected the caching filter pattern --- .../src/main/webapp/WEB-INF/web.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/webapp/WEB-INF/web.xml b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/webapp/WEB-INF/web.xml index aa49482557..b23f60be4c 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/webapp/WEB-INF/web.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/webapp/WEB-INF/web.xml @@ -89,7 +89,7 @@ org.wso2.carbon.ui.filters.cache.ContentTypeBasedCachePreventionFilter patterns - "text/html*","application/json*","text/plain*" + text/html" ,application/json" ,text/plain filterAction From e8ffe60e8c0f852b4911ec5029967b87b1f50eb3 Mon Sep 17 00:00:00 2001 From: Jasintha Date: Wed, 18 Jan 2017 14:27:05 +0530 Subject: [PATCH 3/7] Fixing firealam policy push notification issue --- .../pom.xml | 1 + .../mqtt/MQTTNotificationStrategy.java | 50 +++++++++++++++---- 2 files changed, 41 insertions(+), 10 deletions(-) diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt/pom.xml b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt/pom.xml index 703f3ba348..c885da4270 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt/pom.xml +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt/pom.xml @@ -144,6 +144,7 @@ org.wso2.carbon.event.output.adapter.core, org.wso2.carbon.event.output.adapter.core.exception, org.osgi.framework, + org.wso2.carbon.device.mgt.core.operation.mgt, org.wso2.carbon.core diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/mqtt/MQTTNotificationStrategy.java b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/mqtt/MQTTNotificationStrategy.java index 03f2d8f9d3..93be818999 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/mqtt/MQTTNotificationStrategy.java +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/mqtt/MQTTNotificationStrategy.java @@ -22,17 +22,21 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; +import org.wso2.carbon.device.mgt.common.policy.mgt.Profile; import org.wso2.carbon.device.mgt.common.push.notification.NotificationContext; import org.wso2.carbon.device.mgt.common.push.notification.NotificationStrategy; import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationConfig; import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationExecutionFailedException; +import org.wso2.carbon.device.mgt.core.operation.mgt.ProfileOperation; import org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt.internal.MQTTDataHolder; import org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt.internal.util.MQTTAdapterConstants; import org.wso2.carbon.event.output.adapter.core.MessageType; import org.wso2.carbon.event.output.adapter.core.OutputEventAdapterConfiguration; import org.wso2.carbon.event.output.adapter.core.exception.OutputEventAdapterException; +import org.wso2.carbon.device.mgt.core.operation.mgt.PolicyOperation; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Properties; @@ -57,7 +61,7 @@ public class MQTTNotificationStrategy implements NotificationStrategy { configProperties.put(MQTTAdapterConstants.MQTT_ADAPTER_PROPERTY_USERNAME, config.getProperty(MQTTAdapterConstants.MQTT_ADAPTER_PROPERTY_USERNAME)); configProperties.put(MQTTAdapterConstants.MQTT_ADAPTER_PROPERTY_PASSWORD, - config.getProperty(MQTTAdapterConstants.MQTT_ADAPTER_PROPERTY_PASSWORD)); + config.getProperty(MQTTAdapterConstants.MQTT_ADAPTER_PROPERTY_PASSWORD)); configProperties.put(MQTTAdapterConstants.MQTT_ADAPTER_PROPERTY_CLEAR_SESSION, config.getProperty(MQTTAdapterConstants.MQTT_ADAPTER_PROPERTY_CLEAR_SESSION)); configProperties.put(MQTTAdapterConstants.MQTT_ADAPTER_PROPERTY_SCOPES, @@ -79,23 +83,48 @@ public class MQTTNotificationStrategy implements NotificationStrategy { @Override public void execute(NotificationContext ctx) throws PushNotificationExecutionFailedException { - Map dynamicProperties = new HashMap<>(); + Operation operation = ctx.getOperation(); Properties properties = operation.getProperties(); if (properties != null && properties.get(MQTT_ADAPTER_TOPIC) != null) { + Map dynamicProperties = new HashMap<>(); dynamicProperties.put("topic", (String) properties.get(MQTT_ADAPTER_TOPIC)); + MQTTDataHolder.getInstance().getOutputEventAdapterService().publish(mqttAdapterName, dynamicProperties, + operation.getPayLoad()); } else { - String topic = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(true) + "/" - + ctx.getDeviceId().getType() + "/" + ctx.getDeviceId().getId() + "/" + operation.getType() - .toString().toLowerCase() + "/" + operation.getCode(); - dynamicProperties.put("topic", topic); - if (operation.getPayLoad() == null) { - operation.setPayLoad(""); + if (PolicyOperation.POLICY_OPERATION_CODE.equals(operation.getCode())) { + PolicyOperation policyOperation = (PolicyOperation) operation; + List profileOperations = policyOperation.getProfileOperations(); + String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(true); + String deviceType = ctx.getDeviceId().getType(); + String deviceId = ctx.getDeviceId().getId(); + for (ProfileOperation profileOperation : profileOperations) { + Map dynamicProperties = new HashMap<>(); + String topic = tenantDomain + "/" + + deviceType + "/" + deviceId + "/" + profileOperation.getType() + .toString().toLowerCase() + "/" + profileOperation.getCode().toLowerCase(); + dynamicProperties.put("topic", topic); + MQTTDataHolder.getInstance().getOutputEventAdapterService().publish(mqttAdapterName, dynamicProperties, + profileOperation.getPayLoad()); + } + + } else { + Map dynamicProperties = new HashMap<>(); + String topic = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(true) + "/" + + ctx.getDeviceId().getType() + "/" + ctx.getDeviceId().getId() + "/" + operation.getType() + .toString().toLowerCase() + "/" + operation.getCode(); + dynamicProperties.put("topic", topic); + if (operation.getPayLoad() == null) { + operation.setPayLoad(""); + } + MQTTDataHolder.getInstance().getOutputEventAdapterService().publish(mqttAdapterName, dynamicProperties, + operation.getPayLoad()); + } + } - MQTTDataHolder.getInstance().getOutputEventAdapterService().publish(mqttAdapterName, dynamicProperties, - operation.getPayLoad()); + } @Override @@ -109,3 +138,4 @@ public class MQTTNotificationStrategy implements NotificationStrategy { } } + From 1bec5e51860eeeaacb55c6d3e9c1e6d988bc23e7 Mon Sep 17 00:00:00 2001 From: sameera910409 Date: Wed, 18 Jan 2017 14:52:12 +0530 Subject: [PATCH 4/7] fixed user password reset failure issue in iot console --- .../mgt/jaxrs/service/api/admin/UserManagementAdminService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/admin/UserManagementAdminService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/admin/UserManagementAdminService.java index c6c7130926..b909ff609b 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/admin/UserManagementAdminService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/admin/UserManagementAdminService.java @@ -72,7 +72,7 @@ import javax.ws.rs.core.Response; "Further, this is strictly restricted to admin users only ") public interface UserManagementAdminService { - @PUT + @POST @Path("/{username}/credentials") @ApiOperation( consumes = MediaType.APPLICATION_JSON, From e9c3a0c3e81b48ed7c1bcd061ef2b92ff29594f8 Mon Sep 17 00:00:00 2001 From: Milan Perera Date: Wed, 18 Jan 2017 18:14:55 +0530 Subject: [PATCH 5/7] Fixed token expiration issue --- .../oauth/token-protected-service-invokers.js | 41 ++++++++++++++++--- 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/oauth/token-protected-service-invokers.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/oauth/token-protected-service-invokers.js index d29498a318..ed40ee7de8 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/oauth/token-protected-service-invokers.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/oauth/token-protected-service-invokers.js @@ -117,15 +117,44 @@ var invokers = function () { log.debug("Response status : " + xmlHttpRequest.status); log.debug("Response payload if any : " + xmlHttpRequest.responseText); - if (xmlHttpRequest.status == 401 && (xmlHttpRequest.responseText == TOKEN_EXPIRED || - xmlHttpRequest.responseText == TOKEN_INVALID ) && count < 5) { - tokenUtil.refreshTokenPair(); - return privateMethods.execute(httpMethod, requestPayload, endpoint, responseCallback, ++count, headers); - } else { + if (xmlHttpRequest.status == 401) { + if ((xmlHttpRequest.responseText == TOKEN_EXPIRED || + xmlHttpRequest.responseText == TOKEN_INVALID ) && count < 5) { + tokenUtil.refreshTokenPair(); + return privateMethods.execute(httpMethod, requestPayload, endpoint, responseCallback, ++count, headers); + } else if (privateMethods.isInvalidCredential(xmlHttpRequest.responseText)) { + tokenUtil.refreshTokenPair(); + return privateMethods.execute(httpMethod, requestPayload, endpoint, responseCallback, ++count, headers); + } + } else { return responseCallback(xmlHttpRequest); - } + } }; + + /** + * This method verify whether the access token is expired using response payload. + * This is required when using API gateway. + * @param responsePayload response payload. + * return true if it is invalid otherwise false. + */ + privateMethods["isInvalidCredential"] = + function (responsePayload) { + if (responsePayload) { + try { + payload = parse(responsePayload); + if (payload["fault"]["code"] == 900901) { + log.debug("Access token is invalid: " + payload["fault"]["code"]); + log.debug(payload["fault"]["description"]); + return true; + } + } catch (err) { + // do nothing + } + } + return false; + }; + /** * This method add Oauth authentication header to outgoing XML-HTTP Requests if Oauth authentication is enabled. * @param httpMethod HTTP request type. From 0bb04789a603e5409b71d0228c0baad143b48e32 Mon Sep 17 00:00:00 2001 From: inoshperera Date: Wed, 18 Jan 2017 20:48:39 +0530 Subject: [PATCH 6/7] adding permissions necessery for iOS to config.json --- .../devicemgt/app/conf/config.json | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json index 573d973b3a..b8eae70992 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json @@ -141,6 +141,39 @@ "perm:admin:certificates:view", "perm:admin:certificates:add", "perm:admin:certificates:verify", + "perm:ios:enroll", + "perm:ios:view-device", + "perm:ios:apn", + "perm:ios:ldap", + "perm:ios:enterprise-app", + "perm:ios:store-application", + "perm:ios:remove-application", + "perm:ios:app-list", + "perm:ios:profile-list", + "perm:ios:lock", + "perm:ios:enterprise-wipe", + "perm:ios:device-info", + "perm:ios:restriction", + "perm:ios:email", + "perm:ios:cellular", + "perm:ios:applications", + "perm:ios:wifi", + "perm:ios:ring", + "perm:ios:location", + "perm:ios:notification", + "perm:ios:airplay", + "perm:ios:caldav", + "perm:ios:cal-subscription", + "perm:ios:passcode-policy", + "perm:ios:webclip", + "perm:ios:vpn", + "perm:ios:per-app-vpn", + "perm:ios:app-to-per-app-vpn", + "perm:ios:app-lock", + "perm:ios:clear-passcode", + "perm:ios:remove-profile", + "perm:ios:get-restrictions", + "perm:ios:wipe-data", "perm:admin" ], "isOAuthEnabled" : true, From 27e953cda3fe811cca35b7662a80e22d694a77d3 Mon Sep 17 00:00:00 2001 From: Rasika Perera Date: Wed, 18 Jan 2017 21:23:21 +0530 Subject: [PATCH 7/7] API subscription permission added to [devicemgt-user] role --- .../main/resources/jaggeryapps/devicemgt/app/modules/init.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/init.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/init.js index 4815edd59d..50cbba4dca 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/init.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/init.js @@ -29,7 +29,8 @@ var carbonServer = new carbonModule.server.Server({ application.put("carbonServer", carbonServer); var permissions = { - "/permission/admin/Login": ["ui.execute"] + "/permission/admin/Login": ["ui.execute"], + "/permission/admin/manage/api/subscribe": ["ui.execute"] }; var adminPermissions = {