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/operations/util/Constants.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/operations/util/Constants.java index b68bca44c3..b20f31baa6 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/operations/util/Constants.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/operations/util/Constants.java @@ -79,6 +79,8 @@ public class Constants { public static final String META_FORMAT_INT = "int"; public static final String META_FORMAT_CHARACTER = "chr"; + public static final String SCOPE = "scope"; + /** * SynclML service related constants. */ 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/ConfigurationMgtService.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/ConfigurationMgtService.java index 1796a637cb..5b69ba25d7 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/ConfigurationMgtService.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/ConfigurationMgtService.java @@ -32,9 +32,12 @@ import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponses; import io.swagger.annotations.ResponseHeader; +import org.wso2.carbon.apimgt.annotations.api.Scope; +import org.wso2.carbon.apimgt.annotations.api.Scopes; import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration; import org.wso2.carbon.device.mgt.mobile.windows.api.common.exceptions.WindowsConfigurationException; import org.wso2.carbon.device.mgt.mobile.windows.api.common.util.Message; +import org.wso2.carbon.device.mgt.mobile.windows.api.operations.util.Constants; import javax.jws.WebService; import javax.ws.rs.*; @@ -66,8 +69,30 @@ import javax.ws.rs.core.Response; description = "This carries all the resources related to Windows configurations management functionalities") @WebService @Path("/configuration") -@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) -@Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) +@Produces({"application/json", "application/xml"}) +@Consumes({"application/json", "application/xml"}) +@Scopes( + scopes = { + @Scope( + name = "Enroll Device", + description = "Register an Windows device", + key = "cdmf:windows:enroll", + permissions = {"/device-mgt/devices/enroll/windows"} + ), + @Scope( + name = "View Configurations", + description = "Getting Windows Platform Configurations", + key = "cdmf:windows:view-configuration", + permissions = {"/device-mgt/platform-configurations/view"} + ), + @Scope( + name = "Manage Configurations", + description = "Updating Windows Platform Configurations", + key = "cdmf:windows:manage-configuration", + permissions = {"/device-mgt/platform-configurations/manage"} + ) + } +) public interface ConfigurationMgtService { @GET @@ -78,12 +103,10 @@ public interface ConfigurationMgtService { notes = "Get the Windows platform configuration details using this REST API.", response = PlatformConfiguration.class, tags = "Windows Configuration Management", - authorizations = { - @Authorization( - value = "permission", - scopes = {@AuthorizationScope(scope = "/device-mgt/platform-configurations/view", - description = "View Configurations")} - ) + extensions = { + @Extension(properties = { + @ExtensionProperty(name = Constants.SCOPE, value = "cdmf:windows:view-configuration") + }) } ) @ApiResponses(value = { @@ -139,12 +162,10 @@ public interface ConfigurationMgtService { value = "Updating Windows Platform Configurations", notes = "Update the Windows platform configurations using this REST API.", tags = "Windows Configuration Management", - authorizations = { - @Authorization( - value = "permission", - scopes = {@AuthorizationScope(scope = "/device-mgt/configurations/manage", - description = "Manage Configurations")} - ) + extensions = { + @Extension(properties = { + @ExtensionProperty(name = Constants.SCOPE, value = "cdmf:windows:manage-configuration") + }) } ) @ApiResponses(value = { @@ -197,12 +218,10 @@ public interface ConfigurationMgtService { "registration process.", response = String.class, tags = "Windows Configuration Management", - authorizations = { - @Authorization( - value = "permission", - scopes = {@AuthorizationScope(scope = "/device-mgt/devices/enroll/windows", - description = "Enroll Device")} - ) + extensions = { + @Extension(properties = { + @ExtensionProperty(name = Constants.SCOPE, value = "cdmf:windows:enroll") + }) } ) @ApiResponses(value = { 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 c56d270c76..c054f821f8 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 @@ -19,8 +19,12 @@ package org.wso2.carbon.device.mgt.mobile.windows.api.services; import io.swagger.annotations.*; + +import org.wso2.carbon.apimgt.annotations.api.Scope; +import org.wso2.carbon.apimgt.annotations.api.Scopes; import org.wso2.carbon.device.mgt.common.operation.mgt.Activity; import org.wso2.carbon.device.mgt.mobile.windows.api.common.exceptions.WindowsDeviceEnrolmentException; +import org.wso2.carbon.device.mgt.mobile.windows.api.operations.util.Constants; import javax.jws.WebService; import javax.ws.rs.Consumes; @@ -57,9 +61,43 @@ import java.util.List; @Api(value = "Windows Device Management Administrative Service", description = "Device management related admin APIs.") @WebService -@Path("/operation/admin/devices") -@Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) -@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) +@Path("/admin/devices") +@Consumes(MediaType.APPLICATION_JSON) +@Produces(MediaType.APPLICATION_JSON) +@Scopes( + scopes = { + @Scope( + name = "Lock Device", + description = "Adding a Device Lock on Windows devices.", + key = "cdmf:windows:lock-devices", + permissions = {"/device-mgt/devices/owning-device/operations/windows/lock"} + ), + @Scope( + name = "Un-enroll Device", + description = "Unregister an Windows device", + key = "cdmf:windows:disenroll", + permissions = {"/device-mgt/devices/disenroll/windows"} + ), + @Scope( + name = "Factory Reset", + description = "Factory Resetting Windows Devices", + key = "cdmf:windows:wipe", + permissions = {"/device-mgt/devices/owning-device/operations/windows/wipe"} + ), + @Scope( + name = "Ring Device", + description = "Ring Windows devices", + key = "cdmf:windows:ring", + permissions = {"/device-mgt/devices/owning-device/operations/windows/ring"} + ), + @Scope( + name = "Lock Reset", + description = "Lock reset on Windows devices", + key = "cdmf:windows:lock-reset", + permissions = {"/device-mgt/devices/owning-device/operations/windows/lock-reset"} + ) + } +) public interface DeviceManagementAdminService { @POST @@ -71,13 +109,10 @@ public interface DeviceManagementAdminService { notes = "Using this API you have the option of Device Windows device.", response = Activity.class, tags = "Windows Device Management Administrative Service", - authorizations = { - @Authorization( - value = "permission", - scopes = {@AuthorizationScope( - scope = "/device-mgt/devices/owning-device/operations/windows/lock", - description = "Lock Device")} - ) + extensions = { + @Extension(properties = { + @ExtensionProperty(name = Constants.SCOPE, value = "cdmf:windows:lock-devices") + }) } ) @ApiResponses(value = { @@ -133,13 +168,10 @@ public interface DeviceManagementAdminService { notes = "Dis-enroll on Android devices", response = Activity.class, tags = "Windows Device Management Administrative Service.", - authorizations = { - @Authorization( - value = "permission", - scopes = {@AuthorizationScope( - scope = "/device-mgt/devices/disenroll/windows", - description = "Dis-enroll the windows devices ")} - ) + extensions = { + @Extension(properties = { + @ExtensionProperty(name = Constants.SCOPE, value = "cdmf:windows:disenroll") + }) } ) @ApiResponses(value = { @@ -197,13 +229,10 @@ public interface DeviceManagementAdminService { "to restore them back to the original system.", response = Activity.class, tags = "Windows Device Management Administrative Service", - authorizations = { - @Authorization( - value = "permission", - scopes = {@AuthorizationScope( - scope = "/device-mgt/devices/owning-device/operations/windows/wipe", - description = "DeviceWipe")} - ) + extensions = { + @Extension(properties = { + @ExtensionProperty(name = Constants.SCOPE, value = "cdmf:windows:wipe") + }) } ) @ApiResponses(value = { @@ -258,13 +287,10 @@ public interface DeviceManagementAdminService { notes = "Ring Windows devices.", response = Activity.class, tags = "Windows Device Management Administrative Service", - authorizations = { - @Authorization( - value="permission", - scopes = { @AuthorizationScope( - scope = "/device-mgt/devices/owning-device/operations/windows/ring", - description = "Ring Device") } - ) + extensions = { + @Extension(properties = { + @ExtensionProperty(name = Constants.SCOPE, value = "cdmf:windows:ring") + }) } ) @ApiResponses(value = { @@ -320,13 +346,10 @@ public interface DeviceManagementAdminService { notes = "Lock reset on Windows devices.Its use to reset the device pass code", response = Activity.class, tags = "Windows Device Management Administrative Service", - authorizations = { - @Authorization( - value="permission", - scopes = { @AuthorizationScope( - scope = "/device-mgt/devices/owning-device/operations/windows/lock-reset", - description = "Lock reset") } - ) + extensions = { + @Extension(properties = { + @ExtensionProperty(name = Constants.SCOPE, value = "cdmf:windows:lock-reset") + }) } ) @ApiResponses(value = { 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/authbst/BSTProvider.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/authbst/BSTProvider.java index b3272d703e..5b55a8ed07 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/authbst/BSTProvider.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/authbst/BSTProvider.java @@ -19,7 +19,11 @@ package org.wso2.carbon.device.mgt.mobile.windows.api.services.authbst; import io.swagger.annotations.*; + +import org.wso2.carbon.apimgt.annotations.api.Scope; +import org.wso2.carbon.apimgt.annotations.api.Scopes; import org.wso2.carbon.device.mgt.mobile.windows.api.common.exceptions.WindowsDeviceEnrolmentException; +import org.wso2.carbon.device.mgt.mobile.windows.api.operations.util.Constants; import org.wso2.carbon.device.mgt.mobile.windows.api.services.authbst.beans.Credentials; import javax.jws.WebService; @@ -56,6 +60,16 @@ import javax.ws.rs.core.Response; @Path("/bst") @Produces({"application/json", "application/xml"}) @Consumes({"application/json", "application/xml"}) +@Scopes( + scopes = { + @Scope( + name = "Enroll Device", + description = "Register Windows device", + key = "cdmf:windows:enroll", + permissions = {"/device-mgt/devices/enroll/windows"} + ) + } +) public interface BSTProvider { @POST @@ -68,13 +82,10 @@ public interface BSTProvider { value = "Getting Binary security token.", notes = "Using this API to fetch Binary security token to call window enrollment and policy endpoints.", tags = "BST Provider", - authorizations = { - @Authorization( - value = "permission", - scopes = {@AuthorizationScope(scope = "/device-mgt/devices/enroll/windows", - description = "Getting Binary security token for Windows enrollment " + - "and policy endpoints.")} - ) + extensions = { + @Extension(properties = { + @ExtensionProperty(name = Constants.SCOPE, value = "cdmf:windows:enroll") + }) } ) @ApiResponses(