From 9c220a5b44145eda85190ea8e327d1380ae45722 Mon Sep 17 00:00:00 2001 From: Madawa Soysa Date: Thu, 24 Jan 2019 22:02:12 +1100 Subject: [PATCH] Add permission for global proxy operation & refactor Refactored API path for global-proxy operation and add permissions and scopes to the API --- .../services/DeviceManagementAdminService.java | 13 ++++++++++--- .../impl/DeviceManagementAdminServiceImpl.java | 6 +++--- .../public/js/operation-mod.js | 2 +- .../private/config.json | 1 + 4 files changed, 15 insertions(+), 7 deletions(-) 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 a981c408f..998503b13 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 @@ -210,6 +210,12 @@ import java.util.List; key = "perm:android:configure-wifi", permissions = {"/device-mgt/devices/owning-device/operations/android/wifi"} ), + @Scope( + name = "Configure Global Proxy", + description = "Configure Global Proxy on Android Device", + key = "perm:android:configure-global-proxy", + permissions = {"/device-mgt/devices/owning-device/operations/android/global-proxy"} + ), @Scope( name = "Encrypt Storage", description = "Encrypting storage on Android Device", @@ -1852,7 +1858,7 @@ public interface DeviceManagementAdminService { WebClipBeanWrapper webClipBeanWrapper); @POST - @Path("/set-global-proxy") + @Path("/configure-global-proxy") @ApiOperation( consumes = MediaType.APPLICATION_JSON, httpMethod = "POST", @@ -1863,14 +1869,15 @@ public interface DeviceManagementAdminService { tags = "Android Device Management Administrative Service", extensions = { @Extension(properties = { - @ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:set-global-proxy") + @ExtensionProperty(name = AndroidConstants.SCOPE, + value = "perm:android:configure-global-proxy") }) } ) @ApiResponses(value = { @ApiResponse( code = 201, - message = "Created. \n Successfully scheduled the set global proxy operation.", + message = "Created. \n Successfully scheduled the global proxy operation.", response = Activity.class, responseHeaders = { @ResponseHeader( diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/DeviceManagementAdminServiceImpl.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/DeviceManagementAdminServiceImpl.java index 5bc879d66..042d81c11 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/DeviceManagementAdminServiceImpl.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/DeviceManagementAdminServiceImpl.java @@ -977,16 +977,16 @@ public class DeviceManagementAdminServiceImpl implements DeviceManagementAdminSe } @POST - @Path("/set-global-proxy") + @Path("/configure-global-proxy") @Override public Response setRecommendedGlobalProxy(GlobalProxyBeanWrapper globalProxyBeanWrapper) { if (log.isDebugEnabled()) { - log.debug("Invoking 'set-global-proxy' operation"); + log.debug("Invoking 'configure-global-proxy' operation"); } try { if (globalProxyBeanWrapper == null || globalProxyBeanWrapper.getOperation() == null) { - String errorMessage = "The payload of the set global proxy operation is incorrect"; + String errorMessage = "The payload of the global proxy operation is incorrect"; log.error(errorMessage); throw new BadRequestException( new ErrorResponse.ErrorResponseBuilder().setCode(400L).setMessage(errorMessage).build()); diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.operation-mod/public/js/operation-mod.js b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.operation-mod/public/js/operation-mod.js index de615926d..6821ab1ec 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.operation-mod/public/js/operation-mod.js +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.operation-mod/public/js/operation-mod.js @@ -460,7 +460,7 @@ var androidOperationModule = function () { publicMethods.getAndroidServiceEndpoint = function (operationCode) { var featureMap = { "WIFI": "configure-wifi", - "GLOBAL_PROXY": "set-global-proxy", + "GLOBAL_PROXY": "configure-global-proxy", "CAMERA": "control-camera", "VPN": "configure-vpn", "DEVICE_LOCK": "lock-devices", 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/private/config.json 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/private/config.json index e6ab55c5d..1f8a82010 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/private/config.json +++ 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/private/config.json @@ -13,6 +13,7 @@ "perm:android:lock-devices", "perm:android:configure-vpn", "perm:android:configure-wifi", + "perm:android:configure-global-proxy", "perm:android:enroll", "perm:android:uninstall-application", "perm:android:manage-configuration",