Improving scope annotations in android plugin

merge-requests/1/head
Madawa Soysa 8 years ago committed by Milan Perera
parent 8a384a6664
commit 1b56ebb831

@ -143,6 +143,11 @@
<artifactId>org.wso2.carbon.device.mgt.common</artifactId> <artifactId>org.wso2.carbon.device.mgt.common</artifactId>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.apimgt.annotations</artifactId>
<scope>provided</scope>
</dependency>
<dependency> <dependency>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.device.mgt.core</artifactId> <artifactId>org.wso2.carbon.device.mgt.core</artifactId>

@ -24,15 +24,16 @@ import io.swagger.annotations.ExtensionProperty;
import io.swagger.annotations.Extension; import io.swagger.annotations.Extension;
import io.swagger.annotations.Tag; import io.swagger.annotations.Tag;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.AuthorizationScope;
import io.swagger.annotations.Authorization;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses; import io.swagger.annotations.ApiResponses;
import io.swagger.annotations.ResponseHeader; 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.operation.mgt.Activity; import org.wso2.carbon.device.mgt.common.operation.mgt.Activity;
import org.wso2.carbon.mdm.services.android.bean.wrapper.*; import org.wso2.carbon.mdm.services.android.bean.wrapper.*;
import org.wso2.carbon.mdm.services.android.util.AndroidConstants;
import javax.validation.Valid; import javax.validation.Valid;
import javax.ws.rs.Consumes; import javax.ws.rs.Consumes;
@ -64,6 +65,160 @@ import java.util.List;
@Api(value = "Android Device Management Administrative Service", description = "Device management related admin APIs.") @Api(value = "Android Device Management Administrative Service", description = "Device management related admin APIs.")
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@Scopes(
scopes = {
@Scope(
name = "Lock Device",
description = "Hard lock own device",
key = "cdmf:android:lock-devices",
permissions = {"/device-mgt/devices/owning-device/operations/android/lock"}
),
@Scope(
name = "Unlock Device",
description = "Unlock permanently locked device",
key = "cdmf:android:unlock-devices",
permissions = {"/device-mgt/devices/owning-device/operations/android/unlock"}
),
@Scope(
name = "Get Location",
description = "Request device location coordinates",
key = "cdmf:android:location",
permissions = {"/device-mgt/devices/owning-device/operations/android/location"}
),
@Scope(
name = "Clear Password",
description = "Clear the password on Android devices",
key = "cdmf:android:clear-password",
permissions = {"/device-mgt/devices/owning-device/operations/android/clear-password"}
),
@Scope(
name = "Control Camera",
description = "Enabling or Disabling the Camera on Android Devices",
key = "cdmf:android:control-camera",
permissions = {"/device-mgt/devices/owning-device/operations/android/camera"}
),
@Scope(
name = "Get Info",
description = "Requesting device information from Android Devices",
key = "cdmf:android:info",
permissions = {"/device-mgt/devices/owning-device/operations/android/info"}
),
@Scope(
name = "Get Logs",
description = "Requesting Logcat Details from Android Devices",
key = "cdmf:android:logcat",
permissions = {"/device-mgt/devices/owning-device/operations/android/logcat"}
),
@Scope(
name = "Enterprise Wipe",
description = "Enterprise Wiping Android Devices",
key = "cdmf:android:enterprise-wipe",
permissions = {"/device-mgt/devices/owning-device/operations/android/enterprise-wipe"}
),
@Scope(
name = "Factory Reset",
description = "Factory Resetting Android Devices",
key = "cdmf:android:wipe",
permissions = {"/device-mgt/devices/owning-device/operations/android/wipe"}
),
@Scope(
name = "Get Installed Applications",
description = "Get list of installed applications",
key = "cdmf:android:applications",
permissions = {"/device-mgt/devices/owning-device/operations/android/applications"}
),
@Scope(
name = "Ring Device",
description = "Ring Android devices",
key = "cdmf:android:ring",
permissions = {"/device-mgt/devices/owning-device/operations/android/ring"}
),
@Scope(
name = "Reboot Device",
description = "Reboot Android devices",
key = "cdmf:android:reboot",
permissions = {"/device-mgt/devices/owning-device/operations/android/reboot"}
),
@Scope(
name = "Mute Device",
description = "Mute Android devices",
key = "cdmf:android:mute",
permissions = {"/device-mgt/devices/owning-device/operations/android/mute"}
),
@Scope(
name = "Install Applications",
description = "Installing an Application on Android Devices",
key = "cdmf:android:install-application",
permissions = {"/device-mgt/devices/owning-device/operations/android/install-app"}
),
@Scope(
name = "Update Applications",
description = "Updating an Application on Android Devices",
key = "cdmf:android:update-application",
permissions = {"/device-mgt/devices/owning-device/operations/android/update-app"}
),
@Scope(
name = "Uninstall Applications",
description = "Uninstalling an Application on Android Devices",
key = "cdmf:android:uninstall-application",
permissions = {"/device-mgt/devices/owning-device/operations/android/uninstall-app"}
),
@Scope(
name = "Blacklist Applications",
description = "Blacklisting applications on Android Devices",
key = "cdmf:android:blacklist-applications",
permissions = {"/device-mgt/devices/owning-device/operations/android/blacklist-app"}
),
@Scope(
name = "Upgrade Firmware",
description = "Upgrading Firmware of Android Devices",
key = "cdmf:android:upgrade-firmware",
permissions = {"/device-mgt/devices/owning-device/operations/android/upgrade"}
),
@Scope(
name = "Configure VPN",
description = "Configure VPN on Android Device",
key = "cdmf:android:configure-vpn",
permissions = {"/device-mgt/devices/owning-device/operations/android/vpn"}
),
@Scope(
name = "Send Notification",
description = "Sending a notification to Android Device",
key = "cdmf:android:send-notification",
permissions = {"/device-mgt/devices/owning-device/operations/android/send-notification"}
),
@Scope(
name = "Configure Wi-Fi",
description = "Configure Wi-Fi on Android Device",
key = "cdmf:android:configure-wifi",
permissions = {"/device-mgt/devices/owning-device/operations/android/wifi"}
),
@Scope(
name = "Encrypt Storage",
description = "Encrypting storage on Android Device",
key = "cdmf:android:encrypt-storage",
permissions = {"/device-mgt/devices/owning-device/operations/android/encrypt"}
),
@Scope(
name = "Change Password",
description = "Changing the lock code of an Android Device",
key = "cdmf:android:change-lock-code",
permissions = {"/device-mgt/devices/owning-device/operations/android/change-lock-code"}
),
@Scope(
name = "Password Policy",
description = "Set password policy of an Android Device",
key = "cdmf:android:set-password-policy",
permissions = {"/device-mgt/devices/owning-device/operations/android/password-policy"}
),
@Scope(
name = "Add Web clip",
description = "Setting a Web Clip on Android Devices",
key = "cdmf:android:set-webclip",
permissions = {"/device-mgt/devices/owning-device/operations/android/webclip"}
)
}
)
public interface DeviceManagementAdminService { public interface DeviceManagementAdminService {
@POST @POST
@ -76,13 +231,10 @@ public interface DeviceManagementAdminService {
"permanently locks the device or screen locking an Android device.", "permanently locks the device or screen locking an Android device.",
response = Activity.class, response = Activity.class,
tags = "Android Device Management Administrative Service", tags = "Android Device Management Administrative Service",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:lock-devices")
scopes = { @AuthorizationScope( })
scope = "/device-mgt/devices/owning-device/operations/android/lock",
description = "Lock Device") }
)
} }
) )
@ApiResponses(value = { @ApiResponses(value = {
@ -142,13 +294,10 @@ public interface DeviceManagementAdminService {
notes = "Unlock devices that were locked permanently using the hard lock operation. Devices that are hard locked can only be unlocked by the EMM administrator.", notes = "Unlock devices that were locked permanently using the hard lock operation. Devices that are hard locked can only be unlocked by the EMM administrator.",
response = Activity.class, response = Activity.class,
tags = "Android Device Management Administrative Service", tags = "Android Device Management Administrative Service",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:unlock-devices")
scopes = { @AuthorizationScope( })
scope = "/device-mgt/devices/owning-device/operations/android/unlock",
description = "Unlock Device") }
)
} }
) )
@ApiResponses(value = { @ApiResponses(value = {
@ -208,13 +357,10 @@ public interface DeviceManagementAdminService {
"Example: In situations where you have lost your device and need to find out where it is, you can use this REST API to get the location of the device.", "Example: In situations where you have lost your device and need to find out where it is, you can use this REST API to get the location of the device.",
response = Activity.class, response = Activity.class,
tags = "Android Device Management Administrative Service", tags = "Android Device Management Administrative Service",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:location")
scopes = { @AuthorizationScope( })
scope = "/device-mgt/devices/owning-device/operations/android/location",
description = "Get Device Location") }
)
} }
) )
@ApiResponses(value = { @ApiResponses(value = {
@ -270,13 +416,10 @@ public interface DeviceManagementAdminService {
notes = "Clear the password on Android devices", notes = "Clear the password on Android devices",
response = Activity.class, response = Activity.class,
tags = "Android Device Management Administrative Service.", tags = "Android Device Management Administrative Service.",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:clear-password")
scopes = { @AuthorizationScope( })
scope = "/device-mgt/devices/owning-device/operations/android/clear-password",
description = "Clear Password of Device") }
)
} }
) )
@ApiResponses(value = { @ApiResponses(value = {
@ -331,13 +474,11 @@ public interface DeviceManagementAdminService {
notes = "Enable or disable the camera on Android devices.", notes = "Enable or disable the camera on Android devices.",
response = Activity.class, response = Activity.class,
tags = "Android Device Management Administrative Service", tags = "Android Device Management Administrative Service",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:control-camera")
scopes = { @AuthorizationScope(scope = "/device-mgt/devices/owning-device/operations/android/camera", description = "Manage Camera") } })
) } )
}
)
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse( @ApiResponse(
code = 201, code = 201,
@ -398,13 +539,10 @@ public interface DeviceManagementAdminService {
"the list of operations that needs to be executed on the device", "the list of operations that needs to be executed on the device",
response = Activity.class, response = Activity.class,
tags = "Android Device Management Administrative Service", tags = "Android Device Management Administrative Service",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:info")
scopes = { @AuthorizationScope( })
scope = "/device-mgt/devices/owning-device/operations/android/info",
description = "Get Device Information") }
)
} }
) )
@ApiResponses(value = { @ApiResponses(value = {
@ -464,13 +602,10 @@ public interface DeviceManagementAdminService {
"the list of operations that needs to be executed on the device.", "the list of operations that needs to be executed on the device.",
response = Activity.class, response = Activity.class,
tags = "Android Device Management Administrative Service", tags = "Android Device Management Administrative Service",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:logcat")
scopes = { @AuthorizationScope( })
scope = "/device-mgt/devices/owning-device/operations/android/logcat",
description = "Get Logs") }
)
} }
) )
@ApiResponses(value = { @ApiResponses(value = {
@ -529,13 +664,10 @@ public interface DeviceManagementAdminService {
"personal data intact. You are able to enterprise wipe Android devices using this REST API.", "personal data intact. You are able to enterprise wipe Android devices using this REST API.",
response = Activity.class, response = Activity.class,
tags = "Android Device Management Administrative Service", tags = "Android Device Management Administrative Service",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:enterprise-wipe")
scopes = { @AuthorizationScope( })
scope = "/device-mgt/devices/owning-device/operations/android/enterprise-wipe",
description = "Enterprise Wipe") }
)
} }
) )
@ApiResponses(value = { @ApiResponses(value = {
@ -592,13 +724,10 @@ public interface DeviceManagementAdminService {
"to restore them back to the original system.", "to restore them back to the original system.",
response = Activity.class, response = Activity.class,
tags = "Android Device Management Administrative Service", tags = "Android Device Management Administrative Service",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:wipe")
scopes = { @AuthorizationScope( })
scope = "/device-mgt/devices/owning-device/operations/android/wipe",
description = "Factory Reset") }
)
} }
) )
@ApiResponses(value = { @ApiResponses(value = {
@ -659,13 +788,10 @@ public interface DeviceManagementAdminService {
"on the device.", "on the device.",
response = Activity.class, response = Activity.class,
tags = "Android Device Management Administrative Service", tags = "Android Device Management Administrative Service",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:applications")
scopes = { @AuthorizationScope( })
scope = "/device-mgt/devices/owning-device/operations/android/applications",
description = "Get Installed Application") }
)
} }
) )
@ApiResponses(value = { @ApiResponses(value = {
@ -722,13 +848,10 @@ public interface DeviceManagementAdminService {
notes = "Ring Android devices.", notes = "Ring Android devices.",
response = Activity.class, response = Activity.class,
tags = "Android Device Management Administrative Service", tags = "Android Device Management Administrative Service",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:ring")
scopes = { @AuthorizationScope( })
scope = "/device-mgt/devices/owning-device/operations/android/ring",
description = "Ring Device") }
)
} }
) )
@ApiResponses(value = { @ApiResponses(value = {
@ -785,13 +908,10 @@ public interface DeviceManagementAdminService {
notes = "Reboot or restart your Android devices.", notes = "Reboot or restart your Android devices.",
response = Activity.class, response = Activity.class,
tags = "Android Device Management Administrative Service", tags = "Android Device Management Administrative Service",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:reboot")
scopes = { @AuthorizationScope( })
scope = "/device-mgt/devices/owning-device/operations/android/reboot",
description = "Reboot Device") }
)
} }
) )
@ApiResponses(value = { @ApiResponses(value = {
@ -840,6 +960,7 @@ public interface DeviceManagementAdminService {
List<String> deviceIDs); List<String> deviceIDs);
@POST @POST
@Path("/mute")
@ApiOperation( @ApiOperation(
consumes = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON,
httpMethod = "POST", httpMethod = "POST",
@ -847,13 +968,10 @@ public interface DeviceManagementAdminService {
notes = "Mute or enable a silent profile for Android devices.", notes = "Mute or enable a silent profile for Android devices.",
response = Activity.class, response = Activity.class,
tags = "Android Device Management Administrative Service", tags = "Android Device Management Administrative Service",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:mute")
scopes = { @AuthorizationScope( })
scope = "/device-mgt/devices/owning-device/operations/android/mute",
description = "Mute Device") }
)
} }
) )
@ApiResponses(value = { @ApiResponses(value = {
@ -894,7 +1012,6 @@ public interface DeviceManagementAdminService {
message = "Internal Server Error. \n " + message = "Internal Server Error. \n " +
"Server error occurred while adding a new device mute operation.") "Server error occurred while adding a new device mute operation.")
}) })
@Path("/mute")
Response muteDevice( Response muteDevice(
@ApiParam( @ApiParam(
name = "deviceIDs", name = "deviceIDs",
@ -913,13 +1030,10 @@ public interface DeviceManagementAdminService {
" the application installation will happen in silent mode, else the device user's consent will be required.", " the application installation will happen in silent mode, else the device user's consent will be required.",
response = Activity.class, response = Activity.class,
tags = "Android Device Management Administrative Service", tags = "Android Device Management Administrative Service",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:install-application")
scopes = { @AuthorizationScope( })
scope = "/device-mgt/devices/owning-device/operations/android/install-app",
description = "Install Applications") }
)
} }
) )
@ApiResponses(value = { @ApiResponses(value = {
@ -981,13 +1095,10 @@ public interface DeviceManagementAdminService {
"mode, else the device user's consent is required.", "mode, else the device user's consent is required.",
response = Activity.class, response = Activity.class,
tags = "Android Device Management Administrative Service", tags = "Android Device Management Administrative Service",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:update-application")
scopes = { @AuthorizationScope( })
scope = "/device-mgt/devices/owning-device/operations/android/update-app",
description = "Update installed applications") }
)
} }
) )
@ApiResponses(value = { @ApiResponses(value = {
@ -1046,13 +1157,10 @@ public interface DeviceManagementAdminService {
notes = "Uninstall an application from Android devices.", notes = "Uninstall an application from Android devices.",
response = Activity.class, response = Activity.class,
tags = "Android Device Management Administrative Service", tags = "Android Device Management Administrative Service",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:uninstall-application")
scopes = { @AuthorizationScope( })
scope = "/device-mgt/devices/owning-device/operations/android/uninstall-app",
description = "Uninstall Applications") }
)
} }
) )
@ApiResponses(value = { @ApiResponses(value = {
@ -1115,13 +1223,10 @@ public interface DeviceManagementAdminService {
"COPE devices. Applications can be blacklisted via the application restriction policy too.", "COPE devices. Applications can be blacklisted via the application restriction policy too.",
response = Activity.class, response = Activity.class,
tags = "Android Device Management Administrative Service", tags = "Android Device Management Administrative Service",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:blacklist-applications")
scopes = { @AuthorizationScope( })
scope = "/device-mgt/devices/owning-device/operations/android/blacklist-app",
description = "Blacklist Applications") }
)
} }
) )
@ApiResponses(value = { @ApiResponses(value = {
@ -1176,17 +1281,14 @@ public interface DeviceManagementAdminService {
consumes = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON,
produces = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON,
httpMethod = "POST", httpMethod = "POST",
value = "UUpgrading Firmware of Android Devices", value = "Upgrading Firmware of Android Devices",
notes = "Upgrade the firmware of Android devices.", notes = "Upgrade the firmware of Android devices.",
response = Activity.class, response = Activity.class,
tags = "Android Device Management Administrative Service", tags = "Android Device Management Administrative Service",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:upgrade-firmware")
scopes = { @AuthorizationScope( })
scope = "/device-mgt/devices/owning-device/operations/android/upgrade",
description = "Upgrade Firmware") }
)
} }
) )
@ApiResponses(value = { @ApiResponses(value = {
@ -1247,13 +1349,10 @@ public interface DeviceManagementAdminService {
notes = "Configure VPN on Android devices.", notes = "Configure VPN on Android devices.",
response = Activity.class, response = Activity.class,
tags = "Android Device Management Administrative Service", tags = "Android Device Management Administrative Service",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:configure-vpn")
scopes = { @AuthorizationScope( })
scope = "/device-mgt/devices/owning-device/operations/android/vpn",
description = "Add VPN") }
)
} }
) )
@ApiResponses(value = { @ApiResponses(value = {
@ -1310,13 +1409,10 @@ public interface DeviceManagementAdminService {
notes = "Send a notification or message to Android devices.", notes = "Send a notification or message to Android devices.",
response = Activity.class, response = Activity.class,
tags = "Android Device Management Administrative Service", tags = "Android Device Management Administrative Service",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:send-notification")
scopes = { @AuthorizationScope( })
scope = "/device-mgt/devices/owning-device/operations/android/send-notification",
description = "Send Notifications") }
)
} }
) )
@ApiResponses(value = { @ApiResponses(value = {
@ -1374,13 +1470,10 @@ public interface DeviceManagementAdminService {
notes = "Configure Wi-Fi on Android devices.", notes = "Configure Wi-Fi on Android devices.",
response = Activity.class, response = Activity.class,
tags = "Android Device Management Administrative Service", tags = "Android Device Management Administrative Service",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:configure-wifi")
scopes = { @AuthorizationScope( })
scope = "/device-mgt/devices/owning-device/operations/android/wifi",
description = "Add Wifi Configuration") }
)
} }
) )
@ApiResponses(value = { @ApiResponses(value = {
@ -1439,13 +1532,10 @@ public interface DeviceManagementAdminService {
notes = "Encrypt the data stored on Android devices.", notes = "Encrypt the data stored on Android devices.",
response = Activity.class, response = Activity.class,
tags = "Android Device Management Administrative Service", tags = "Android Device Management Administrative Service",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:encrypt-storage")
scopes = { @AuthorizationScope( })
scope = "/device-mgt/devices/owning-device/operations/android/encrypt",
description = "Encrypt Device") }
)
} }
) )
@ApiResponses(value = { @ApiResponses(value = {
@ -1504,13 +1594,10 @@ public interface DeviceManagementAdminService {
notes = "Change the lock code on Android devices.", notes = "Change the lock code on Android devices.",
response = Activity.class, response = Activity.class,
tags = "Android Device Management Administrative Service", tags = "Android Device Management Administrative Service",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:change-lock-code")
scopes = { @AuthorizationScope( })
scope = "/device-mgt/devices/owning-device/operations/android/change-lock-code",
description = "Change Password of Device") }
)
} }
) )
@ApiResponses(value = { @ApiResponses(value = {
@ -1569,13 +1656,10 @@ public interface DeviceManagementAdminService {
notes = "Set a password policy on Android devices.", notes = "Set a password policy on Android devices.",
response = Activity.class, response = Activity.class,
tags = "Android Device Management Administrative Service", tags = "Android Device Management Administrative Service",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:set-password-policy")
scopes = { @AuthorizationScope( })
scope = "/device-mgt/devices/owning-device/operations/android/password-policy",
description = "Set Password Policy") }
)
} }
) )
@ApiResponses(value = { @ApiResponses(value = {
@ -1624,7 +1708,7 @@ public interface DeviceManagementAdminService {
PasswordPolicyBeanWrapper passwordPolicyBeanWrapper); PasswordPolicyBeanWrapper passwordPolicyBeanWrapper);
@POST @POST
@Path("set-webclip") @Path("/set-webclip")
@ApiOperation( @ApiOperation(
consumes = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON,
httpMethod = "POST", httpMethod = "POST",
@ -1632,13 +1716,10 @@ public interface DeviceManagementAdminService {
notes = "Set a web clip on Android devices. A web clip is used to add a bookmark to a web application.", notes = "Set a web clip on Android devices. A web clip is used to add a bookmark to a web application.",
response = Activity.class, response = Activity.class,
tags = "Android Device Management Administrative Service", tags = "Android Device Management Administrative Service",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:set-webclip")
scopes = { @AuthorizationScope( })
scope = "/device-mgt/devices/owning-device/operations/android/webclip",
description = "Add Webclips") }
)
} }
) )
@ApiResponses(value = { @ApiResponses(value = {

@ -18,22 +18,14 @@
*/ */
package org.wso2.carbon.mdm.services.android.services; package org.wso2.carbon.mdm.services.android.services;
import io.swagger.annotations.Api; import io.swagger.annotations.*;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam; import org.wso2.carbon.apimgt.annotations.api.Scope;
import io.swagger.annotations.ApiResponse; import org.wso2.carbon.apimgt.annotations.api.Scopes;
import io.swagger.annotations.ApiResponses;
import io.swagger.annotations.Authorization;
import io.swagger.annotations.AuthorizationScope;
import io.swagger.annotations.Extension;
import io.swagger.annotations.ExtensionProperty;
import io.swagger.annotations.Info;
import io.swagger.annotations.ResponseHeader;
import io.swagger.annotations.SwaggerDefinition;
import io.swagger.annotations.Tag;
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
import org.wso2.carbon.mdm.services.android.bean.wrapper.AndroidApplication; import org.wso2.carbon.mdm.services.android.bean.wrapper.AndroidApplication;
import org.wso2.carbon.mdm.services.android.bean.wrapper.AndroidDevice; import org.wso2.carbon.mdm.services.android.bean.wrapper.AndroidDevice;
import org.wso2.carbon.mdm.services.android.util.AndroidConstants;
import javax.validation.Valid; import javax.validation.Valid;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
@ -72,6 +64,22 @@ import java.util.List;
@Path("/devices") @Path("/devices")
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@Scopes(
scopes = {
@Scope(
name = "Enroll Device",
description = "Register an Android device",
key = "cdmf:android:enroll",
permissions = {"/device-mgt/devices/enroll/android"}
),
@Scope(
name = "Un-enroll Device",
description = "Unregister an Android device",
key = "cdmf:android:disenroll",
permissions = {"/device-mgt/devices/disenroll/android"}
)
}
)
public interface DeviceManagementService { public interface DeviceManagementService {
@PUT @PUT
@ -83,12 +91,10 @@ public interface DeviceManagementService {
value = "Updating the Application Details on Android Devices", value = "Updating the Application Details on Android Devices",
notes = "Update the details of the applications that are installed on Android devices.", notes = "Update the details of the applications that are installed on Android devices.",
tags = "Android Device Management", tags = "Android Device Management",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:enroll")
scopes = { @AuthorizationScope(scope = "/device-mgt/devices/enroll/android", })
description = "Enroll Device") }
)
} }
) )
@ApiResponses(value = { @ApiResponses(value = {
@ -150,12 +156,10 @@ public interface DeviceManagementService {
"The server then updates the status of the operations that were carried out on the device.", "The server then updates the status of the operations that were carried out on the device.",
response = Operation.class, response = Operation.class,
tags = "Android Device Management", tags = "Android Device Management",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:enroll")
scopes = { @AuthorizationScope(scope = "/device-mgt/devices/enroll/android", })
description = "Enroll Device") }
)
} }
) )
@ApiResponses(value = { @ApiResponses(value = {
@ -216,12 +220,10 @@ public interface DeviceManagementService {
" you can use this REST API to register an Android device with WSO2 EMM, without having to install" + " you can use this REST API to register an Android device with WSO2 EMM, without having to install" +
" an Android Agent. This API can be mainly used to test the device enrollment process.", " an Android Agent. This API can be mainly used to test the device enrollment process.",
tags = "Android Device Management", tags = "Android Device Management",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:enroll")
scopes = { @AuthorizationScope(scope = "/device-mgt/devices/enroll/android", })
description = "Enroll Device") }
)
} }
) )
@ApiResponses(value = { @ApiResponses(value = {
@ -273,12 +275,10 @@ public interface DeviceManagementService {
value = "Getting the Registration Status of an Android Device", value = "Getting the Registration Status of an Android Device",
notes = "Use this REST API to retrieve the registration status of an Android device.", notes = "Use this REST API to retrieve the registration status of an Android device.",
tags = "Android Device Management", tags = "Android Device Management",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:enroll")
scopes = { @AuthorizationScope(scope = "/device-mgt/devices/enroll/android", })
description = "Enroll Device") }
)
} }
) )
@ApiResponses(value = { @ApiResponses(value = {
@ -328,12 +328,10 @@ public interface DeviceManagementService {
value = "Updating the Registration Details of an Android Device", value = "Updating the Registration Details of an Android Device",
notes = "Use this REST API to update the registration details of an Android device.", notes = "Use this REST API to update the registration details of an Android device.",
tags = "Android Device Management", tags = "Android Device Management",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:enroll")
scopes = { @AuthorizationScope(scope = "/device-mgt/devices/enroll/android", })
description = "Enroll Device") }
)
} }
) )
@ApiResponses( @ApiResponses(
@ -386,11 +384,10 @@ public interface DeviceManagementService {
value = "Unregistering an Android Device", value = "Unregistering an Android Device",
notes = "Use this REST API to unregister an Android device.", notes = "Use this REST API to unregister an Android device.",
tags = "Android Device Management", tags = "Android Device Management",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:disenroll")
scopes = { @AuthorizationScope(scope = "/device-mgt/devices/disenroll/android", description = "Disenroll Device") } })
)
} }
) )
@ApiResponses(value = { @ApiResponses(value = {

@ -24,16 +24,17 @@ import io.swagger.annotations.ExtensionProperty;
import io.swagger.annotations.Extension; import io.swagger.annotations.Extension;
import io.swagger.annotations.Tag; import io.swagger.annotations.Tag;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.AuthorizationScope;
import io.swagger.annotations.Authorization;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses; import io.swagger.annotations.ApiResponses;
import io.swagger.annotations.ResponseHeader; 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.common.configuration.mgt.PlatformConfiguration;
import org.wso2.carbon.mdm.services.android.bean.AndroidPlatformConfiguration; import org.wso2.carbon.mdm.services.android.bean.AndroidPlatformConfiguration;
import org.wso2.carbon.mdm.services.android.exception.AndroidAgentException; import org.wso2.carbon.mdm.services.android.exception.AndroidAgentException;
import org.wso2.carbon.mdm.services.android.util.AndroidConstants;
import javax.validation.Valid; import javax.validation.Valid;
import javax.ws.rs.*; import javax.ws.rs.*;
@ -61,6 +62,28 @@ import javax.ws.rs.core.Response;
@Path("/configuration") @Path("/configuration")
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@Scopes(
scopes = {
@Scope(
name = "Enroll Device",
description = "Register an Android device",
key = "cdmf:android:enroll",
permissions = {"/device-mgt/devices/enroll/android"}
),
@Scope(
name = "View Configurations",
description = "Getting Android Platform Configurations",
key = "cdmf:android:view-configuration",
permissions = {"/device-mgt/platform-configurations/view"}
),
@Scope(
name = "Manage Configurations",
description = "Updating Android Platform Configurations",
key = "cdmf:android:manage-configuration",
permissions = {"/device-mgt/platform-configurations/manage"}
)
}
)
public interface DeviceTypeConfigurationService { public interface DeviceTypeConfigurationService {
@GET @GET
@ -71,12 +94,10 @@ public interface DeviceTypeConfigurationService {
notes = "Get the Android platform configuration details using this REST API.", notes = "Get the Android platform configuration details using this REST API.",
response = PlatformConfiguration.class, response = PlatformConfiguration.class,
tags = "Android Configuration Management", tags = "Android Configuration Management",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:view-configuration")
scopes = { @AuthorizationScope(scope = "/device-mgt/platform-configurations/view", })
description = "View Configurations") }
)
} }
) )
@ApiResponses(value = { @ApiResponses(value = {
@ -127,12 +148,10 @@ public interface DeviceTypeConfigurationService {
value = "Updating Android Platform Configurations", value = "Updating Android Platform Configurations",
notes = "Update the Android platform configurations using this REST API.", notes = "Update the Android platform configurations using this REST API.",
tags = "Android Configuration Management", tags = "Android Configuration Management",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:manage-configuration")
scopes = { @AuthorizationScope(scope = "/device-mgt/platform-configurations/manage", })
description = "Manage Configurations") }
)
} }
) )
@ApiResponses(value = { @ApiResponses(value = {
@ -184,12 +203,10 @@ public interface DeviceTypeConfigurationService {
"registration process.", "registration process.",
response = String.class, response = String.class,
tags = "Android Configuration Management", tags = "Android Configuration Management",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:enroll")
scopes = { @AuthorizationScope(scope = "/device-mgt/devices/enroll/android", })
description = "Enroll Device") }
)
} }
) )
@ApiResponses(value = { @ApiResponses(value = {

@ -24,15 +24,16 @@ import io.swagger.annotations.ExtensionProperty;
import io.swagger.annotations.Extension; import io.swagger.annotations.Extension;
import io.swagger.annotations.Tag; import io.swagger.annotations.Tag;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.AuthorizationScope;
import io.swagger.annotations.Authorization;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses; import io.swagger.annotations.ApiResponses;
import io.swagger.annotations.ResponseHeader; 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.mdm.services.android.bean.DeviceState; import org.wso2.carbon.mdm.services.android.bean.DeviceState;
import org.wso2.carbon.mdm.services.android.bean.wrapper.EventBeanWrapper; import org.wso2.carbon.mdm.services.android.bean.wrapper.EventBeanWrapper;
import org.wso2.carbon.mdm.services.android.util.AndroidConstants;
import javax.validation.Valid; import javax.validation.Valid;
import javax.validation.constraints.Size; import javax.validation.constraints.Size;
@ -61,6 +62,16 @@ import javax.ws.rs.core.Response;
@Path("/events") @Path("/events")
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@Scopes(
scopes = {
@Scope(
name = "Enroll Device",
description = "Register an Android device",
key = "cdmf:android:enroll",
permissions = {"/device-mgt/devices/enroll/android"}
)
}
)
public interface EventReceiverService { public interface EventReceiverService {
@POST @POST
@ -72,12 +83,10 @@ public interface EventReceiverService {
value = "Publishing Events", value = "Publishing Events",
notes = "Publish events received by the WSO2 EMM Android client to the WSO2 Data Analytics Server (DAS) using this API.", notes = "Publish events received by the WSO2 EMM Android client to the WSO2 Data Analytics Server (DAS) using this API.",
tags = "Event Receiver", tags = "Event Receiver",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:enroll")
scopes = { @AuthorizationScope(scope = "/device-mgt/devices/enroll/android", })
description = "Publish Events to DAS") }
)
} }
) )
@ApiResponses( @ApiResponses(
@ -137,12 +146,10 @@ public interface EventReceiverService {
response = DeviceState.class, response = DeviceState.class,
responseContainer = "List", responseContainer = "List",
tags = "Event Receiver", tags = "Event Receiver",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:enroll")
scopes = { @AuthorizationScope(scope = "/device-mgt/devices/enroll/android", })
description = "Publish Events to DAS") }
)
} }
) )
@ApiResponses( @ApiResponses(

@ -26,6 +26,7 @@ public final class AndroidConstants {
public static final String DEVICE_TYPE_ANDROID = "android"; public static final String DEVICE_TYPE_ANDROID = "android";
public static final String HEADER_CONTENT_TYPE = "Content-Type"; public static final String HEADER_CONTENT_TYPE = "Content-Type";
public static final String APPLICATION_JSON = "application/json"; public static final String APPLICATION_JSON = "application/json";
public static final String SCOPE = "scope";
public final class DeviceProperties { public final class DeviceProperties {
private DeviceProperties() { private DeviceProperties() {

Loading…
Cancel
Save