From fe28bc25f1d27cf8925584f7de7eebc7d9c6e424 Mon Sep 17 00:00:00 2001 From: mharindu Date: Mon, 4 Jul 2016 14:06:30 +0530 Subject: [PATCH] Refactored scopes --- .../api/ActivityInfoProviderService.java | 4 +-- .../api/ConfigurationManagementService.java | 4 +-- .../service/api/DeviceManagementService.java | 35 ++++--------------- .../api/NotificationManagementService.java | 2 +- .../service/api/PolicyManagementService.java | 18 +++++----- .../service/api/RoleManagementService.java | 14 ++++---- .../ApplicationManagementAdminService.java | 4 +-- .../admin/DeviceManagementAdminService.java | 2 +- .../api/admin/UserManagementAdminService.java | 2 +- 9 files changed, 32 insertions(+), 53 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/ActivityInfoProviderService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/ActivityInfoProviderService.java index 5b457b1b151..bb1320938ad 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/ActivityInfoProviderService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/ActivityInfoProviderService.java @@ -91,7 +91,7 @@ public interface ActivityInfoProviderService { message = "Internal Server Error. \n Server error occurred while fetching activity data.", response = ErrorResponse.class) }) - @Permission(scope = "activity-view", roles = {"emm-user", "emm-admin"}) + @Permission(scope = "activity:view", roles = {"admin"}) Response getActivity( @ApiParam( name = "id", @@ -150,7 +150,7 @@ public interface ActivityInfoProviderService { message = "Internal Server Error. \n Server error occurred while fetching activity data.", response = ErrorResponse.class) }) - @Permission(scope = "activity-view", roles = {"emm-admin"}) + @Permission(scope = "activity:view", roles = {"admin"}) Response getActivities( @ApiParam( name = "since", diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/ConfigurationManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/ConfigurationManagementService.java index bbeaf3cf0d5..32fa08fd96d 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/ConfigurationManagementService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/ConfigurationManagementService.java @@ -81,7 +81,7 @@ public interface ConfigurationManagementService { "platform configuration.", response = ErrorResponse.class) }) - @Permission(scope = "configuration-view", roles = {"emm-admin"}) + @Permission(scope = "configuration:view", roles = {"admin"}) Response getConfiguration( @ApiParam( name = "If-Modified-Since", @@ -127,7 +127,7 @@ public interface ConfigurationManagementService { "Server error occurred while modifying general platform configuration.", response = ErrorResponse.class) }) - @Permission(scope = "configuration-modify", roles = {"emm-admin"}) + @Permission(scope = "configuration:modify", roles = {"admin"}) Response updateConfiguration( @ApiParam( name = "configuration", diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceManagementService.java index 11d1672b891..d2ef6fc7012 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceManagementService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceManagementService.java @@ -90,7 +90,7 @@ public interface DeviceManagementService { message = "Internal Server Error. \n Server error occurred while fetching the device list.", response = ErrorResponse.class) }) - @Permission(scope = "device-list", roles = {"emm-admin"}) + @Permission(scope = "device:list", roles = {"admin"}) Response getDevices( @ApiParam( name = "type", @@ -194,7 +194,7 @@ public interface DeviceManagementService { "Server error occurred while retrieving information requested device.", response = ErrorResponse.class) }) - @Permission(scope = "device-view", roles = {"emm-admin"}) + @Permission(scope = "device:view", roles = {"admin"}) Response getDevice( @ApiParam( name = "type", @@ -274,7 +274,7 @@ public interface DeviceManagementService { "Server error occurred while retrieving feature list of the device.", response = ErrorResponse.class) }) - @Permission(scope = "device-search", roles = {"emm-admin"}) + @Permission(scope = "device:view", roles = {"admin"}) Response getFeaturesOfDevice( @ApiParam( name = "type", @@ -348,7 +348,7 @@ public interface DeviceManagementService { "Server error occurred while enrolling the device.", response = ErrorResponse.class) }) - @Permission(scope = "device-search", roles = {"emm-admin" }) + @Permission(scope = "device:search", roles = {"admin" }) Response searchDevices( @ApiParam( name = "offset", @@ -427,7 +427,7 @@ public interface DeviceManagementService { "Server error occurred while retrieving installed application list of the device.", response = ErrorResponse.class) }) - @Permission(scope = "operation-view", roles = {"emm-admin"}) + @Permission(scope = "device:view", roles = {"admin"}) Response getInstalledApplications( @ApiParam( name = "type", @@ -521,7 +521,7 @@ public interface DeviceManagementService { "Server error occurred while retrieving operation list scheduled for the device.", response = ErrorResponse.class) }) - @Permission(scope = "operation-view", roles = {"emm-admin"}) + @Permission(scope = "device:view", roles = {"admin"}) Response getDeviceOperations( @ApiParam( name = "type", @@ -617,7 +617,7 @@ public interface DeviceManagementService { response = ErrorResponse.class) } ) - @Permission(scope = "operation-view", roles = {"emm-admin"}) + @Permission(scope = "device:view", roles = {"admin"}) Response getEffectivePolicyOfDevice( @ApiParam( name = "type", @@ -639,25 +639,4 @@ public interface DeviceManagementService { @HeaderParam("If-Modified-Since") String ifModifiedSince); - @GET - @Path("/types") - @ApiOperation( - produces = MediaType.APPLICATION_JSON, - httpMethod = "GET", - value = "Get the device type.", - notes = "You are able to register Android, iOS and Windows devices with WSO2 EMM. In order to" - + "retrieve the device type details that are registered this end-point van be used.", - tags = "Device Management") - @ApiResponses( - value = { - @ApiResponse( - code = 200, - message = "OK. \n Registered device types have successfully retrieved"), - @ApiResponse( - code = 500, - message = "Error occurred while fetching the list of device types.") - } - ) - @Permission(scope = "operation-view", roles = {"emm-admin"}) - Response getDeviceTypes(); } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/NotificationManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/NotificationManagementService.java index 5656bbf3b2e..da4b7c36286 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/NotificationManagementService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/NotificationManagementService.java @@ -90,7 +90,7 @@ public interface NotificationManagementService { "\n Server error occurred while fetching the notification list.", response = ErrorResponse.class) }) - @Permission(scope = "device-notification-view", roles = {"emm-admin"}) + @Permission(scope = "notification:view", roles = {"admin"}) Response getNotifications( @ApiParam( name = "status", diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/PolicyManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/PolicyManagementService.java index 17ec195fbc1..edd6ea4c8f7 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/PolicyManagementService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/PolicyManagementService.java @@ -99,7 +99,7 @@ public interface PolicyManagementService { "Server error occurred while adding a new policy.", response = ErrorResponse.class) }) - @Permission(scope = "policy-modify", roles = {"emm-admin"}) + @Permission(scope = "policy:add", roles = {"admin"}) Response addPolicy( @ApiParam( name = "policy", @@ -153,7 +153,7 @@ public interface PolicyManagementService { "policies."), response = ErrorResponse.class) }) - @Permission(scope = "policy-view", roles = {"emm-admin"}) + @Permission(scope = "policy:list", roles = {"admin"}) Response getPolicies( @ApiParam( name = "If-Modified-Since", @@ -219,7 +219,7 @@ public interface PolicyManagementService { "policy.", response = ErrorResponse.class) }) - @Permission(scope = "policy-view", roles = {"emm-admin"}) + @Permission(scope = "policy:view", roles = {"admin"}) Response getPolicy( @ApiParam( name = "id", @@ -283,7 +283,7 @@ public interface PolicyManagementService { "Server error occurred while updating the policy.", response = ErrorResponse.class) }) - @Permission(scope = "policy-modify", roles = {"emm-admin"}) + @Permission(scope = "policy:modify", roles = {"admin"}) Response updatePolicy( @ApiParam( name = "id", @@ -329,7 +329,7 @@ public interface PolicyManagementService { "Server error occurred while bulk removing policies.", response = ErrorResponse.class) }) - @Permission(scope = "policy-modify", roles = {"emm-admin"}) + @Permission(scope = "policy:modify", roles = {"admin"}) Response removePolicies( @ApiParam( name = "policyIds", @@ -365,7 +365,7 @@ public interface PolicyManagementService { message = "ErrorResponse in activating policies.", response = ErrorResponse.class) }) - @Permission(scope = "policy-modify", roles = {"emm-admin"}) + @Permission(scope = "policy:add", roles = {"admin"}) Response activatePolicies( @ApiParam( name = "policyIds", @@ -401,7 +401,7 @@ public interface PolicyManagementService { message = "ErrorResponse in deactivating policies.", response = ErrorResponse.class) }) - @Permission(scope = "policy-modify", roles = {"emm-admin"}) + @Permission(scope = "policy:add", roles = {"admin"}) Response deactivatePolicies( @ApiParam( name = "policyIds", @@ -434,7 +434,7 @@ public interface PolicyManagementService { message = "ErrorResponse in deactivating policies.", response = ErrorResponse.class) }) - @Permission(scope = "policy-modify", roles = {"emm-admin"}) + @Permission(scope = "policy:add", roles = {"admin"}) Response applyChanges(); @@ -463,7 +463,7 @@ public interface PolicyManagementService { message = "Exception in updating policy priorities.", response = ErrorResponse.class) }) - @Permission(scope = "policy-modify", roles = {"emm-admin"}) + @Permission(scope = "policy:add", roles = {"admin"}) Response updatePolicyPriorities( @ApiParam( name = "priorityUpdatedPolicies", diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/RoleManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/RoleManagementService.java index 3c08c1b1fb1..cef486e9358 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/RoleManagementService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/RoleManagementService.java @@ -77,7 +77,7 @@ public interface RoleManagementService { message = "Internal Server Error. \n Server error occurred while fetching requested list of roles.", response = ErrorResponse.class) }) - @Permission(scope = "roles-view", roles = {"emm-admin"}) + @Permission(scope = "roles:list", roles = {"admin"}) Response getRoles( @ApiParam( name = "filter", @@ -159,7 +159,7 @@ public interface RoleManagementService { message = "Internal Server ErrorResponse. \n Server error occurred while fetching the permission list of the requested role.", response = ErrorResponse.class) }) - @Permission(scope = "roles-view", roles = {"emm-admin"}) + @Permission(scope = "roles:view", roles = {"admin"}) Response getPermissionsOfRole( @ApiParam( name = "roleName", @@ -222,7 +222,7 @@ public interface RoleManagementService { "requested role.", response = ErrorResponse.class) }) - @Permission(scope = "roles-view", roles = {"emm-admin"}) + @Permission(scope = "roles:view", roles = {"admin"}) Response getRole( @ApiParam( name = "roleName", @@ -282,7 +282,7 @@ public interface RoleManagementService { message = "Internal Server Error. \n Server error occurred while adding a new role.", response = ErrorResponse.class) }) - @Permission(scope = "roles-modify", roles = {"emm-admin"}) + @Permission(scope = "roles:add", roles = {"admin"}) Response addRole( @ApiParam( name = "role", @@ -332,7 +332,7 @@ public interface RoleManagementService { message = "Internal Server Error. \n Server error occurred while updating the role.", response = ErrorResponse.class) }) - @Permission(scope = "roles-modify", roles = {"emm-admin"}) + @Permission(scope = "roles:modify", roles = {"admin"}) Response updateRole( @ApiParam( name = "roleName", @@ -369,7 +369,7 @@ public interface RoleManagementService { message = "Internal Server Error. \n Server error occurred while removing the role.", response = ErrorResponse.class) }) - @Permission(scope = "roles-modify", roles = {"emm-admin"}) + @Permission(scope = "roles:modify", roles = {"admin"}) Response deleteRole( @ApiParam( name = "roleName", @@ -427,7 +427,7 @@ public interface RoleManagementService { "Server error occurred while updating the user list of the role.", response = ErrorResponse.class) }) - @Permission(scope = "roles-modify", roles = {"emm-admin"}) + @Permission(scope = "roles:modify", roles = {"admin"}) Response updateUsersOfRole( @ApiParam( name = "roleName", diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/admin/ApplicationManagementAdminService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/admin/ApplicationManagementAdminService.java index 508820e7e4e..8b102458ad5 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/admin/ApplicationManagementAdminService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/admin/ApplicationManagementAdminService.java @@ -74,7 +74,7 @@ public interface ApplicationManagementAdminService { "a given set of devices.", response = ErrorResponse.class) }) - @Permission(scope = "application-modify", roles = {"emm-admin"}) + @Permission(scope = "application:install", roles = {"admin"}) Response installApplication( @ApiParam( name = "applicationWrapper", @@ -113,7 +113,7 @@ public interface ApplicationManagementAdminService { "a given set of devices.", response = ErrorResponse.class) }) - @Permission(scope = "application-modify", roles = {"emm-admin"}) + @Permission(scope = "application:uninstall", roles = {"admin"}) Response uninstallApplication( @ApiParam( name = "applicationWrapper", diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/admin/DeviceManagementAdminService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/admin/DeviceManagementAdminService.java index 7ae98c4d315..21fe80e3ed2 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/admin/DeviceManagementAdminService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/admin/DeviceManagementAdminService.java @@ -84,7 +84,7 @@ public interface DeviceManagementAdminService { message = "Internal Server Error. \n Server error occurred while fetching the device list.", response = ErrorResponse.class) }) - @Permission(scope = "device-view", roles = {"emm-admin"}) + @Permission(scope = "device:view", roles = {"admin"}) Response getDevicesByName( @ApiParam( name = "name", 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 51157551d2c..85072428e8e 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 @@ -67,7 +67,7 @@ public interface UserManagementAdminService { "Server error occurred while updating credentials of the user.", response = ErrorResponse.class) }) - @Permission(scope = "user-modify", roles = {"emm-admin"}) + @Permission(scope = "user:modify", roles = {"admin"}) Response resetUserPassword( @ApiParam( name = "username",