Improving scope annotations in windows plugin

revert-dabc3590
Madawa Soysa 8 years ago committed by Milan Perera
parent 1b56ebb831
commit 855162c028

@ -79,6 +79,8 @@ public class Constants {
public static final String META_FORMAT_INT = "int"; public static final String META_FORMAT_INT = "int";
public static final String META_FORMAT_CHARACTER = "chr"; public static final String META_FORMAT_CHARACTER = "chr";
public static final String SCOPE = "scope";
/** /**
* SynclML service related constants. * SynclML service related constants.
*/ */

@ -32,9 +32,12 @@ 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.device.mgt.mobile.windows.api.common.exceptions.WindowsConfigurationException; 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.common.util.Message;
import org.wso2.carbon.device.mgt.mobile.windows.api.operations.util.Constants;
import javax.jws.WebService; import javax.jws.WebService;
import javax.ws.rs.*; 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") description = "This carries all the resources related to Windows configurations management functionalities")
@WebService @WebService
@Path("/configuration") @Path("/configuration")
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) @Produces({"application/json", "application/xml"})
@Consumes({MediaType.APPLICATION_JSON, MediaType.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 { public interface ConfigurationMgtService {
@GET @GET
@ -78,12 +103,10 @@ public interface ConfigurationMgtService {
notes = "Get the Windows platform configuration details using this REST API.", notes = "Get the Windows platform configuration details using this REST API.",
response = PlatformConfiguration.class, response = PlatformConfiguration.class,
tags = "Windows Configuration Management", tags = "Windows Configuration Management",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value = "permission", @ExtensionProperty(name = Constants.SCOPE, value = "cdmf:windows:view-configuration")
scopes = {@AuthorizationScope(scope = "/device-mgt/platform-configurations/view", })
description = "View Configurations")}
)
} }
) )
@ApiResponses(value = { @ApiResponses(value = {
@ -139,12 +162,10 @@ public interface ConfigurationMgtService {
value = "Updating Windows Platform Configurations", value = "Updating Windows Platform Configurations",
notes = "Update the Windows platform configurations using this REST API.", notes = "Update the Windows platform configurations using this REST API.",
tags = "Windows Configuration Management", tags = "Windows Configuration Management",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value = "permission", @ExtensionProperty(name = Constants.SCOPE, value = "cdmf:windows:manage-configuration")
scopes = {@AuthorizationScope(scope = "/device-mgt/configurations/manage", })
description = "Manage Configurations")}
)
} }
) )
@ApiResponses(value = { @ApiResponses(value = {
@ -197,12 +218,10 @@ public interface ConfigurationMgtService {
"registration process.", "registration process.",
response = String.class, response = String.class,
tags = "Windows Configuration Management", tags = "Windows Configuration Management",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value = "permission", @ExtensionProperty(name = Constants.SCOPE, value = "cdmf:windows:enroll")
scopes = {@AuthorizationScope(scope = "/device-mgt/devices/enroll/windows", })
description = "Enroll Device")}
)
} }
) )
@ApiResponses(value = { @ApiResponses(value = {

@ -19,8 +19,12 @@
package org.wso2.carbon.device.mgt.mobile.windows.api.services; package org.wso2.carbon.device.mgt.mobile.windows.api.services;
import io.swagger.annotations.*; 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.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.common.exceptions.WindowsDeviceEnrolmentException;
import org.wso2.carbon.device.mgt.mobile.windows.api.operations.util.Constants;
import javax.jws.WebService; import javax.jws.WebService;
import javax.ws.rs.Consumes; import javax.ws.rs.Consumes;
@ -57,9 +61,43 @@ import java.util.List;
@Api(value = "Windows Device Management Administrative Service", @Api(value = "Windows Device Management Administrative Service",
description = "Device management related admin APIs.") description = "Device management related admin APIs.")
@WebService @WebService
@Path("/operation/admin/devices") @Path("/admin/devices")
@Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) @Consumes(MediaType.APPLICATION_JSON)
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) @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 { public interface DeviceManagementAdminService {
@POST @POST
@ -71,13 +109,10 @@ public interface DeviceManagementAdminService {
notes = "Using this API you have the option of Device Windows device.", notes = "Using this API you have the option of Device Windows device.",
response = Activity.class, response = Activity.class,
tags = "Windows Device Management Administrative Service", tags = "Windows Device Management Administrative Service",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value = "permission", @ExtensionProperty(name = Constants.SCOPE, value = "cdmf:windows:lock-devices")
scopes = {@AuthorizationScope( })
scope = "/device-mgt/devices/owning-device/operations/windows/lock",
description = "Lock Device")}
)
} }
) )
@ApiResponses(value = { @ApiResponses(value = {
@ -133,13 +168,10 @@ public interface DeviceManagementAdminService {
notes = "Dis-enroll on Android devices", notes = "Dis-enroll on Android devices",
response = Activity.class, response = Activity.class,
tags = "Windows Device Management Administrative Service.", tags = "Windows Device Management Administrative Service.",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value = "permission", @ExtensionProperty(name = Constants.SCOPE, value = "cdmf:windows:disenroll")
scopes = {@AuthorizationScope( })
scope = "/device-mgt/devices/disenroll/windows",
description = "Dis-enroll the windows devices ")}
)
} }
) )
@ApiResponses(value = { @ApiResponses(value = {
@ -197,13 +229,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 = "Windows Device Management Administrative Service", tags = "Windows Device Management Administrative Service",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value = "permission", @ExtensionProperty(name = Constants.SCOPE, value = "cdmf:windows:wipe")
scopes = {@AuthorizationScope( })
scope = "/device-mgt/devices/owning-device/operations/windows/wipe",
description = "DeviceWipe")}
)
} }
) )
@ApiResponses(value = { @ApiResponses(value = {
@ -258,13 +287,10 @@ public interface DeviceManagementAdminService {
notes = "Ring Windows devices.", notes = "Ring Windows devices.",
response = Activity.class, response = Activity.class,
tags = "Windows Device Management Administrative Service", tags = "Windows Device Management Administrative Service",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = Constants.SCOPE, value = "cdmf:windows:ring")
scopes = { @AuthorizationScope( })
scope = "/device-mgt/devices/owning-device/operations/windows/ring",
description = "Ring Device") }
)
} }
) )
@ApiResponses(value = { @ApiResponses(value = {
@ -320,13 +346,10 @@ public interface DeviceManagementAdminService {
notes = "Lock reset on Windows devices.Its use to reset the device pass code", notes = "Lock reset on Windows devices.Its use to reset the device pass code",
response = Activity.class, response = Activity.class,
tags = "Windows Device Management Administrative Service", tags = "Windows Device Management Administrative Service",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = Constants.SCOPE, value = "cdmf:windows:lock-reset")
scopes = { @AuthorizationScope( })
scope = "/device-mgt/devices/owning-device/operations/windows/lock-reset",
description = "Lock reset") }
)
} }
) )
@ApiResponses(value = { @ApiResponses(value = {

@ -19,7 +19,11 @@
package org.wso2.carbon.device.mgt.mobile.windows.api.services.authbst; package org.wso2.carbon.device.mgt.mobile.windows.api.services.authbst;
import io.swagger.annotations.*; 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.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 org.wso2.carbon.device.mgt.mobile.windows.api.services.authbst.beans.Credentials;
import javax.jws.WebService; import javax.jws.WebService;
@ -56,6 +60,16 @@ import javax.ws.rs.core.Response;
@Path("/bst") @Path("/bst")
@Produces({"application/json", "application/xml"}) @Produces({"application/json", "application/xml"})
@Consumes({"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 { public interface BSTProvider {
@POST @POST
@ -68,13 +82,10 @@ public interface BSTProvider {
value = "Getting Binary security token.", value = "Getting Binary security token.",
notes = "Using this API to fetch Binary security token to call window enrollment and policy endpoints.", notes = "Using this API to fetch Binary security token to call window enrollment and policy endpoints.",
tags = "BST Provider", tags = "BST Provider",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value = "permission", @ExtensionProperty(name = Constants.SCOPE, value = "cdmf:windows:enroll")
scopes = {@AuthorizationScope(scope = "/device-mgt/devices/enroll/windows", })
description = "Getting Binary security token for Windows enrollment " +
"and policy endpoints.")}
)
} }
) )
@ApiResponses( @ApiResponses(

Loading…
Cancel
Save