From 36cbc967130e7d1b17d805b452c5e377d0285033 Mon Sep 17 00:00:00 2001 From: Hasunie Date: Thu, 8 Dec 2016 16:04:46 +0530 Subject: [PATCH 1/3] adding swagger annotations --- .../pom.xml | 14 + .../windows/api/common/PluginConstants.java | 2 +- .../api/services/ConfigurationMgtService.java | 41 ++- .../DeviceManagementAdminService.java | 322 ++++++++++++++++-- .../api/services/PolicyManagementService.java | 46 --- .../api/services/authbst/BSTProvider.java | 81 ++++- .../services/authbst/beans/Credentials.java | 3 + .../services/discovery/DiscoveryService.java | 129 ++++++- .../discovery/beans/DiscoveryRequest.java | 9 + .../impl/ConfigurationMgtServiceImpl.java | 36 +- .../impl/DeviceManagementServiceImpl.java | 314 ++++++++--------- .../impl/PolicyManagementServiceImpl.java | 71 ---- .../api/services/syncml/SyncmlService.java | 77 ++++- .../syncml/impl/SyncmlServiceImpl.java | 18 +- .../wstep/CertificateEnrollmentService.java | 91 ++++- .../CertificateEnrollmentPolicyService.java | 84 ++++- .../src/main/webapp/WEB-INF/cxf-servlet.xml | 80 ++--- .../src/main/webapp/WEB-INF/web.xml | 6 +- .../windows-web-agent/app/conf/config.json | 2 +- .../modules/business-controllers/device.js | 2 +- 20 files changed, 1017 insertions(+), 411 deletions(-) delete mode 100644 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/PolicyManagementService.java delete mode 100644 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/impl/PolicyManagementServiceImpl.java diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/pom.xml b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/pom.xml index 9278bbf32..0527ae239 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/pom.xml +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/pom.xml @@ -351,6 +351,20 @@ io.swagger swagger-annotations + + + io.swagger + swagger-core + + + org.slf4j + slf4j-api + + + + + io.swagger + swagger-jaxrs org.slf4j 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/common/PluginConstants.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/common/PluginConstants.java index b399420af..e2959baf0 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/common/PluginConstants.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/common/PluginConstants.java @@ -189,7 +189,7 @@ public final class PluginConstants { public static final int MODEL_POSITION = 5; public static final int MAC_ADDRESS_POSITION = 7; public static final int RESOLUTION_POSITION = 8; - public static final int DEVICE_NAME_POSITION = 9; + public static final int DEVICE_NAME_POSITION = 10; public static final String SYNCML_DATA_ONE = "1"; public static final String SYNCML_DATA_ZERO = "0"; public static final String OS_VERSION = "OS_VERSION"; 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 ab4c2574b..a5f207595 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 @@ -54,7 +54,7 @@ import javax.ws.rs.core.Response; @Extension(properties = { @ExtensionProperty(name = "name", value = "Windows Configuration Management"), @ExtensionProperty(name = "context", - value = "/api/device-mgt/windows/v1.0/services/configuration"), + value = "/api/device-mgt/windows/v1.0/configuration"), }) } ), @@ -63,13 +63,13 @@ import javax.ws.rs.core.Response; } ) @Api(value = "Windows Configuration Management", - 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 -@Path("services/configuration") +@Path("/configuration") @Produces({"application/json", "application/xml"}) @Consumes({"application/json", "application/xml"}) public interface ConfigurationMgtService { - + @GET @ApiOperation( produces = MediaType.APPLICATION_JSON, @@ -80,9 +80,9 @@ public interface ConfigurationMgtService { tags = "Windows Configuration Management", authorizations = { @Authorization( - value="permission", - scopes = { @AuthorizationScope(scope = "/device-mgt/platform-configurations/view", - description = "View Configurations") } + value = "permission", + scopes = {@AuthorizationScope(scope = "/device-mgt/platform-configurations/view", + description = "View Configurations")} ) } ) @@ -117,7 +117,12 @@ public interface ConfigurationMgtService { code = 500, message = "Internal Server Error. \n Server error occurred while fetching the Windows platform configuration.") }) - PlatformConfiguration getConfiguration() throws WindowsConfigurationException; + Response getConfiguration(@ApiParam( + name = "If-Modified-Since", + value = "Checks if the requested variant was modified, since the specified date-time.\n" + + "Provide the value in the following format: EEE, d MMM yyyy HH:mm:ss Z.\n" + + "Example: Mon, 05 Jan 2014 15:10:00 +0200", + required = false) @HeaderParam("If-Modified-Since") String ifModifiedSince); /** * Update Tenant Configurations for the specific Device type. @@ -136,9 +141,9 @@ public interface ConfigurationMgtService { tags = "Windows Configuration Management", authorizations = { @Authorization( - value="permission", - scopes = { @AuthorizationScope(scope = "/device-mgt/configurations/manage", - description = "Manage Configurations") } + value = "permission", + scopes = {@AuthorizationScope(scope = "/device-mgt/configurations/manage", + description = "Manage Configurations")} ) } ) @@ -175,11 +180,11 @@ public interface ConfigurationMgtService { message = "Internal Server Error. \n " + "Server error occurred while modifying the Windows platform configurations.") }) - Message updateConfiguration - ( @ApiParam( + Response updateConfiguration + (@ApiParam( name = "configuration", value = "The properties to update the Windows platform configurations.") - PlatformConfiguration configuration) throws WindowsConfigurationException; + PlatformConfiguration configuration) throws WindowsConfigurationException; @GET @Path("license") @@ -194,9 +199,9 @@ public interface ConfigurationMgtService { tags = "Windows Configuration Management", authorizations = { @Authorization( - value="permission", - scopes = { @AuthorizationScope(scope = "/device-mgt/devices/enroll/windows", - description = "Enroll Device") } + value = "permission", + scopes = {@AuthorizationScope(scope = "/device-mgt/devices/enroll/windows", + description = "Enroll Device")} ) } ) @@ -236,7 +241,7 @@ public interface ConfigurationMgtService { name = "If-Modified-Since", value = "Checks if the requested variant was modified, since the specified date-time.\n" + "Provide the value in the following format: EEE, d MMM yyyy HH:mm:ss Z.\n" + - "Example: Mon, 05 Jan 2014 15:10:00 +0200", + "Example: Mon, 05 Jan 2014 15:10:00 +0200.", required = false) @HeaderParam("If-Modified-Since") String ifModifiedSince) throws WindowsConfigurationException; 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 5e325938c..8ff15ea34 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 @@ -18,13 +18,9 @@ package org.wso2.carbon.device.mgt.mobile.windows.api.services; -import io.swagger.annotations.SwaggerDefinition; -import io.swagger.annotations.Info; -import io.swagger.annotations.ExtensionProperty; -import io.swagger.annotations.Extension; -import io.swagger.annotations.Tag; -import io.swagger.annotations.Api; +import io.swagger.annotations.*; import org.wso2.carbon.apimgt.annotations.api.Permission; +import org.wso2.carbon.device.mgt.common.operation.mgt.Activity; import org.wso2.carbon.device.mgt.mobile.windows.api.common.exceptions.WindowsDeviceEnrolmentException; import javax.jws.WebService; @@ -41,7 +37,7 @@ import java.util.List; * Interface for Admin operations persisting. This interface accepts operations added via UI. */ @Api(value = "Windows Device Management Administrative Service", - description = "Device management related admin APIs.") + description = "Device management related admin APIs.") @SwaggerDefinition( info = @Info( @@ -68,31 +64,313 @@ public interface DeviceManagementAdminService { @POST @Path("/lock-devices") - @Permission(name = "Lock Device", permission = "/device-mgt/devices/owning-device/operations/windows/lock") - Response lock(@HeaderParam("Accept") String headerParam, List deviceIds) throws - WindowsDeviceEnrolmentException; + @ApiOperation( + consumes = MediaType.APPLICATION_JSON, + httpMethod = "POST", + value = "Adding a Device Lock on Windows devices.", + 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")} + ) + } + ) + @ApiResponses(value = { + @ApiResponse( + code = 201, + message = "Created. \n Successfully scheduled the device lock operation.", + response = Activity.class, + responseHeaders = { + @ResponseHeader( + name = "Content-Location", + description = "URL of the activity instance that refers to the scheduled operation."), + @ResponseHeader( + name = "Content-Type", + description = "Content type of the body"), + @ResponseHeader( + name = "ETag", + description = "Entity Tag of the response resource.\n" + + "Used by caches, or in conditional requests."), + @ResponseHeader( + name = "Last-Modified", + description = "Date and time the resource was last modified. \n" + + "Used by caches, or in conditional requests.")}), + @ApiResponse( + code = 303, + message = "See Other. \n The source can be retrieved from the URL specified in the location header.", + responseHeaders = { + @ResponseHeader( + name = "Content-Location", + description = "The Source URL of the document.")}), + @ApiResponse( + code = 400, + message = "Bad Request. \n Invalid request or validation error."), + @ApiResponse( + code = 415, + message = "Unsupported media type. \n The format of the requested entity was not supported.\n"), + @ApiResponse( + code = 500, + message = "Internal Server Error. \n " + + "Server error occurred while locking the device.") + }) + Response lock(@HeaderParam("Accept") String headerParam, @ApiParam( + name = "deviceIDs", + value = "Provide the ID of the AWindows device. Multiple device IDs can be added by " + + "using comma separated values. ", + required = true) List deviceIds) throws WindowsDeviceEnrolmentException; @POST @Path("/disenroll-devices") - @Permission(name = "Disenroll Device", permission = "/device-mgt/devices/disenroll/windows") - Response disenroll(@HeaderParam("Accept") String headerParam, List deviceIds) throws - WindowsDeviceEnrolmentException; + @ApiOperation( + consumes = MediaType.APPLICATION_JSON, + httpMethod = "POST", + value = "Dis-enrol the windows Devices", + 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 ")} + ) + } + ) + @ApiResponses(value = { + @ApiResponse( + code = 201, + message = "Created. \n Successfully scheduled the Dis-enroll operation.", + response = Activity.class, + responseHeaders = { + @ResponseHeader( + name = "Content-Location", + description = "URL of the activity instance that refers to the scheduled operation."), + @ResponseHeader( + name = "Content-Type", + description = "Content type of the body"), + @ResponseHeader( + name = "ETag", + description = "Entity Tag of the response resource.\n" + + "Used by caches, or in conditional requests."), + @ResponseHeader( + name = "Last-Modified", + description = "Date and time the resource was last modified the last time.\n" + + "Used by caches, or in conditional requests.")}), + @ApiResponse( + code = 303, + message = "See Other. \n The source can be retrieved from the URL specified in the location header.\n", + responseHeaders = { + @ResponseHeader( + name = "Content-Location", + description = "The Source URL of the document.")}), + @ApiResponse( + code = 400, + message = "Bad Request. \n Invalid request or validation error."), + @ApiResponse( + code = 415, + message = "Unsupported media type. \n The format of the requested entity was not supported."), + @ApiResponse( + code = 500, + message = "Internal Server Error. \n " + + "Server error occurred while adding a Dis-enroll operation.") + }) + Response disenroll(@HeaderParam("Accept") String headerParam, @ApiParam( + name = "deviceIDs", + value = "Provide the ID of the A Windows device. Multiple device IDs can be added by " + + "using comma separated values. ", + required = true) List deviceIds) throws WindowsDeviceEnrolmentException; @POST @Path("/wipe-devices") - @Permission(name = "Wipe Device", permission = "/device-mgt/devices/owning-device/operations/windows/wipe") - Response wipe(@HeaderParam("Accept") String headerParam, List deviceIds) throws - WindowsDeviceEnrolmentException; + @ApiOperation( + consumes = MediaType.APPLICATION_JSON, + produces = MediaType.APPLICATION_JSON, + httpMethod = "POST", + value = "Factory Resetting an Windows Device", + notes = "Factory rest or erase all the data stored on the Windows devices" + + "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")} + ) + } + ) + @ApiResponses(value = { + @ApiResponse( + code = 201, + message = "Created. \n Successfully scheduled the Data wipe operation.", + response = Activity.class, + responseHeaders = { + @ResponseHeader( + name = "Content-Location", + description = "URL of the activity instance that refers to the scheduled operation."), + @ResponseHeader( + name = "Content-Type", + description = "Content type of the body"), + @ResponseHeader( + name = "ETag", + description = "Entity Tag of the response resource.\n" + + "Used by caches, or in conditional requests."), + @ResponseHeader( + name = "Last-Modified", + description = "Date and time the resource was last modified." + + "Used by caches, or in conditional requests.")}), + @ApiResponse( + code = 303, + message = "See Other. \n The source can be retrieved from the URL specified in the location header.\n", + responseHeaders = { + @ResponseHeader( + name = "Content-Location", + description = "The Source URL of the document.")}), + @ApiResponse( + code = 400, + message = "Bad Request. \n Invalid request or validation error."), + @ApiResponse( + code = 415, + message = "Unsupported media type. \n The format of the requested entity was not supported."), + @ApiResponse( + code = 500, + message = "Internal Server Error. \n " + + "Server error occurred while adding the Data wipe operation.")}) + Response wipe(@HeaderParam("Accept") String headerParam, @ApiParam( + name = "deviceIDs", + value = "Provide the ID of the A Windows device. Multiple device IDs can be added by " + + "using comma separated values. ", + required = true) List deviceIds) throws WindowsDeviceEnrolmentException; @POST @Path("/ring-devices") - @Permission(name = "Ring Device", permission = "/device-mgt/devices/owning-device/operations/windows/ring") - Response ring(@HeaderParam("Accept") String headerParam, List deviceIds) throws - WindowsDeviceEnrolmentException; + @ApiOperation( + consumes = MediaType.APPLICATION_JSON, + httpMethod = "POST", + value = "Ringing Windows Devices", + 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") } + ) + } + ) + @ApiResponses(value = { + @ApiResponse( + code = 201, + message = "Created. \n Successfully scheduled the device ring operation.", + response = Activity.class, + responseHeaders = { + @ResponseHeader( + name = "Content-Location", + description = "URL of the activity instance that refers to the scheduled operation."), + @ResponseHeader( + name = "Content-Type", + description = "Content type of the body"), + @ResponseHeader( + name = "ETag", + description = "Entity Tag of the response resource.\n" + + "Used by caches, or in conditional requests."), + @ResponseHeader( + name = "Last-Modified", + description = "Date and time the resource was last modified.\n" + + "Used by caches, or in conditional requests.")}), + @ApiResponse( + code = 303, + message = "See Other. \n The source can be retrieved from the URL specified in the location header.", + responseHeaders = { + @ResponseHeader( + name = "Content-Location", + description = "The Source URL of the document.")}), + @ApiResponse( + code = 400, + message = "Bad Request. \n Invalid request or validation error."), + @ApiResponse( + code = 415, + message = "Unsupported media type. \n The format of the requested entity was not supported.\n"), + @ApiResponse( + code = 500, + message = "Internal Server Error. \n " + + "Server error occurred while adding a new device ring operation.") + }) + Response ring(@HeaderParam("Accept") String headerParam, @ApiParam( + name = "deviceIDs", + value = "Provide the ID of the A Windows device. Multiple device IDs can be added by " + + "using comma separated values. ", + required = true) List deviceIds) throws WindowsDeviceEnrolmentException; @POST @Path("/lock-reset-devices") - @Permission(name = "Lock-Reset Device", permission = "/device-mgt/devices/owning-device/operations/windows/lock-reset") - Response lockReset(@HeaderParam("Accept") String acceptHeader, List deviceIds) - throws WindowsDeviceEnrolmentException; + @ApiOperation( + consumes = MediaType.APPLICATION_JSON, + httpMethod = "POST", + value = "Lock reset on Windows devices", + 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") } + ) + } + ) + @ApiResponses(value = { + @ApiResponse( + code = 201, + message = "Created. \n Successfully scheduled the lock-reset operation.", + response = Activity.class, + responseHeaders = { + @ResponseHeader( + name = "Content-Location", + description = "URL of the activity instance that refers to the scheduled operation."), + @ResponseHeader( + name = "Content-Type", + description = "Content type of the body"), + @ResponseHeader( + name = "ETag", + description = "Entity Tag of the response resource.\n" + + "Used by caches, or in conditional requests."), + @ResponseHeader( + name = "Last-Modified", + description = "Date and time the resource was last modified.\n" + + "Used by caches, or in conditional requests.")}), + @ApiResponse( + code = 303, + message = "See Other. \n The source can be retrieved from the URL specified in the location header.\n", + responseHeaders = { + @ResponseHeader( + name = "Content-Location", + description = "The Source URL of the document.")}), + @ApiResponse( + code = 400, + message = "Bad Request. \n Invalid request or validation error."), + @ApiResponse( + code = 415, + message = "Unsupported media type. \n The format of the requested entity was not supported."), + @ApiResponse( + code = 500, + message = "Internal Server Error. \n " + + "Server error occurred while adding adding a lock-reset operation.") + }) + // + Response lockReset(@HeaderParam("Accept") String acceptHeader, @ApiParam( + name = "deviceIDs", + value = "Provide the ID of the A Windows device. Multiple device IDs can be added by " + + "using comma separated values. ", + required = true) List deviceIds) throws WindowsDeviceEnrolmentException; } 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/PolicyManagementService.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/PolicyManagementService.java deleted file mode 100644 index 387bac682..000000000 --- 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/PolicyManagementService.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * you may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.wso2.carbon.device.mgt.mobile.windows.api.services; - -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 javax.jws.WebService; -import javax.ws.rs.*; - -/** - * Endpoint for Enforce Effective Policy. - */ -@WebService -@Produces({ "application/json", "application/xml"}) -@Consumes({"application/json", "application/xml"}) -public interface PolicyManagementService { - - /** - * Get the applicable effective policy for an enrolled windows device. - * - * @param deviceId Device Id - * @return Returns retrieved devices. - * @throws WindowsConfigurationException occurred while retrieving all the devices from DB. - */ - @GET - @Path("{deviceId}") - Message getEffectivePolicy(@HeaderParam("Accept") String acceptHeader, - @PathParam("deviceId") String deviceId) throws WindowsConfigurationException; -} 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 220d0e02d..1cea655c4 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 @@ -18,25 +18,104 @@ package org.wso2.carbon.device.mgt.mobile.windows.api.services.authbst; +import io.swagger.annotations.*; import org.wso2.carbon.apimgt.annotations.api.Permission; import org.wso2.carbon.device.mgt.mobile.windows.api.common.exceptions.WindowsDeviceEnrolmentException; import org.wso2.carbon.device.mgt.mobile.windows.api.services.authbst.beans.Credentials; +import javax.jws.WebService; import javax.ws.rs.Consumes; import javax.ws.rs.POST; import javax.ws.rs.Path; +import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; /** * Interface for handling authentication request comes via MDM login page. */ + +@SwaggerDefinition( + info = @Info( + version = "1.0.0", + title = "", + extensions = { + @Extension(properties = { + @ExtensionProperty(name = "name", value = "Windows Binary security token provider"), + @ExtensionProperty(name = "context", + value = "/api/device-mgt/windows/v1.0/federated"), + }) + } + ), + tags = { + @Tag(name = "devicemgt_windows", description = "") + } +) +@Api(value = "Windows BST Management", + description = "This carries all the resources related to Windows Binary security token management.") +@WebService @Path("/bst") +@Produces({"application/json", "application/xml"}) +@Consumes({"application/json", "application/xml"}) public interface BSTProvider { @POST @Consumes(MediaType.APPLICATION_JSON) @Path("/authentication") @Permission(name = "Enroll Device", permission = "/device-mgt/devices/enroll/windows") - Response getBST(Credentials credentials) throws WindowsDeviceEnrolmentException; + @ApiOperation( + produces = MediaType.APPLICATION_JSON, + consumes = MediaType.APPLICATION_JSON, + httpMethod = "POST", + 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.")} + ) + } + ) + @ApiResponses( + value = { + @ApiResponse(code = 200, message = "Ok. \n Successfully fetching the binary security token.", + responseHeaders = { + @ResponseHeader( + name = "Content-Location", + description = "The URL of the added policy."), + @ResponseHeader( + name = "Content-Type", + description = "The content type of the body"), + @ResponseHeader( + name = "ETag", + description = "Entity Tag of the response resource.\n" + + "Used by caches, or in conditional requests."), + @ResponseHeader( + name = "Last-Modified", + description = "Date and time the resource was last modified.\n" + + "Used by caches, or in conditional requests.") + }), + @ApiResponse( + code = 303, + message = "See Other. \n The source can be retrieved from the URL specified in the location header.", + responseHeaders = { + @ResponseHeader( + name = "Content-Location", + description = "The Source URL of the document.")}), + @ApiResponse( + code = 400, + message = "Bad Request. \n Invalid request or validation error."), + @ApiResponse( + code = 415, + message = "Unsupported media type. \n The format of the requested entity was not supported."), + @ApiResponse( + code = 500, + message = "Internal Server Error. \n " + + "Server error occurred while fetching Binary security token.") + }) + Response getBST(Credentials credentials) + throws WindowsDeviceEnrolmentException; } 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/beans/Credentials.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/beans/Credentials.java index b7f8a9235..3444b141c 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/beans/Credentials.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/beans/Credentials.java @@ -18,6 +18,9 @@ package org.wso2.carbon.device.mgt.mobile.windows.api.services.authbst.beans; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; 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/discovery/DiscoveryService.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/discovery/DiscoveryService.java index e105f4ee2..c84a0b9cf 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/discovery/DiscoveryService.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/discovery/DiscoveryService.java @@ -18,6 +18,8 @@ package org.wso2.carbon.device.mgt.mobile.windows.api.services.discovery; +import io.swagger.annotations.*; +import org.wso2.carbon.device.mgt.common.operation.mgt.Activity; import org.wso2.carbon.device.mgt.mobile.windows.api.common.PluginConstants; import org.wso2.carbon.device.mgt.mobile.windows.api.common.exceptions.WindowsDeviceEnrolmentException; import org.wso2.carbon.device.mgt.mobile.windows.api.services.discovery.beans.DiscoveryRequest; @@ -29,6 +31,8 @@ import javax.jws.WebResult; import javax.jws.WebService; import javax.ws.rs.GET; import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.xml.ws.BindingType; import javax.xml.ws.RequestWrapper; @@ -38,23 +42,142 @@ import javax.xml.ws.soap.SOAPBinding; /** * Interface for Discovery service related operations. */ +@SwaggerDefinition( + info = @Info( + version = "1.0.0", + title = "", + extensions = { + @Extension(properties = { + @ExtensionProperty(name = "name", value = "Windows Discovery service provider"), + @ExtensionProperty(name = "context", + value = "api/device-mgt/windows/v1.0/discovery/post"), + }) + } + ), + tags = { + @Tag(name = "devicemgt_windows", description = "") + } +) +@Api(value = "Windows Discovery service", + description = "This carries all the resources related to Windows Discovery service.") @WebService(targetNamespace = PluginConstants.DISCOVERY_SERVICE_TARGET_NAMESPACE, name = "IDiscoveryService") @BindingType(value = SOAPBinding.SOAP12HTTP_BINDING) public interface DiscoveryService { - @POST + @ApiOperation( + httpMethod = "POST", + value = "Discovering the server Enrollment policy and Enrollment service Endpoints.", + notes = "Using this API to discover the Enrollment policy,Enrollment service and " + + "federated login page server endpoints in the server. ", + response = DiscoveryResponse.class, + tags = "Windows Device Enrollment.", + authorizations = { + @Authorization( + value = "permission", + scopes = {@AuthorizationScope( + scope = "/device-mgt/devices/enroll/windows", + description = "Discover the service endpoints.")} + ) + } + ) + @ApiResponses(value = { + @ApiResponse( + code = 200, + message = "Ok. \n Accepted and getting server endpoints.", + response = DiscoveryResponse.class, + responseHeaders = { + @ResponseHeader( + name = "Content-Location", + description = "URL of the activity instance."), + @ResponseHeader( + name = "Content-Type", + description = "Content type of the body"), + @ResponseHeader( + name = "ETag", + description = "Entity Tag of the response resource.\n" + + "Used by caches, or in conditional requests."), + @ResponseHeader( + name = "Last-Modified", + description = "Date and time the resource was last modified. \n" + + "Used by caches, or in conditional requests.")}), + @ApiResponse( + code = 303, + message = "See Other. \n The source can be retrieved from the URLr.", + responseHeaders = { + @ResponseHeader( + name = "Content-Location", + description = "The Source URL of the document.")}), + @ApiResponse( + code = 400, + message = "Bad Request. \n Invalid request or validation error."), + @ApiResponse( + code = 415, + message = "Unsupported media type. \n The format of the requested entity was not supported.\n"), + @ApiResponse( + code = 500, + message = "Internal Server Error. \n " + + "Server error occurred while fetching the server endpoints.") + }) @RequestWrapper(localName = "Discover", targetNamespace = PluginConstants.DISCOVERY_SERVICE_TARGET_NAMESPACE) @WebMethod(operationName = "Discover") @ResponseWrapper(localName = "DiscoverResponse", targetNamespace = PluginConstants.DISCOVERY_SERVICE_TARGET_NAMESPACE) void discover( @WebParam(name = "request", targetNamespace = PluginConstants.DISCOVERY_SERVICE_TARGET_NAMESPACE) - DiscoveryRequest request, + @ApiParam( + name = "DiscoveryRequest", + value = "Discovery service SOAP request.") + DiscoveryRequest request, @WebParam(mode = WebParam.Mode.OUT, name = "DiscoverResult", targetNamespace = PluginConstants.DISCOVERY_SERVICE_TARGET_NAMESPACE) - javax.xml.ws.Holder response + javax.xml.ws.Holder response ) throws WindowsDeviceEnrolmentException; + + @ApiOperation( + httpMethod = "GET", + value = "Device ping the server to check whether it is running or not.", + notes = ".", + tags = "Windows Discovery service.", + authorizations = { + @Authorization( + value = "permission", + scopes = {@AuthorizationScope(scope = "/device-mgt/devices/enroll/windows", + description = "Ping the Discovery service")} + ) + } + ) + @ApiResponses( + value = { + @ApiResponse( + code = 200, + message = "OK. \n Server is already running."), + @ApiResponse( + code = 303, + message = "See Other. \n The source can be retrieved from the URL specified " + + "in the location header.", + responseHeaders = { + @ResponseHeader(name = "Content-Location", + description = "Source URL of the document.") + }), + @ApiResponse( + code = 304, + message = "Not Modified. \n " + + "Empty body because the client already has the latest version of " + + "the requested resource."), + @ApiResponse( + code = 400, + message = "Bad Request. \n Invalid request or validation error. You must provide" + + " the device identifier. Additionally, the device identifier can be combined" + + " with either the device type" + + " OR the from and to date."), + @ApiResponse( + code = 404, + message = "Not Found. \n The specified resource does not exist."), + @ApiResponse( + code = 500, + message = "Error occurred while pinging the server.") + }) @GET @WebMethod @WebResult() 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/discovery/beans/DiscoveryRequest.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/discovery/beans/DiscoveryRequest.java index d397e3b57..e5f123d01 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/discovery/beans/DiscoveryRequest.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/discovery/beans/DiscoveryRequest.java @@ -18,6 +18,9 @@ package org.wso2.carbon.device.mgt.mobile.windows.api.services.discovery.beans; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; @@ -26,15 +29,21 @@ import java.io.Serializable; @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "DiscoveryRequest") +@ApiModel(value = "DiscoveryRequest", + description = "Discover request related information.") @SuppressWarnings("unused") public class DiscoveryRequest implements Serializable { + @ApiModelProperty(name = "emailId", value = "User email address which is submitted to the workplace app" + + " once sign in .", required = true) @XmlElement(name = "EmailAddress", required = true) private String emailId; + @ApiModelProperty(name = "version", value = "OS version on the Windows Device.", required = true) @XmlElement(name = "RequestVersion") private String version; + @ApiModelProperty(name = "deviceType", value = "Type of the Device(LapTop/Mobile Device).", required = true) @XmlElement(name = "DeviceType") private String deviceType; 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/impl/ConfigurationMgtServiceImpl.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/impl/ConfigurationMgtServiceImpl.java index 1802df8dc..5f0d8f7e1 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/impl/ConfigurationMgtServiceImpl.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/impl/ConfigurationMgtServiceImpl.java @@ -29,7 +29,6 @@ import org.wso2.carbon.device.mgt.mobile.windows.api.common.PluginConstants; import org.wso2.carbon.device.mgt.mobile.windows.api.common.beans.ErrorResponse; import org.wso2.carbon.device.mgt.mobile.windows.api.common.exceptions.UnexpectedServerErrorException; 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.WindowsAPIUtils; import org.wso2.carbon.device.mgt.mobile.windows.api.services.ConfigurationMgtService; @@ -55,17 +54,17 @@ public class ConfigurationMgtServiceImpl implements ConfigurationMgtService { * @throws WindowsConfigurationException */ @GET - public PlatformConfiguration getConfiguration() throws WindowsConfigurationException { + public Response getConfiguration(@HeaderParam("If-Modified-Since") String ifModifiedSince) { String msg; - PlatformConfiguration tenantConfiguration; + PlatformConfiguration platformConfiguration; List configs; try { - tenantConfiguration = WindowsAPIUtils.getDeviceManagementService(). + platformConfiguration = WindowsAPIUtils.getDeviceManagementService(). getConfiguration(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS); - if (tenantConfiguration != null) { - configs = tenantConfiguration.getConfiguration(); + if (platformConfiguration != null) { + configs = platformConfiguration.getConfiguration(); } else { - tenantConfiguration = new PlatformConfiguration(); + platformConfiguration = new PlatformConfiguration(); configs = new ArrayList<>(); } @@ -79,28 +78,29 @@ public class ConfigurationMgtServiceImpl implements ConfigurationMgtService { entry.setName(PluginConstants.TenantConfigProperties.LICENSE_KEY); entry.setValue(license.getText()); configs.add(entry); - tenantConfiguration.setConfiguration(configs); + platformConfiguration.setConfiguration(configs); } } catch (DeviceManagementException e) { - msg = "Error occurred while retrieving the Windows tenant configuration"; + msg = "Error occurred while retrieving the Android tenant configuration"; log.error(msg, e); - throw new WindowsConfigurationException(msg, e); + throw new UnexpectedServerErrorException( + new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build()); } - return tenantConfiguration; + return Response.status(Response.Status.OK).entity(platformConfiguration).build(); } /** * Update Tenant Configurations for the specific Device type. * - * @param configuration Tenant configurations to be updated. + * @param configurations to be updated. * @return Response message. * @throws WindowsConfigurationException */ @PUT - public Message updateConfiguration(PlatformConfiguration configuration) throws WindowsConfigurationException { + public Response updateConfiguration(PlatformConfiguration windowsPlatformConfiguration) throws WindowsConfigurationException { String message; - Message responseMsg = new Message(); ConfigurationEntry licenseEntry = null; + PlatformConfiguration configuration = new PlatformConfiguration(); try { configuration.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS); List configs = configuration.getConfiguration(); @@ -123,14 +123,14 @@ public class ConfigurationMgtServiceImpl implements ConfigurationMgtService { configuration.setConfiguration(configs); WindowsAPIUtils.getDeviceManagementService().saveConfiguration(configuration); Response.status(Response.Status.CREATED); - responseMsg.setResponseMessage("Windows platform configuration succeeded."); - responseMsg.setResponseCode(Response.Status.CREATED.toString()); } catch (DeviceManagementException e) { message = "Error occurred while modifying configuration settings of Windows platform."; log.error(message, e); - throw new WindowsConfigurationException(message, e); + throw new UnexpectedServerErrorException( + new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(message).build()); } - return responseMsg; + return Response.status(Response.Status.OK).entity("Android platform configuration has been updated successfully.").build(); + } @GET 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/impl/DeviceManagementServiceImpl.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/impl/DeviceManagementServiceImpl.java index 6829c6cb6..67651edb5 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/impl/DeviceManagementServiceImpl.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/impl/DeviceManagementServiceImpl.java @@ -1,157 +1,157 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * you may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.wso2.carbon.device.mgt.mobile.windows.api.services.impl; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.device.mgt.common.Device; -import org.wso2.carbon.device.mgt.common.DeviceIdentifier; -import org.wso2.carbon.device.mgt.common.DeviceManagementConstants; -import org.wso2.carbon.device.mgt.common.DeviceManagementException; -import org.wso2.carbon.device.mgt.common.license.mgt.License; -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.WindowsAPIUtils; -import org.wso2.carbon.device.mgt.mobile.windows.api.services.DeviceManagementService; - -import javax.jws.WebService; -import javax.ws.rs.*; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import java.util.List; - -/** - * Windows Device Management REST-API implementation. - * All end points supports JSON, XMl with content negotiation. - */ -@WebService -@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) -@Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) -public class DeviceManagementServiceImpl implements DeviceManagementService { - - - private static Log log = LogFactory.getLog( - org.wso2.carbon.device.mgt.mobile.windows.api.services.impl.DeviceManagementServiceImpl.class); - - /** - * Get all devices.Returns list of Windows devices registered in MDM. - * - * @return Returns retrieved devices. - * @throws WindowsConfigurationException occurred while retrieving all the devices from DB. - */ - @GET - public List getAllDevices() throws WindowsConfigurationException { - String msg; - List devices; - try { - devices = WindowsAPIUtils.getDeviceManagementService(). - getAllDevices(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS); - } catch (DeviceManagementException e) { - msg = "Error occurred while fetching the device list."; - log.error(msg, e); - throw new WindowsConfigurationException(msg, e); - } - return devices; - } - - /** - * Fetch Windows device details of a given device Id. - * - * @param deviceId Device Id - * @return Returns retrieved device. - * @throws WindowsConfigurationException occurred while getting device from DB. - */ - @GET - @Path("{id}") - public Device getDevice(@PathParam("id") String deviceId) throws WindowsConfigurationException { - String msg; - Device device; - try { - DeviceIdentifier deviceIdentifier = WindowsAPIUtils.convertToDeviceIdentifierObject(deviceId); - device = WindowsAPIUtils.getDeviceManagementService().getDevice(deviceIdentifier); - if (device == null) { - Response.status(Response.Status.NOT_FOUND); - } - } catch (DeviceManagementException e) { - msg = "Error occurred while fetching the device information."; - log.error(msg, e); - throw new WindowsConfigurationException(msg, e); - } - return device; - } - - /** - * Update Windows device details of given device id. - * - * @param deviceId Device Id. - * @param device Device details to be updated. - * @return Returns the message whether device update or not. - * @throws WindowsConfigurationException occurred while updating the Device Info. - */ - @PUT - @Path("{id}") - public Message updateDevice(@PathParam("id") String deviceId, Device device) throws WindowsConfigurationException { - String msg; - Message responseMessage = new Message(); - DeviceIdentifier deviceIdentifier = new DeviceIdentifier(); - deviceIdentifier.setId(deviceId); - deviceIdentifier.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS); - boolean isUpdated; - try { - device.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS); - isUpdated = WindowsAPIUtils.getDeviceManagementService().updateDeviceInfo(deviceIdentifier, device); - if (isUpdated) { - Response.status(Response.Status.ACCEPTED); - responseMessage.setResponseMessage("Device information has modified successfully."); - } else { - Response.status(Response.Status.NOT_MODIFIED); - responseMessage.setResponseMessage("Device not found for the update."); - } - } catch (DeviceManagementException e) { - msg = "Error occurred while modifying the device information."; - log.error(msg, e); - throw new WindowsConfigurationException(msg, e); - } - return responseMessage; - } - - /** - * Fetch the Licence agreement for specific windows platform. - * - * @return Returns License agreement. - * @throws WindowsConfigurationException occurred while getting licence for specific platform and Language. - */ - @GET - @Path("license") - @Produces("application/json") - public License getLicense() throws WindowsConfigurationException { - License license; - try { - license = - WindowsAPIUtils.getDeviceManagementService().getLicense( - DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS, - DeviceManagementConstants.LanguageCodes.LANGUAGE_CODE_ENGLISH_US); - } catch (DeviceManagementException e) { - String msg = "Error occurred while retrieving the license configured for Windows device enrollment"; - log.error(msg, e); - throw new WindowsConfigurationException(msg, e); - } - return license; - } -} +///* +// * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. +// * +// * WSO2 Inc. licenses this file to you under the Apache License, +// * Version 2.0 (the "License"); you may not use this file except +// * in compliance with the License. +// * you may obtain a copy of the License at +// * +// * http://www.apache.org/licenses/LICENSE-2.0 +// * +// * Unless required by applicable law or agreed to in writing, +// * software distributed under the License is distributed on an +// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// * KIND, either express or implied. See the License for the +// * specific language governing permissions and limitations +// * under the License. +// */ +// +//package org.wso2.carbon.device.mgt.mobile.windows.api.services.impl; +// +//import org.apache.commons.logging.Log; +//import org.apache.commons.logging.LogFactory; +//import org.wso2.carbon.device.mgt.common.Device; +//import org.wso2.carbon.device.mgt.common.DeviceIdentifier; +//import org.wso2.carbon.device.mgt.common.DeviceManagementConstants; +//import org.wso2.carbon.device.mgt.common.DeviceManagementException; +//import org.wso2.carbon.device.mgt.common.license.mgt.License; +//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.WindowsAPIUtils; +//import org.wso2.carbon.device.mgt.mobile.windows.api.services.DeviceManagementService; +// +//import javax.jws.WebService; +//import javax.ws.rs.*; +//import javax.ws.rs.core.MediaType; +//import javax.ws.rs.core.Response; +//import java.util.List; +// +///** +// * Windows Device Management REST-API implementation. +// * All end points supports JSON, XMl with content negotiation. +// */ +//@WebService +//@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) +//@Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) +//public class DeviceManagementServiceImpl implements DeviceManagementService { +// +// +// private static Log log = LogFactory.getLog( +// org.wso2.carbon.device.mgt.mobile.windows.api.services.impl.DeviceManagementServiceImpl.class); +// +// /** +// * Get all devices.Returns list of Windows devices registered in MDM. +// * +// * @return Returns retrieved devices. +// * @throws WindowsConfigurationException occurred while retrieving all the devices from DB. +// */ +// @GET +// public List getAllDevices() throws WindowsConfigurationException { +// String msg; +// List devices; +// try { +// devices = WindowsAPIUtils.getDeviceManagementService(). +// getAllDevices(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS); +// } catch (DeviceManagementException e) { +// msg = "Error occurred while fetching the device list."; +// log.error(msg, e); +// throw new WindowsConfigurationException(msg, e); +// } +// return devices; +// } +// +// /** +// * Fetch Windows device details of a given device Id. +// * +// * @param deviceId Device Id +// * @return Returns retrieved device. +// * @throws WindowsConfigurationException occurred while getting device from DB. +// */ +// @GET +// @Path("{id}") +// public Device getDevice(@PathParam("id") String deviceId) throws WindowsConfigurationException { +// String msg; +// Device device; +// try { +// DeviceIdentifier deviceIdentifier = WindowsAPIUtils.convertToDeviceIdentifierObject(deviceId); +// device = WindowsAPIUtils.getDeviceManagementService().getDevice(deviceIdentifier); +// if (device == null) { +// Response.status(Response.Status.NOT_FOUND); +// } +// } catch (DeviceManagementException e) { +// msg = "Error occurred while fetching the device information."; +// log.error(msg, e); +// throw new WindowsConfigurationException(msg, e); +// } +// return device; +// } +// +// /** +// * Update Windows device details of given device id. +// * +// * @param deviceId Device Id. +// * @param device Device details to be updated. +// * @return Returns the message whether device update or not. +// * @throws WindowsConfigurationException occurred while updating the Device Info. +// */ +// @PUT +// @Path("{id}") +// public Message updateDevice(@PathParam("id") String deviceId, Device device) throws WindowsConfigurationException { +// String msg; +// Message responseMessage = new Message(); +// DeviceIdentifier deviceIdentifier = new DeviceIdentifier(); +// deviceIdentifier.setId(deviceId); +// deviceIdentifier.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS); +// boolean isUpdated; +// try { +// device.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS); +// isUpdated = WindowsAPIUtils.getDeviceManagementService().updateDeviceInfo(deviceIdentifier, device); +// if (isUpdated) { +// Response.status(Response.Status.ACCEPTED); +// responseMessage.setResponseMessage("Device information has modified successfully."); +// } else { +// Response.status(Response.Status.NOT_MODIFIED); +// responseMessage.setResponseMessage("Device not found for the update."); +// } +// } catch (DeviceManagementException e) { +// msg = "Error occurred while modifying the device information."; +// log.error(msg, e); +// throw new WindowsConfigurationException(msg, e); +// } +// return responseMessage; +// } +// +// /** +// * Fetch the Licence agreement for specific windows platform. +// * +// * @return Returns License agreement. +// * @throws WindowsConfigurationException occurred while getting licence for specific platform and Language. +// */ +// @GET +// @Path("license") +// @Produces("application/json") +// public License getLicense() throws WindowsConfigurationException { +// License license; +// try { +// license = +// WindowsAPIUtils.getDeviceManagementService().getLicense( +// DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS, +// DeviceManagementConstants.LanguageCodes.LANGUAGE_CODE_ENGLISH_US); +// } catch (DeviceManagementException e) { +// String msg = "Error occurred while retrieving the license configured for Windows device enrollment"; +// log.error(msg, e); +// throw new WindowsConfigurationException(msg, e); +// } +// return license; +// } +//} 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/impl/PolicyManagementServiceImpl.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/impl/PolicyManagementServiceImpl.java deleted file mode 100644 index fa5c8c438..000000000 --- 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/impl/PolicyManagementServiceImpl.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * you may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.wso2.carbon.device.mgt.mobile.windows.api.services.impl; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.device.mgt.common.DeviceIdentifier; -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.WindowsAPIUtils; -import org.wso2.carbon.device.mgt.mobile.windows.api.services.PolicyManagementService; -import org.wso2.carbon.policy.mgt.common.Policy; -import org.wso2.carbon.policy.mgt.common.PolicyManagementException; -import org.wso2.carbon.policy.mgt.core.PolicyManagerService; - -import javax.jws.WebService; -import javax.ws.rs.*; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; - -@WebService -@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) -@Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) -public class PolicyManagementServiceImpl implements PolicyManagementService { - private static Log log = LogFactory.getLog( - org.wso2.carbon.device.mgt.mobile.windows.api.services.impl.PolicyManagementServiceImpl.class); - - @GET - @Path("{deviceId}") - public Message getEffectivePolicy(@HeaderParam("Accept") String acceptHeader, - @PathParam("deviceId") String deviceId) throws WindowsConfigurationException { - - DeviceIdentifier deviceIdentifier = WindowsAPIUtils.convertToDeviceIdentifierObject(deviceId); - Message responseMessage = new Message(); - Policy policy; - try { - PolicyManagerService policyManagerService = WindowsAPIUtils.getPolicyManagerService(); - policy = policyManagerService.getEffectivePolicy(deviceIdentifier); - if (policy == null) { - responseMessage.setResponseCode(Response.Status.NO_CONTENT.toString()); - responseMessage.setResponseMessage("No effective policy found"); - return responseMessage; - } else { - responseMessage.setResponseCode(Response.Status.OK.toString()); - responseMessage.setResponseMessage("Effective policy added to operation"); - return responseMessage; - } - - } catch (PolicyManagementException e) { - String msg = "Error occurred while getting the policy."; - log.error(msg, e); - throw new WindowsConfigurationException(msg, e); - } - } -} 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/syncml/SyncmlService.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/syncml/SyncmlService.java index f24898002..37194987b 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/syncml/SyncmlService.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/syncml/SyncmlService.java @@ -18,8 +18,10 @@ package org.wso2.carbon.device.mgt.mobile.windows.api.services.syncml; +import io.swagger.annotations.*; import org.w3c.dom.Document; import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagementException; +import org.wso2.carbon.device.mgt.common.operation.mgt.Activity; import org.wso2.carbon.device.mgt.mobile.windows.api.common.PluginConstants; import org.wso2.carbon.device.mgt.mobile.windows.api.common.exceptions.WindowsConfigurationException; import org.wso2.carbon.device.mgt.mobile.windows.api.common.exceptions.WindowsDeviceEnrolmentException; @@ -35,14 +37,85 @@ import javax.ws.rs.core.Response; /** * Interface for Syncml message flow. */ +@SwaggerDefinition( + info = @Info( + version = "1.0.0", + title = "", + extensions = { + @Extension(properties = { + @ExtensionProperty(name = "name", value = "Syncml Endpoint"), + @ExtensionProperty(name = "context", + value = "/api/device-mgt/windows/v1.0/syncml"), + }) + } + ), + tags = { + @Tag(name = "devicemgt_windows", description = "") + } +) +@Api(value = "Windows syncml service", + description = "This carries all the resources related to Windows syncml message flow.") @Path("/devicemanagement") public interface SyncmlService { @Path("/request") @POST - @Consumes({ PluginConstants.SYNCML_MEDIA_TYPE, MediaType.APPLICATION_XML}) + @Consumes({PluginConstants.SYNCML_MEDIA_TYPE, MediaType.APPLICATION_XML}) @Produces(PluginConstants.SYNCML_MEDIA_TYPE) + @ApiOperation( + httpMethod = "POST", + value = "Getting pending operations for Windows device.", + notes = "Using this API to fetching more information to enroll the Device and " + + "getting pending operations.", + tags = "Windows Device Management Administrative Service", + authorizations = { + @Authorization( + value = "permission", + scopes = {@AuthorizationScope( + scope = "/device-mgt/devices/enroll/windows", + description = "Getting pending operations and " + + "device information to enroll the device")} + ) + } + ) + @ApiResponses(value = { + @ApiResponse( + code = 201, + message = "Ok. \n Successfully getting pending operations.", + responseHeaders = { + @ResponseHeader( + name = "Content-Location", + description = "URL of the activity instance that refers to the scheduled operation."), + @ResponseHeader( + name = "Content-Type", + description = "Content type of the body"), + @ResponseHeader( + name = "ETag", + description = "Entity Tag of the response resource.\n" + + "Used by caches, or in conditional requests."), + @ResponseHeader( + name = "Last-Modified", + description = "Date and time the resource was last modified. \n" + + "Used by caches, or in conditional requests.")}), + @ApiResponse( + code = 303, + message = "See Other. \n The source can be retrieved from the URL specified in the location header.", + responseHeaders = { + @ResponseHeader( + name = "Content-Location", + description = "The Source URL of the document.")}), + @ApiResponse( + code = 400, + message = "Bad Request. \n Invalid request or validation error."), + @ApiResponse( + code = 415, + message = "Unsupported media type. \n The format of the requested entity was not supported.\n"), + @ApiResponse( + code = 500, + message = "Internal Server Error. \n " + + "Server error occurred while getting pending operations.") + }) Response getResponse(Document request) throws WindowsDeviceEnrolmentException, WindowsOperationException, - NotificationManagementException, WindowsConfigurationException; + NotificationManagementException, WindowsConfigurationException; } 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/syncml/impl/SyncmlServiceImpl.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/syncml/impl/SyncmlServiceImpl.java index e431d9c96..1bd6c827a 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/syncml/impl/SyncmlServiceImpl.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/syncml/impl/SyncmlServiceImpl.java @@ -235,7 +235,6 @@ public class SyncmlServiceImpl implements SyncmlService { String devLang; String vendor; String macAddress; - String resolution; String modVersion; boolean status = false; String user; @@ -287,7 +286,6 @@ public class SyncmlServiceImpl implements SyncmlService { vendor = itemList.get(PluginConstants.SyncML.VENDOR_POSITION).getData(); devMod = itemList.get(PluginConstants.SyncML.MODEL_POSITION).getData(); macAddress = itemList.get(PluginConstants.SyncML.MAC_ADDRESS_POSITION).getData(); - resolution = itemList.get(PluginConstants.SyncML.RESOLUTION_POSITION).getData(); deviceName = itemList.get(PluginConstants.SyncML.DEVICE_NAME_POSITION).getData(); DeviceIdentifier deviceIdentifier = convertToDeviceIdentifierObject(syncmlDocument. getHeader().getSource().getLocURI()); @@ -320,24 +318,16 @@ public class SyncmlServiceImpl implements SyncmlService { macAddressProperty.setValue(macAddress); existingProperties.add(macAddressProperty); -// Device.Property resolutionProperty = new Device.Property(); -// resolutionProperty.setName(PluginConstants.SyncML.DEVICE_INFO); -// resolutionProperty.setValue("null"); -// existingProperties.add(resolutionProperty); - - Device.Property deviceNameProperty = new Device.Property(); - deviceNameProperty.setName(PluginConstants.SyncML.DEVICE_NAME); - deviceNameProperty.setValue(deviceName); - existingProperties.add(deviceNameProperty); - Device.Property deviceModelProperty = new Device.Property(); - deviceNameProperty.setName(PluginConstants.SyncML.MODEL); - deviceNameProperty.setValue(devMod); + deviceModelProperty.setName(PluginConstants.SyncML.MODEL); + deviceModelProperty.setValue(devMod); existingProperties.add(deviceModelProperty); + existingDevice.setName(deviceName); existingDevice.setProperties(existingProperties); existingDevice.setDeviceIdentifier(syncmlDocument.getHeader().getSource().getLocURI()); existingDevice.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS); + status = WindowsAPIUtils.getDeviceManagementService().modifyEnrollment(existingDevice); // call effective policy for the enrolling device. PolicyManagerService policyManagerService = WindowsAPIUtils.getPolicyManagerService(); 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/wstep/CertificateEnrollmentService.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/wstep/CertificateEnrollmentService.java index 5d1fb6289..2bdf78128 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/wstep/CertificateEnrollmentService.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/wstep/CertificateEnrollmentService.java @@ -17,6 +17,7 @@ */ package org.wso2.carbon.device.mgt.mobile.windows.api.services.wstep; +import io.swagger.annotations.*; import org.wso2.carbon.device.mgt.mobile.windows.api.common.PluginConstants; import org.wso2.carbon.device.mgt.mobile.windows.api.common.exceptions.WAPProvisioningException; import org.wso2.carbon.device.mgt.mobile.windows.api.common.exceptions.WindowsDeviceEnrolmentException; @@ -26,6 +27,11 @@ import org.wso2.carbon.device.mgt.mobile.windows.api.services.wstep.beans.Reques import javax.jws.WebMethod; import javax.jws.WebParam; import javax.jws.WebService; +import javax.ws.rs.Consumes; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; import javax.xml.ws.BindingType; import javax.xml.ws.RequestWrapper; import javax.xml.ws.ResponseWrapper; @@ -35,6 +41,24 @@ import java.io.UnsupportedEncodingException; /** * Interface of WSTEP implementation. */ +@SwaggerDefinition( + info = @Info( + version = "1.0.0", + title = "", + extensions = { + @Extension(properties = { + @ExtensionProperty(name = "name", value = "Windows enrollment service provider"), + @ExtensionProperty(name = "context", + value = "/api/device-mgt/windows/v1.0/deviceenrolment/wstep"), + }) + } + ), + tags = { + @Tag(name = "devicemgt_windows", description = "") + } +) +@Api(value = "Windows Enrollment service Management", + description = "This carries all the resources related to Windows enrollment service.") @WebService(targetNamespace = PluginConstants.DEVICE_ENROLLMENT_SERVICE_TARGET_NAMESPACE, name = "wstep") @BindingType(value = SOAPBinding.SOAP12HTTP_BINDING) public interface CertificateEnrollmentService { @@ -44,20 +68,73 @@ public interface CertificateEnrollmentService { @WebMethod(operationName = "RequestSecurityToken") @ResponseWrapper(localName = "RequestSecurityTokenResponseCollection", targetNamespace = PluginConstants.WS_TRUST_TARGET_NAMESPACE) + @POST + @ApiOperation( + httpMethod = "POST", + value = "Signing the certificate signing request(CSR) and provide request security token response.", + notes = "Using this API to fetching more information to enroll the Device and " + + "getting pending operations.", + tags = "Windows Device Enrollment Service.", + authorizations = { + @Authorization( + value = "permission", + scopes = {@AuthorizationScope( + scope = "/device-mgt/devices/enroll/windows", + description = "GSigning the certificate signing request(CSR) " + + "and provide request security token response")} + ) + } + ) + @ApiResponses(value = { + @ApiResponse( + code = 200, + message = "Ok.Successfully signed the CSR.", + responseHeaders = { + @ResponseHeader( + name = "Content-Location", + description = "URL of the activity instance that refers to the scheduled operation."), + @ResponseHeader( + name = "Content-Type", + description = "Content type of the body"), + @ResponseHeader( + name = "ETag", + description = "Entity Tag of the response resource.\n" + + "Used by caches, or in conditional requests."), + @ResponseHeader( + name = "Last-Modified", + description = "Date and time the resource was last modified. \n" + + "Used by caches, or in conditional requests.")}), + @ApiResponse( + code = 303, + message = "See Other. \n The source can be retrieved from the URL specified in the location header.", + responseHeaders = { + @ResponseHeader( + name = "Content-Location", + description = "The Source URL of the document.")}), + @ApiResponse( + code = 400, + message = "Bad Request. \n Invalid request or validation error."), + @ApiResponse( + code = 415, + message = "Unsupported media type. \n The format of the requested entity was not supported.\n"), + @ApiResponse( + code = 500, + message = "Internal Server Error. \n " + + "Server error occurred while Signing the CSR.") + }) void requestSecurityToken( @WebParam(name = "TokenType", targetNamespace = PluginConstants.WS_TRUST_TARGET_NAMESPACE) - String tokenType, + String tokenType, @WebParam(name = "RequestType", targetNamespace = PluginConstants.WS_TRUST_TARGET_NAMESPACE) - String requestType, + String requestType, @WebParam(name = "BinarySecurityToken", targetNamespace = PluginConstants .WS_SECURITY_TARGET_NAMESPACE) - String binarySecurityToken, + String binarySecurityToken, @WebParam(name = "AdditionalContext", targetNamespace = PluginConstants .SOAP_AUTHORIZATION_TARGET_NAMESPACE) - AdditionalContext additionalContext, + AdditionalContext additionalContext, @WebParam(mode = WebParam.Mode.OUT, name = "RequestSecurityTokenResponse", targetNamespace = PluginConstants.WS_TRUST_TARGET_NAMESPACE) - javax.xml.ws.Holder response) throws - WindowsDeviceEnrolmentException, UnsupportedEncodingException, - WAPProvisioningException; + javax.xml.ws.Holder response) throws + WindowsDeviceEnrolmentException, UnsupportedEncodingException, WAPProvisioningException; } 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/xcep/CertificateEnrollmentPolicyService.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/xcep/CertificateEnrollmentPolicyService.java index 86f900867..70d6cbb21 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/xcep/CertificateEnrollmentPolicyService.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/xcep/CertificateEnrollmentPolicyService.java @@ -18,12 +18,18 @@ package org.wso2.carbon.device.mgt.mobile.windows.api.services.xcep; +import io.swagger.annotations.*; import org.wso2.carbon.device.mgt.mobile.windows.api.common.PluginConstants; import org.wso2.carbon.device.mgt.mobile.windows.api.services.xcep.beans.*; import javax.jws.WebMethod; import javax.jws.WebParam; import javax.jws.WebService; +import javax.ws.rs.Consumes; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; import javax.xml.bind.annotation.XmlSeeAlso; import javax.xml.ws.BindingType; import javax.xml.ws.Holder; @@ -34,6 +40,25 @@ import javax.xml.ws.soap.SOAPBinding; /** * Interface for MS-XCEP implementation. */ + +@SwaggerDefinition( + info = @Info( + version = "1.0.0", + title = "", + extensions = { + @io.swagger.annotations.Extension(properties = { + @ExtensionProperty(name = "name", value = "Windows Enrollment policy service"), + @ExtensionProperty(name = "context", + value = "/api/device-mgt/windows/v1.0/certificatepolicy/xcep"), + }) + } + ), + tags = { + @Tag(name = "devicemgt_windows", description = "") + } +) +@Api(value = "Windows enrollment policy Management", + description = "This carries all the resources related to Windows enrollment policy.") @WebService(targetNamespace = PluginConstants.CERTIFICATE_ENROLLMENT_POLICY_SERVICE_TARGET_NAMESPACE, name = "IPolicy") @BindingType(value = SOAPBinding.SOAP12HTTP_BINDING) @@ -45,7 +70,64 @@ public interface CertificateEnrollmentPolicyService { @WebMethod(operationName = "GetPolicies") @ResponseWrapper(localName = "GetPoliciesResponse", targetNamespace = PluginConstants. ENROLLMENT_POLICY_TARGET_NAMESPACE, className = PluginConstants. - RESPONSE_WRAPPER_CLASS_NAME) void getPolicies( + RESPONSE_WRAPPER_CLASS_NAME) + @POST + @Consumes({PluginConstants.SYNCML_MEDIA_TYPE, MediaType.APPLICATION_XML}) + @Produces(PluginConstants.SYNCML_MEDIA_TYPE) + @ApiOperation( + httpMethod = "POST", + value = "Getting pending operations for Windows device.", + notes = "Using this API to fetching more information to enroll the Device and " + + "getting pending operations.", + tags = "Windows Device Management Administrative Service", + authorizations = { + @Authorization( + value = "permission", + scopes = {@AuthorizationScope( + scope = "/device-mgt/devices/enroll/windows", + description = "Getting pending operations and " + + "device information to enroll the device")} + ) + } + ) + @ApiResponses(value = { + @ApiResponse( + code = 201, + message = "Ok. \n Successfully getting pending operations.", + responseHeaders = { + @ResponseHeader( + name = "Content-Location", + description = "URL of the activity instance that refers to the scheduled operation."), + @ResponseHeader( + name = "Content-Type", + description = "Content type of the body"), + @ResponseHeader( + name = "ETag", + description = "Entity Tag of the response resource.\n" + + "Used by caches, or in conditional requests."), + @ResponseHeader( + name = "Last-Modified", + description = "Date and time the resource was last modified. \n" + + "Used by caches, or in conditional requests.")}), + @ApiResponse( + code = 303, + message = "See Other. \n The source can be retrieved from the URL specified in the location header.", + responseHeaders = { + @ResponseHeader( + name = "Content-Location", + description = "The Source URL of the document.")}), + @ApiResponse( + code = 400, + message = "Bad Request. \n Invalid request or validation error."), + @ApiResponse( + code = 415, + message = "Unsupported media type. \n The format of the requested entity was not supported.\n"), + @ApiResponse( + code = 500, + message = "Internal Server Error. \n " + + "Server error occurred while getting pending operations.") + }) + void getPolicies( @WebParam(name = "client", targetNamespace = PluginConstants. ENROLLMENT_POLICY_TARGET_NAMESPACE) Client client, diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/webapp/WEB-INF/cxf-servlet.xml b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/webapp/WEB-INF/cxf-servlet.xml index 2d54d092b..ad46159e1 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/webapp/WEB-INF/cxf-servlet.xml +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/webapp/WEB-INF/cxf-servlet.xml @@ -33,7 +33,12 @@ + + + + + @@ -88,43 +93,39 @@ - - - - - - - - - - - - - + + + + + + + + + + + + @@ -132,35 +133,15 @@ + + - - - - - - - - - - - - - - - - - - - - - - - + - + + + + + + + + + + + + + + + - - - diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/webapp/WEB-INF/web.xml b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/webapp/WEB-INF/web.xml index 8087d45a0..0921d588b 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/webapp/WEB-INF/web.xml +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/webapp/WEB-INF/web.xml @@ -43,7 +43,7 @@ JAXServlet-windows - /services/* + /* 60 @@ -66,7 +66,7 @@ nonSecuredEndPoints - /services/discovery/get,/services/discovery/post,/services/certificatepolicy/xcep, - ,/services/deviceenrolment/wstep,/services/syncml/devicemanagement/request + /discovery/get,/discovery/post,/certificatepolicy/xcep, + ,/deviceenrolment/wstep,/syncml/devicemanagement/request \ No newline at end of file diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/windows-web-agent/app/conf/config.json b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/windows-web-agent/app/conf/config.json index ce3efe795..d02ddd740 100755 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/windows-web-agent/app/conf/config.json +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/windows-web-agent/app/conf/config.json @@ -34,7 +34,7 @@ } }, "androidAgentApp" : "android-agent.apk", - "windowsConfigRoot" : "%http.ip%/api/device-mgt/windows/v1.0/services/federated/bst/authentication", + "windowsConfigRoot" : "%http.ip%/api/device-mgt/windows/v1.0/federated/bst/authentication", "ssoConfiguration" : { "enabled" : false, "issuer" : "mdm", diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/windows-web-agent/app/modules/business-controllers/device.js b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/windows-web-agent/app/modules/business-controllers/device.js index 3dce168f4..c0c190384 100755 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/windows-web-agent/app/modules/business-controllers/device.js +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/windows-web-agent/app/modules/business-controllers/device.js @@ -312,7 +312,7 @@ deviceModule = function () { var url; var license; if (deviceType == "windows") { - url = devicemgtProps["httpURL"] + "/api/device-mgt/windows/v1.0/services/configuration/license"; + url = devicemgtProps["httpURL"] + "/api/device-mgt/windows/v1.0/configuration/license"; } else if (deviceType == "ios") { url = devicemgtProps["httpsURL"] + "/ios-enrollment/license/"; } From d2d39a241e1926151a6ff04bd10360f4c1f4fd07 Mon Sep 17 00:00:00 2001 From: Hasunie Date: Thu, 8 Dec 2016 16:18:01 +0530 Subject: [PATCH 2/3] adding error handler --- .../src/main/webapp/WEB-INF/cxf-servlet.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/webapp/WEB-INF/cxf-servlet.xml b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/webapp/WEB-INF/cxf-servlet.xml index ad46159e1..a81ccfd47 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/webapp/WEB-INF/cxf-servlet.xml +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/webapp/WEB-INF/cxf-servlet.xml @@ -141,7 +141,7 @@ - + + From 68cabad5b8b4ed7a0b091c64ae6d1b4053ed4536 Mon Sep 17 00:00:00 2001 From: Hasunie Date: Thu, 8 Dec 2016 16:43:05 +0530 Subject: [PATCH 3/3] deleting unused components --- .../api/services/DeviceManagementService.java | 111 ------------- .../impl/DeviceManagementServiceImpl.java | 157 ------------------ 2 files changed, 268 deletions(-) delete mode 100644 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/DeviceManagementService.java delete mode 100644 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/impl/DeviceManagementServiceImpl.java 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/DeviceManagementService.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/DeviceManagementService.java deleted file mode 100644 index 63d046860..000000000 --- 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/DeviceManagementService.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * you may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.wso2.carbon.device.mgt.mobile.windows.api.services; - -import io.swagger.annotations.SwaggerDefinition; -import io.swagger.annotations.Info; -import io.swagger.annotations.ExtensionProperty; -import io.swagger.annotations.Extension; -import io.swagger.annotations.Tag; -import io.swagger.annotations.Api; -import org.wso2.carbon.device.mgt.common.Device; -import org.wso2.carbon.device.mgt.common.license.mgt.License; -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 javax.jws.WebService; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; -import java.util.List; - -/** - * Windows Device Management REST-API implementation. All end points supports JSON, XMl with content negotiation. - */ -@Api(value = "Windows Device Management", - description = "This carries all the resources related to Windows device management functionalities") - -@SwaggerDefinition( - info = @Info( - version = "1.0.0", - title = "", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = "name", value = "Windows Device Management"), - @ExtensionProperty(name = "context", value = "/api/device-mgt/windows/v1.0/devices"), - }) - } - ), - tags = { - @Tag(name = "devicemgt_windows", description = "") - } -) -@WebService -@Path("/devices") -@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) -@Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) -public interface DeviceManagementService { - - /** - * Get all devices.Returns list of Windows devices registered in MDM. - * - * @return Returns retrieved devices. - * @throws WindowsConfigurationException occurred while retrieving all the devices from DB. - */ - @GET - List getAllDevices() throws WindowsConfigurationException; - - /** - * Fetch Windows device details of a given device Id. - * - * @param deviceId Device Id - * @return Returns retrieved device. - * @throws WindowsConfigurationException occurred while getting device from DB. - */ - @GET - @Path("{id}") - Device getDevice(@PathParam("id") String deviceId) throws WindowsConfigurationException; - - /** - * Update Windows device details of given device id. - * - * @param deviceId Device Id. - * @param device Device details to be updated. - * @return Returns the message whether device update or not. - * @throws WindowsConfigurationException occurred while updating the Device Info. - */ - @PUT - @Path("{id}") - Message updateDevice(@PathParam("id") String deviceId, Device device) throws WindowsConfigurationException; - - /** - * Fetch the Licence agreement for specific windows platform. - * - * @return Returns License agreement. - * @throws WindowsConfigurationException occurred while getting licence for specific platform and Language. - */ - @GET - @Path("license") - @Produces("application/json") - License getLicense() throws WindowsConfigurationException; -} 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/impl/DeviceManagementServiceImpl.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/impl/DeviceManagementServiceImpl.java deleted file mode 100644 index 67651edb5..000000000 --- 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/impl/DeviceManagementServiceImpl.java +++ /dev/null @@ -1,157 +0,0 @@ -///* -// * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. -// * -// * WSO2 Inc. licenses this file to you under the Apache License, -// * Version 2.0 (the "License"); you may not use this file except -// * in compliance with the License. -// * you may obtain a copy of the License at -// * -// * http://www.apache.org/licenses/LICENSE-2.0 -// * -// * Unless required by applicable law or agreed to in writing, -// * software distributed under the License is distributed on an -// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// * KIND, either express or implied. See the License for the -// * specific language governing permissions and limitations -// * under the License. -// */ -// -//package org.wso2.carbon.device.mgt.mobile.windows.api.services.impl; -// -//import org.apache.commons.logging.Log; -//import org.apache.commons.logging.LogFactory; -//import org.wso2.carbon.device.mgt.common.Device; -//import org.wso2.carbon.device.mgt.common.DeviceIdentifier; -//import org.wso2.carbon.device.mgt.common.DeviceManagementConstants; -//import org.wso2.carbon.device.mgt.common.DeviceManagementException; -//import org.wso2.carbon.device.mgt.common.license.mgt.License; -//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.WindowsAPIUtils; -//import org.wso2.carbon.device.mgt.mobile.windows.api.services.DeviceManagementService; -// -//import javax.jws.WebService; -//import javax.ws.rs.*; -//import javax.ws.rs.core.MediaType; -//import javax.ws.rs.core.Response; -//import java.util.List; -// -///** -// * Windows Device Management REST-API implementation. -// * All end points supports JSON, XMl with content negotiation. -// */ -//@WebService -//@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) -//@Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) -//public class DeviceManagementServiceImpl implements DeviceManagementService { -// -// -// private static Log log = LogFactory.getLog( -// org.wso2.carbon.device.mgt.mobile.windows.api.services.impl.DeviceManagementServiceImpl.class); -// -// /** -// * Get all devices.Returns list of Windows devices registered in MDM. -// * -// * @return Returns retrieved devices. -// * @throws WindowsConfigurationException occurred while retrieving all the devices from DB. -// */ -// @GET -// public List getAllDevices() throws WindowsConfigurationException { -// String msg; -// List devices; -// try { -// devices = WindowsAPIUtils.getDeviceManagementService(). -// getAllDevices(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS); -// } catch (DeviceManagementException e) { -// msg = "Error occurred while fetching the device list."; -// log.error(msg, e); -// throw new WindowsConfigurationException(msg, e); -// } -// return devices; -// } -// -// /** -// * Fetch Windows device details of a given device Id. -// * -// * @param deviceId Device Id -// * @return Returns retrieved device. -// * @throws WindowsConfigurationException occurred while getting device from DB. -// */ -// @GET -// @Path("{id}") -// public Device getDevice(@PathParam("id") String deviceId) throws WindowsConfigurationException { -// String msg; -// Device device; -// try { -// DeviceIdentifier deviceIdentifier = WindowsAPIUtils.convertToDeviceIdentifierObject(deviceId); -// device = WindowsAPIUtils.getDeviceManagementService().getDevice(deviceIdentifier); -// if (device == null) { -// Response.status(Response.Status.NOT_FOUND); -// } -// } catch (DeviceManagementException e) { -// msg = "Error occurred while fetching the device information."; -// log.error(msg, e); -// throw new WindowsConfigurationException(msg, e); -// } -// return device; -// } -// -// /** -// * Update Windows device details of given device id. -// * -// * @param deviceId Device Id. -// * @param device Device details to be updated. -// * @return Returns the message whether device update or not. -// * @throws WindowsConfigurationException occurred while updating the Device Info. -// */ -// @PUT -// @Path("{id}") -// public Message updateDevice(@PathParam("id") String deviceId, Device device) throws WindowsConfigurationException { -// String msg; -// Message responseMessage = new Message(); -// DeviceIdentifier deviceIdentifier = new DeviceIdentifier(); -// deviceIdentifier.setId(deviceId); -// deviceIdentifier.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS); -// boolean isUpdated; -// try { -// device.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS); -// isUpdated = WindowsAPIUtils.getDeviceManagementService().updateDeviceInfo(deviceIdentifier, device); -// if (isUpdated) { -// Response.status(Response.Status.ACCEPTED); -// responseMessage.setResponseMessage("Device information has modified successfully."); -// } else { -// Response.status(Response.Status.NOT_MODIFIED); -// responseMessage.setResponseMessage("Device not found for the update."); -// } -// } catch (DeviceManagementException e) { -// msg = "Error occurred while modifying the device information."; -// log.error(msg, e); -// throw new WindowsConfigurationException(msg, e); -// } -// return responseMessage; -// } -// -// /** -// * Fetch the Licence agreement for specific windows platform. -// * -// * @return Returns License agreement. -// * @throws WindowsConfigurationException occurred while getting licence for specific platform and Language. -// */ -// @GET -// @Path("license") -// @Produces("application/json") -// public License getLicense() throws WindowsConfigurationException { -// License license; -// try { -// license = -// WindowsAPIUtils.getDeviceManagementService().getLicense( -// DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS, -// DeviceManagementConstants.LanguageCodes.LANGUAGE_CODE_ENGLISH_US); -// } catch (DeviceManagementException e) { -// String msg = "Error occurred while retrieving the license configured for Windows device enrollment"; -// log.error(msg, e); -// throw new WindowsConfigurationException(msg, e); -// } -// return license; -// } -//}