From bbbaac4d28739022e1eb68c817914ae712ccfa6b Mon Sep 17 00:00:00 2001 From: kamidu Date: Tue, 2 Aug 2016 15:43:44 +0530 Subject: [PATCH 1/6] Fix for the 'Requested resource /app/conf/reader/main.js cannot be found' exception on startup --- .../units/cdmf.unit.device.type.android.type-view/type-view.js | 2 +- .../devicemgt/app/units/mdm.unit.ui.navbar.nav-menu/nav-menu.js | 2 +- .../units/cdmf.unit.device.type.windows.type-view/type-view.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.type-view/type-view.js b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.type-view/type-view.js index a24959159..ac41dedd7 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.type-view/type-view.js +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.type-view/type-view.js @@ -18,7 +18,7 @@ function onRequest(context){ var viewModel = {}; - var devicemgtProps = require("/app/conf/reader/main.js")["conf"]; + var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"]; viewModel.hostName = devicemgtProps["httpsURL"]; return viewModel; } \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.ui.navbar.nav-menu/nav-menu.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.ui.navbar.nav-menu/nav-menu.js index 1c257453f..363d9688e 100644 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.ui.navbar.nav-menu/nav-menu.js +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.ui.navbar.nav-menu/nav-menu.js @@ -28,7 +28,7 @@ function onRequest(context) { } }); var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; - var mdmProps = require('/app/conf/reader/main.js')["conf"]; + var mdmProps = require("/app/modules/conf-reader/main.js")["conf"]; var constants = require("/app/modules/constants.js"); var uiPermissions = userModule.getUIPermissions(); context["permissions"] = uiPermissions; diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.type-view/type-view.js b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.type-view/type-view.js index a24959159..ac41dedd7 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.type-view/type-view.js +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.type-view/type-view.js @@ -18,7 +18,7 @@ function onRequest(context){ var viewModel = {}; - var devicemgtProps = require("/app/conf/reader/main.js")["conf"]; + var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"]; viewModel.hostName = devicemgtProps["httpsURL"]; return viewModel; } \ No newline at end of file From 8d151120df8f9aa3aea92fdd5a9a8991ee298499 Mon Sep 17 00:00:00 2001 From: kamidu Date: Tue, 2 Aug 2016 18:50:23 +0530 Subject: [PATCH 2/6] enabling policy wizard for android --- .../policy-wizard.hbs | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-wizard/policy-wizard.hbs b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-wizard/policy-wizard.hbs index 0669d1ca6..fe04c3ce6 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-wizard/policy-wizard.hbs +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-wizard/policy-wizard.hbs @@ -1 +1,29 @@ -{{unit "mdm.unit.policy.wizard"}} \ No newline at end of file +
+
+

ADD POLICY

+
+
+
+
+
+

Step 2: Configure profile

+
+ +
+
+
+      +    Loading platform features . . . +

+
+
+
+ Back + Continue +
+
+
+
+
\ No newline at end of file From 7b62aa33614dd58078e7867ef157f1df8462507f Mon Sep 17 00:00:00 2001 From: Rasika Perera Date: Tue, 2 Aug 2016 22:23:23 +0530 Subject: [PATCH 3/6] Fixing: Requested resource /app/conf/reader/main.js cannot be found --- .../analytics-view.js | 2 +- .../cdmf.unit.device.type.android_sense.type-view/type-view.js | 2 +- .../analytics-view.js | 2 +- .../analytics-view.js | 2 +- .../devicemgt/app/pages/iot.page.register/register.js | 2 +- .../analytics-view.js | 2 +- .../analytics-view.js | 2 +- .../analytics-view.js | 2 +- .../analytics-view.js | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.realtime.analytics-view/analytics-view.js b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.realtime.analytics-view/analytics-view.js index a0a8c1602..8d783f1ab 100644 --- a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.realtime.analytics-view/analytics-view.js +++ b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.realtime.analytics-view/analytics-view.js @@ -18,7 +18,7 @@ function onRequest(context) { var device = context.unit.params.device; - var devicemgtProps = require("/app/conf/reader/main.js")["conf"]; + var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"]; var constants = require("/app/modules/constants.js"); var websocketEndpoint = devicemgtProps["httpsURL"].replace("https", "wss"); var tokenPair = session.get(constants.ACCESS_TOKEN_PAIR_IDENTIFIER); diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/type-view.js b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/type-view.js index 2fad1ce56..0badb0355 100644 --- a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/type-view.js +++ b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/type-view.js @@ -18,7 +18,7 @@ function onRequest(context){ var viewModel = {}; - var devicemgtProps = require("/app/conf/reader/main.js")["conf"]; + var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"]; viewModel.hostName = devicemgtProps["httpsWebURL"]; return viewModel; } \ No newline at end of file diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.analytics-view/analytics-view.js b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.analytics-view/analytics-view.js index c124fb251..ef49dbe96 100644 --- a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.analytics-view/analytics-view.js +++ b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.analytics-view/analytics-view.js @@ -17,7 +17,7 @@ */ function onRequest(context) { - var devicemgtProps = require("/app/conf/reader/main.js")["conf"]; + var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"]; var devices = context.unit.params.devices; var deviceType = context.uriParams.deviceType; diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.realtime.analytics-view/analytics-view.js b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.realtime.analytics-view/analytics-view.js index d5b886085..655c182d1 100644 --- a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.realtime.analytics-view/analytics-view.js +++ b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.realtime.analytics-view/analytics-view.js @@ -19,7 +19,7 @@ function onRequest(context) { var log = new Log("stats.js"); var device = context.unit.params.device; - var devicemgtProps = require("/app/conf/reader/main.js")["conf"]; + var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"]; var constants = require("/app/modules/constants.js"); var websocketEndpoint = devicemgtProps["wssURL"].replace("https", "wss"); var tokenPair = session.get(constants.ACCESS_TOKEN_PAIR_IDENTIFIER); diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/iot.page.register/register.js b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/iot.page.register/register.js index b3cbd10f1..f359aabc9 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/iot.page.register/register.js +++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/iot.page.register/register.js @@ -23,7 +23,7 @@ * @returns {*} A context object that returns the dynamic state of this page to be presented */ function onRequest(context) { - var devicemgtProps = require("/app/conf/reader/main.js")["conf"]; + var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"]; var page = {}; page["usernameJSRegEx"] = devicemgtProps.userValidationConfig.usernameJSRegEx; page["usernameHelpText"] = devicemgtProps.userValidationConfig.usernameHelpMsg; diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.analytics-view/analytics-view.js b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.analytics-view/analytics-view.js index d3dcd174b..f9b7d0801 100644 --- a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.analytics-view/analytics-view.js +++ b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.analytics-view/analytics-view.js @@ -17,7 +17,7 @@ */ function onRequest(context) { - var devicemgtProps = require("/app/conf/reader/main.js")["conf"]; + var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"]; var devices = context.unit.params.devices; var deviceType = context.uriParams.deviceType; diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.realtime.analytics-view/analytics-view.js b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.realtime.analytics-view/analytics-view.js index d5b886085..655c182d1 100644 --- a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.realtime.analytics-view/analytics-view.js +++ b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.realtime.analytics-view/analytics-view.js @@ -19,7 +19,7 @@ function onRequest(context) { var log = new Log("stats.js"); var device = context.unit.params.device; - var devicemgtProps = require("/app/conf/reader/main.js")["conf"]; + var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"]; var constants = require("/app/modules/constants.js"); var websocketEndpoint = devicemgtProps["wssURL"].replace("https", "wss"); var tokenPair = session.get(constants.ACCESS_TOKEN_PAIR_IDENTIFIER); diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.analytics-view/analytics-view.js b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.analytics-view/analytics-view.js index 3aa50cea1..2e8285abf 100644 --- a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.analytics-view/analytics-view.js +++ b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.analytics-view/analytics-view.js @@ -17,7 +17,7 @@ */ function onRequest(context) { - var devicemgtProps = require("/app/conf/reader/main.js")["conf"]; + var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"]; var devices = context.unit.params.devices; var deviceType = context.uriParams.deviceType; diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.realtime.analytics-view/analytics-view.js b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.realtime.analytics-view/analytics-view.js index 7493d6897..e4b0e14b0 100644 --- a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.realtime.analytics-view/analytics-view.js +++ b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.realtime.analytics-view/analytics-view.js @@ -19,7 +19,7 @@ function onRequest(context) { var log = new Log("stats.js"); var device = context.unit.params.device; - var devicemgtProps = require("/app/conf/reader/main.js")["conf"]; + var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"]; var constants = require("/app/modules/constants.js"); var websocketEndpoint = devicemgtProps["wssURL"].replace("https", "wss"); var jwtService = carbon.server.osgiService('org.wso2.carbon.identity.jwt.client.extension.service.JWTClientManagerService'); From 97eac5064ec78b0156b2745cbdc937282f541dd7 Mon Sep 17 00:00:00 2001 From: Rasika Perera Date: Tue, 2 Aug 2016 23:11:42 +0530 Subject: [PATCH 4/6] Fixed Requested resource /app/conf/reader/main.js not found --- .../devicemgt/app/pages/mdm.page.dashboard/dashboard.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.dashboard/dashboard.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.dashboard/dashboard.js index 2f881b830..0fb3cf4a9 100644 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.dashboard/dashboard.js +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.dashboard/dashboard.js @@ -19,7 +19,7 @@ function onRequest(context) { var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; var generalConfig = context.app.conf["generalConfig"]; - var mdmProps = require('/app/conf/reader/main.js')["conf"]; + var mdmProps = require("/app/modules/conf-reader/main.js")["conf"]; var viewModel = {}; viewModel.permissions = userModule.getUIPermissions(); From 86056df4343b531329463172fe6be726923e504b Mon Sep 17 00:00:00 2001 From: hasuniea Date: Thu, 4 Aug 2016 15:29:25 +0530 Subject: [PATCH 5/6] fixing windows plugin relalted slf4j issue --- .../pom.xml | 23 + .../windows/common/PluginConstants.java | 73 +-- .../windows/common/SyncmlCommandType.java | 6 +- .../authenticator/OAuth2TokenValidator.java | 37 ++ .../common/authenticator/OAuthConstants.java | 40 ++ .../OAuthTokenValidationStubFactory.java | 214 ++++++++ .../authenticator/OAuthValidatorFactory.java | 81 +++ .../impl/LocalOAuthValidator.java | 74 +++ .../impl/RemoteOAuthValidator.java | 121 +++++ .../windows/common/beans/CacheEntry.java | 19 +- .../windows/common/beans/Token.java | 13 +- .../common/beans/WindowsPluginProperties.java | 103 ---- .../exceptions/AuthenticationException.java | 6 +- .../exceptions/BadRequestException.java | 8 +- .../CertificateGenerationException.java | 6 +- .../exceptions/FileOperationException.java | 6 +- .../KeyStoreGenerationException.java | 6 +- .../common/exceptions/MDMAPIException.java | 8 +- .../OAuthTokenValidationException.java | 59 ++ .../SyncmlMessageFormatException.java | 6 +- .../exceptions/SyncmlOperationException.java | 6 +- .../exceptions/WAPProvisioningException.java | 6 +- .../WindowsConfigurationException.java | 8 +- .../WindowsDeviceEnrolmentException.java | 6 +- .../WindowsOperationsException.java | 8 +- .../common/util/AuthenticationInfo.java | 18 +- .../windows/common/util/BSTValidator.java | 132 ++--- .../ConfigInitializerContextListener.java | 138 ----- .../common/util/ContextInitializer.java | 51 ++ .../windows/common/util/DeviceIDHolder.java | 25 +- .../windows/common/util/DeviceUtil.java | 15 +- .../windows/common/util/ErrorHandler.java | 6 +- .../windows/common/util/ErrorMessage.java | 12 +- .../common/util/GsonMessageBodyHandler.java | 10 +- .../windows/common/util/Message.java | 6 +- .../common/util/OAuthValidationResponse.java | 71 +++ .../common/util/SOAPSecurityHandler.java | 6 +- .../common/util/UsernameTokenValidator.java | 38 +- .../windows/common/util/WindowsAPIUtils.java | 152 +++--- .../common/util/WindowsDeviceUtils.java | 13 +- .../windows/operations/AddTag.java | 21 +- .../operations/{Alert.java => AlertTag.java} | 15 +- .../windows/operations/AtomicTag.java | 22 +- .../windows/operations/ChallengeTag.java | 19 +- .../{Credential.java => CredentialTag.java} | 14 +- .../windows/operations/DeleteTag.java | 22 +- .../windows/operations/ExecuteTag.java | 22 +- .../operations/{Get.java => GetTag.java} | 24 +- .../operations/{Item.java => ItemTag.java} | 29 +- .../windows/operations/MetaTag.java | 13 +- .../{Replace.java => ReplaceTag.java} | 24 +- .../{Results.java => ResultsTag.java} | 26 +- .../windows/operations/SequenceTag.java | 42 +- .../{Source.java => SourceTag.java} | 27 +- .../{Status.java => StatusTag.java} | 27 +- .../windows/operations/SyncmlBody.java | 47 +- .../windows/operations/SyncmlDocument.java | 11 +- .../windows/operations/SyncmlHeader.java | 33 +- .../{Target.java => TargetTag.java} | 14 +- .../operations/WindowsOperationException.java | 6 +- .../windows/operations/util/Constants.java | 26 +- .../windows/operations/util/DeviceInfo.java | 6 +- .../operations/util/OperationCode.java | 11 +- .../operations/util/OperationHandler.java | 490 +++++++++++++++++ .../operations/util/OperationReply.java | 301 +++++------ .../operations/util/OperationUtils.java | 502 ------------------ ...entials.java => SyncmlCredentialUtil.java} | 24 +- .../operations/util/SyncmlGenerator.java | 28 +- .../windows/operations/util/SyncmlParser.java | 122 ++--- .../windows/operations/util/TagUtil.java | 56 ++ .../services/adminoperations/Operations.java | 80 +-- .../adminoperations/beans/Device.java | 12 +- .../beans/OperationRequest.java | 49 ++ .../adminoperations/impl/OperationsImpl.java | 22 +- .../adminoperations/util/OperationStore.java | 112 ++++ .../windows/services/authbst/BSTProvider.java | 22 +- .../services/authbst/beans/Credentials.java | 19 +- .../authbst/impl/BSTProviderImpl.java | 37 +- .../ConfigurationMgtService.java | 173 ++++-- .../impl/ConfigurationMgtServiceImpl.java | 182 ------- .../DeviceManagementService.java | 173 +++--- .../impl/DeviceManagementServiceImpl.java | 158 ------ .../services/discovery/DiscoveryService.java | 34 +- .../discovery/beans/DiscoveryRequest.java | 14 +- .../discovery/beans/DiscoveryResponse.java | 19 +- .../discovery/beans/package-info.java | 32 +- .../discovery/impl/DiscoveryServiceImpl.java | 90 ++-- .../policymgtservice/PolicyMgtService.java | 63 ++- .../impl/PolicyMgtServiceImpl.java | 72 --- .../services/syncml/SyncmlService.java | 22 +- .../services/syncml/beans/BasicOperation.java | 13 +- .../services/syncml/beans/PasscodePolicy.java | 27 +- .../services/syncml/beans/Profile.java | 15 +- .../windows/services/syncml/beans/Wifi.java | 20 +- .../services/syncml/beans/WindowsDevice.java | 100 ++++ .../syncml/impl/SyncmlServiceImpl.java | 236 +++----- .../wstep/CertificateEnrollmentService.java | 6 +- .../wstep/beans/AdditionalContext.java | 6 +- .../wstep/beans/BinarySecurityToken.java | 12 +- .../services/wstep/beans/ContextItem.java | 6 +- .../wstep/beans/RequestSecurityToken.java | 6 +- .../beans/RequestSecurityTokenResponse.java | 12 +- .../wstep/beans/RequestedSecurityToken.java | 6 +- .../services/wstep/beans/package-info.java | 24 +- .../CertificateEnrollmentServiceImpl.java | 230 ++++---- .../wstep/util/CertificateSigningService.java | 32 +- .../wstep/util/KeyStoreGenerator.java | 28 +- .../services/wstep/util/MessageHandler.java | 40 +- .../CertificateEnrollmentPolicyService.java | 13 +- .../services/xcep/beans/Attributes.java | 6 +- .../windows/services/xcep/beans/CA.java | 6 +- .../services/xcep/beans/CACollection.java | 6 +- .../xcep/beans/CAReferenceCollection.java | 6 +- .../windows/services/xcep/beans/CAURI.java | 6 +- .../services/xcep/beans/CAURICollection.java | 6 +- .../beans/CertificateEnrollmentPolicy.java | 6 +- .../xcep/beans/CertificateValidity.java | 6 +- .../windows/services/xcep/beans/Client.java | 6 +- .../services/xcep/beans/CryptoProviders.java | 6 +- .../xcep/beans/EnrollmentPermission.java | 6 +- .../services/xcep/beans/Extension.java | 6 +- .../xcep/beans/ExtensionCollection.java | 6 +- .../xcep/beans/FilterOIDCollection.java | 6 +- .../services/xcep/beans/GetPolicies.java | 12 +- .../xcep/beans/GetPoliciesResponse.java | 12 +- .../xcep/beans/KeyArchivalAttributes.java | 6 +- .../windows/services/xcep/beans/OID.java | 6 +- .../services/xcep/beans/OIDCollection.java | 6 +- .../xcep/beans/OIDReferenceCollection.java | 6 +- .../services/xcep/beans/ObjectFactory.java | 6 +- .../services/xcep/beans/PolicyCollection.java | 6 +- .../xcep/beans/PrivateKeyAttributes.java | 12 +- .../services/xcep/beans/RARequirements.java | 12 +- .../services/xcep/beans/RequestFilter.java | 6 +- .../windows/services/xcep/beans/Response.java | 6 +- .../windows/services/xcep/beans/Revision.java | 6 +- .../xcep/beans/SupersededPolicies.java | 6 +- .../services/xcep/beans/package-info.java | 24 +- ...ertificateEnrollmentPolicyServiceImpl.java | 8 +- .../src/main/webapp/WEB-INF/cxf-servlet.xml | 6 +- .../src/main/webapp/WEB-INF/web.xml | 2 +- pom.xml | 5 + 142 files changed, 3044 insertions(+), 3070 deletions(-) create mode 100644 components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/authenticator/OAuth2TokenValidator.java create mode 100644 components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/authenticator/OAuthConstants.java create mode 100644 components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/authenticator/OAuthTokenValidationStubFactory.java create mode 100644 components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/authenticator/OAuthValidatorFactory.java create mode 100644 components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/authenticator/impl/LocalOAuthValidator.java create mode 100644 components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/authenticator/impl/RemoteOAuthValidator.java delete mode 100644 components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/beans/WindowsPluginProperties.java create mode 100644 components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/exceptions/OAuthTokenValidationException.java delete mode 100644 components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/util/ConfigInitializerContextListener.java create mode 100644 components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/util/ContextInitializer.java create mode 100644 components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/util/OAuthValidationResponse.java rename components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/{Alert.java => AlertTag.java} (74%) rename components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/{Credential.java => CredentialTag.java} (72%) rename components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/{Get.java => GetTag.java} (67%) rename components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/{Item.java => ItemTag.java} (66%) rename components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/{Replace.java => ReplaceTag.java} (66%) rename components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/{Results.java => ResultsTag.java} (71%) rename components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/{Source.java => SourceTag.java} (67%) rename components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/{Status.java => StatusTag.java} (75%) rename components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/{Target.java => TargetTag.java} (74%) create mode 100644 components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/util/OperationHandler.java delete mode 100644 components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/util/OperationUtils.java rename components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/util/{SyncmlCredentials.java => SyncmlCredentialUtil.java} (72%) create mode 100644 components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/util/TagUtil.java create mode 100644 components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/adminoperations/beans/OperationRequest.java create mode 100644 components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/adminoperations/util/OperationStore.java delete mode 100644 components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/configurationmgtservice/impl/ConfigurationMgtServiceImpl.java delete mode 100644 components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/devicemgtservice/impl/DeviceManagementServiceImpl.java delete mode 100644 components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/policymgtservice/impl/PolicyMgtServiceImpl.java create mode 100644 components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/syncml/beans/WindowsDevice.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 c0aab46b1..897b7adbe 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 @@ -260,6 +260,17 @@ org.wso2.carbon.device.mgt.common provided + + org.wso2.carbon.devicemgt + org.wso2.carbon.webapp.authenticator.framework + provided + + + org.wso2.carbon.identity + org.wso2.carbon.identity.base + + + org.wso2.carbon.identity org.wso2.carbon.identity.oauth.stub @@ -281,6 +292,12 @@ cache-api 0.5 provided + + + org.slf4j + slf4j-api + + org.wso2.carbon.devicemgt @@ -318,6 +335,12 @@ io.swagger swagger-annotations + + + org.slf4j + slf4j-api + + diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/PluginConstants.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/PluginConstants.java index fd65c4dff..6e9fc7e5a 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/PluginConstants.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/PluginConstants.java @@ -1,17 +1,17 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ @@ -28,11 +28,9 @@ public final class PluginConstants { public static final String DISCOVERY_SERVICE_ENDPOINT = "org.wso2.carbon.mdm.mobileservices.windows.services.discovery.DiscoveryService"; public static final String CERTIFICATE_ENROLLMENT_SERVICE_ENDPOINT = - "org.wso2.carbon.mdm.mobileservices.windows.services.wstep" + - ".CertificateEnrollmentService"; + "org.wso2.carbon.mdm.mobileservices.windows.services.wstep.CertificateEnrollmentService"; public static final String CERTIFICATE_ENROLLMENT_POLICY_SERVICE_ENDPOINT = - "org.wso2.carbon.mdm.mobileservices.windows.services.xcep" + - ".CertificateEnrollmentPolicyService"; + "org.wso2.carbon.mdm.mobileservices.windows.services.xcep.CertificateEnrollmentPolicyService"; //Services' target namespaces public static final String DISCOVERY_SERVICE_TARGET_NAMESPACE = @@ -60,11 +58,11 @@ public final class PluginConstants { //Servlet Context attributes names public static final String CONTEXT_WAP_PROVISIONING_FILE = "WAP_PROVISIONING_FILE"; - public static final String WINDOWS_PLUGIN_PROPERTIES = "WINDOWS_PLUGIN_PROPERTIES"; //Message handler constants public static final String CONTENT_LENGTH = "Content-Length"; public static final String SECURITY = "Security"; + public static final String TO = "To"; public static final String CXF_REQUEST_URI = "org.apache.cxf.request.uri"; //Web services media types @@ -78,20 +76,16 @@ public final class PluginConstants { throw new AssertionError(); } - public static final String ENROLL_SUBDOMAIN = "https://EnterpriseEnrollment."; + public static final String DEVICE_ENROLLMENT_SUBDOMAIN = "https://EnterpriseEnrollment."; public static final String CERTIFICATE_ENROLLMENT_POLICY_SERVICE_URL = - "/ENROLLMENTSERVER/PolicyEnrollmentWebservice" + - ".svc"; + "/ENROLLMENTSERVER/PolicyEnrollmentWebservice.svc"; public static final String CERTIFICATE_ENROLLMENT_SERVICE_URL = - "/ENROLLMENTSERVER/DeviceEnrollmentWebservice" + - ".svc"; + "/ENROLLMENTSERVER/DeviceEnrollmentWebservice.svc"; public static final String ONPREMISE_CERTIFICATE_ENROLLMENT_POLICY = - "/ENROLLMENTSERVER/ONPREMISE/" + - "PolicyEnrollmentWebservice.svc"; + "/ENROLLMENTSERVER/ONPREMISE/PolicyEnrollmentWebservice.svc"; public static final String ONPREMISE_CERTIFICATE_ENROLLMENT_SERVICE_URL = "/ENROLLMENTSERVER/ONPREMISE/DeviceEnrollmentWebservice.svc"; - public static final String WAB_URL = "/mdm/enrollments/windows/login-agent"; - + public static final String WAB_URL = "/emm-web-agent/enrollments/windows/login-agent"; } /** @@ -113,7 +107,7 @@ public final class PluginConstants { } /** - * Certificate enrollment Service related constants + * Certificate enrollment Service related constants. */ public final class CertificateEnrolment { private CertificateEnrolment() { @@ -121,17 +115,14 @@ public final class PluginConstants { } public static final String TOKEN_TYPE = - "http://schemas.microsoft.com/5.0.0" + - ".0/ConfigurationManager/Enrollment/DeviceEnrollmentToken"; + "http://schemas.microsoft.com/5.0.0.0/ConfigurationManager/Enrollment/DeviceEnrollmentToken"; public static final String PARM = "parm"; public static final String TYPE = "type"; public static final String VALUE = "value"; public static final String VALUE_TYPE = - "http://schemas.microsoft.com/5.0.0" + - ".0/ConfigurationManager/Enrollment/DeviceEnrollmentProvisionDoc"; + "http://schemas.microsoft.com/5.0.0.0/ConfigurationManager/Enrollment/DeviceEnrollmentProvisionDoc"; public static final String ENCODING_TYPE = - "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0" + - ".xsd#base64binary"; + "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd#base64binary"; public static final String CA_CERT = "cacert"; public static final String X_509 = "X.509"; public static final String PROPERTIES_XML = "properties.xml"; @@ -141,8 +132,7 @@ public final class PluginConstants { public static final String JKS = "JKS"; public static final String SECURITY = "Security"; public static final String WSS_SECURITY_UTILITY = - "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0" + - ".xsd"; + "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"; public static final String TIMESTAMP_ID = "Id"; public static final String TIMESTAMP_U = "u"; public static final String TIMESTAMP = "Timestamp"; @@ -150,10 +140,23 @@ public final class PluginConstants { public static final String CREATED = "Created"; public static final String EXPIRES = "Expires"; public static final String UTF_8 = "utf-8"; + + public static final int DOMAIN_SEGMENT = 1; + public static final int EMAIL_SEGMENT = 0; + public static final int REQUEST_ID = 0; + public static final int CA_CERTIFICATE_POSITION = 0; + public static final int SIGNED_CERTIFICATE_POSITION = 1; + public static final int APPAUTH_USERNAME_POSITION = 21; + public static final int APPAUTH_PASSWORD_POSITION = 22; + public static final int POLLING_FREQUENCY_POSITION = 24; + public static final int SYNCML_PROVISIONING_ADDR_POSITION = 8; + public static final int DOMAIN_POSITION = 7; + public static final String ENROLL_SUBDOMAIN = "https://EnterpriseEnrollment."; + public static final String SYNCML_PROVISIONING_SERVICE_URL = "/Syncml/initialquery"; } /** - * SynclML service related constants + * SynclML service related constants. */ public final class SyncML { private SyncML() { @@ -182,9 +185,9 @@ public final class PluginConstants { public static final int DEVICE_LANG_POSITION = 4; public static final int IMSI_POSITION = 1; public static final int IMEI_POSITION = 2; - public static final int VENDER_POSITION = 4; + public static final int VENDOR_POSITION = 4; public static final int MODEL_POSITION = 5; - public static final int MACADDRESS_POSITION = 7; + 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 String SYNCML_DATA_ONE = "1"; @@ -275,7 +278,8 @@ public final class PluginConstants { public static final String CONTENT_TYPE_TEXT = "text"; public static final String NOTIFIER_FREQUENCY = "notifierFrequency"; public static final String DEFAULT_FREQUENCY = "8"; - + public static final String AUTH_POLICY = "authPolicy"; + public static final String DEFAULT_AUTH_POLICY = "Federated"; } /** @@ -290,4 +294,13 @@ public final class PluginConstants { public static final String ENCRYPTED_ENABLE = "encrypted"; public static final String ENABLE_PASSWORD = "enablePassword"; } + + /** + * Authentication related constants. + */ + public final class AuthenticatorProperties { + private AuthenticatorProperties() { throw new AssertionError(); } + public static final String MAX_CONNECTION_PER_HOST = "MaxConnectionsPerHost"; + public static final String MAX_TOTAL_CONNECTIONS = "MaxTotalConnections"; + } } diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/SyncmlCommandType.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/SyncmlCommandType.java index 4d8ec46ff..6f4969231 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/SyncmlCommandType.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/SyncmlCommandType.java @@ -1,17 +1,17 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/authenticator/OAuth2TokenValidator.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/authenticator/OAuth2TokenValidator.java new file mode 100644 index 000000000..26a790826 --- /dev/null +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/authenticator/OAuth2TokenValidator.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2015, 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.mdm.mobileservices.windows.common.authenticator; + +import org.wso2.carbon.mdm.mobileservices.windows.common.exceptions.OAuthTokenValidationException; +import org.wso2.carbon.mdm.mobileservices.windows.common.util.OAuthValidationResponse; + +/** + * Declares the contract for OAuth2TokenValidator implementations. + */ +public interface OAuth2TokenValidator { + /** + * This method gets a string accessToken and validates it and generate the OAuthValidationResponse + * containing the validity and user details if valid. + * + * @param accessToken which need to be validated. + * @param resource which need to be validated. + * @return OAuthValidationResponse with the validated results. + */ + OAuthValidationResponse validateToken(String accessToken, String resource) throws OAuthTokenValidationException; +} diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/authenticator/OAuthConstants.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/authenticator/OAuthConstants.java new file mode 100644 index 000000000..cc36f62f7 --- /dev/null +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/authenticator/OAuthConstants.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2015, 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.mdm.mobileservices.windows.common.authenticator; + +import org.wso2.carbon.utils.CarbonUtils; + +import java.io.File; + +/** + * Defines constants to be used inside oauth validators. + */ +public class OAuthConstants { + + public static final String AUTHORIZATION_HEADER_PREFIX_BEARER = "Bearer"; + public static final String AUTHORIZATION_HEADER_PREFIX_BASIC = "Basic"; + public static final String BEARER_TOKEN_TYPE = "bearer"; + public static final String BEARER_TOKEN_IDENTIFIER = "token"; + public static final String AUTHENTICATOR_NAME = "OAuthAuthenticator"; + public static final String RESOURCE_KEY = "resource"; + public static final String AUTHENTICATOR_CONFIG_PATH = CarbonUtils.getEtcCarbonConfigDirPath() + + File.separator + "webapp-authenticator-config.xml"; + private static final String AUTHENTICATOR_CONFIG_SCHEMA_PATH = + "resources/config/schema/webapp-authenticator-config-schema.xsd"; +} diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/authenticator/OAuthTokenValidationStubFactory.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/authenticator/OAuthTokenValidationStubFactory.java new file mode 100644 index 000000000..7397b4da8 --- /dev/null +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/authenticator/OAuthTokenValidationStubFactory.java @@ -0,0 +1,214 @@ +/* + * Copyright (c) 2015, 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.mdm.mobileservices.windows.common.authenticator; + +import org.apache.axis2.AxisFault; +import org.apache.axis2.client.Options; +import org.apache.axis2.client.ServiceClient; +import org.apache.axis2.transport.http.HTTPConstants; +import org.apache.commons.codec.binary.Base64; +import org.apache.commons.httpclient.Header; +import org.apache.commons.httpclient.HttpClient; +import org.apache.commons.httpclient.HttpConnectionManager; +import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager; +import org.apache.commons.httpclient.params.HttpConnectionManagerParams; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.commons.pool.PoolableObjectFactory; +import org.apache.http.conn.HttpClientConnectionManager; +import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; +import org.wso2.carbon.identity.oauth2.stub.OAuth2TokenValidationServiceStub; +import org.wso2.carbon.mdm.mobileservices.windows.common.PluginConstants; +import org.wso2.carbon.mdm.mobileservices.windows.common.exceptions.OAuthTokenValidationException; + +import java.util.ArrayList; +import java.util.List; +import java.util.Properties; + +public class OAuthTokenValidationStubFactory implements PoolableObjectFactory { + private String url; + private String basicAuthHeader; + private HttpClient httpClient; + + private static final Log log = LogFactory.getLog(OAuthTokenValidationStubFactory.class); + + public OAuthTokenValidationStubFactory(String url, String adminUsername, String adminPassword, + Properties properties) { + this.validateUrl(url); + this.url = url; + + this.validateCredentials(adminUsername, adminPassword); + this.basicAuthHeader = new String(Base64.encodeBase64((adminUsername + ":" + adminPassword).getBytes())); + + HttpConnectionManager connectionManager = this.createConnectionManager(properties); + this.httpClient = new HttpClient(connectionManager); + } + + /** + * Creates an instance of MultiThreadedHttpConnectionManager using HttpClient 3.x APIs + * + * @param properties Properties to configure MultiThreadedHttpConnectionManager + * @return An instance of properly configured MultiThreadedHttpConnectionManager + */ + private HttpConnectionManager createConnectionManager(Properties properties) { + HttpConnectionManagerParams params = new HttpConnectionManagerParams(); + if (properties == null || properties.isEmpty()) { + throw new IllegalArgumentException("Parameters required to initialize HttpClient instances " + + "associated with OAuth token validation service stub are not provided"); + } + String maxConnectionsPerHostParam = properties.getProperty(PluginConstants. + AuthenticatorProperties.MAX_CONNECTION_PER_HOST); + if (maxConnectionsPerHostParam == null || maxConnectionsPerHostParam.isEmpty()) { + if (log.isDebugEnabled()) { + log.debug("MaxConnectionsPerHost parameter is not explicitly defined. Therefore, the default, " + + "which is 2, will be used"); + } + } else { + params.setDefaultMaxConnectionsPerHost(Integer.parseInt(maxConnectionsPerHostParam)); + } + + String maxTotalConnectionsParam = properties.getProperty(PluginConstants. + AuthenticatorProperties.MAX_TOTAL_CONNECTIONS); + if (maxTotalConnectionsParam == null || maxTotalConnectionsParam.isEmpty()) { + if (log.isDebugEnabled()) { + log.debug("MaxTotalConnections parameter is not explicitly defined. Therefore, the default, " + + "which is 10, will be used"); + } + } else { + params.setMaxTotalConnections(Integer.parseInt(maxTotalConnectionsParam)); + } + HttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager(); + connectionManager.setParams(params); + return connectionManager; + } + + /** + * Creates an instance of PoolingHttpClientConnectionManager using HttpClient 4.x APIs + * + * @param properties Properties to configure PoolingHttpClientConnectionManager + * @return An instance of properly configured PoolingHttpClientConnectionManager + */ + private HttpClientConnectionManager createClientConnectionManager(Properties properties) { + PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager(); + if (properties != null) { + String maxConnectionsPerHostParam = properties.getProperty(PluginConstants. + AuthenticatorProperties.MAX_CONNECTION_PER_HOST); + if (maxConnectionsPerHostParam == null || maxConnectionsPerHostParam.isEmpty()) { + if (log.isDebugEnabled()) { + log.debug("MaxConnectionsPerHost parameter is not explicitly defined. Therefore, the default, " + + "which is 2, will be used"); + } + } else { + connectionManager.setDefaultMaxPerRoute(Integer.parseInt(maxConnectionsPerHostParam)); + } + + String maxTotalConnectionsParam = properties.getProperty(PluginConstants. + AuthenticatorProperties.MAX_TOTAL_CONNECTIONS); + if (maxTotalConnectionsParam == null || maxTotalConnectionsParam.isEmpty()) { + if (log.isDebugEnabled()) { + log.debug("MaxTotalConnections parameter is not explicitly defined. Therefore, the default, " + + "which is 10, will be used"); + } + } else { + connectionManager.setMaxTotal(Integer.parseInt(maxTotalConnectionsParam)); + } + } else { + if (log.isDebugEnabled()) { + log.debug("Properties, i.e. MaxTotalConnections/MaxConnectionsPerHost, required to tune the " + + "HttpClient used in OAuth token validation service stub instances are not provided. " + + "Therefore, the defaults, 2/10 respectively, will be used"); + } + } + return connectionManager; + } + + @Override + public Object makeObject() throws Exception { + return this.createStub(); + } + + @Override + public void destroyObject(Object o) throws Exception { + + } + + @Override + public boolean validateObject(Object o) { + return true; + } + + @Override + public void activateObject(Object o) throws Exception { + if (log.isDebugEnabled()) { + log.debug("OAuth token validate stub instance is activated"); + } + } + + @Override + public void passivateObject(Object o) throws Exception { + if (o instanceof OAuth2TokenValidationServiceStub) { + OAuth2TokenValidationServiceStub stub = (OAuth2TokenValidationServiceStub) o; + stub._getServiceClient().cleanupTransport(); + } + } + + private OAuth2TokenValidationServiceStub createStub() throws OAuthTokenValidationException { + OAuth2TokenValidationServiceStub stub; + try { + stub = new OAuth2TokenValidationServiceStub(url); + ServiceClient client = stub._getServiceClient(); + client.getServiceContext().getConfigurationContext().setProperty( + HTTPConstants.CACHED_HTTP_CLIENT, httpClient); + + List
headerList = new ArrayList<>(); + Header header = new Header(); + header.setName(HTTPConstants.HEADER_AUTHORIZATION); + header.setValue(OAuthConstants.AUTHORIZATION_HEADER_PREFIX_BASIC + " " + basicAuthHeader); + headerList.add(header); + + Options options = client.getOptions(); + options.setProperty(HTTPConstants.HTTP_HEADERS, headerList); + options.setProperty(HTTPConstants.REUSE_HTTP_CLIENT, "true"); + client.setOptions(options); + } catch (AxisFault axisFault) { + throw new OAuthTokenValidationException("Error occurred while creating the " + + "OAuth2TokenValidationServiceStub.", axisFault); + } + return stub; + } + + private void validateUrl(String url) { + if (url == null || url.isEmpty()) { + throw new IllegalArgumentException("Url provided as the endpoint of the OAuth token validation service " + + "is null"); + } + } + + private void validateCredentials(String adminUsername, String adminPassword) { + if (adminUsername == null || adminUsername.isEmpty()) { + throw new IllegalArgumentException("An appropriate username required to initialize OAuth token " + + "validation service stub factory hasn't been provided"); + } + if (adminPassword == null || adminPassword.isEmpty()) { + throw new IllegalArgumentException("An appropriate password required to initialize OAuth token " + + "validation service stub factory hasn't been provided"); + } + } + +} diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/authenticator/OAuthValidatorFactory.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/authenticator/OAuthValidatorFactory.java new file mode 100644 index 000000000..c2e2de481 --- /dev/null +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/authenticator/OAuthValidatorFactory.java @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2015, 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.mdm.mobileservices.windows.common.authenticator; + +import org.wso2.carbon.mdm.mobileservices.windows.common.authenticator.impl.LocalOAuthValidator; +import org.wso2.carbon.mdm.mobileservices.windows.common.authenticator.impl.RemoteOAuthValidator; +import org.wso2.carbon.mdm.mobileservices.windows.common.util.WindowsAPIUtils; +import org.wso2.carbon.webapp.authenticator.framework.config.AuthenticatorConfig; + +import java.util.Properties; + +/** + * The class validate the configurations and provide the most suitable implementation according to the configuration. + * Factory class for OAuthValidator. + */ +public class OAuthValidatorFactory { + + private static Properties authenticatorProperties; + + public static OAuth2TokenValidator getValidator() { + Properties authenticatorProperties = getAuthenticatorProperties(); + boolean isRemote = Boolean.parseBoolean(authenticatorProperties.getProperty("IsRemote")); + if (isRemote) { + String url = authenticatorProperties.getProperty("TokenValidationEndpointUrl"); + if ((url == null) || (url.isEmpty())) { + throw new IllegalStateException("OAuth token validation endpoint url is not provided"); + } + String adminUsername = authenticatorProperties.getProperty("Username"); + if (adminUsername == null) { + throw new IllegalStateException("Username to connect to the OAuth token validation endpoint " + + "is not provided"); + } + + String adminPassword = authenticatorProperties.getProperty("Password"); + if (adminPassword == null) { + throw new IllegalStateException("Password to connect to the OAuth token validation endpoint " + + "is not provided"); + } + + Properties validatorProperties = new Properties(); + validatorProperties.setProperty("MaxTotalConnections", authenticatorProperties.getProperty("MaxTotalConnections")); + validatorProperties.setProperty("MaxConnectionsPerHost", authenticatorProperties.getProperty("MaxConnectionsPerHost")); + if ((url != null) && (!url.trim().isEmpty())) { + url = url + "/services/OAuth2TokenValidationService.OAuth2TokenValidationServiceHttpsSoap12Endpoint/"; + return new RemoteOAuthValidator(url, adminUsername, adminPassword, validatorProperties); + } + throw new IllegalStateException("Remote server host can't be empty in OAuthAuthenticator configuration."); + } + return new LocalOAuthValidator(); + } + + private static Properties getAuthenticatorProperties() { + if (authenticatorProperties == null) { + AuthenticatorConfig config = WindowsAPIUtils.getBSTAuthenticatorConfig(); + if ((config.getParams() != null) && (!config.getParams().isEmpty())) { + Properties properties = new Properties(); + for (AuthenticatorConfig.Parameter param : config.getParams()) { + properties.setProperty(param.getName(), param.getValue()); + } + authenticatorProperties = properties; + } + } + return authenticatorProperties; + } +} diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/authenticator/impl/LocalOAuthValidator.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/authenticator/impl/LocalOAuthValidator.java new file mode 100644 index 000000000..0ff61759d --- /dev/null +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/authenticator/impl/LocalOAuthValidator.java @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2015, 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.mdm.mobileservices.windows.common.authenticator.impl; + +import org.wso2.carbon.identity.oauth2.dto.OAuth2TokenValidationRequestDTO; +import org.wso2.carbon.mdm.mobileservices.windows.common.authenticator.OAuth2TokenValidator; +import org.wso2.carbon.mdm.mobileservices.windows.common.authenticator.OAuthConstants; +import org.wso2.carbon.mdm.mobileservices.windows.common.exceptions.OAuthTokenValidationException; +import org.wso2.carbon.mdm.mobileservices.windows.common.util.OAuthValidationResponse; +import org.wso2.carbon.mdm.mobileservices.windows.common.util.WindowsAPIUtils; +import org.wso2.carbon.utils.multitenancy.MultitenantUtils; + +/** + * Handles the OAuth2 token validation from the same server using OSGi services. + */ +public class LocalOAuthValidator implements OAuth2TokenValidator { + @Override + public OAuthValidationResponse validateToken(String accessToken, String resource) + throws OAuthTokenValidationException { + + OAuth2TokenValidationRequestDTO validationRequest = new OAuth2TokenValidationRequestDTO(); + OAuth2TokenValidationRequestDTO.OAuth2AccessToken oauthToken = + validationRequest.new OAuth2AccessToken(); + oauthToken.setTokenType(OAuthConstants.BEARER_TOKEN_TYPE); + oauthToken.setIdentifier(accessToken); + validationRequest.setAccessToken(oauthToken); + + //Set the resource context param. This will be used in scope validation. + OAuth2TokenValidationRequestDTO.TokenValidationContextParam + resourceContextParam = validationRequest.new TokenValidationContextParam(); + resourceContextParam.setKey(OAuthConstants.RESOURCE_KEY); + resourceContextParam.setValue(resource); + + OAuth2TokenValidationRequestDTO.TokenValidationContextParam[] + tokenValidationContextParams = + new OAuth2TokenValidationRequestDTO.TokenValidationContextParam[1]; + tokenValidationContextParams[0] = resourceContextParam; + validationRequest.setContext(tokenValidationContextParams); + + org.wso2.carbon.identity.oauth2.dto.OAuth2TokenValidationResponseDTO tokenValidationResponse = + WindowsAPIUtils.getOAuth2TokenValidationService().findOAuthConsumerIfTokenIsValid( + validationRequest).getAccessTokenValidationResponse(); + boolean isValid = tokenValidationResponse.isValid(); + String username; + String tenantDomain; + if (isValid) { + username = MultitenantUtils.getTenantAwareUsername( + tokenValidationResponse.getAuthorizedUser()); + tenantDomain = + MultitenantUtils.getTenantDomain(tokenValidationResponse.getAuthorizedUser()); + } else { + OAuthValidationResponse oAuthValidationResponse = new OAuthValidationResponse(); + oAuthValidationResponse.setErrorMsg(tokenValidationResponse.getErrorMsg()); + return oAuthValidationResponse; + } + return new OAuthValidationResponse(username, tenantDomain, isValid); + } +} diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/authenticator/impl/RemoteOAuthValidator.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/authenticator/impl/RemoteOAuthValidator.java new file mode 100644 index 000000000..fe8dd46c8 --- /dev/null +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/authenticator/impl/RemoteOAuthValidator.java @@ -0,0 +1,121 @@ +/* + * Copyright (c) 2015, 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.mdm.mobileservices.windows.common.authenticator.impl; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.commons.pool.impl.GenericObjectPool; +import org.wso2.carbon.identity.oauth2.stub.OAuth2TokenValidationServiceStub; +import org.wso2.carbon.identity.oauth2.stub.dto.OAuth2TokenValidationRequestDTO; +import org.wso2.carbon.identity.oauth2.stub.dto.OAuth2TokenValidationRequestDTO_OAuth2AccessToken; +import org.wso2.carbon.identity.oauth2.stub.dto.OAuth2TokenValidationRequestDTO_TokenValidationContextParam; +import org.wso2.carbon.identity.oauth2.stub.dto.OAuth2TokenValidationResponseDTO; +import org.wso2.carbon.mdm.mobileservices.windows.common.authenticator.OAuth2TokenValidator; +import org.wso2.carbon.mdm.mobileservices.windows.common.authenticator.OAuthTokenValidationStubFactory; +import org.wso2.carbon.mdm.mobileservices.windows.common.exceptions.OAuthTokenValidationException; +import org.wso2.carbon.mdm.mobileservices.windows.common.util.OAuthValidationResponse; +import org.wso2.carbon.utils.multitenancy.MultitenantUtils; + +import java.rmi.RemoteException; +import java.util.Properties; + +/** + * Handles the OAuth2 token validation from remote IS servers using remote OAuthValidation service-stub. + */ +public class RemoteOAuthValidator implements OAuth2TokenValidator { + + private GenericObjectPool stubs; + private static final Log log = LogFactory.getLog(RemoteOAuthValidator.class); + + public RemoteOAuthValidator(String hostURL, String adminUsername, String adminPassword, Properties properties) { + this.stubs = + new GenericObjectPool(new OAuthTokenValidationStubFactory( + hostURL, adminUsername, adminPassword, properties)); + } + + public OAuthValidationResponse validateToken(String accessToken, + String resource) throws OAuthTokenValidationException { + OAuth2TokenValidationServiceStub stub = null; + OAuth2TokenValidationResponseDTO validationResponse; + try { + OAuth2TokenValidationRequestDTO validationRequest = createValidationRequest(accessToken, resource); + stub = (OAuth2TokenValidationServiceStub) this.stubs.borrowObject(); + validationResponse = + stub.findOAuthConsumerIfTokenIsValid(validationRequest).getAccessTokenValidationResponse(); + } catch (RemoteException e) { + throw new OAuthTokenValidationException("Remote Exception occurred while invoking the Remote " + + "IS server for OAuth2 token validation.", e); + } catch (Exception e) { + throw new OAuthTokenValidationException("Error occurred while borrowing an oauth token validation " + + "service stub from the pool", e); + } finally { + try { + this.stubs.returnObject(stub); + } catch (Exception e) { + log.warn("Error occurred while returning the object back to the oauth token validation service " + + "stub pool", e); + } + } + + if (validationResponse == null) { + if (log.isDebugEnabled()) { + log.debug("Response returned by the OAuth token validation service is null"); + } + return null; + } + + boolean isValid = validationResponse.getValid(); + String tenantDomain; + String username; + if (isValid) { + username = MultitenantUtils.getTenantAwareUsername(validationResponse.getAuthorizedUser()); + tenantDomain = MultitenantUtils.getTenantDomain(validationResponse.getAuthorizedUser()); + } else { + OAuthValidationResponse oAuthValidationResponse = new OAuthValidationResponse(); + oAuthValidationResponse.setErrorMsg(validationResponse.getErrorMsg()); + return oAuthValidationResponse; + } + return new OAuthValidationResponse(username, tenantDomain, isValid); + } + + private OAuth2TokenValidationRequestDTO createValidationRequest(String accessToken, String resource) { + OAuth2TokenValidationRequestDTO validationRequest = new OAuth2TokenValidationRequestDTO(); + OAuth2TokenValidationRequestDTO_OAuth2AccessToken oauthToken = + new OAuth2TokenValidationRequestDTO_OAuth2AccessToken(); + + oauthToken.setTokenType("bearer"); + oauthToken.setIdentifier(accessToken); + validationRequest.setAccessToken(oauthToken); + + OAuth2TokenValidationRequestDTO_TokenValidationContextParam resourceContextParam = + new OAuth2TokenValidationRequestDTO_TokenValidationContextParam(); + + resourceContextParam.setKey("resource"); + resourceContextParam.setValue(resource); + + OAuth2TokenValidationRequestDTO_TokenValidationContextParam[] tokenValidationContextParams = + new OAuth2TokenValidationRequestDTO_TokenValidationContextParam[1]; + + tokenValidationContextParams[0] = resourceContextParam; + validationRequest.setContext(tokenValidationContextParams); + + return validationRequest; + } + +} diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/beans/CacheEntry.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/beans/CacheEntry.java index d8ed5d476..1aff89acf 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/beans/CacheEntry.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/beans/CacheEntry.java @@ -1,40 +1,35 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.wso2.carbon.mdm.mobileservices.windows.common.beans; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; +import java.io.Serializable; /** * Class for java CacheEntry */ -@ApiModel(value = "CacheEntry", - description = "This class carries all information related to token cache") -public class CacheEntry { - - @ApiModelProperty(name = "deviceID", value = "Windows deviceIdentifier", required = true) +public class CacheEntry implements Serializable { private String deviceID; - @ApiModelProperty(name = "username", value = "Enrolled User", required = true) private String username; - @ApiModelProperty(name = "ownership", value = "Enrollment ownership(BYOD/COPE)", required = true) private String ownership; + private static final long serialVersionUID = 19981017L; + public String getOwnership() { return ownership; } diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/beans/Token.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/beans/Token.java index f55124e6e..cabbbf96d 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/beans/Token.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/beans/Token.java @@ -1,34 +1,27 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.wso2.carbon.mdm.mobileservices.windows.common.beans; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - /** * Class for challenge token */ -@ApiModel(value = "Token", description = "Details related device encryption.") public class Token { - - @ApiModelProperty(name = "challengeToken", - value = "Enrollment Binary security token", required = true) private String challengeToken; public String getChallengeToken() { diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/beans/WindowsPluginProperties.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/beans/WindowsPluginProperties.java deleted file mode 100644 index ba3fac6e3..000000000 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/beans/WindowsPluginProperties.java +++ /dev/null @@ -1,103 +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.mdm.mobileservices.windows.common.beans; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - -/** - * Bean class for storing Windows plugin properties after reading the property file. - */ -@ApiModel(value = "WindowsPluginProperties", description = "Windows plugin related properties.") -public class WindowsPluginProperties { - - @ApiModelProperty(name = "keyStorePassword", value = "Password of the keyStore.", required = true) - private String keyStorePassword; - @ApiModelProperty(name = "privateKeyPassword", value = "password of the privateKey.", required = true) - private String privateKeyPassword; - @ApiModelProperty(name = "commonName", value = "Common Name of the certificate.", required = true) - private String commonName; - @ApiModelProperty(name = "authPolicy", value = "Windows enrollment authentication policy(Federated/on-premise).", required = true) - private String authPolicy; - @ApiModelProperty(name = "domain", value = "Domain of the given Email.", required = true) - private String domain; - @ApiModelProperty(name = "notBeforeDays", value = "Number of days to before the certificate expire.", required = true) - private int notBeforeDays; - @ApiModelProperty(name = "notAfterDays", value = "Number of days to after the certificate has been expired.", required = true) - private int notAfterDays; - - public String getKeyStorePassword() { - return keyStorePassword; - } - - public String getPrivateKeyPassword() { - return privateKeyPassword; - } - - public String getCommonName() { - return commonName; - } - - public int getNotBeforeDays() { - return notBeforeDays; - } - - public int getNotAfterDays() { - return notAfterDays; - } - - public void setKeyStorePassword(String keyStorePassword) { - this.keyStorePassword = keyStorePassword; - } - - public void setPrivateKeyPassword(String privateKeyPassword) { - this.privateKeyPassword = privateKeyPassword; - } - - public void setCommonName(String commonName) { - this.commonName = commonName; - } - - public void setNotBeforeDays(int notBeforeDays) { - this.notBeforeDays = notBeforeDays; - } - - public void setNotAfterDays(int notAfterDays) { - this.notAfterDays = notAfterDays; - } - - public String getAuthPolicy() { - return authPolicy; - } - - public void setAuthPolicy(String authPolicy) { - this.authPolicy = authPolicy; - } - - public String getDomain() { - return domain; - } - - public void setDomain(String domain) { - this.domain = domain; - } - - -} - diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/exceptions/AuthenticationException.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/exceptions/AuthenticationException.java index 5d4196a6a..8e827ce77 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/exceptions/AuthenticationException.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/exceptions/AuthenticationException.java @@ -1,17 +1,17 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/exceptions/BadRequestException.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/exceptions/BadRequestException.java index 878475796..dbe1b3f60 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/exceptions/BadRequestException.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/exceptions/BadRequestException.java @@ -1,17 +1,17 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ @@ -30,7 +30,7 @@ import javax.ws.rs.core.Response; public class BadRequestException extends WebApplicationException { public BadRequestException(Message message, MediaType mediaType) { - super(Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(message). + super(Response.status(Response.Status.BAD_REQUEST).entity(message). type(mediaType).build()); } } \ No newline at end of file diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/exceptions/CertificateGenerationException.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/exceptions/CertificateGenerationException.java index 12330b475..ce2f135db 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/exceptions/CertificateGenerationException.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/exceptions/CertificateGenerationException.java @@ -1,17 +1,17 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/exceptions/FileOperationException.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/exceptions/FileOperationException.java index c119b298e..4fbc04398 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/exceptions/FileOperationException.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/exceptions/FileOperationException.java @@ -1,17 +1,17 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/exceptions/KeyStoreGenerationException.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/exceptions/KeyStoreGenerationException.java index 35433b10e..4a783abda 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/exceptions/KeyStoreGenerationException.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/exceptions/KeyStoreGenerationException.java @@ -1,17 +1,17 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/exceptions/MDMAPIException.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/exceptions/MDMAPIException.java index d075c9937..ec705496a 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/exceptions/MDMAPIException.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/exceptions/MDMAPIException.java @@ -1,17 +1,17 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ @@ -19,7 +19,7 @@ package org.wso2.carbon.mdm.mobileservices.windows.common.exceptions; /** - * MDMAPIUtils class provides utility function used by CDM REST-API classes. + * MDMAPIUtils class provides utility function which are used by CDM REST-API classes. */ public class MDMAPIException extends Exception { diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/exceptions/OAuthTokenValidationException.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/exceptions/OAuthTokenValidationException.java new file mode 100644 index 000000000..0e757d5c4 --- /dev/null +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/exceptions/OAuthTokenValidationException.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2015, 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.mdm.mobileservices.windows.common.exceptions; + +/** + * Custom exception to be thrown inside OAuthTokenValidation related functionality. + */ +public class OAuthTokenValidationException extends Exception { + private static final long serialVersionUID = -3151279311929070297L; + + private String errorMessage; + + public String getErrorMessage() { + return errorMessage; + } + + public void setErrorMessage(String errorMessage) { + this.errorMessage = errorMessage; + } + + public OAuthTokenValidationException(String msg, Exception nestedEx) { + super(msg, nestedEx); + setErrorMessage(msg); + } + + public OAuthTokenValidationException(String message, Throwable cause) { + super(message, cause); + setErrorMessage(message); + } + + public OAuthTokenValidationException(String msg) { + super(msg); + setErrorMessage(msg); + } + + public OAuthTokenValidationException() { + super(); + } + + public OAuthTokenValidationException(Throwable cause) { + super(cause); + } +} diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/exceptions/SyncmlMessageFormatException.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/exceptions/SyncmlMessageFormatException.java index aae1b738e..e37b8b6b5 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/exceptions/SyncmlMessageFormatException.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/exceptions/SyncmlMessageFormatException.java @@ -1,17 +1,17 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/exceptions/SyncmlOperationException.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/exceptions/SyncmlOperationException.java index d326877d5..409ca57e0 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/exceptions/SyncmlOperationException.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/exceptions/SyncmlOperationException.java @@ -1,17 +1,17 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/exceptions/WAPProvisioningException.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/exceptions/WAPProvisioningException.java index 7485221df..d23368332 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/exceptions/WAPProvisioningException.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/exceptions/WAPProvisioningException.java @@ -1,17 +1,17 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/exceptions/WindowsConfigurationException.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/exceptions/WindowsConfigurationException.java index 3a7543a22..ba02b1fee 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/exceptions/WindowsConfigurationException.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/exceptions/WindowsConfigurationException.java @@ -1,17 +1,17 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ @@ -19,7 +19,7 @@ package org.wso2.carbon.mdm.mobileservices.windows.common.exceptions; /** - * Custom class for windows API configurations. + * Custom class for windows device configurations. */ public class WindowsConfigurationException extends Exception { diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/exceptions/WindowsDeviceEnrolmentException.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/exceptions/WindowsDeviceEnrolmentException.java index f2a13aa48..4722b7621 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/exceptions/WindowsDeviceEnrolmentException.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/exceptions/WindowsDeviceEnrolmentException.java @@ -1,17 +1,17 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/exceptions/WindowsOperationsException.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/exceptions/WindowsOperationsException.java index de8061c0e..14677391d 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/exceptions/WindowsOperationsException.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/exceptions/WindowsOperationsException.java @@ -1,17 +1,17 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * you may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/util/AuthenticationInfo.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/util/AuthenticationInfo.java index 91a5ba3b5..80458a50a 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/util/AuthenticationInfo.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/util/AuthenticationInfo.java @@ -1,40 +1,30 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * you may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.wso2.carbon.mdm.mobileservices.windows.common.util; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - /** * DTO class to hold the information of authenticated user. */ -@ApiModel(value = "ApplicationInstallation", - description = "This class carries all information related to install application") - public class AuthenticationInfo { - @ApiModelProperty(name = "message", value = "Authentication info message.", required = true) private String message; - @ApiModelProperty(name = "username", value = "Username of the enrolled user.", required = true) private String username; - @ApiModelProperty(name = "tenantDomain", value = "Enrolled user's tenant domain.", required = true) private String tenantDomain; - @ApiModelProperty(name = "tenantId", value = "Enrolled user's tenant ID)", required = true) private int tenantId = -1; public String getUsername() { diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/util/BSTValidator.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/util/BSTValidator.java index 603d6411a..c21b558d0 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/util/BSTValidator.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/util/BSTValidator.java @@ -1,17 +1,17 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * you may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ @@ -19,8 +19,6 @@ package org.wso2.carbon.mdm.mobileservices.windows.common.util; import org.apache.commons.codec.binary.Base64; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.apache.ws.security.WSSecurityException; import org.apache.ws.security.handler.RequestData; import org.apache.ws.security.message.token.BinarySecurity; @@ -28,13 +26,12 @@ import org.apache.ws.security.validate.Credential; import org.apache.ws.security.validate.Validator; import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.device.mgt.common.DeviceManagementException; -import org.wso2.carbon.identity.oauth2.dto.OAuth2TokenValidationRequestDTO; -import org.wso2.carbon.identity.oauth2.dto.OAuth2TokenValidationResponseDTO; import org.wso2.carbon.mdm.mobileservices.windows.common.PluginConstants; +import org.wso2.carbon.mdm.mobileservices.windows.common.authenticator.OAuthValidatorFactory; import org.wso2.carbon.mdm.mobileservices.windows.common.beans.CacheEntry; import org.wso2.carbon.mdm.mobileservices.windows.common.exceptions.AuthenticationException; +import org.wso2.carbon.mdm.mobileservices.windows.common.exceptions.OAuthTokenValidationException; import org.wso2.carbon.mdm.mobileservices.windows.common.exceptions.WindowsDeviceEnrolmentException; -import org.wso2.carbon.utils.multitenancy.MultitenantUtils; import java.util.HashMap; @@ -43,119 +40,98 @@ import java.util.HashMap; */ public class BSTValidator implements Validator { - private static Log log = LogFactory.getLog(BSTValidator.class); - private static final String BEARER_TOKEN_TYPE = "bearer"; - private static final String RESOURCE_KEY = "resource"; - /** * This method validates the binary security token in SOAP message coming from the device. * - * @param credential - binary security token credential object - * @param requestData - Request data associated with the request - * @return - Credential object if authentication is success, or null if not success + * @param credential - binary security token credential object. + * @param requestData - Request data associated with the request. + * @return - Credential object if authentication is success, or null if not success. * @throws WSSecurityException */ @Override public Credential validate(Credential credential, RequestData requestData) throws WSSecurityException { - String encodedBinarySecurityToken; + String bearerToken; String requestedUri; - Credential returnCredentials = null; + Credential userCredentials; HashMap msgContext = (HashMap) requestData.getMsgContext(); requestedUri = msgContext.get(PluginConstants.CXF_REQUEST_URI).toString(); BinarySecurity binarySecurityTokenObject = credential.getBinarySecurityToken(); String binarySecurityToken = binarySecurityTokenObject.getElement().getFirstChild().getTextContent(); Base64 base64 = new Base64(); - encodedBinarySecurityToken = new String(base64.decode(binarySecurityToken)); + bearerToken = new String(base64.decode(binarySecurityToken)); AuthenticationInfo authenticationInfo; try { - authenticationInfo = validateRequest(requestedUri, encodedBinarySecurityToken); - PrivilegedCarbonContext.startTenantFlow(); - PrivilegedCarbonContext privilegedCarbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext(); - privilegedCarbonContext.setTenantId(authenticationInfo.getTenantId()); - privilegedCarbonContext.setTenantDomain(authenticationInfo.getTenantDomain()); - privilegedCarbonContext.setUsername(authenticationInfo.getUsername()); + authenticationInfo = validateRequest(requestedUri, bearerToken); + WindowsAPIUtils.startTenantFlow(authenticationInfo); - if (authenticate(binarySecurityToken)) { - returnCredentials = credential; + if (authenticate(binarySecurityToken, authenticationInfo)) { + userCredentials = credential; } else { - String msg = "Authentication failure due to invalid binary security token."; - log.error(msg); - throw new WindowsDeviceEnrolmentException(msg); + throw new WindowsDeviceEnrolmentException( + "Authentication failure due to invalid binary security token."); } } catch (AuthenticationException e) { - String msg = "Failure occurred in the BST validator."; - log.error(msg, e); - throw new WSSecurityException(msg, e); + throw new WSSecurityException("Failure occurred in the BST validator.", e); } catch (WindowsDeviceEnrolmentException e) { - String msg = "Authentication Failure occurred due to binary security token."; - log.error(msg, e); - throw new WSSecurityException(msg, e); + throw new WSSecurityException("Authentication failure occurred due to binary security token.", e); + } catch (OAuthTokenValidationException e) { + throw new WSSecurityException( + "Failed to authenticate the incoming request due to oauth token validation error.", e); + } finally { + PrivilegedCarbonContext.endTenantFlow(); } - return returnCredentials; + return userCredentials; } /** - * This method authenticates the user checking the binary security token in the user store. + * This method authenticates the client who comes with binary security token. * - * @param binarySecurityToken - Binary security token received in the SOAP message header - * @return - Authentication status + * @param binarySecurityToken - Binary security token received in the SOAP message header. + * @return - Authentication status. * @throws AuthenticationException */ - public boolean authenticate(String binarySecurityToken) throws + private boolean authenticate(String binarySecurityToken, AuthenticationInfo authenticationInfo) throws AuthenticationException { - - CacheEntry cacheentry = (CacheEntry) DeviceUtil.getCacheEntry(binarySecurityToken); - String username = cacheentry.getUsername(); - return username != null; + WindowsAPIUtils.startTenantFlow(authenticationInfo); + if (DeviceUtil.getCacheEntry(binarySecurityToken) != null) { + CacheEntry cacheentry = (CacheEntry) DeviceUtil.getCacheEntry(binarySecurityToken); + String username = cacheentry.getUsername(); + return username != null; + } else { + return false; + } } /** * Validate SOAP request token. * - * @param requestedUri- Requested endpoint URI. - * @param encodedBinarySecurityToken-Binary security token comes from the soap request message. + * @param requestedUri -Requested endpoint URI. + * @param binarySecurityToken -Binary security token comes from the soap request message. * @return returns authorized user information. * @throws WindowsDeviceEnrolmentException */ - public AuthenticationInfo validateRequest(String requestedUri, String encodedBinarySecurityToken) - throws WindowsDeviceEnrolmentException { + private AuthenticationInfo validateRequest(String requestedUri, String binarySecurityToken) + throws WindowsDeviceEnrolmentException, OAuthTokenValidationException { AuthenticationInfo authenticationInfo = new AuthenticationInfo(); - // Create a OAuth2TokenValidationRequestDTO object for validating access token - OAuth2TokenValidationRequestDTO dto = new OAuth2TokenValidationRequestDTO(); - //Set the access token info - OAuth2TokenValidationRequestDTO.OAuth2AccessToken oAuth2AccessToken = dto.new OAuth2AccessToken(); - oAuth2AccessToken.setTokenType(BSTValidator.BEARER_TOKEN_TYPE); - oAuth2AccessToken.setIdentifier(encodedBinarySecurityToken); - dto.setAccessToken(oAuth2AccessToken); - - //Set the resource context param. This will be used in scope validation. - OAuth2TokenValidationRequestDTO.TokenValidationContextParam - resourceContextParam = dto.new TokenValidationContextParam(); - resourceContextParam.setKey(BSTValidator.RESOURCE_KEY); - resourceContextParam.setValue(requestedUri + ":POST"); - - OAuth2TokenValidationRequestDTO.TokenValidationContextParam[] - tokenValidationContextParams = - new OAuth2TokenValidationRequestDTO.TokenValidationContextParam[1]; - tokenValidationContextParams[0] = resourceContextParam; - dto.setContext(tokenValidationContextParams); + String resource = requestedUri + ":POST"; + OAuthValidationResponse oAuthValidationResponse = OAuthValidatorFactory.getValidator(). + validateToken(binarySecurityToken, resource); try { - OAuth2TokenValidationResponseDTO oAuth2TokenValidationResponseDTO = - WindowsAPIUtils.getOAuth2TokenValidationService().validate(dto); - if (oAuth2TokenValidationResponseDTO.isValid()) { - String username = oAuth2TokenValidationResponseDTO.getAuthorizedUser(); + if (oAuthValidationResponse.isValid()) { + String username = oAuthValidationResponse.getUserName(); + String tenantDomain = oAuthValidationResponse.getTenantDomain(); + authenticationInfo.setUsername(username); - authenticationInfo.setTenantDomain(MultitenantUtils.getTenantDomain(username)); - authenticationInfo.setTenantId(WindowsAPIUtils.getTenantIdOFUser(username)); + authenticationInfo.setTenantDomain(tenantDomain); + authenticationInfo.setTenantId(WindowsAPIUtils.getTenantIdOFUser(username + "@" + tenantDomain)); } else { - authenticationInfo.setMessage(oAuth2TokenValidationResponseDTO.getErrorMsg()); + authenticationInfo.setMessage(oAuthValidationResponse.getErrorMsg()); } } catch (DeviceManagementException e) { - String msg = "Authentication failure due to invalid binary security token."; - log.error(msg, e); - throw new WindowsDeviceEnrolmentException(msg, e); + throw new WindowsDeviceEnrolmentException( + "Authentication failure due to invalid binary security token.", e); } return authenticationInfo; } diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/util/ConfigInitializerContextListener.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/util/ConfigInitializerContextListener.java deleted file mode 100644 index 777ddc599..000000000 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/util/ConfigInitializerContextListener.java +++ /dev/null @@ -1,138 +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.mdm.mobileservices.windows.common.util; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.w3c.dom.Document; -import org.wso2.carbon.mdm.mobileservices.windows.common.PluginConstants; -import org.wso2.carbon.mdm.mobileservices.windows.common.beans.WindowsPluginProperties; -import org.xml.sax.SAXException; - -import javax.servlet.ServletContext; -import javax.servlet.ServletContextEvent; -import javax.servlet.ServletContextListener; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; -import java.io.File; -import java.io.IOException; - -/** - * This class performs one time operations. - */ -public class ConfigInitializerContextListener implements ServletContextListener { - - public static final int INITIAL_VALUE = 0; - private static Log log = LogFactory.getLog(ConfigInitializerContextListener.class); - - private enum PropertyName { - PROPERTY_SIGNED_CERT_CN("SignedCertCN"), - PROPERTY_SIGNED_CERT_NOT_BEFORE("SignedCertNotBefore"), - PROPERTY_SIGNED_CERT_NOT_AFTER("SignedCertNotAfter"), - PROPERTY_PASSWORD("Password"), - PROPERTY_PRIVATE_KEY_PASSWORD("PrivateKeyPassword"), - AUTH_POLICY("AuthPolicy"), - DOMAIN("domain"); - - private final String propertyName; - - PropertyName(final String propertyName) { - this.propertyName = propertyName; - } - - public String getValue() { - return this.propertyName; - } - } - - /** - * This method loads wap-provisioning file / property file, sets wap-provisioning file and - * extracted properties as attributes in servlet context. - * - * @param servletContextEvent - Uses when servlet communicating with servlet container. - */ - @Override - public void contextInitialized(ServletContextEvent servletContextEvent) { - - ServletContext servletContext = servletContextEvent.getServletContext(); - File propertyFile = new File(getClass().getClassLoader().getResource( - PluginConstants.CertificateEnrolment.PROPERTIES_XML).getFile()); - DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance(); - DocumentBuilder docBuilder; - Document document = null; - try { - docBuilder = docBuilderFactory.newDocumentBuilder(); - if (docBuilder != null) { - document = docBuilder.parse(propertyFile); - } - } catch (ParserConfigurationException e) { - log.error("Parser configuration failure while reading properties.xml."); - } catch (SAXException e) { - log.error("Parsing error occurred while reading properties.xml."); - } catch (IOException e) { - log.error("File reading error occurred while accessing properties.xml."); - } - - String password = null; - String privateKeyPassword = null; - String signedCertCommonName = null; - String authPolicy = null; - String domain = null; - int signedCertNotBeforeDate = INITIAL_VALUE; - int signedCertNotAfterDate = INITIAL_VALUE; - - if (document != null) { - password = document.getElementsByTagName(PropertyName.PROPERTY_PASSWORD.getValue()).item(0). - getTextContent(); - privateKeyPassword = document.getElementsByTagName(PropertyName.PROPERTY_PRIVATE_KEY_PASSWORD.getValue()). - item(0).getTextContent(); - signedCertCommonName = - document.getElementsByTagName(PropertyName.PROPERTY_SIGNED_CERT_CN.getValue()).item(0). - getTextContent(); - authPolicy = document.getElementsByTagName(PropertyName.AUTH_POLICY.getValue()).item(0). - getTextContent(); - signedCertNotBeforeDate = Integer.valueOf(document.getElementsByTagName( - PropertyName.PROPERTY_SIGNED_CERT_NOT_BEFORE.getValue()).item(0).getTextContent()); - signedCertNotAfterDate = Integer.valueOf(document.getElementsByTagName( - PropertyName.PROPERTY_SIGNED_CERT_NOT_AFTER.getValue()).item(0).getTextContent()); - domain = document.getElementsByTagName(PropertyName.DOMAIN.getValue()).item(0).getTextContent(); - - } - - WindowsPluginProperties properties = new WindowsPluginProperties(); - properties.setKeyStorePassword(password); - properties.setPrivateKeyPassword(privateKeyPassword); - properties.setCommonName(signedCertCommonName); - properties.setNotBeforeDays(signedCertNotBeforeDate); - properties.setNotAfterDays(signedCertNotAfterDate); - properties.setAuthPolicy(authPolicy); - properties.setDomain(domain); - servletContext.setAttribute(PluginConstants.WINDOWS_PLUGIN_PROPERTIES, properties); - - File wapProvisioningFile = new File(getClass().getClassLoader().getResource( - PluginConstants.CertificateEnrolment.WAP_PROVISIONING_XML).getFile()); - servletContext.setAttribute(PluginConstants.CONTEXT_WAP_PROVISIONING_FILE, wapProvisioningFile); - } - - @Override - public void contextDestroyed(ServletContextEvent servletContextEvent) { - } - -} diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/util/ContextInitializer.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/util/ContextInitializer.java new file mode 100644 index 000000000..695708a9b --- /dev/null +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/util/ContextInitializer.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2015, 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.mdm.mobileservices.windows.common.util; + +import org.wso2.carbon.mdm.mobileservices.windows.common.PluginConstants; + +import javax.servlet.ServletContext; +import javax.servlet.ServletContextEvent; +import javax.servlet.ServletContextListener; +import java.io.File; + +/** + * This class performs one time operations. + */ +public class ContextInitializer implements ServletContextListener { + + /** + * This method loads wap-provisioning file and sets wap-provisioning file as attribute in servlet context. + * + * @param servletContextEvent - Uses when servlet communicating with servlet container. + */ + @Override + public void contextInitialized(ServletContextEvent servletContextEvent) { + ServletContext servletContext = servletContextEvent.getServletContext(); + + File wapProvisioningFile = new File(getClass().getClassLoader().getResource( + PluginConstants.CertificateEnrolment.WAP_PROVISIONING_XML).getFile()); + servletContext.setAttribute(PluginConstants.CONTEXT_WAP_PROVISIONING_FILE, wapProvisioningFile); + } + + @Override + public void contextDestroyed(ServletContextEvent servletContextEvent) { + } + +} diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/util/DeviceIDHolder.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/util/DeviceIDHolder.java index a7e6fa532..9e05c9dd8 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/util/DeviceIDHolder.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/util/DeviceIDHolder.java @@ -1,46 +1,41 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * you may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.wso2.carbon.mdm.mobileservices.windows.common.util; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import java.util.List; /** - * Class for holding device ids. + * Class for holding valid and invalid devices. */ -@ApiModel(value = "DeviceIDHolder", description = "This class carries all information related to DeviceIDs") public class DeviceIDHolder { - @ApiModelProperty(name = "errorDeviceIdList", value = "Error occurred DeviceIds.)", required = true) - private List errorDeviceIdList; - @ApiModelProperty(name = "validDeviceIDList", value = "Valid DeviceIDs.)", required = true) + private List invalidDeviceIdList; private List validDeviceIDList; - public List getErrorDeviceIdList() { - return errorDeviceIdList; + public List getInvalidDeviceIdList() { + return invalidDeviceIdList; } - public void setErrorDeviceIdList(List errorDeviceIdList) { - this.errorDeviceIdList = errorDeviceIdList; + public void setInvalidDeviceIdList(List invalidDeviceIdList) { + this.invalidDeviceIdList = invalidDeviceIdList; } public List getValidDeviceIDList() { diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/util/DeviceUtil.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/util/DeviceUtil.java index 207e02293..5f1c90b1b 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/util/DeviceUtil.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/util/DeviceUtil.java @@ -1,24 +1,23 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.wso2.carbon.mdm.mobileservices.windows.common.util; -import org.wso2.carbon.device.mgt.common.DeviceManagementException; import org.wso2.carbon.mdm.mobileservices.windows.common.beans.CacheEntry; import javax.cache.Cache; @@ -29,7 +28,7 @@ import java.util.UUID; import java.util.concurrent.TimeUnit; /** - * Class for generate random token for XCEP and WSTEP + * Class for generate random token for XCEP and WSTEP. */ public class DeviceUtil { @@ -42,7 +41,7 @@ public class DeviceUtil { return String.valueOf(UUID.randomUUID()); } - public static void persistChallengeToken(String token, String deviceID, String username) throws DeviceManagementException { + public static void persistChallengeToken(String token, String deviceID, String username) { Object objCacheEntry = getCacheEntry(token); CacheEntry cacheEntry; @@ -70,12 +69,12 @@ public class DeviceUtil { CacheManager contextCacheManager = Caching.getCacheManager(TOKEN_CACHE_MANAGER). getCache(TOKEN_CACHE).getCacheManager(); if (!isContextCacheInitialized) { + return Caching.getCacheManager(TOKEN_CACHE_MANAGER).getCache(TOKEN_CACHE); + } else { isContextCacheInitialized = true; return contextCacheManager.createCacheBuilder(TOKEN_CACHE_MANAGER).setExpiry( CacheConfiguration.ExpiryType.MODIFIED, new CacheConfiguration.Duration(TimeUnit.MINUTES, CACHE_DURATION)).setStoreByValue(false).build(); - } else { - return Caching.getCacheManager(TOKEN_CACHE_MANAGER).getCache(TOKEN_CACHE); } } } diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/util/ErrorHandler.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/util/ErrorHandler.java index d44749a80..2640302a5 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/util/ErrorHandler.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/util/ErrorHandler.java @@ -1,17 +1,17 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/util/ErrorMessage.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/util/ErrorMessage.java index 961a5a09f..52e120523 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/util/ErrorMessage.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/util/ErrorMessage.java @@ -1,20 +1,21 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ + /** * Generate Error Messages for responses. */ @@ -23,7 +24,6 @@ package org.wso2.carbon.mdm.mobileservices.windows.common.util; public class ErrorMessage { private String errorMessage; - private String errorCode; public String getErrorMessage() { return errorMessage; @@ -33,7 +33,5 @@ public class ErrorMessage { this.errorMessage = errorMessage; } - public String getErrorCode() { - return errorCode; - } + } diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/util/GsonMessageBodyHandler.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/util/GsonMessageBodyHandler.java index 94fc0b437..c71c2675e 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/util/GsonMessageBodyHandler.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/util/GsonMessageBodyHandler.java @@ -1,17 +1,17 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ @@ -60,9 +60,7 @@ public class GsonMessageBodyHandler implements MessageBodyWriter, Messag public Object readFrom(Class objectClass, Type type, Annotation[] annotations, MediaType mediaType, MultivaluedMap stringStringMultivaluedMap, InputStream entityStream) throws IOException, WebApplicationException { - - InputStreamReader reader = new InputStreamReader(entityStream, "UTF-8"); - + InputStreamReader reader = new InputStreamReader(entityStream, UTF_8); try { return getGson().fromJson(reader, type); } finally { diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/util/Message.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/util/Message.java index b358d9122..c3f2cc793 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/util/Message.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/util/Message.java @@ -1,17 +1,17 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/util/OAuthValidationResponse.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/util/OAuthValidationResponse.java new file mode 100644 index 000000000..397b446b6 --- /dev/null +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/util/OAuthValidationResponse.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2015, 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.mdm.mobileservices.windows.common.util; + +/** + * Class for OAuthValidation Response. + */ +public class OAuthValidationResponse { + + private String userName; + private String tenantDomain; + private boolean isValid; + private String errorMsg; + + public OAuthValidationResponse() { + } + + public OAuthValidationResponse(String userName, String tenantDomain, boolean isValid) { + this.userName = userName; + this.tenantDomain = tenantDomain; + this.isValid = isValid; + } + + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + public String getTenantDomain() { + return tenantDomain; + } + + public void setTenantDomain(String tenantDomain) { + this.tenantDomain = tenantDomain; + } + + public boolean isValid() { + return isValid; + } + + public void setIsValid(boolean isValid) { + this.isValid = isValid; + } + + public String getErrorMsg() { + return errorMsg; + } + + public void setErrorMsg(String errorMsg) { + this.errorMsg = errorMsg; + } +} diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/util/SOAPSecurityHandler.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/util/SOAPSecurityHandler.java index a5053d2ef..679ac010c 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/util/SOAPSecurityHandler.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/util/SOAPSecurityHandler.java @@ -1,17 +1,17 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/util/UsernameTokenValidator.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/util/UsernameTokenValidator.java index 982982308..5056df278 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/util/UsernameTokenValidator.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/util/UsernameTokenValidator.java @@ -1,25 +1,23 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.wso2.carbon.mdm.mobileservices.windows.common.util; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.apache.ws.security.WSSecurityException; import org.apache.ws.security.handler.RequestData; import org.apache.ws.security.validate.Credential; @@ -40,7 +38,6 @@ public class UsernameTokenValidator implements Validator { private static final int USER_SEGMENT = 0; private static final int DOMAIN_SEGMENT = 1; private static final String DELIMITER = "@"; - private static Log log = LogFactory.getLog(UsernameTokenValidator.class); /** * This method validates the username token in SOAP message coming from the device. @@ -65,20 +62,12 @@ public class UsernameTokenValidator implements Validator { if (authenticate(user, password, domain)) { returnCredentials = credential; } else { - String msg = "Authentication failure due to incorrect credentials."; - log.error(msg); - throw new WindowsDeviceEnrolmentException(msg); + throw new WindowsDeviceEnrolmentException("Authentication failure due to incorrect credentials."); } - //Generic exception is caught here as there is no need of taking different actions for - //different exceptions. } catch (AuthenticationException e) { - String msg = "Failure occurred in the BST validator."; - log.error(msg, e); - throw new WSSecurityException(msg, e); + throw new WSSecurityException("Failure occurred in the BST validator.", e); } catch (WindowsDeviceEnrolmentException e) { - String msg = "Authentication Failure occurred due to binary security token."; - log.error(msg, e); - throw new WSSecurityException(msg, e); + throw new WSSecurityException("Authentication Failure occurred due to binary security token.", e); } return returnCredentials; } @@ -103,30 +92,21 @@ public class UsernameTokenValidator implements Validator { RealmService realmService = (RealmService) ctx.getOSGiService(RealmService.class, null); if (realmService == null) { - String msg = "RealmService not initialized."; - log.error(msg); - throw new AuthenticationException(msg); + throw new AuthenticationException("RealmService not initialized."); } - int tenantId; if (tenantDomain == null || tenantDomain.trim().isEmpty()) { tenantId = MultitenantConstants.SUPER_TENANT_ID; } else { tenantId = realmService.getTenantManager().getTenantId(tenantDomain); } - if (tenantId == MultitenantConstants.INVALID_TENANT_ID) { - String msg = "Invalid tenant domain " + tenantDomain; - log.error(msg); - throw new AuthenticationException(msg); + throw new AuthenticationException("Invalid tenant domain " + tenantDomain); } UserRealm userRealm = realmService.getTenantUserRealm(tenantId); - return userRealm.getUserStoreManager().authenticate(username, password); } catch (UserStoreException e) { - String msg = "User store is not initialized."; - log.error(msg, e); - throw new AuthenticationException(msg, e); + throw new AuthenticationException("User store is not initialized.", e); } finally { PrivilegedCarbonContext.endTenantFlow(); } diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/util/WindowsAPIUtils.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/util/WindowsAPIUtils.java index 13f115240..72cf1522d 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/util/WindowsAPIUtils.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/util/WindowsAPIUtils.java @@ -1,32 +1,29 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.wso2.carbon.mdm.mobileservices.windows.common.util; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.wso2.carbon.base.MultitenantConstants; -import org.wso2.carbon.certificate.mgt.core.service.CertificateManagementService; import org.wso2.carbon.context.PrivilegedCarbonContext; 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.configuration.mgt.ConfigurationEntry; import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration; import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagementService; import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; @@ -35,13 +32,13 @@ import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; import org.wso2.carbon.identity.core.util.IdentityTenantUtil; import org.wso2.carbon.identity.oauth2.OAuth2TokenValidationService; import org.wso2.carbon.mdm.mobileservices.windows.common.PluginConstants; -import org.wso2.carbon.mdm.mobileservices.windows.common.exceptions.MDMAPIException; import org.wso2.carbon.policy.mgt.core.PolicyManagerService; import org.wso2.carbon.user.api.TenantManager; import org.wso2.carbon.user.api.UserStoreException; -import org.wso2.carbon.user.api.UserStoreManager; import org.wso2.carbon.user.core.service.RealmService; import org.wso2.carbon.utils.multitenancy.MultitenantUtils; +import org.wso2.carbon.webapp.authenticator.framework.config.AuthenticatorConfig; +import org.wso2.carbon.webapp.authenticator.framework.config.AuthenticatorConfigService; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; @@ -52,8 +49,6 @@ import java.util.List; */ public class WindowsAPIUtils { - private static Log log = LogFactory.getLog(WindowsAPIUtils.class); - public static DeviceIdentifier convertToDeviceIdentifierObject(String deviceId) { DeviceIdentifier identifier = new DeviceIdentifier(); identifier.setId(deviceId); @@ -61,59 +56,23 @@ public class WindowsAPIUtils { return identifier; } - public static CertificateManagementService getCertificateManagementService() { - CertificateManagementService cmService; - PrivilegedCarbonContext.startTenantFlow(); - PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); - ctx.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME); - ctx.setTenantId(MultitenantConstants.SUPER_TENANT_ID); - cmService = - (CertificateManagementService)ctx.getOSGiService(DeviceManagementProviderService.class, null); - PrivilegedCarbonContext.endTenantFlow(); - return cmService; - } - public static DeviceManagementProviderService getDeviceManagementService() { PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); DeviceManagementProviderService deviceManagementProviderService = (DeviceManagementProviderService) ctx.getOSGiService(DeviceManagementProviderService.class, null); if (deviceManagementProviderService == null) { - String msg = "Device Management service has not initialized."; - log.error(msg); - throw new IllegalStateException(msg); + throw new IllegalStateException("Device Management service has not initialized."); } return deviceManagementProviderService; } - - public static UserStoreManager getUserStoreManager() throws MDMAPIException { - RealmService realmService; - UserStoreManager userStoreManager; - try { - PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); - realmService = (RealmService) ctx.getOSGiService(RealmService.class, null); - if (realmService == null) { - String msg = "Realm service has not initialized."; - throw new IllegalStateException(msg); - } - int tenantId = ctx.getTenantId(); - userStoreManager = realmService.getTenantUserRealm(tenantId).getUserStoreManager(); - } catch (UserStoreException e) { - String msg = "Error occurred while retrieving current user store manager"; - throw new MDMAPIException(msg, e); - } - return userStoreManager; - } - public static NotificationManagementService getNotificationManagementService() { NotificationManagementService notificationManagementService; PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); - notificationManagementService = (NotificationManagementService) ctx.getOSGiService( - NotificationManagementService.class, null); + notificationManagementService = + (NotificationManagementService) ctx.getOSGiService(NotificationManagementService.class, null); if (notificationManagementService == null) { - String msg = "Notification Management service not initialized."; - log.error(msg); - throw new IllegalStateException(msg); + throw new IllegalStateException("Notification Management service not initialized."); } return notificationManagementService; } @@ -134,25 +93,23 @@ public class WindowsAPIUtils { WindowsDeviceUtils deviceUtils = new WindowsDeviceUtils(); DeviceIDHolder deviceIDHolder = deviceUtils.validateDeviceIdentifiers(deviceIDs, message, responseMediaType); - getDeviceManagementService().addOperation("windows", operation, deviceIDHolder.getValidDeviceIDList()); - if (!deviceIDHolder.getErrorDeviceIdList().isEmpty()) { - return javax.ws.rs.core.Response.status(PluginConstants.StatusCodes. +// getDeviceManagementService().addOperation(operation, deviceIDHolder.getValidDeviceIDList()); + if (!deviceIDHolder.getInvalidDeviceIdList().isEmpty()) { + return Response.status(PluginConstants.StatusCodes. MULTI_STATUS_HTTP_CODE).type( responseMediaType).entity(deviceUtils. - convertErrorMapIntoErrorMessage(deviceIDHolder.getErrorDeviceIdList())).build(); + convertErrorMapIntoErrorMessage(deviceIDHolder.getInvalidDeviceIdList())).build(); } - return javax.ws.rs.core.Response.status(javax.ws.rs.core.Response.Status.CREATED). + return Response.status(Response.Status.CREATED). type(responseMediaType).build(); } public static PolicyManagerService getPolicyManagerService() { PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); - PolicyManagerService policyManagerService = (PolicyManagerService) ctx.getOSGiService( - PolicyManagerService.class, null); + PolicyManagerService policyManagerService = + (PolicyManagerService) ctx.getOSGiService(PolicyManagerService.class, null); if (policyManagerService == null) { - String msg = "Policy Manager service has not initialized"; - log.error(msg); - throw new IllegalStateException(msg); + throw new IllegalStateException("Policy Manager service has not initialized"); } return policyManagerService; } @@ -165,6 +122,14 @@ public class WindowsAPIUtils { getDeviceManagementService().updateOperation(deviceIdentifier, operation); } + public static List getPendingOperations(DeviceIdentifier deviceIdentifier) + throws OperationManagementException, DeviceManagementException { + List pendingDataOperations; + pendingDataOperations = WindowsAPIUtils.getDeviceManagementService().getOperationsByDeviceAndStatus( + deviceIdentifier, Operation.Status.PENDING); + return pendingDataOperations; + } + public static PlatformConfiguration getTenantConfiguration() throws DeviceManagementException { return getDeviceManagementService().getConfiguration( DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS); @@ -172,16 +137,20 @@ public class WindowsAPIUtils { public static int getTenantIdOFUser(String username) throws DeviceManagementException { int tenantId = 0; + RealmService realmService; String domainName = MultitenantUtils.getTenantDomain(username); if (domainName != null) { try { - TenantManager tenantManager = IdentityTenantUtil.getRealmService().getTenantManager(); - tenantId = tenantManager.getTenantId(domainName); + if ((realmService = IdentityTenantUtil.getRealmService()) != null) { + TenantManager tenantManager = realmService.getTenantManager(); + tenantId = tenantManager.getTenantId(domainName); + } + if (realmService == null) { + throw new IllegalStateException("Realm service has not initialized."); + } } catch (UserStoreException e) { - String errorMsg = "Error when getting the tenant id from the tenant domain : " + - domainName; - log.error(errorMsg, e); - throw new DeviceManagementException(errorMsg, e); + throw new DeviceManagementException("Error when getting the tenant id from the tenant domain : " + + domainName, e); } } return tenantId; @@ -192,19 +161,50 @@ public class WindowsAPIUtils { OAuth2TokenValidationService oAuth2TokenValidationService = (OAuth2TokenValidationService) ctx.getOSGiService(OAuth2TokenValidationService.class, null); if (oAuth2TokenValidationService == null) { - String msg = "OAuth2TokenValidation service has not initialized."; - log.error(msg); - throw new IllegalStateException(msg); + throw new IllegalStateException("OAuth2TokenValidation service has not initialized."); } return oAuth2TokenValidationService; } - public static void startTenantFlow(String userName) { + public static AuthenticatorConfig getBSTAuthenticatorConfig() { + PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); + AuthenticatorConfigService authenticatorConfigService = + (AuthenticatorConfigService) ctx.getOSGiService(AuthenticatorConfigService.class, null); + AuthenticatorConfig authenticatorConfig = authenticatorConfigService.getAuthenticatorConfig("BST"); + if (authenticatorConfigService == null) { + throw new IllegalStateException("AuthenticatorConfiguration service has not initialized."); + } + if (authenticatorConfig == null) { + throw new IllegalStateException("BST authenticatorConfig has not initialized."); + } + return authenticatorConfig; + } + + public static void startTenantFlow(AuthenticationInfo authenticationInfo) { PrivilegedCarbonContext.startTenantFlow(); - PrivilegedCarbonContext privilegedCarbonContext = PrivilegedCarbonContext. - getThreadLocalCarbonContext(); - privilegedCarbonContext.setTenantId(MultitenantConstants.SUPER_TENANT_ID); - privilegedCarbonContext.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME); - privilegedCarbonContext.setUsername(userName); + PrivilegedCarbonContext privilegedCarbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext(); + if (authenticationInfo.getTenantDomain() == null) { + privilegedCarbonContext.setTenantId(MultitenantConstants.SUPER_TENANT_ID); + privilegedCarbonContext.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME); + } else { + privilegedCarbonContext.setTenantId(authenticationInfo.getTenantId()); + privilegedCarbonContext.setTenantDomain(authenticationInfo.getTenantDomain()); + } + privilegedCarbonContext.setUsername(authenticationInfo.getUsername()); + } + + /** + * This method is used to get tenant configurations. + * + * @return List of Configurations entries. + * @throws DeviceManagementException + */ + public static List getTenantConfigurationData() throws DeviceManagementException { + PlatformConfiguration tenantConfiguration; + if ((tenantConfiguration = WindowsAPIUtils.getTenantConfiguration()) != null) { + return tenantConfiguration.getConfiguration(); + } else { + return null; + } } } diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/util/WindowsDeviceUtils.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/util/WindowsDeviceUtils.java index 335487b81..b1bb0b5cc 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/util/WindowsDeviceUtils.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/util/WindowsDeviceUtils.java @@ -1,17 +1,17 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ @@ -43,8 +43,8 @@ public class WindowsDeviceUtils { message.setResponseMessage("Device identifier list is empty"); throw new BadRequestException(message, responseMediaType); } - List errorDeviceIdList = new ArrayList(); - List validDeviceIDList = new ArrayList(); + List errorDeviceIdList = new ArrayList<>(); + List validDeviceIDList = new ArrayList<>(); int deviceIDCounter = 0; for (String deviceID : deviceIDs) { @@ -75,11 +75,12 @@ public class WindowsDeviceUtils { } DeviceIDHolder deviceIDHolder = new DeviceIDHolder(); deviceIDHolder.setValidDeviceIDList(validDeviceIDList); - deviceIDHolder.setErrorDeviceIdList(errorDeviceIdList); + deviceIDHolder.setInvalidDeviceIdList(errorDeviceIdList); return deviceIDHolder; } public String convertErrorMapIntoErrorMessage(List errorDeviceIdList) { return StringUtils.join(errorDeviceIdList.iterator(), COMMA_SEPARATION_PATTERN); } + } diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/AddTag.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/AddTag.java index a2e45ce3c..43fb0ce4a 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/AddTag.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/AddTag.java @@ -1,25 +1,23 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.wso2.carbon.mdm.mobileservices.windows.operations; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.wso2.carbon.mdm.mobileservices.windows.operations.util.Constants; @@ -30,12 +28,9 @@ import java.util.List; /** * Configurations that needs to be added on the device. */ -@ApiModel(value = "AddTag", description = "This class carries all information related to Syncml AddTag.") public class AddTag { - @ApiModelProperty(name = "commandId", value = "CommandID of the AddTag.", required = true) int commandId = -1; - @ApiModelProperty(name = "items", value = "List of items of the AddTag.", required = true) - List items; + List items; public int getCommandId() { return commandId; @@ -45,11 +40,11 @@ public class AddTag { this.commandId = commandId; } - public List getItems() { + public List getItems() { return items; } - public void setItems(List items) { + public void setItems(List items) { this.items = items; } @@ -62,8 +57,8 @@ public class AddTag { commandId.appendChild(doc.createTextNode(String.valueOf(getCommandId()))); add.appendChild(commandId); } - for (Iterator itemIterator = getItems().iterator(); itemIterator.hasNext(); ) { - Item item = itemIterator.next(); + for (Iterator itemIterator = getItems().iterator(); itemIterator.hasNext();) { + ItemTag item = itemIterator.next(); if (item != null) { item.buildItemElement(doc, add); } diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/Alert.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/AlertTag.java similarity index 74% rename from components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/Alert.java rename to components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/AlertTag.java index 40a9aace1..ab30ea604 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/Alert.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/AlertTag.java @@ -1,25 +1,23 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.wso2.carbon.mdm.mobileservices.windows.operations; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.wso2.carbon.mdm.mobileservices.windows.operations.util.Constants; @@ -27,12 +25,9 @@ import org.wso2.carbon.mdm.mobileservices.windows.operations.util.Constants; /** * Inform an event occurred from device to server. */ -@ApiModel(value = "Alert", - description = "This class carries all information related to Syncml alert.") -public class Alert { - @ApiModelProperty(name = "commandId", value = "CommandId of The Syncml Alert.", required = true) +public class AlertTag { + int commandId = -1; - @ApiModelProperty(name = "data", value = "Data of the AlertTag.", required = true) String data; public int getCommandId() { diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/AtomicTag.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/AtomicTag.java index 29d2d9672..7cd06bc8f 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/AtomicTag.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/AtomicTag.java @@ -1,25 +1,23 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.wso2.carbon.mdm.mobileservices.windows.operations; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.wso2.carbon.mdm.mobileservices.windows.operations.util.Constants; @@ -30,20 +28,16 @@ import java.util.List; /** * Wrapper for other SyncML elements. */ -@ApiModel(value = "AtomicTag", description = "This class carries all information related to syncml Engine Atomic tag") public class AtomicTag { - @ApiModelProperty(name = "commandId", value = "Syncml Atomic tag CommandId", required = true) int commandId = -1; - @ApiModelProperty(name = "adds", value = "List of addtags", required = true) List adds; - @ApiModelProperty(name = "replaces", value = "List of replace tags", required = true) - List replaces; + List replaces; - public List getReplaces() { + public List getReplaces() { return replaces; } - public void setReplaces(List replaces) { + public void setReplaces(List replaces) { this.replaces = replaces; } @@ -80,8 +74,8 @@ public class AtomicTag { } } if (getReplaces() != null) { - for (Iterator replaceIterator = getReplaces().iterator(); replaceIterator.hasNext(); ) { - Replace add = replaceIterator.next(); + for (Iterator replaceIterator = getReplaces().iterator(); replaceIterator.hasNext(); ) { + ReplaceTag add = replaceIterator.next(); if (add != null) { add.buildReplaceElement(doc, atomic); } diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/ChallengeTag.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/ChallengeTag.java index 2985caf84..1a2666089 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/ChallengeTag.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/ChallengeTag.java @@ -1,25 +1,23 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.wso2.carbon.mdm.mobileservices.windows.operations; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.wso2.carbon.mdm.mobileservices.windows.operations.util.Constants; @@ -27,10 +25,7 @@ import org.wso2.carbon.mdm.mobileservices.windows.operations.util.Constants; /** * Challenge data pass through the device and Device Management server for the security purpose. */ -@ApiModel(value = "ChallengeTag", - description = "This class carries all information related to install application") public class ChallengeTag { - @ApiModelProperty(name = "meta", value = "Syncml MetaTag", required = true) MetaTag meta; public MetaTag getMeta() { @@ -41,11 +36,11 @@ public class ChallengeTag { this.meta = meta; } - public void buildChallElement(Document doc, Element rootElement) { - Element chal = doc.createElement(Constants.CHALLENGE); - rootElement.appendChild(chal); + public void buildChallengeElement(Document doc, Element rootElement) { + Element challenge = doc.createElement(Constants.CHALLENGE); + rootElement.appendChild(challenge); if (getMeta() != null) { - getMeta().buildMetaElement(doc, chal); + getMeta().buildMetaElement(doc, challenge); } } } diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/Credential.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/CredentialTag.java similarity index 72% rename from components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/Credential.java rename to components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/CredentialTag.java index f12dc3111..726d9a6f6 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/Credential.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/CredentialTag.java @@ -1,25 +1,23 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.wso2.carbon.mdm.mobileservices.windows.operations; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.wso2.carbon.mdm.mobileservices.windows.operations.util.Constants; @@ -27,12 +25,8 @@ import org.wso2.carbon.mdm.mobileservices.windows.operations.util.Constants; /** * Credentials passed between the device and the server for security purposes. */ -@ApiModel(value = "Credential", - description = "This class carries all information related to syncml credentials") -public class Credential { - @ApiModelProperty(name = "meta", value = "Syncml credential's MetaTag reference.)", required = true) +public class CredentialTag { MetaTag meta; - @ApiModelProperty(name = "data", value = "Data of the Credential Tag.)", required = true) String data; public MetaTag getMeta() { diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/DeleteTag.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/DeleteTag.java index f357d0a3e..afcaf3194 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/DeleteTag.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/DeleteTag.java @@ -1,25 +1,23 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.wso2.carbon.mdm.mobileservices.windows.operations; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.wso2.carbon.mdm.mobileservices.windows.operations.util.Constants; @@ -30,13 +28,9 @@ import java.util.List; /** * Configurations that need to be delete on Device. */ -@ApiModel(value = "DeleteTag", - description = "This class carries all information related to Syncml DeleteTag.") public class DeleteTag { - @ApiModelProperty(name = "commandId", value = "CommandId of the Syncl DeleteTag.", required = true) int commandId = -1; - @ApiModelProperty(name = "items", value = "List of items of the syncml DeleteTag. ", required = true) - List items; + List items; public int getCommandId() { return commandId; @@ -46,11 +40,11 @@ public class DeleteTag { this.commandId = commandId; } - public List getItems() { + public List getItems() { return items; } - public void setItems(List items) { + public void setItems(List items) { this.items = items; } @@ -63,8 +57,8 @@ public class DeleteTag { commandId.appendChild(doc.createTextNode(String.valueOf(getCommandId()))); delete.appendChild(commandId); } - for (Iterator itemIterator = getItems().iterator(); itemIterator.hasNext(); ) { - Item item = itemIterator.next(); + for (Iterator itemIterator = getItems().iterator(); itemIterator.hasNext(); ) { + ItemTag item = itemIterator.next(); if (item != null) { item.buildItemElement(doc, delete); } diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/ExecuteTag.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/ExecuteTag.java index f8e10e5c8..38b6ff673 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/ExecuteTag.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/ExecuteTag.java @@ -1,25 +1,23 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.wso2.carbon.mdm.mobileservices.windows.operations; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.wso2.carbon.mdm.mobileservices.windows.operations.util.Constants; @@ -30,13 +28,9 @@ import java.util.List; /** * Commands that needs to be executed on the device. */ -@ApiModel(value = "ExecuteTag", - description = "This class carries all information related to Syncml ExecuteTag.") public class ExecuteTag { - @ApiModelProperty(name = "type", value = "CommandId of the syncml ExecuteTag.", required = true) int commandId = -1; - @ApiModelProperty(name = "type", value = "List of items of the Syncml ExecuteTag.", required = true) - List items; + List items; public int getCommandId() { return commandId; @@ -46,11 +40,11 @@ public class ExecuteTag { this.commandId = commandId; } - public List getItems() { + public List getItems() { return items; } - public void setItems(List items) { + public void setItems(List items) { this.items = items; } @@ -63,8 +57,8 @@ public class ExecuteTag { commandId.appendChild(doc.createTextNode(String.valueOf(getCommandId()))); exec.appendChild(commandId); } - for (Iterator itemIterator = getItems().iterator(); itemIterator.hasNext(); ) { - Item item = itemIterator.next(); + for (Iterator itemIterator = getItems().iterator(); itemIterator.hasNext(); ) { + ItemTag item = itemIterator.next(); if (item != null) { item.buildItemElement(doc, exec); } diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/Get.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/GetTag.java similarity index 67% rename from components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/Get.java rename to components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/GetTag.java index 57389415c..8d26a45ba 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/Get.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/GetTag.java @@ -1,25 +1,23 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.wso2.carbon.mdm.mobileservices.windows.operations; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.wso2.carbon.mdm.mobileservices.windows.operations.util.Constants; @@ -30,13 +28,9 @@ import java.util.List; /** * Data that needs to be retrieved from the device. */ -@ApiModel(value = "Get", - description = "This class carries all information related to syncml GetTag.") -public class Get { - @ApiModelProperty(name = "commandId", value = "CommandId of the syncml GetTag.", required = true) +public class GetTag { int commandId = -1; - @ApiModelProperty(name = "items", value = "List of items of the Syncml GetTag.", required = true) - List items; + List items; public int getCommandId() { return commandId; @@ -46,11 +40,11 @@ public class Get { this.commandId = commandId; } - public List getItems() { + public List getItems() { return items; } - public void setItems(List items) { + public void setItems(List items) { this.items = items; } @@ -64,8 +58,8 @@ public class Get { get.appendChild(commandId); } if (getItems() != null) { - for (Iterator itemIterator = getItems().iterator(); itemIterator.hasNext(); ) { - Item item = itemIterator.next(); + for (Iterator itemIterator = getItems().iterator(); itemIterator.hasNext(); ) { + ItemTag item = itemIterator.next(); if (item != null) { item.buildItemElement(doc, get); } diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/Item.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/ItemTag.java similarity index 66% rename from components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/Item.java rename to components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/ItemTag.java index 595640332..b586f050e 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/Item.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/ItemTag.java @@ -1,25 +1,23 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.wso2.carbon.mdm.mobileservices.windows.operations; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.wso2.carbon.mdm.mobileservices.windows.operations.util.Constants; @@ -27,16 +25,11 @@ import org.wso2.carbon.mdm.mobileservices.windows.operations.util.Constants; /** * Represents an items that should be retrieved from the device or a command. */ -@ApiModel(value = "Item", - description = "This class carries all information related to Syncml Item.") -public class Item { - @ApiModelProperty(name = "target", value = "Target reference value of the Syncml Message(ex:Device).", required = true) - Target target; - @ApiModelProperty(name = "source", value = "Source reference of the syncml message.(Ex:EMM Server).", required = true) - Source source; - @ApiModelProperty(name = "data", value = "Content of the syncml message.", required = true) +public class ItemTag { + + TargetTag target; + SourceTag source; String data; - @ApiModelProperty(name = "meta", value = "Meta data of the syncml messsage.", required = true) MetaTag meta; public MetaTag getMeta() { @@ -55,19 +48,19 @@ public class Item { this.data = data; } - public Source getSource() { + public SourceTag getSource() { return source; } - public void setSource(Source source) { + public void setSource(SourceTag source) { this.source = source; } - public Target getTarget() { + public TargetTag getTarget() { return target; } - public void setTarget(Target target) { + public void setTarget(TargetTag target) { this.target = target; } diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/MetaTag.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/MetaTag.java index b6b1e145e..fd22b710f 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/MetaTag.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/MetaTag.java @@ -1,25 +1,23 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.wso2.carbon.mdm.mobileservices.windows.operations; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import org.w3c.dom.Attr; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -28,13 +26,10 @@ import org.wso2.carbon.mdm.mobileservices.windows.operations.util.Constants; /** * MetaTag data related to credentials. */ -@ApiModel(value = "MetaTag", description = "This class carries all information related to MetaTag") public class MetaTag { - @ApiModelProperty(name = "format", value = "MetaTag format.)", required = true) + String format; - @ApiModelProperty(name = "type", value = "MetaTag type)", required = true) String type; - @ApiModelProperty(name = "nextNonce", value = "Syncml Nextnonce)", required = true) String nextNonce; public String getNextNonce() { diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/Replace.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/ReplaceTag.java similarity index 66% rename from components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/Replace.java rename to components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/ReplaceTag.java index 3469a590c..f4b7427ab 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/Replace.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/ReplaceTag.java @@ -1,25 +1,23 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.wso2.carbon.mdm.mobileservices.windows.operations; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.wso2.carbon.mdm.mobileservices.windows.operations.util.Constants; @@ -30,13 +28,9 @@ import java.util.List; /** * Commands sent from the device. */ -@ApiModel(value = "Replace", - description = "This class carries all information related to Syncml ReplaceTag.") -public class Replace { - @ApiModelProperty(name = "commandId", value = "CommandId of the syncml ReplaceTag.", required = true) +public class ReplaceTag { int commandId = -1; - @ApiModelProperty(name = "items", value = "List of items of the syncml ReplaceTag.", required = true) - List items; + List items; public int getCommandId() { return commandId; @@ -46,11 +40,11 @@ public class Replace { this.commandId = commandId; } - public List getItems() { + public List getItems() { return items; } - public void setItems(List items) { + public void setItems(List items) { this.items = items; } @@ -64,8 +58,8 @@ public class Replace { replace.appendChild(commandId); } if (getItems() != null) { - for (Iterator itemIterator = getItems().iterator(); itemIterator.hasNext(); ) { - Item item = itemIterator.next(); + for (Iterator itemIterator = getItems().iterator(); itemIterator.hasNext(); ) { + ItemTag item = itemIterator.next(); if (item != null) { item.buildItemElement(doc, replace); } diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/Results.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/ResultsTag.java similarity index 71% rename from components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/Results.java rename to components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/ResultsTag.java index 6c04067c3..a2774c8c4 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/Results.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/ResultsTag.java @@ -1,25 +1,23 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.wso2.carbon.mdm.mobileservices.windows.operations; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.wso2.carbon.mdm.mobileservices.windows.operations.util.Constants; @@ -30,17 +28,11 @@ import java.util.List; /** * Results sent for the requests made to the device. */ -@ApiModel(value = "Results", - description = "This class carries all information related to Syncml Item.") -public class Results { - @ApiModelProperty(name = "commandId", value = "CommandID of the Syncml Results Tag.", required = true) +public class ResultsTag { int commandId = -1; - @ApiModelProperty(name = "messageReference", value = "MessageReference of the Syncml Results Tag.", required = true) int messageReference = -1; - @ApiModelProperty(name = "commandReference", value = "CommandReference of the Syncml Results Tag.", required = true) int commandReference = -1; - @ApiModelProperty(name = "item", value = "List of Items in Syncml ResultTag.", required = true) - List item; + List item; public int getCommandId() { return commandId; @@ -66,11 +58,11 @@ public class Results { this.commandReference = commandReference; } - public List getItem() { + public List getItem() { return item; } - public void setItem(List item) { + public void setItem(List item) { this.item = item; } @@ -93,8 +85,8 @@ public class Results { results.appendChild(messageReference); } if (getItem() != null) { - for (Iterator itemIterator = getItem().iterator(); itemIterator.hasNext(); ) { - Item item = itemIterator.next(); + for (Iterator itemIterator = getItem().iterator(); itemIterator.hasNext(); ) { + ItemTag item = itemIterator.next(); if (item != null) { item.buildItemElement(doc, results); } diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/SequenceTag.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/SequenceTag.java index 47cc6501a..ca8312694 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/SequenceTag.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/SequenceTag.java @@ -1,25 +1,23 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.wso2.carbon.mdm.mobileservices.windows.operations; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.wso2.carbon.mdm.mobileservices.windows.operations.util.Constants; @@ -28,23 +26,16 @@ import java.util.Iterator; import java.util.List; /** - * Sequence data that use to execute tag list + * Class used to build syncml SequenceTag. */ -@ApiModel(value = "SequenceTag", - description = "This class carries all information related to Syncml SequenceTag.") public class SequenceTag { - @ApiModelProperty(name = "commandId", value = "CommandId of the Syncml SequenceTag", required = true) + int commandId; - @ApiModelProperty(name = "exec", value = "ExcecuteTag sequence of the Syncml SequenceTag", required = true) ExecuteTag exec; - @ApiModelProperty(name = "get", value = "GetTag of the syncml SequenceTag.", required = true) - Get get; - @ApiModelProperty(name = "deleteTag", value = "DeleteTag of the syncml SequenceTag.", required = true) + GetTag get; DeleteTag deleteTag; - @ApiModelProperty(name = "atomicTag", value = "AtomicTag sequence of the syncml SequenceTag.", required = true) AtomicTag atomicTag; - @ApiModelProperty(name = "replaces", value = "ReplaceTag of the syncml SequenceTag.", required = true) - List replaces; + List replaces; public DeleteTag getDeleteTag() { return deleteTag; @@ -54,11 +45,11 @@ public class SequenceTag { this.deleteTag = deleteTag; } - public List getReplaces() { + public List getReplaces() { return replaces; } - public void setReplaces(List replaces) { + public void setReplaces(List replaces) { this.replaces = replaces; } @@ -86,11 +77,11 @@ public class SequenceTag { this.commandId = commandId; } - public Get getGet() { + public GetTag getGet() { return get; } - public void setGet(Get get) { + public void setGet(GetTag get) { this.get = get; } @@ -109,18 +100,19 @@ public class SequenceTag { getGet().buildGetElement(doc, sequence); } if (getReplaces() != null) { - for (Iterator replaceIterator = getReplaces().iterator(); replaceIterator.hasNext(); ) { - Replace replace = replaceIterator.next(); + for (Iterator replaceIterator = getReplaces().iterator(); replaceIterator.hasNext(); ) { + ReplaceTag replace = replaceIterator.next(); if (replace != null) { replace.buildReplaceElement(doc, sequence); } } } - if (getAtomicTag() != null) { - getAtomicTag().buildAtomicElement(doc, sequence); - } if (getDeleteTag() != null) { getDeleteTag().buildDeleteElement(doc, sequence); } + if (getAtomicTag() != null) { + getAtomicTag().buildAtomicElement(doc, sequence); + } + } } diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/Source.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/SourceTag.java similarity index 67% rename from components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/Source.java rename to components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/SourceTag.java index b4d866ad1..bfca1adf3 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/Source.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/SourceTag.java @@ -1,25 +1,23 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.wso2.carbon.mdm.mobileservices.windows.operations; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.wso2.carbon.mdm.mobileservices.windows.operations.util.Constants; @@ -27,28 +25,25 @@ import org.wso2.carbon.mdm.mobileservices.windows.operations.util.Constants; /** * Source details of syncml header's. */ -@ApiModel(value = "Source", - description = "This class carries all information related to Syncml source.") -public class Source { - @ApiModelProperty(name = "LocURI", value = "Location URI.(Source Location:Device)", required = true) - private String LocURI; - @ApiModelProperty(name = "LocName", value = "Name of the location", required = true) - private String LocName; +public class SourceTag { + + private String locURI; + private String locName; public String getLocURI() { - return LocURI; + return locURI; } public void setLocURI(String locURI) { - LocURI = locURI; + this.locURI = locURI; } public String getLocName() { - return LocName; + return locName; } public void setLocName(String locName) { - LocName = locName; + this.locName = locName; } public void buildSourceElement(Document doc, Element rootElement) { diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/Status.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/StatusTag.java similarity index 75% rename from components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/Status.java rename to components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/StatusTag.java index 4a595cf0d..d7a0851b9 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/Status.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/StatusTag.java @@ -1,25 +1,23 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.wso2.carbon.mdm.mobileservices.windows.operations; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.wso2.carbon.mdm.mobileservices.windows.operations.util.Constants; @@ -27,26 +25,17 @@ import org.wso2.carbon.mdm.mobileservices.windows.operations.util.Constants; /** * Status of a previously sent message to device; */ -@ApiModel(value = "Status", - description = "This class carries all information related to Syncml Device statuses.") -public class Status { - @ApiModelProperty(name = "commandId", value = "CommandId of the Syncml StatusTag.", required = true) +public class StatusTag { int commandId = -1; - @ApiModelProperty(name = "messageReference", value = "Message referenceId.", required = true) int messageReference = -1; - @ApiModelProperty(name = "commandReference", value = "Command referenceId.", required = true) int commandReference = -1; - @ApiModelProperty(name = "command", value = "Command String.", required = true) String command; - @ApiModelProperty(name = "targetReference", value = "Target reference of the status message.", required = true) String targetReference; - @ApiModelProperty(name = "data", value = "Status data of the message.(ex:200,404,500...)", required = true) String data; - @ApiModelProperty(name = "challenge", value = "Challenge value.", required = true) ChallengeTag challenge; - public Status(int commandId, int messageReference, int commandReference, String command, - String targetReference, String data) { + public StatusTag(int commandId, int messageReference, int commandReference, String command, + String targetReference, String data) { this.commandId = commandId; this.messageReference = messageReference; this.commandReference = commandReference; @@ -55,7 +44,7 @@ public class Status { this.data = data; } - public Status() { + public StatusTag() { } public ChallengeTag getChallenge() { @@ -143,7 +132,7 @@ public class Status { status.appendChild(targetReference); } if (getChallenge() != null) { - getChallenge().buildChallElement(doc, status); + getChallenge().buildChallengeElement(doc, status); } if (getData() != null) { Element data = doc.createElement(Constants.DATA); diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/SyncmlBody.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/SyncmlBody.java index 8710ff743..d8ee2e322 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/SyncmlBody.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/SyncmlBody.java @@ -1,25 +1,23 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.wso2.carbon.mdm.mobileservices.windows.operations; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.wso2.carbon.mdm.mobileservices.windows.operations.util.Constants; @@ -30,23 +28,14 @@ import java.util.List; /** * Represents the body details of a syncml. */ -@ApiModel(value = "SyncmlBody", description = "This class carries all information related to SyncmlBody.") public class SyncmlBody { - @ApiModelProperty(name = "getCommands", value = "Get value of the syncmlBody.", required = true) - Get getCommands; - @ApiModelProperty(name = "exec", value = "List of executeTags in syncmlBody.", required = true) + GetTag getCommands; List exec; - @ApiModelProperty(name = "status", value = "List of statusTags in syncmlBody.", required = true) - List status; - @ApiModelProperty(name = "alert", value = "Alert tag in syncmlBody.", required = true) - Alert alert; - @ApiModelProperty(name = "replace", value = "replace tag in syncmlBody.", required = true) - Replace replace; - @ApiModelProperty(name = "results", value = "Results tag in syncmlBody.", required = true) - Results results; - @ApiModelProperty(name = "sequence", value = "Sequence tag in syncmlBody.", required = true) + List status; + AlertTag alert; + ReplaceTag replace; + ResultsTag results; SequenceTag sequence; - @ApiModelProperty(name = "atomicTag", value = "Atomic tag in syncmlBody.", required = true) AtomicTag atomicTag; public AtomicTag getAtomicTag() { @@ -73,43 +62,43 @@ public class SyncmlBody { this.exec = exec; } - public Results getResults() { + public ResultsTag getResults() { return results; } - public void setResults(Results results) { + public void setResults(ResultsTag results) { this.results = results; } - public Replace getReplace() { + public ReplaceTag getReplace() { return replace; } - public void setReplace(Replace replace) { + public void setReplace(ReplaceTag replace) { this.replace = replace; } - public List getStatus() { + public List getStatus() { return status; } - public void setStatus(List status) { + public void setStatus(List status) { this.status = status; } - public Alert getAlert() { + public AlertTag getAlert() { return alert; } - public void setAlert(Alert alert) { + public void setAlert(AlertTag alert) { this.alert = alert; } - public Get getGet() { + public GetTag getGet() { return getCommands; } - public void setGet(Get get) { + public void setGet(GetTag get) { this.getCommands = get; } diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/SyncmlDocument.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/SyncmlDocument.java index fa63a27a2..284897abe 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/SyncmlDocument.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/SyncmlDocument.java @@ -1,36 +1,31 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.wso2.carbon.mdm.mobileservices.windows.operations; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import org.w3c.dom.Document; import org.w3c.dom.Element; /** * Represents a base format of a syncml document */ -@ApiModel(value = "SyncmlDocument", description = "This class carries all information related to SyncmlDocument.") public class SyncmlDocument { - @ApiModelProperty(name = "header", value = "Header of the syncmlDocument.", required = true) SyncmlHeader header; - @ApiModelProperty(name = "body", value = "Body of the SyncmlDocument.", required = true) SyncmlBody body; public SyncmlHeader getHeader() { diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/SyncmlHeader.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/SyncmlHeader.java index b135837a7..94c0b3402 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/SyncmlHeader.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/SyncmlHeader.java @@ -1,25 +1,23 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.wso2.carbon.mdm.mobileservices.windows.operations; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.wso2.carbon.mdm.mobileservices.windows.operations.util.Constants; @@ -27,19 +25,12 @@ import org.wso2.carbon.mdm.mobileservices.windows.operations.util.Constants; /** * Represents the header details of a syncml. */ -@ApiModel(value = "SyncmlHeader", description = "This class carries all information related to SyncmlHeader.") public class SyncmlHeader { - @ApiModelProperty(name = "sessionId", value = "SessionId of the syncml Message.", required = true) private int sessionId = -1; - @ApiModelProperty(name = "MsgID", value = "MessageId of the syncml Session.", required = true) private int MsgID = -1; - @ApiModelProperty(name = "target", value = "Target of the syncml Message.(Ex:Device/Server.)", required = true) - private Target target; - @ApiModelProperty(name = "source", value = "Source of the Syncml Message.(Ex:Server/Device.)", required = true) - private Source source; - @ApiModelProperty(name = "credential", value = "Credentials of the Syncml header.", required = true) - private Credential credential; - @ApiModelProperty(name = "hexadecimalSessionId", value = "HexaDecimal SessionId of the syncmlHeader.", required = true) + private TargetTag target; + private SourceTag source; + private CredentialTag credential; private String hexadecimalSessionId; public String getHexadecimalSessionId() { @@ -50,11 +41,11 @@ public class SyncmlHeader { this.hexadecimalSessionId = hexSessionId; } - public Credential getCredential() { + public CredentialTag getCredential() { return credential; } - public void setCredential(Credential credential) { + public void setCredential(CredentialTag credential) { this.credential = credential; } @@ -74,19 +65,19 @@ public class SyncmlHeader { this.MsgID = msgID; } - public Target getTarget() { + public TargetTag getTarget() { return target; } - public void setTarget(Target target) { + public void setTarget(TargetTag target) { this.target = target; } - public Source getSource() { + public SourceTag getSource() { return source; } - public void setSource(Source source) { + public void setSource(SourceTag source) { this.source = source; } diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/Target.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/TargetTag.java similarity index 74% rename from components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/Target.java rename to components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/TargetTag.java index 9cb980be9..a134227be 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/Target.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/TargetTag.java @@ -1,25 +1,23 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.wso2.carbon.mdm.mobileservices.windows.operations; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.wso2.carbon.mdm.mobileservices.windows.operations.util.Constants; @@ -27,11 +25,9 @@ import org.wso2.carbon.mdm.mobileservices.windows.operations.util.Constants; /** * Target details of syncml header's. */ -@ApiModel(value = "Target", description = "This class carries all information related to Syncml Target.") -public class Target { - @ApiModelProperty(name = "LocURI", value = "Location URI of the target.", required = true) +public class TargetTag { + private String LocURI; - @ApiModelProperty(name = "LocName", value = "Location Name of the target.", required = true) private String LocName; public String getLocURI() { diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/WindowsOperationException.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/WindowsOperationException.java index 91dbe0cd1..d4202f660 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/WindowsOperationException.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/WindowsOperationException.java @@ -1,17 +1,17 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/util/Constants.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/util/Constants.java index 053fd39ea..30d985120 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/util/Constants.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/util/Constants.java @@ -1,17 +1,17 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ @@ -22,7 +22,6 @@ package org.wso2.carbon.mdm.mobileservices.windows.operations.util; * Constant values used in syncml generator. */ public class Constants { - public static final String PROVIDER_ID = "MobiCDMServer"; public static final String SERVER_SECRET = "dummy"; public static final String INITIAL_NONCE = "ZHVtbXk="; @@ -35,8 +34,6 @@ public class Constants { public static final String UTF_8 = "UTF-8"; public static final String MD5 = "MD5"; public static final String YES = "yes"; - public static final String ERROR = "Error"; - public static final String INFORMATION = "information"; public static final String EXECUTE = "Exec"; public static final String ATOMIC = "Atomic"; @@ -82,17 +79,26 @@ public class Constants { public static final String META_FORMAT_CHARACTER = "chr"; /** - * SynclML service related constants + * SynclML service related constants. */ public final class SyncMLResponseCodes { public static final String AUTHENTICATION_ACCEPTED = "212"; public static final String ACCEPTED = "200"; public static final String ACCEPTED_FOR_PROCESSING = "202"; public static final String PIN_NOTFOUND = "405"; - public static final String CREDENTIALS_MISSING = "407"; - public static final String INVALID_CREDENTIALS = "401"; - public static final String LOCKRESET_NOTIFICATION = "Error occurred in Device Lock Operation. " + + public static final String LOCK_RESET_NOTIFICATION = "Error occurred in Device Lock Operation. " + "Please trigger lock-reset operation."; + public static final String POSITIVE_CSP_DATA = "1"; + public static final String NEGATIVE_CSP_DATA = "0"; } + /** + * SyncmML message related constants. + */ + public final class SyncmlMessageCodes { + public static final int replaceCommandId = 300; + public static final int elementCommandId = 75; + public static final int atomicCommandId = 400; + public static final int addCommandId = 90; + } } diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/util/DeviceInfo.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/util/DeviceInfo.java index 5766d537b..052ff48e2 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/util/DeviceInfo.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/util/DeviceInfo.java @@ -1,17 +1,17 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/util/OperationCode.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/util/OperationCode.java index a84e2cd56..8bd5b399b 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/util/OperationCode.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/util/OperationCode.java @@ -1,17 +1,17 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ @@ -31,7 +31,7 @@ public class OperationCode { IMSI("./Vendor/MSFT/DeviceInstanceService/Identity/Identity1/IMSI"), IMEI("./Vendor/MSFT/DeviceInstanceService/Identity/Identity1/IMEI"), SOFTWARE_VERSION("./DevDetail/SwV"), - VENDER("./DevDetail/OEM"), + VENDOR("./DevDetail/OEM"), MAC_ADDRESS("./DevDetail/Ext/WLANMACAddress"), RESOLUTION("./DevDetail/Ext/Microsoft/Resolution"), DEVICE_NAME("./DevDetail/Ext/Microsoft/DeviceName"), @@ -68,7 +68,8 @@ public class OperationCode { ENCRYPT_STORAGE("./Vendor/MSFT/PolicyManager/My/Security/RequireDeviceEncryption"), CAMERA_STATUS("./Vendor/MSFT/PolicyManager/Device/Camera/AllowCamera"), ENCRYPT_STORAGE_STATUS("./Vendor/MSFT/PolicyManager/Device/Security/RequireDeviceEncryption"), - DEVICE_PASSWORD_ENABLE("./Vendor/MSFT/PolicyManager/My/DeviceLock/DevicePasswordEnabled"); + DEVICE_PASSWORD_ENABLE("./Vendor/MSFT/PolicyManager/My/DeviceLock/DevicePasswordEnabled"), + DEVICE_PASSCODE_DELETE("./Vendor/MSFT/PolicyManager/My/DeviceLock"); private final String code; diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/util/OperationHandler.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/util/OperationHandler.java new file mode 100644 index 000000000..7287960a7 --- /dev/null +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/util/OperationHandler.java @@ -0,0 +1,490 @@ +/* + * Copyright (c) 2015, 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.mdm.mobileservices.windows.operations.util; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.json.JSONException; +import org.json.JSONObject; +import org.wso2.carbon.device.mgt.common.DeviceIdentifier; +import org.wso2.carbon.device.mgt.common.DeviceManagementException; +import org.wso2.carbon.device.mgt.common.notification.mgt.Notification; +import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagementException; +import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagementService; +import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; +import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException; +import org.wso2.carbon.mdm.mobileservices.windows.common.PluginConstants; +import org.wso2.carbon.mdm.mobileservices.windows.common.util.WindowsAPIUtils; +import org.wso2.carbon.mdm.mobileservices.windows.operations.*; +import org.wso2.carbon.mdm.mobileservices.windows.services.syncml.beans.Profile; +import org.wso2.carbon.policy.mgt.common.PolicyManagementException; +import org.wso2.carbon.policy.mgt.common.ProfileFeature; +import org.wso2.carbon.policy.mgt.common.monitor.ComplianceFeature; +import org.wso2.carbon.policy.mgt.common.monitor.PolicyComplianceException; + +import java.util.ArrayList; +import java.util.List; + +import static org.wso2.carbon.mdm.mobileservices.windows.common.util.WindowsAPIUtils.convertToDeviceIdentifierObject; + +/** + * This class is used to handle pending operations of the device. + */ +public class OperationHandler { + private static Log log = LogFactory.getLog(OperationHandler.class); + + + /** + * Update the operations using device status payload. + * + * @param status Client side status for the specific operations. + * @param syncmlDocument syncml payload for operation status which parse through the syncml engine. + * @param deviceIdentifier specific device identifier for each device. + * @throws OperationManagementException + */ + public void updateDeviceOperations(StatusTag status, SyncmlDocument syncmlDocument, + DeviceIdentifier deviceIdentifier) throws OperationManagementException { + List pendingDataOperations; + try { + pendingDataOperations = WindowsAPIUtils.getPendingOperations(deviceIdentifier); + + if (Constants.SyncMLResponseCodes.ACCEPTED.equals(status.getData()) || + (Constants.SyncMLResponseCodes.ACCEPTED_FOR_PROCESSING.equals(status.getData()))) { + for (Operation operation : pendingDataOperations) { + if (operation.getId() == status.getCommandReference()) { + operation.setStatus(Operation.Status.COMPLETED); + } + } + if (syncmlDocument.getHeader().getSource().getLocURI() != null) { + updateStatus(syncmlDocument.getHeader().getSource().getLocURI(), pendingDataOperations); + } + } else if (Constants.SyncMLResponseCodes.PIN_NOTFOUND.equals(status.getData())) { + for (Operation operation : pendingDataOperations) { + if (operation.getId() == status.getCommandReference() && (OperationCode.Command.DEVICE_LOCK.equals( + operation.getCode()))) { + operation.setStatus(Operation.Status.ERROR); + if (syncmlDocument.getHeader().getSource().getLocURI() != null) { + updateStatus(syncmlDocument.getHeader().getSource().getLocURI(), pendingDataOperations); + } + NotificationManagementService nmService = WindowsAPIUtils.getNotificationManagementService(); + Notification lockResetNotification = new Notification(); + lockResetNotification.setOperationId(status.getCommandReference()); + lockResetNotification.setStatus(String.valueOf(Notification.Status.NEW)); +// lockResetNotification.setDeviceIdentifier(deviceIdentifier); + lockResetNotification.setDescription( + Constants.SyncMLResponseCodes.LOCK_RESET_NOTIFICATION); + nmService.addNotification(deviceIdentifier, lockResetNotification); + } + } + } + } catch (DeviceManagementException e) { + throw new OperationManagementException("Error occurred in getting pending operations."); + } catch (NotificationManagementException e) { + throw new OperationManagementException("Error occurred while adding notification", e); + } + } + + /** + * Update operation statuses. + * + * @param deviceId specific device Id. + * @param operations operation list to be update. + * @throws OperationManagementException + */ + public static void updateStatus(String deviceId, List operations) + throws OperationManagementException { + for (Operation operation : operations) { + WindowsAPIUtils.updateOperation(deviceId, operation); + if (log.isDebugEnabled()) { + log.debug("Updating operation '" + operation.toString() + "'"); + } + } + } + + /** + * Update Status of the lock operation. + * + * @param status Status of the operation. + * @param syncmlDocument parsed syncml payload. + * @param deviceIdentifier Device Id. + * @throws OperationManagementException + */ + public void updateLockOperation(StatusTag status, SyncmlDocument syncmlDocument, DeviceIdentifier deviceIdentifier) + throws OperationManagementException { + List pendingDataOperations; + try { + pendingDataOperations = WindowsAPIUtils.getPendingOperations(deviceIdentifier); + if (Constants.SyncMLResponseCodes.ACCEPTED.equals(status.getData())) { + for (Operation operation : pendingDataOperations) { + if ((OperationCode.Command.DEVICE_LOCK.getCode().equals(operation.getCode())) + && operation.getId() == status.getCommandReference()) { + operation.setStatus(Operation.Status.COMPLETED); + updateStatus(syncmlDocument.getHeader().getSource().getLocURI(), pendingDataOperations); + } + } + } + if (Constants.SyncMLResponseCodes.PIN_NOTFOUND.equals(status.getData())) { + for (Operation operation : pendingDataOperations) { + + if ((OperationCode.Command.DEVICE_LOCK.getCode().equals(operation.getCode()) && + operation.getId() == status.getCommandReference())) { + operation.setStatus(Operation.Status.ERROR); + updateStatus(syncmlDocument.getHeader().getSource().getLocURI(), pendingDataOperations); + + NotificationManagementService nmService = WindowsAPIUtils.getNotificationManagementService(); + Notification lockResetNotification = new Notification(); + lockResetNotification.setOperationId(status.getCommandReference()); + lockResetNotification.setStatus(String.valueOf(Notification.Status.NEW)); +// lockResetNotification.setDeviceIdentifier(deviceIdentifier); + lockResetNotification.setDescription(Constants.SyncMLResponseCodes.LOCK_RESET_NOTIFICATION); + + nmService.addNotification(deviceIdentifier, lockResetNotification); + } + } + } + } catch (DeviceManagementException e) { + throw new OperationManagementException("Error occurred in getting pending operations."); + } catch (NotificationManagementException e) { + throw new OperationManagementException("Error occurred in adding notifications."); + } + } + + /*** + * Update status of the ring operation. + * + * @param status Ring status of the device. + * @param syncmlDocument Parsed syncml payload from the syncml engine. + * @param deviceIdentifier specific device id to be update. + * @throws OperationManagementException + */ + public void ring(StatusTag status, SyncmlDocument syncmlDocument, DeviceIdentifier deviceIdentifier) + throws OperationManagementException { + List pendingDataOperations; + try { + if ((Constants.SyncMLResponseCodes.ACCEPTED.equals(status.getData()))) { + pendingDataOperations = WindowsAPIUtils.getPendingOperations(deviceIdentifier); + for (Operation operation : pendingDataOperations) { + if ((OperationCode.Command.DEVICE_RING.equals(operation.getCode())) && + (operation.getId() == status.getCommandReference())) { + operation.setStatus(Operation.Status.COMPLETED); + updateStatus(syncmlDocument.getHeader().getSource().getLocURI(), + pendingDataOperations); + } + } + } + } catch (DeviceManagementException e) { + throw new OperationManagementException("Error occurred in getting pending operation."); + } + } + + /*** + * Update the status of the DataWipe operation. + * + * @param status Status of the data wipe. + * @param syncmlDocument Parsed syncml payload from the syncml engine. + * @param deviceIdentifier specific device id to be wiped. + * @throws OperationManagementException + */ + public void dataWipe(StatusTag status, SyncmlDocument syncmlDocument, DeviceIdentifier deviceIdentifier) + throws OperationManagementException { + List pendingDataOperations; + if ((Constants.SyncMLResponseCodes.ACCEPTED.equals(status.getData()))) { + try { + pendingDataOperations = WindowsAPIUtils.getPendingOperations(deviceIdentifier); + } catch (DeviceManagementException e) { + throw new OperationManagementException("Error occurred in getting pending operation."); + } + for (Operation operation : pendingDataOperations) { + + if ((OperationCode.Command.WIPE_DATA.equals(operation.getCode())) && + (operation.getId() == status.getCommandReference())) { + operation.setStatus(Operation.Status.COMPLETED); + updateStatus(syncmlDocument.getHeader().getSource().getLocURI(), + pendingDataOperations); + } + } + } + } + + /** + * Get pending operations. + * + * @param syncmlDocument SyncmlDocument object which creates from the syncml engine using syncml payload + * @return Return list of pending operations. + * @throws OperationManagementException + */ + public List getPendingOperations(SyncmlDocument syncmlDocument) + throws OperationManagementException, WindowsOperationException { + + List pendingOperations; + DeviceIdentifier deviceIdentifier = convertToDeviceIdentifierObject( + syncmlDocument.getHeader().getSource().getLocURI()); + UpdateUriOperations(syncmlDocument); + generateComplianceFeatureStatus(syncmlDocument); + + pendingOperations = WindowsAPIUtils.getDeviceManagementService().getPendingOperations(deviceIdentifier); + return pendingOperations; + } + + /** + * Set compliance of the feature according to the device status for the specific feature. + * + * @param activeFeature Features to be applied on the device. + * @param deviceFeature Actual features applied on the device. + * @return Returns setting up compliance feature. + */ + public ComplianceFeature setComplianceFeatures(ProfileFeature activeFeature, Profile deviceFeature) { + ComplianceFeature complianceFeature = new ComplianceFeature(); + complianceFeature.setFeature(activeFeature); + complianceFeature.setFeatureCode(activeFeature.getFeatureCode()); + complianceFeature.setCompliance(deviceFeature.isCompliance()); + return complianceFeature; + } + + /** + * Update the completed/Error status of the operation which have the URI of the operation code in the syncml payload. + * + * @param syncmlDocument SyncmlDocument object generated from the the syncml engine. + * @throws OperationManagementException + */ + public void UpdateUriOperations(SyncmlDocument syncmlDocument) throws OperationManagementException, + WindowsOperationException { + List pendingDataOperations; + DeviceIdentifier deviceIdentifier = convertToDeviceIdentifierObject( + syncmlDocument.getHeader().getSource().getLocURI()); + + List statuses = syncmlDocument.getBody().getStatus(); + try { + pendingDataOperations = WindowsAPIUtils.getPendingOperations(deviceIdentifier); + } catch (DeviceManagementException e) { + throw new OperationManagementException("Error occurred in getting pending operation."); + } + for (StatusTag status : statuses) { + + if ((Constants.EXECUTE.equals(status.getCommand()))) { + if (status.getTargetReference() == null) { + updateDeviceOperations(status, syncmlDocument, deviceIdentifier); + } else { + if ((OperationCode.Command.DEVICE_LOCK.equals(status.getTargetReference()))) { + updateLockOperation(status, syncmlDocument, deviceIdentifier); + } + if ((OperationCode.Command.DEVICE_RING.equals(status.getTargetReference()))) { + ring(status, syncmlDocument, deviceIdentifier); + } + if (equals(OperationCode.Command.WIPE_DATA.equals(status.getTargetReference()))) { + dataWipe(status, syncmlDocument, deviceIdentifier); + } + } + } + if ((Constants.SEQUENCE.equals(status.getCommand()))) { + if ((Constants.SyncMLResponseCodes.ACCEPTED.equals(status.getData()))) { + for (Operation operation : pendingDataOperations) { + if ((PluginConstants.OperationCodes.POLICY_BUNDLE.equals(operation.getCode())) && + operation.getId() == status.getCommandReference()) { + operation.setStatus(Operation.Status.COMPLETED); + } + if ((PluginConstants.OperationCodes.MONITOR.equals(operation.getCode())) && + operation.getId() == status.getCommandReference()) { + operation.setStatus(Operation.Status.COMPLETED); + } + } + updateStatus(syncmlDocument.getHeader().getSource().getLocURI(), + pendingDataOperations); + } else { + for (Operation operation : pendingDataOperations) { + + if ((PluginConstants.OperationCodes.POLICY_BUNDLE.equals(operation.getCode())) && + operation.getId() == status.getCommandReference()) { + operation.setStatus(Operation.Status.ERROR); + } + if ((PluginConstants.OperationCodes.MONITOR.equals(operation.getCode())) && + operation.getId() == status.getCommandReference()) { + operation.setStatus(Operation.Status.ERROR); + } + } + updateStatus(syncmlDocument.getHeader().getSource().getLocURI(), + pendingDataOperations); + } + } + } + } + + /** + * Generate status of the features that have been activated on the device. + * + * @param syncmlDocument syncmlDocument object pasrsed from the syncml engine. + * @return device statuses for the activated features + * @throws WindowsOperationException + */ + public List generateDeviceOperationStatusObject(SyncmlDocument syncmlDocument) throws + WindowsOperationException { + + DeviceIdentifier deviceIdentifier = convertToDeviceIdentifierObject( + syncmlDocument.getHeader().getSource().getLocURI()); + String lockUri = null; + ResultsTag result = syncmlDocument.getBody().getResults(); + + List profiles = new ArrayList<>(); + if (result != null) { + List results = result.getItem(); + for (OperationCode.Info info : OperationCode.Info.values()) { + if (PluginConstants.OperationCodes.PIN_CODE.equals(info + .name())) { + lockUri = info.getCode(); + } + } + for (ItemTag item : results) { + for (OperationCode.Info info : OperationCode.Info.values()) { + if (item.getSource().getLocURI().equals(info.getCode()) && + PluginConstants.OperationCodes.CAMERA_STATUS.equals(info.name())) { + Profile cameraProfile = new Profile(); + cameraProfile.setFeatureCode(PluginConstants.OperationCodes.CAMERA); + cameraProfile.setData(item.getData()); + if ((PluginConstants.SyncML.SYNCML_DATA_ONE.equals(item.getData()))) { + cameraProfile.setEnable(true); + } else { + cameraProfile.setEnable(false); + } + profiles.add(cameraProfile); + } + if (item.getSource().getLocURI().equals(info.getCode()) && + PluginConstants.OperationCodes.ENCRYPT_STORAGE_STATUS.equals(info.name())) { + Profile encryptStorage = new Profile(); + encryptStorage.setFeatureCode(PluginConstants.OperationCodes.ENCRYPT_STORAGE); + encryptStorage.setData(item.getData()); + if ((PluginConstants.SyncML.SYNCML_DATA_ONE.equals(item.getData()))) { + encryptStorage.setEnable(true); + } else { + encryptStorage.setEnable(false); + } + profiles.add(encryptStorage); + } + if (item.getSource().getLocURI().equals(info.getCode()) && + PluginConstants.OperationCodes.DEVICE_PASSWORD_STATUS.equals(info.name())) { + Profile encryptStorage = new Profile(); + encryptStorage.setFeatureCode(PluginConstants.OperationCodes.PASSCODE_POLICY); + encryptStorage.setData(item.getData()); + if ((PluginConstants.SyncML.SYNCML_DATA_ZERO.equals(item.getData()))) { + encryptStorage.setEnable(true); + } else { + encryptStorage.setEnable(false); + } + profiles.add(encryptStorage); + } + if (!item.getData().isEmpty() && item.getSource().getLocURI().equals(lockUri)) { + String pinValue = item.getData(); + NotificationManagementService nmService = WindowsAPIUtils.getNotificationManagementService(); + Notification notification = new Notification(); + notification.setDescription("Auto generated DevicePin : " + pinValue); + notification.setOperationId(result.getCommandReference()); +// notification.setDeviceIdentifier(deviceIdentifier); + notification.setStatus(String.valueOf(Notification.Status.NEW)); + try { + nmService.addNotification(deviceIdentifier, notification); + } catch (NotificationManagementException e) { + throw new WindowsOperationException("Failure Occurred while getting notification" + + " service.", e); + } + break; + } + } + } + } + return profiles; + } + + /** + * Generate Compliance Features. + * + * @param syncmlDocument syncmlDocument object parsed from the syncml engine. + * @throws WindowsOperationException + */ + public void generateComplianceFeatureStatus(SyncmlDocument syncmlDocument) throws WindowsOperationException { + List profiles = generateDeviceOperationStatusObject(syncmlDocument); + DeviceIdentifier deviceIdentifier = convertToDeviceIdentifierObject( + syncmlDocument.getHeader().getSource().getLocURI()); + boolean isCompliance = false; + if (profiles.size() != Constants.EMPTY) { + try { + if (WindowsAPIUtils.getPolicyManagerService().getAppliedPolicyToDevice(deviceIdentifier).getProfile(). + getProfileFeaturesList() != null) { + List profileFeatures = WindowsAPIUtils.getPolicyManagerService(). + getAppliedPolicyToDevice(deviceIdentifier).getProfile().getProfileFeaturesList(); + List complianceFeatures = new ArrayList<>(); + for (ProfileFeature activeFeature : profileFeatures) { + JSONObject policyContent = new JSONObject(activeFeature.getContent().toString()); + + for (Profile deviceFeature : profiles) { + if (deviceFeature.getFeatureCode().equals(activeFeature.getFeatureCode()) && + (PluginConstants.OperationCodes.CAMERA.equals(deviceFeature.getFeatureCode()))) { + if (policyContent.getBoolean(PluginConstants.PolicyConfigProperties. + POLICY_ENABLE) == (deviceFeature.isEnable())) { + isCompliance = true; + deviceFeature.setCompliance(isCompliance); + } else { + deviceFeature.setCompliance(isCompliance); + } + ComplianceFeature complianceFeature = setComplianceFeatures(activeFeature, + deviceFeature); + complianceFeatures.add(complianceFeature); + } + if (deviceFeature.getFeatureCode().equals(activeFeature.getFeatureCode()) && + (PluginConstants.OperationCodes. + ENCRYPT_STORAGE.equals(deviceFeature.getFeatureCode()))) { + if (policyContent.getBoolean(PluginConstants.PolicyConfigProperties. + ENCRYPTED_ENABLE) == (deviceFeature.isEnable())) { + isCompliance = true; + deviceFeature.setCompliance(isCompliance); + } else { + deviceFeature.setCompliance(isCompliance); + } + ComplianceFeature complianceFeature = setComplianceFeatures(activeFeature, + deviceFeature); + complianceFeatures.add(complianceFeature); + } + if (deviceFeature.getFeatureCode().equals(activeFeature.getFeatureCode()) && + (PluginConstants.OperationCodes. + PASSCODE_POLICY.equals(deviceFeature.getFeatureCode()))) { + if (policyContent.getBoolean(PluginConstants.PolicyConfigProperties. + ENABLE_PASSWORD) == (deviceFeature.isEnable())) { + isCompliance = true; + deviceFeature.setCompliance(isCompliance); + } else { + deviceFeature.setCompliance(isCompliance); + } + ComplianceFeature complianceFeature = setComplianceFeatures(activeFeature, + deviceFeature); + complianceFeatures.add(complianceFeature); + } + } + } + WindowsAPIUtils.getPolicyManagerService().checkPolicyCompliance(deviceIdentifier, + complianceFeatures); + } + } catch (JSONException e) { + throw new WindowsOperationException("Error occurred while parsing json object.", e); + } catch (PolicyComplianceException e) { + throw new WindowsOperationException("Error occurred while setting up policy compliance.", e); + } catch (PolicyManagementException e) { + throw new WindowsOperationException("Error occurred while getting effective policy.", e); + } + } + + } +} diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/util/OperationReply.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/util/OperationReply.java index b32e4f930..cd7ff4be6 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/util/OperationReply.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/util/OperationReply.java @@ -1,17 +1,17 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ @@ -77,20 +77,20 @@ public class OperationReply { } private void generateHeader() throws SyncmlMessageFormatException { - String nextnonceValue = Constants.INITIAL_NONCE; + String nextNonceValue = Constants.INITIAL_NONCE; SyncmlHeader sourceHeader = syncmlDocument.getHeader(); SyncmlHeader header = new SyncmlHeader(); header.setMsgID(sourceHeader.getMsgID()); header.setHexadecimalSessionId(Integer.toHexString(sourceHeader.getSessionId())); - Target target = new Target(); + TargetTag target = new TargetTag(); target.setLocURI(sourceHeader.getSource().getLocURI()); header.setTarget(target); - Source source = new Source(); + SourceTag source = new SourceTag(); source.setLocURI(sourceHeader.getTarget().getLocURI()); header.setSource(source); - Credential cred = new Credential(); + CredentialTag cred = new CredentialTag(); if (sourceHeader.getCredential() == null) { MetaTag meta = new MetaTag(); meta.setFormat(Constants.CRED_FORMAT); @@ -100,15 +100,15 @@ public class OperationReply { cred.setMeta(sourceHeader.getCredential().getMeta()); } SyncmlBody sourcebody = syncmlDocument.getBody(); - List statuses = sourcebody.getStatus(); + List statuses = sourcebody.getStatus(); - for (Status status : statuses) { + for (StatusTag status : statuses) { if (HEADER_COMMAND_TEXT.equals(status.getCommand()) && status.getChallenge() != null) { - nextnonceValue = status.getChallenge().getMeta().getNextNonce(); + nextNonceValue = status.getChallenge().getMeta().getNextNonce(); } } - cred.setData(new SyncmlCredentials().generateCredData(nextnonceValue)); + cred.setData(SyncmlCredentialUtil.generateCredData(nextNonceValue)); header.setCredential(cred); replySyncmlDocument.setHeader(header); @@ -131,22 +131,22 @@ public class OperationReply { private SyncmlBody generateStatuses() { SyncmlBody sourceSyncmlBody = syncmlDocument.getBody(); SyncmlHeader sourceHeader = syncmlDocument.getHeader(); - Status headerStatus; + StatusTag headerStatus; SyncmlBody syncmlBodyReply = new SyncmlBody(); - List statuses = new ArrayList<>(); - List sourceStatuses = sourceSyncmlBody.getStatus(); + List statuses = new ArrayList<>(); + List sourceStatuses = sourceSyncmlBody.getStatus(); if (sourceStatuses.isEmpty()) { headerStatus = - new Status(headerCommandId, sourceHeader.getMsgID(), HEADER_STATUS_ID, + new StatusTag(headerCommandId, sourceHeader.getMsgID(), HEADER_STATUS_ID, HEADER_COMMAND_TEXT, sourceHeader.getSource().getLocURI(), String.valueOf(Constants.SyncMLResponseCodes.AUTHENTICATION_ACCEPTED)); statuses.add(headerStatus); } else { - for (Status sourceStatus : sourceStatuses) { + for (StatusTag sourceStatus : sourceStatuses) { if (sourceStatus.getChallenge() != null && HEADER_COMMAND_TEXT.equals(sourceStatus.getCommand())) { headerStatus = - new Status(headerCommandId, sourceHeader.getMsgID(), HEADER_STATUS_ID, + new StatusTag(headerCommandId, sourceHeader.getMsgID(), HEADER_STATUS_ID, HEADER_COMMAND_TEXT, sourceHeader.getSource().getLocURI(), String.valueOf(Constants.SyncMLResponseCodes.AUTHENTICATION_ACCEPTED)); statuses.add(headerStatus); @@ -155,14 +155,14 @@ public class OperationReply { } if (sourceSyncmlBody.getResults() != null) { int ResultCommandId = ++headerCommandId; - Status resultStatus = new Status(ResultCommandId, sourceHeader.getMsgID(), + StatusTag resultStatus = new StatusTag(ResultCommandId, sourceHeader.getMsgID(), sourceSyncmlBody.getResults().getCommandId(), RESULTS_COMMAND_TEXT, null, String.valueOf(Constants.SyncMLResponseCodes.ACCEPTED)); statuses.add(resultStatus); } if (sourceSyncmlBody.getAlert() != null) { int alertCommandId = ++headerCommandId; - Status alertStatus = new Status(alertCommandId, + StatusTag alertStatus = new StatusTag(alertCommandId, sourceHeader.getMsgID(), sourceSyncmlBody.getAlert().getCommandId(), ALERT_COMMAND_TEXT, null, @@ -171,7 +171,7 @@ public class OperationReply { } if (sourceSyncmlBody.getReplace() != null) { int replaceCommandId = ++headerCommandId; - Status replaceStatus = new Status(replaceCommandId, sourceHeader.getMsgID(), + StatusTag replaceStatus = new StatusTag(replaceCommandId, sourceHeader.getMsgID(), sourceSyncmlBody.getReplace().getCommandId(), REPLACE_COMMAND_TEXT, null, String.valueOf(Constants.SyncMLResponseCodes.ACCEPTED) ); @@ -181,7 +181,7 @@ public class OperationReply { List Executes = sourceSyncmlBody.getExec(); for (ExecuteTag exec : Executes) { int execCommandId = ++headerCommandId; - Status execStatus = new Status(execCommandId, sourceHeader.getMsgID(), + StatusTag execStatus = new StatusTag(execCommandId, sourceHeader.getMsgID(), exec.getCommandId(), EXEC_COMMAND_TEXT, null, String.valueOf( Constants.SyncMLResponseCodes.ACCEPTED)); statuses.add(execStatus); @@ -189,7 +189,7 @@ public class OperationReply { } if (sourceSyncmlBody.getGet() != null) { int getCommandId = ++headerCommandId; - Status execStatus = new Status(getCommandId, sourceHeader.getMsgID(), sourceSyncmlBody + StatusTag execStatus = new StatusTag(getCommandId, sourceHeader.getMsgID(), sourceSyncmlBody .getGet().getCommandId(), GET_COMMAND_TEXT, null, String.valueOf( Constants.SyncMLResponseCodes.ACCEPTED)); statuses.add(execStatus); @@ -200,13 +200,13 @@ public class OperationReply { private void appendOperations(SyncmlBody syncmlBody) throws PolicyManagementException, FeatureManagementException, JSONException, SyncmlOperationException { - Get getElement = new Get(); - List getElements = new ArrayList<>(); + GetTag getElement = new GetTag(); + List getElements = new ArrayList<>(); List executeElements = new ArrayList<>(); AtomicTag atomicTagElement = new AtomicTag(); List addElements = new ArrayList<>(); - Replace replaceElement = new Replace(); - List replaceItems = new ArrayList<>(); + ReplaceTag replaceElement = new ReplaceTag(); + List replaceItems = new ArrayList<>(); SequenceTag monitorSequence = new SequenceTag(); if (operations != null) { @@ -215,8 +215,8 @@ public class OperationReply { switch (type) { case POLICY: if (this.syncmlDocument.getBody().getAlert() != null) { - if (this.syncmlDocument.getBody().getAlert().getData().equals - (Constants.INITIAL_ALERT_DATA)) { + if ((Constants.INITIAL_ALERT_DATA.equals(this.syncmlDocument.getBody() + .getAlert().getData()))) { SequenceTag policySequence = new SequenceTag(); policySequence = buildSequence(operation, policySequence); syncmlBody.setSequence(policySequence); @@ -233,46 +233,40 @@ public class OperationReply { break; case INFO: - Item itemGet = appendGetInfo(operation); + ItemTag itemGet = appendGetInfo(operation); getElements.add(itemGet); break; case COMMAND: - if (operation.getCode().equals(PluginConstants - .OperationCodes.DEVICE_LOCK)) { - ExecuteTag execElement = executeCommand(operation); + ExecuteTag execElement; + if ((PluginConstants.OperationCodes.DEVICE_LOCK.equals(operation.getCode()))) { + execElement = executeCommand(operation); executeElements.add(execElement); } - if (operation.getCode().equals(PluginConstants - .OperationCodes.DEVICE_RING)) { - ExecuteTag execElement = executeCommand(operation); + if ((PluginConstants.OperationCodes.DEVICE_RING.equals(operation.getCode()))) { + execElement = executeCommand(operation); executeElements.add(execElement); } - if (operation.getCode().equals(PluginConstants - .OperationCodes.DISENROLL)) { - ExecuteTag execElement = executeCommand(operation); + if ((PluginConstants.OperationCodes.DISENROLL.equals(operation.getCode()))) { + execElement = executeCommand(operation); executeElements.add(execElement); } - if (operation.getCode().equals(PluginConstants - .OperationCodes.WIPE_DATA)) { - ExecuteTag execElement = executeCommand(operation); + if ((PluginConstants.OperationCodes.WIPE_DATA.equals(operation.getCode()))) { + execElement = executeCommand(operation); executeElements.add(execElement); } - if (operation.getCode().equals(PluginConstants - .OperationCodes.LOCK_RESET)) { + if ((PluginConstants.OperationCodes.LOCK_RESET.equals(operation.getCode()))) { SequenceTag sequenceElement = new SequenceTag(); SequenceTag sequence = buildSequence(operation, sequenceElement); syncmlBody.setSequence(sequence); } - if (operation.getCode().equals(PluginConstants - .OperationCodes.MONITOR)) { - - Get monitorGetElement = new Get(); - List monitorItems; + if ((PluginConstants.OperationCodes.MONITOR.equals(operation.getCode()))) { + GetTag monitorGetElement = new GetTag(); + List monitorItems; List profileFeatures; if (this.syncmlDocument.getBody().getAlert() != null) { - if (this.syncmlDocument.getBody().getAlert().getData().equals - (Constants.INITIAL_ALERT_DATA)) { + if (Constants.INITIAL_ALERT_DATA.equals(this.syncmlDocument.getBody(). + getAlert().getData())) { monitorSequence.setCommandId(operation.getId()); DeviceIdentifier deviceIdentifier = convertToDeviceIdentifierObject( @@ -298,15 +292,15 @@ public class OperationReply { } } if (!replaceItems.isEmpty()) { - replaceElement.setCommandId(300); + replaceElement.setCommandId(Constants.SyncmlMessageCodes.replaceCommandId); replaceElement.setItems(replaceItems); } if (!getElements.isEmpty()) { - getElement.setCommandId(75); + getElement.setCommandId(Constants.SyncmlMessageCodes.elementCommandId); getElement.setItems(getElements); } if (!addElements.isEmpty()) { - atomicTagElement.setCommandId(400); + atomicTagElement.setCommandId(Constants.SyncmlMessageCodes.atomicCommandId); atomicTagElement.setAdds(addElements); } syncmlBody.setGet(getElement); @@ -315,15 +309,15 @@ public class OperationReply { syncmlBody.setReplace(replaceElement); } - private Item appendExecInfo(Operation operation) { - Item item = new Item(); + private ItemTag appendExecInfo(Operation operation) { + ItemTag item = new ItemTag(); String operationCode = operation.getCode(); for (Command command : Command.values()) { if (operationCode != null && operationCode.equals(command.name())) { - Target target = new Target(); + TargetTag target = new TargetTag(); target.setLocURI(command.getCode()); - if (operation.getCode().equals(PluginConstants - .OperationCodes.DISENROLL)) { + if ((PluginConstants + .OperationCodes.DISENROLL.equals(operation.getCode()))) { MetaTag meta = new MetaTag(); meta.setFormat(Constants.META_FORMAT_CHARACTER); item.setMeta(meta); @@ -335,22 +329,22 @@ public class OperationReply { return item; } - private Item appendGetInfo(Operation operation) { - Item item = new Item(); + private ItemTag appendGetInfo(Operation operation) { + ItemTag item = new ItemTag(); String operationCode = operation.getCode(); for (Info info : Info.values()) { if (operationCode != null && operationCode.equals(info.name())) { - Target target = new Target(); + TargetTag target = new TargetTag(); target.setLocURI(info.getCode()); item.setTarget(target); } } - if ((operationCode != null) && operationCode.equals( - PluginConstants.OperationCodes.LOCK_RESET)) { + if ((operationCode != null) && + PluginConstants.OperationCodes.LOCK_RESET.equals(operationCode)) { operation.setCode(PluginConstants.OperationCodes.PIN_CODE); for (Info getInfo : Info.values()) { if (operation.getCode().equals(getInfo.name())) { - Target target = new Target(); + TargetTag target = new TargetTag(); target.setLocURI(getInfo.getCode()); item.setTarget(target); } @@ -359,11 +353,11 @@ public class OperationReply { return item; } - private Item appendReplaceInfo(Operation operation) throws JSONException { + private ItemTag appendReplaceInfo(Operation operation) throws JSONException { String policyAllowData = "1"; String policyDisallowData = "0"; - Item item = new Item(); - Target target = new Target(); + ItemTag item = new ItemTag(); + TargetTag target = new TargetTag(); String operationCode = operation.getCode(); JSONObject payload = new JSONObject(operation.getPayLoad().toString()); for (Command command : Command.values()) { @@ -371,8 +365,7 @@ public class OperationReply { if (operationCode != null && operationCode.equals(command.name())) { target.setLocURI(command.getCode()); - if (operation.getCode().equals(PluginConstants - .OperationCodes.CAMERA)) { + if ((PluginConstants.OperationCodes.CAMERA.equals(operation.getCode()))) { if (payload.getBoolean("enabled")) { MetaTag meta = new MetaTag(); @@ -388,8 +381,8 @@ public class OperationReply { item.setData(policyDisallowData); } } - if (operation.getCode().equals(PluginConstants - .OperationCodes.ENCRYPT_STORAGE)) { + if ((PluginConstants.OperationCodes.ENCRYPT_STORAGE. + equals(operation.getCode()))) { if (payload.getBoolean("encrypted")) { MetaTag meta = new MetaTag(); @@ -415,7 +408,7 @@ public class OperationReply { List addList = new ArrayList<>(); Gson gson = new Gson(); - if (operation.getCode().equals(PluginConstants.OperationCodes.PASSCODE_POLICY)) { + if ((PluginConstants.OperationCodes.PASSCODE_POLICY.equals(operation.getCode()))) { PasscodePolicy passcodeObject = gson.fromJson((String) operation.getPayLoad(), PasscodePolicy.class); @@ -489,11 +482,11 @@ public class OperationReply { MetaTag meta = new MetaTag(); meta.setFormat(Constants.META_FORMAT_CHARACTER); - List items = new ArrayList<>(); + List items = new ArrayList<>(); for (Configure configure : Configure.values()) { if (operationCode != null && operationCode.equals(configure.name())) { - Target target = new Target(); + TargetTag target = new TargetTag(); target.setLocURI(configure.getCode()); items.get(0).setTarget(target); } @@ -512,8 +505,8 @@ public class OperationReply { public ExecuteTag executeCommand(Operation operation) { ExecuteTag execElement = new ExecuteTag(); execElement.setCommandId(operation.getId()); - List itemsExec = new ArrayList<>(); - Item itemExec = appendExecInfo(operation); + List itemsExec = new ArrayList<>(); + ItemTag itemExec = appendExecInfo(operation); itemsExec.add(itemExec); execElement.setItems(itemsExec); return execElement; @@ -523,14 +516,14 @@ public class OperationReply { JSONException, SyncmlOperationException { sequenceElement.setCommandId(operation.getId()); - List replaceItems = new ArrayList<>(); + List replaceItems = new ArrayList<>(); - if (operation.getCode().equals(PluginConstants.OperationCodes.LOCK_RESET)) { + if ((PluginConstants.OperationCodes.LOCK_RESET.equals(operation.getCode()))) { ExecuteTag execElement = executeCommand(operation); - Get getElements = new Get(); + GetTag getElements = new GetTag(); getElements.setCommandId(operation.getId()); - List getItems = new ArrayList<>(); - Item itemGets = appendGetInfo(operation); + List getItems = new ArrayList<>(); + ItemTag itemGets = appendGetInfo(operation); getItems.add(itemGets); getElements.setItems(getItems); @@ -538,7 +531,7 @@ public class OperationReply { sequenceElement.setGet(getElements); return sequenceElement; - } else if (operation.getCode().equals(PluginConstants.OperationCodes.POLICY_BUNDLE)) { + } else if ((PluginConstants.OperationCodes.POLICY_BUNDLE.equals(operation.getCode()))) { List policyOperations; try { policyOperations = (List) operation.getPayLoad(); @@ -546,10 +539,12 @@ public class OperationReply { throw new ClassCastException(); } for (Operation policy : policyOperations) { - if (policy.getCode().equals(PluginConstants.OperationCodes.CAMERA)) { - Replace replaceCameraConfig = new Replace(); - Item cameraItem; - List cameraItems = new ArrayList<>(); + + if (PluginConstants.OperationCodes.CAMERA.equals(policy.getCode())) { + ReplaceTag replaceCameraConfig = new ReplaceTag(); + ItemTag cameraItem; + List cameraItems = new ArrayList<>(); + try { cameraItem = appendReplaceInfo(policy); cameraItems.add(cameraItem); @@ -560,11 +555,11 @@ public class OperationReply { replaceCameraConfig.setItems(cameraItems); replaceItems.add(replaceCameraConfig); } - if (policy.getCode().equals(PluginConstants.OperationCodes.ENCRYPT_STORAGE)) { + if ((PluginConstants.OperationCodes.ENCRYPT_STORAGE.equals(policy.getCode()))) { - Replace replaceStorageConfig = new Replace(); - Item storageItem; - List storageItems = new ArrayList<>(); + ReplaceTag replaceStorageConfig = new ReplaceTag(); + ItemTag storageItem; + List storageItems = new ArrayList<>(); try { storageItem = appendReplaceInfo(policy); storageItems.add(storageItem); @@ -576,14 +571,18 @@ public class OperationReply { replaceItems.add(replaceStorageConfig); } - if (policy.getCode().equals(PluginConstants.OperationCodes.PASSCODE_POLICY)) { + if ((PluginConstants.OperationCodes.PASSCODE_POLICY.equals(policy.getCode()))) { AtomicTag atomicTagElement = new AtomicTag(); List addConfig; + DeleteTag deleteTag = new DeleteTag(); try { addConfig = appendAddInfo(policy); atomicTagElement.setAdds(addConfig); atomicTagElement.setCommandId(operation.getId()); - + List deleteTagItems = buildDeletePasscodeData(policy); + deleteTag.setCommandId(operation.getId()); + deleteTag.setItems(deleteTagItems); + sequenceElement.setDeleteTag(deleteTag); sequenceElement.setAtomicTag(atomicTagElement); } catch (WindowsOperationException e) { throw new SyncmlOperationException("Error occurred while generating operation payload.", e); @@ -600,69 +599,70 @@ public class OperationReply { } } - public List buildMonitorOperation(List effectiveMonitoringFeature) { - List monitorItems = new ArrayList<>(); + public List buildMonitorOperation(List effectiveMonitoringFeature) { + List monitorItems = new ArrayList<>(); Operation monitorOperation; for (ProfileFeature profileFeature : effectiveMonitoringFeature) { - if (profileFeature.getFeatureCode().equals(PluginConstants - .OperationCodes.CAMERA)) { + if ((PluginConstants.OperationCodes.CAMERA.equals + (profileFeature.getFeatureCode()))) { String cameraStatus = PluginConstants .OperationCodes.CAMERA_STATUS; monitorOperation = new Operation(); monitorOperation.setCode(cameraStatus); - Item item = appendGetInfo(monitorOperation); + ItemTag item = appendGetInfo(monitorOperation); monitorItems.add(item); } - if (profileFeature.getFeatureCode().equals(PluginConstants - .OperationCodes.ENCRYPT_STORAGE)) { + if (PluginConstants.OperationCodes.ENCRYPT_STORAGE.equals + (profileFeature.getFeatureCode())) { String encryptStorageStatus = PluginConstants .OperationCodes.ENCRYPT_STORAGE_STATUS; monitorOperation = new Operation(); monitorOperation.setCode(encryptStorageStatus); - Item item = appendGetInfo(monitorOperation); + ItemTag item = appendGetInfo(monitorOperation); monitorItems.add(item); } - if (profileFeature.getFeatureCode().equals(PluginConstants - .OperationCodes.PASSCODE_POLICY)) { + if ((PluginConstants.OperationCodes.PASSCODE_POLICY.equals + (profileFeature.getFeatureCode()))) { String passcodeStatus = PluginConstants .OperationCodes.DEVICE_PASSWORD_STATUS; monitorOperation = new Operation(); monitorOperation.setCode(passcodeStatus); - Item item = appendGetInfo(monitorOperation); + ItemTag item = appendGetInfo(monitorOperation); monitorItems.add(item); } } return monitorItems; } - public List buildDeleteInfo(Operation operation) { - List deleteItems = new ArrayList<>(); - Item deleteItem = new Item(); - Target target = new Target(); - String operationCode = operation.getCode(); - if (operation.getCode().equals(PluginConstants.OperationCodes.PASSCODE_POLICY)) { + + public List buildDeletePasscodeData(Operation operation) { + List deleteTagItems = new ArrayList<>(); + ItemTag itemTag = new ItemTag(); + TargetTag target = new TargetTag(); + if ((PluginConstants.OperationCodes.PASSCODE_POLICY.equals(operation.getCode()))) { operation.setCode(PluginConstants.OperationCodes.DEVICE_PASSCODE_DELETE); for (Command command : Command.values()) { - - if (operationCode != null && operationCode.equals(command.name())) { + if (operation.getCode() != null && operation.getCode().equals(command.name())) { target.setLocURI(command.getCode()); - deleteItem.setTarget(target); + itemTag.setTarget(target); + deleteTagItems.add(itemTag); } + } } - return deleteItems; + return deleteTagItems; } public AddTag generatePasscodePolicyData(Configure configure, int policyData) { String attempt = String.valueOf(policyData); AddTag add = new AddTag(); - List itemList = new ArrayList<>(); - Item item = new Item(); - Target target = new Target(); + List itemList = new ArrayList<>(); + ItemTag item = new ItemTag(); + TargetTag target = new TargetTag(); target.setLocURI(configure.getCode()); MetaTag meta = new MetaTag(); meta.setFormat(Constants.META_FORMAT_INT); @@ -670,15 +670,15 @@ public class OperationReply { item.setMeta(meta); item.setData(attempt); itemList.add(item); - add.setCommandId(90); + add.setCommandId(Constants.SyncmlMessageCodes.addCommandId); add.setItems(itemList); return add; } public AddTag generatePasscodeBooleanData(Operation operation, Configure configure) { - Target target = new Target(); + TargetTag target = new TargetTag(); MetaTag meta = new MetaTag(); - AddTag add = new AddTag(); + AddTag addTag = null; PasscodePolicy passcodePolicy = gson.fromJson((String) operation.getPayLoad(), PasscodePolicy.class); if (operation.getCode() != null && (PluginConstants.OperationCodes.DEVICE_PASSWORD_ENABLE. @@ -686,87 +686,38 @@ public class OperationReply { if (passcodePolicy.isEnablePassword()) { target.setLocURI(configure.getCode()); meta.setFormat(Constants.META_FORMAT_INT); - List itemList = new ArrayList<>(); - Item item = new Item(); - item.setTarget(target); - item.setMeta(meta); - item.setData("0"); - itemList.add(item); - - add.setCommandId(operation.getId()); - add.setItems(itemList); - + addTag = TagUtil.buildAddTag(operation, Constants.SyncMLResponseCodes.NEGATIVE_CSP_DATA); } else { target.setLocURI(configure.getCode()); meta.setFormat(Constants.META_FORMAT_INT); - List itemList = new ArrayList<>(); - Item item = new Item(); - item.setTarget(target); - item.setMeta(meta); - item.setData("1"); - itemList.add(item); - add.setCommandId(operation.getId()); - add.setItems(itemList); - + addTag = TagUtil.buildAddTag(operation, Constants.SyncMLResponseCodes.POSITIVE_CSP_DATA); } } if (PluginConstants.OperationCodes.ALPHANUMERIC_PASSWORD. equals(configure.name())) { if (passcodePolicy.isRequireAlphanumeric()) { - Item item = new Item(); target.setLocURI(configure.getCode()); meta.setFormat(Constants.META_FORMAT_INT); - List itemList = new ArrayList<>(); - item.setTarget(target); - item.setMeta(meta); - item.setData("1"); - itemList.add(item); - add.setCommandId(operation.getId()); - add.setItems(itemList); + addTag = TagUtil.buildAddTag(operation, Constants.SyncMLResponseCodes.POSITIVE_CSP_DATA); } else { target.setLocURI(configure.getCode()); meta.setFormat(Constants.META_FORMAT_INT); - List itemList = new ArrayList<>(); - Item item = new Item(); - item.setTarget(target); - item.setMeta(meta); - item.setData("0"); - itemList.add(item); - add.setCommandId(operation.getId()); - add.setItems(itemList); + addTag = TagUtil.buildAddTag(operation, Constants.SyncMLResponseCodes.NEGATIVE_CSP_DATA); } } if (PluginConstants.OperationCodes.SIMPLE_PASSWORD. equals(configure.name())) { if (passcodePolicy.isAllowSimple()) { - Item item = new Item(); target.setLocURI(configure.getCode()); meta.setFormat(Constants.META_FORMAT_INT); - List itemList = new ArrayList<>(); - item.setTarget(target); - item.setMeta(meta); - item.setData("1"); - itemList.add(item); - add.setCommandId(operation.getId()); - add.setItems(itemList); - + addTag = TagUtil.buildAddTag(operation, Constants.SyncMLResponseCodes.POSITIVE_CSP_DATA); } else { - Item item = new Item(); target.setLocURI(configure.getCode()); meta.setFormat(Constants.META_FORMAT_INT); - List itemList = new ArrayList<>(); - item.setTarget(target); - item.setMeta(meta); - item.setData("0"); - itemList.add(item); - add.setCommandId(operation.getId()); - add.setItems(itemList); + addTag = TagUtil.buildAddTag(operation, Constants.SyncMLResponseCodes.NEGATIVE_CSP_DATA); } } - return add; + return addTag; } } - - - diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/util/OperationUtils.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/util/OperationUtils.java deleted file mode 100644 index 4ff0475af..000000000 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/util/OperationUtils.java +++ /dev/null @@ -1,502 +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.mdm.mobileservices.windows.operations.util; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.json.JSONException; -import org.json.JSONObject; -import org.wso2.carbon.device.mgt.common.DeviceIdentifier; -import org.wso2.carbon.device.mgt.common.DeviceManagementException; -import org.wso2.carbon.device.mgt.common.FeatureManagementException; -import org.wso2.carbon.device.mgt.common.notification.mgt.Notification; -import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagementException; -import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagementService; -import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; -import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException; -import org.wso2.carbon.mdm.mobileservices.windows.common.PluginConstants; -import org.wso2.carbon.mdm.mobileservices.windows.common.exceptions.WindowsDeviceEnrolmentException; -import org.wso2.carbon.mdm.mobileservices.windows.common.util.WindowsAPIUtils; -import org.wso2.carbon.mdm.mobileservices.windows.operations.*; -import org.wso2.carbon.mdm.mobileservices.windows.services.syncml.beans.Profile; -import org.wso2.carbon.policy.mgt.common.ProfileFeature; -import org.wso2.carbon.policy.mgt.common.monitor.ComplianceFeature; -import org.wso2.carbon.policy.mgt.common.monitor.PolicyComplianceException; - -import java.util.ArrayList; -import java.util.List; - -import static org.wso2.carbon.mdm.mobileservices.windows.common.util.WindowsAPIUtils.convertToDeviceIdentifierObject; - -/** - * Class contains Operation related utilities. - */ -public class OperationUtils { - private static Log log = LogFactory.getLog(OperationUtils.class); - List pendingDataOperations; - - - /** - * Update the operations using device status payload. - * - * @param status Client side status for the specific operations - * @param syncmlDocument syncml payload for operation status which parse through the syncml engine - * @param deviceIdentifier specific device identifier for each device - * @throws OperationManagementException - * @throws DeviceManagementException - */ - public void updateDeviceOperations(Status status, SyncmlDocument syncmlDocument, - DeviceIdentifier deviceIdentifier) - throws OperationManagementException, DeviceManagementException, NotificationManagementException, - WindowsOperationException { - - pendingDataOperations = WindowsAPIUtils.getDeviceManagementService() - .getOperationsByDeviceAndStatus(deviceIdentifier, Operation.Status.PENDING); - if (status.getData().equals(Constants.SyncMLResponseCodes.ACCEPTED) || status.getData().equals - (Constants.SyncMLResponseCodes.ACCEPTED_FOR_PROCESSING)) { - for (Operation operation : pendingDataOperations) { - if (operation.getId() == status.getCommandReference()) { - operation.setStatus(Operation.Status.COMPLETED); - } - } - updateOperations(syncmlDocument.getHeader().getSource().getLocURI(), pendingDataOperations); - } else if (status.getData().equals(Constants.SyncMLResponseCodes.PIN_NOTFOUND)) { - for (Operation operation : pendingDataOperations) { - if (operation.getId() == status.getCommandReference() && operation. - getCode().equals(String.valueOf(OperationCode.Command.DEVICE_LOCK))) { - operation.setStatus(Operation.Status.ERROR); - updateOperations(syncmlDocument.getHeader().getSource().getLocURI(), pendingDataOperations); - try { - NotificationManagementService nmService = WindowsAPIUtils.getNotificationManagementService(); - Notification lockResetNotification = new Notification(); - lockResetNotification.setOperationId(status.getCommandReference()); - lockResetNotification.setStatus(String.valueOf(Notification.Status.NEW)); - lockResetNotification.setDescription( - Constants.SyncMLResponseCodes.LOCKRESET_NOTIFICATION); - nmService.addNotification(deviceIdentifier, lockResetNotification); - } catch (NotificationManagementException e) { - throw new WindowsOperationException("Failure occurred in getting notification service", e); - } - } - } - } - } - - /** - * Update operation statuses - * - * @param deviceId specific device Id - * @param operations operation list to be update - * @throws OperationManagementException - */ - public void updateOperations(String deviceId, - List operations) - throws OperationManagementException { - - for (Operation operation : operations) { - WindowsAPIUtils.updateOperation(deviceId, operation); - if (log.isDebugEnabled()) { - log.debug("Updating operation '" + operation.toString() + "'"); - } - } - } - - /** - * Update Status of the lock operation. - * - * @param status Status of the operation. - * @param syncmlDocument parsed syncml payload. - * @param deviceIdentifier Device Id. - * @throws OperationManagementException - * @throws DeviceManagementException - * @throws NotificationManagementException - */ - public void lockOperationUpdate(Status status, SyncmlDocument syncmlDocument, DeviceIdentifier deviceIdentifier) - throws OperationManagementException, DeviceManagementException, NotificationManagementException { - - pendingDataOperations = WindowsAPIUtils.getDeviceManagementService() - .getOperationsByDeviceAndStatus(deviceIdentifier, Operation.Status.PENDING); - if (status.getData().equals(Constants.SyncMLResponseCodes.ACCEPTED)) { - for (Operation operation : pendingDataOperations) { - if (operation.getCode().equals(OperationCode.Command.DEVICE_LOCK.getCode()) - && operation.getId() == status.getCommandReference()) { - operation.setStatus(Operation.Status.COMPLETED); - new OperationUtils().updateOperations(syncmlDocument.getHeader().getSource().getLocURI(), - pendingDataOperations); - } - } - } - if (status.getData().equals(Constants.SyncMLResponseCodes.PIN_NOTFOUND)) { - for (Operation operation : pendingDataOperations) { - - if (operation.getCode().equals(OperationCode.Command.DEVICE_LOCK.getCode()) && - operation.getId() == status.getCommandReference()) { - operation.setStatus(Operation.Status.ERROR); - new OperationUtils().updateOperations(syncmlDocument.getHeader().getSource().getLocURI(), - pendingDataOperations); - try { - NotificationManagementService nmService = WindowsAPIUtils.getNotificationManagementService(); - Notification lockResetNotification = new Notification(); - lockResetNotification.setOperationId(status.getCommandReference()); - lockResetNotification.setStatus(String.valueOf(Notification.Status.NEW)); - lockResetNotification.setDescription(Constants.SyncMLResponseCodes.LOCKRESET_NOTIFICATION); - - nmService.addNotification(deviceIdentifier, lockResetNotification); - } catch (NotificationManagementException e) { - String msg = "Failure occurred in getting notification service"; - log.error(msg, e); - throw new NotificationManagementException(msg, e); - } - } - } - } - } - - /*** - * Update status of the ring operation. - * - * @param status Ring status of the device. - * @param syncmlDocument Parsed syncml payload from the syncml engine. - * @param deviceIdentifier specific device id to be update. - * @throws OperationManagementException - * @throws DeviceManagementException - */ - public void ring(Status status, SyncmlDocument syncmlDocument, - DeviceIdentifier deviceIdentifier) - throws OperationManagementException, DeviceManagementException { - - if (status.getData().equals(Constants.SyncMLResponseCodes.ACCEPTED)) { - pendingDataOperations = WindowsAPIUtils.getDeviceManagementService() - .getOperationsByDeviceAndStatus(deviceIdentifier, Operation.Status.PENDING); - for (Operation operation : pendingDataOperations) { - if (operation.getCode().equals(OperationCode.Command.DEVICE_RING) && - (operation.getId() == status.getCommandReference())) { - operation.setStatus(Operation.Status.COMPLETED); - new OperationUtils().updateOperations(syncmlDocument.getHeader().getSource().getLocURI(), - pendingDataOperations); - } - } - } - } - - /*** - * Update the status of the DataWipe operation. - * - * @param status Status of the datawipe. - * @param syncmlDocument Parsed syncml payload from the syncml engine. - * @param deviceIdentifier specific device id to be wiped. - * @throws OperationManagementException - * @throws DeviceManagementException - */ - public void dataWipe(Status status, SyncmlDocument syncmlDocument, - DeviceIdentifier deviceIdentifier) - throws OperationManagementException, DeviceManagementException { - - if (status.getData().equals(Constants.SyncMLResponseCodes.ACCEPTED)) { - pendingDataOperations = WindowsAPIUtils.getDeviceManagementService() - .getOperationsByDeviceAndStatus(deviceIdentifier, Operation.Status.PENDING); - for (Operation operation : pendingDataOperations) { - - if (operation.getCode().equals(OperationCode.Command.WIPE_DATA) && - (operation.getId() == status.getCommandReference())) { - operation.setStatus(Operation.Status.COMPLETED); - updateOperations(syncmlDocument.getHeader().getSource().getLocURI(), - pendingDataOperations); - } - } - } - } - - /** - * Get pending operations. - * - * @param syncmlDocument SyncmlDocument object which creates from the syncml engine using syncml payload - * @return Return list of pending operations. - * @throws OperationManagementException - * @throws DeviceManagementException - * @throws FeatureManagementException - * @throws PolicyComplianceException - * @throws NotificationManagementException - */ - public List getPendingOperations(SyncmlDocument syncmlDocument) - throws OperationManagementException, DeviceManagementException, FeatureManagementException, - PolicyComplianceException, NotificationManagementException, WindowsDeviceEnrolmentException, - WindowsOperationException { - - List pendingOperations; - DeviceIdentifier deviceIdentifier = convertToDeviceIdentifierObject( - syncmlDocument.getHeader().getSource().getLocURI()); - UpdateUriOperations(syncmlDocument); - generateComplianceFeatureStatus(syncmlDocument); - - pendingOperations = WindowsAPIUtils.getDeviceManagementService().getPendingOperations(deviceIdentifier); - return pendingOperations; - } - - /** - * Set compliance of the feature according to the device status for the specific feature. - * - * @param activeFeature - * @param deviceFeature - * @return Returns setting up compliance feature. - */ - public ComplianceFeature setComplianceFeatures(ProfileFeature activeFeature, Profile deviceFeature) { - ComplianceFeature complianceFeature = new ComplianceFeature(); - complianceFeature.setFeature(activeFeature); - complianceFeature.setFeatureCode(activeFeature.getFeatureCode()); - complianceFeature.setCompliance(deviceFeature.isCompliance()); - return complianceFeature; - } - - /** - * Update the completed/Error status of the operation which have the URI of the operation code in the syncml payload. - * - * @param syncmlDocument SyncmlDocument object generated from the the syncml engine. - * @throws DeviceManagementException - * @throws NotificationManagementException - * @throws OperationManagementException - */ - public void UpdateUriOperations(SyncmlDocument syncmlDocument) throws DeviceManagementException, - NotificationManagementException, OperationManagementException, WindowsOperationException { - DeviceIdentifier deviceIdentifier = convertToDeviceIdentifierObject( - syncmlDocument.getHeader().getSource().getLocURI()); - List statuses = syncmlDocument.getBody().getStatus(); - OperationUtils operationUtils = new OperationUtils(); - - for (Status status : statuses) { - - if (status.getCommand().equals(Constants.EXECUTE)) { - if (status.getTargetReference() == null) { - operationUtils.updateDeviceOperations(status, syncmlDocument, deviceIdentifier); - } else { - if (status.getTargetReference().equals(OperationCode.Command.DEVICE_LOCK)) { - operationUtils.lockOperationUpdate(status, syncmlDocument, deviceIdentifier); - } - if (status.getTargetReference().equals(OperationCode.Command.DEVICE_RING)) { - operationUtils.ring(status, syncmlDocument, deviceIdentifier); - } - if (status.getTargetReference().equals(OperationCode.Command.WIPE_DATA)) { - operationUtils.dataWipe(status, syncmlDocument, deviceIdentifier); - } - } - } - if (status.getCommand().equals(Constants.SEQUENCE)) { - if (status.getData().equals(Constants.SyncMLResponseCodes.ACCEPTED)) { - - pendingDataOperations = WindowsAPIUtils.getDeviceManagementService() - .getOperationsByDeviceAndStatus(deviceIdentifier, Operation.Status.PENDING); - for (Operation operation : pendingDataOperations) { - if (operation.getCode().equals(PluginConstants.OperationCodes.POLICY_BUNDLE) && - operation.getId() == status.getCommandReference()) { - operation.setStatus(Operation.Status.COMPLETED); - } - if (operation.getCode().equals(PluginConstants.OperationCodes.MONITOR) && - operation.getId() == status.getCommandReference()) { - operation.setStatus(Operation.Status.COMPLETED); - } - } - operationUtils.updateOperations(syncmlDocument.getHeader().getSource().getLocURI(), - pendingDataOperations); - } else { - pendingDataOperations = WindowsAPIUtils.getDeviceManagementService() - .getOperationsByDeviceAndStatus(deviceIdentifier, Operation.Status.PENDING); - for (Operation operation : pendingDataOperations) { - - if (operation.getCode().equals(PluginConstants.OperationCodes.POLICY_BUNDLE) && - operation.getId() == status.getCommandReference()) { - operation.setStatus(Operation.Status.ERROR); - } - if (operation.getCode().equals(PluginConstants.OperationCodes.MONITOR) && - operation.getId() == status.getCommandReference()) { - operation.setStatus(Operation.Status.ERROR); - } - } - operationUtils.updateOperations(syncmlDocument.getHeader().getSource().getLocURI(), - pendingDataOperations); - } - } - } - } - - /** - * Generate status of the features that have been activated on the device. - * - * @param syncmlDocument syncmlDocument object pasrsed from the syncml engine. - * @return device statuses for the activated features - * @throws NotificationManagementException - */ - public List generateDeviceOperationStatusObject(SyncmlDocument syncmlDocument) throws - NotificationManagementException, WindowsOperationException { - - DeviceIdentifier deviceIdentifier = convertToDeviceIdentifierObject( - syncmlDocument.getHeader().getSource().getLocURI()); - String lockUri = null; - Results result = syncmlDocument.getBody().getResults(); - - List profiles = new ArrayList<>(); - if (result != null) { - List results = result.getItem(); - for (OperationCode.Info info : OperationCode.Info.values()) { - if (PluginConstants.OperationCodes.PIN_CODE.equals(info - .name())) { - lockUri = info.getCode(); - } - } - for (Item item : results) { - for (OperationCode.Info info : OperationCode.Info.values()) { - if (item.getSource().getLocURI().equals(info.getCode()) && info.name().equals( - PluginConstants.OperationCodes.CAMERA_STATUS)) { - Profile cameraProfile = new Profile(); - cameraProfile.setFeatureCode(PluginConstants.OperationCodes.CAMERA); - cameraProfile.setData(item.getData()); - if (item.getData().equals(PluginConstants.SyncML.SYNCML_DATA_ONE)) { - cameraProfile.setEnable(true); - } else { - cameraProfile.setEnable(false); - } - profiles.add(cameraProfile); - } - if (item.getSource().getLocURI().equals(info.getCode()) && info.name().equals( - PluginConstants.OperationCodes.ENCRYPT_STORAGE_STATUS)) { - Profile encryptStorage = new Profile(); - encryptStorage.setFeatureCode(PluginConstants.OperationCodes.ENCRYPT_STORAGE); - encryptStorage.setData(item.getData()); - if (item.getData().equals(PluginConstants.SyncML.SYNCML_DATA_ONE)) { - encryptStorage.setEnable(true); - } else { - encryptStorage.setEnable(false); - } - profiles.add(encryptStorage); - } - if (item.getSource().getLocURI().equals(info.getCode()) && info.name().equals( - PluginConstants.OperationCodes.DEVICE_PASSWORD_STATUS)) { - Profile encryptStorage = new Profile(); - encryptStorage.setFeatureCode(PluginConstants.OperationCodes.PASSCODE_POLICY); - encryptStorage.setData(item.getData()); - if (item.getData().equals(PluginConstants.SyncML.SYNCML_DATA_ZERO)) { - encryptStorage.setEnable(true); - } else { - encryptStorage.setEnable(false); - } - profiles.add(encryptStorage); - } - if (!item.getData().isEmpty() && item.getSource().getLocURI().equals(lockUri)) { - String pinValue = item.getData(); - NotificationManagementService nmService = WindowsAPIUtils.getNotificationManagementService(); - Notification notification = new Notification(); - notification.setDescription("Auto generated DevicePin : " + pinValue); - notification.setOperationId(result.getCommandReference()); - notification.setStatus(String.valueOf(Notification.Status.NEW)); - try { - nmService.addNotification(deviceIdentifier, notification); - } catch (NotificationManagementException e) { - String msg = "Failure Occurred in getting notification service."; - log.error(msg, e); - throw new WindowsOperationException(msg, e); - } - break; - } - } - } - } - return profiles; - } - - /** - * Generate Compliance Features - * - * @param syncmlDocument syncmlDocument object parsed from the syncml engine. - * @throws NotificationManagementException - * @throws FeatureManagementException - * @throws PolicyComplianceException - */ - public void generateComplianceFeatureStatus(SyncmlDocument syncmlDocument) throws NotificationManagementException, - FeatureManagementException, PolicyComplianceException, WindowsDeviceEnrolmentException, - WindowsOperationException { - List profiles = generateDeviceOperationStatusObject(syncmlDocument); - DeviceIdentifier deviceIdentifier = convertToDeviceIdentifierObject( - syncmlDocument.getHeader().getSource().getLocURI()); - boolean isCompliance = false; - if (profiles.size() != Constants.EMPTY) { - try { - List profileFeatures = WindowsAPIUtils.getPolicyManagerService().getEffectiveFeatures( - deviceIdentifier); - List complianceFeatures = new ArrayList<>(); - for (ProfileFeature activeFeature : profileFeatures) { - JSONObject policyContent = new JSONObject(activeFeature.getContent().toString()); - - for (Profile deviceFeature : profiles) { - if (deviceFeature.getFeatureCode().equals(activeFeature.getFeatureCode()) && - deviceFeature.getFeatureCode().equals(PluginConstants.OperationCodes.CAMERA)) { - if (policyContent.getBoolean(PluginConstants.PolicyConfigProperties. - POLICY_ENABLE) == (deviceFeature.isEnable())) { - isCompliance = true; - deviceFeature.setCompliance(isCompliance); - } else { - deviceFeature.setCompliance(isCompliance); - } - ComplianceFeature complianceFeature = setComplianceFeatures(activeFeature, deviceFeature); - complianceFeatures.add(complianceFeature); - } - if (deviceFeature.getFeatureCode().equals(activeFeature.getFeatureCode()) && - deviceFeature.getFeatureCode().equals(PluginConstants.OperationCodes. - ENCRYPT_STORAGE)) { - if (policyContent.getBoolean(PluginConstants.PolicyConfigProperties. - ENCRYPTED_ENABLE) == (deviceFeature.isEnable())) { - isCompliance = true; - deviceFeature.setCompliance(isCompliance); - } else { - deviceFeature.setCompliance(isCompliance); - } - ComplianceFeature complianceFeature = setComplianceFeatures(activeFeature, deviceFeature); - complianceFeatures.add(complianceFeature); - } - if (deviceFeature.getFeatureCode().equals(activeFeature.getFeatureCode()) && - deviceFeature.getFeatureCode().equals(PluginConstants.OperationCodes. - PASSCODE_POLICY)) { - if (policyContent.getBoolean(PluginConstants.PolicyConfigProperties. - ENABLE_PASSWORD) == (deviceFeature.isEnable())) { - isCompliance = true; - deviceFeature.setCompliance(isCompliance); - } else { - deviceFeature.setCompliance(isCompliance); - } - ComplianceFeature complianceFeature = setComplianceFeatures(activeFeature, deviceFeature); - complianceFeatures.add(complianceFeature); - } - } - } - WindowsAPIUtils.getPolicyManagerService().checkPolicyCompliance(deviceIdentifier, complianceFeatures); - } catch (org.wso2.carbon.policy.mgt.common.FeatureManagementException e) { - String msg = "Error occurred while getting effective policy."; - log.error(msg, e); - throw new FeatureManagementException(msg, e); - } catch (JSONException e) { - String msg = "Error occurred while parsing json object."; - log.error(msg); - throw new WindowsDeviceEnrolmentException(msg, e); - } catch (PolicyComplianceException e) { - String msg = "Error occurred while setting up policy compliance."; - log.error(msg, e); - throw new PolicyComplianceException(msg, e); - } - } - - } -} diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/util/SyncmlCredentials.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/util/SyncmlCredentialUtil.java similarity index 72% rename from components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/util/SyncmlCredentials.java rename to components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/util/SyncmlCredentialUtil.java index e54aadedb..b32d5e0b2 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/util/SyncmlCredentials.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/util/SyncmlCredentialUtil.java @@ -1,17 +1,17 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ @@ -26,11 +26,11 @@ import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; /** - * Class for generate security token for client and server. + * Generate security token to client and server. */ -public class SyncmlCredentials { +public class SyncmlCredentialUtil { - public String generateCredData(String nextNonce) throws SyncmlMessageFormatException { + public static String generateCredData(String nextNonce) throws SyncmlMessageFormatException { MessageDigest digest; String usrPwdNonceHash; String nonce; @@ -42,14 +42,15 @@ public class SyncmlCredentials { String usrPwdNonce = usrPwdHash + ":" + nonce; usrPwdNonceHash = Base64.encodeBase64String(digest.digest(usrPwdNonce.getBytes(Constants.UTF_8))); } catch (UnsupportedEncodingException e) { - throw new SyncmlMessageFormatException("Problem occurred in encoding credentials data.", e); + throw new SyncmlMessageFormatException("Problem occurred while decoding credentials data.", e); } catch (NoSuchAlgorithmException e) { - throw new SyncmlMessageFormatException("Problem occurred in generating password hash.", e); + throw new SyncmlMessageFormatException("Application environment does not have an implementation " + + "available/configured for the requested algorithm", e); } return usrPwdNonceHash; } - public String generateRST(String username, String password) throws SyncmlMessageFormatException { + public static String generateRST(String username, String password) throws SyncmlMessageFormatException { MessageDigest digest; String usrPwdNonceHash; String nonce; @@ -61,9 +62,10 @@ public class SyncmlCredentials { String usrPwdNonce = usrPwdHash + ":" + nonce; usrPwdNonceHash = Base64.encodeBase64String(digest.digest(usrPwdNonce.getBytes(Constants.UTF_8))); } catch (UnsupportedEncodingException e) { - throw new SyncmlMessageFormatException("Problem occurred in encoding credentials data.", e); + throw new SyncmlMessageFormatException("Problem occurred while decoding credentials data.", e); } catch (NoSuchAlgorithmException e) { - throw new SyncmlMessageFormatException("Problem occurred in generating password hash.", e); + throw new SyncmlMessageFormatException("Application environment does not have an implementation " + + "available/configured for the requested algorithm", e); } return usrPwdNonceHash; } diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/util/SyncmlGenerator.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/util/SyncmlGenerator.java index 91b07d315..cb8b6d1e6 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/util/SyncmlGenerator.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/util/SyncmlGenerator.java @@ -1,25 +1,23 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.wso2.carbon.mdm.mobileservices.windows.operations.util; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.wso2.carbon.mdm.mobileservices.windows.common.exceptions.SyncmlOperationException; @@ -36,13 +34,11 @@ import javax.xml.transform.stream.StreamResult; import java.io.StringWriter; /** - * Generates the response syncml xml file that should be sent to the phone. + * Generates the response syncml xml file that should be sent to the Device. */ public class SyncmlGenerator { - private static Log log = LogFactory.getLog(SyncmlGenerator.class); - - public String generatePayload(SyncmlDocument syncmlDocument) throws SyncmlOperationException { + public static String generatePayload(SyncmlDocument syncmlDocument) throws SyncmlOperationException { Document doc = generateDocument(); Element rootElement = createRootElement(doc); SyncmlHeader header = syncmlDocument.getHeader(); @@ -58,9 +54,7 @@ public class SyncmlGenerator { try { docBuilder = documentFactory.newDocumentBuilder(); } catch (ParserConfigurationException e) { - String message = "Error while generating a new document of syncml"; - log.error(message, e); - throw new SyncmlOperationException(message, e); + throw new SyncmlOperationException("Error occurred while generating a new document of syncml", e); } return docBuilder.newDocument(); } @@ -72,16 +66,14 @@ public class SyncmlGenerator { return rootElement; } - private String transformDocument(Document document) throws SyncmlOperationException { + private static String transformDocument(Document document) throws SyncmlOperationException { DOMSource domSource = new DOMSource(document); TransformerFactory transformerFactory = TransformerFactory.newInstance(); Transformer transformer; try { transformer = transformerFactory.newTransformer(); } catch (TransformerConfigurationException e) { - String message = "Error while retrieving a new transformer"; - log.error(message, e); - throw new SyncmlOperationException(message, e); + throw new SyncmlOperationException("Error occurred while retrieving a new transformer", e); } transformer.setOutputProperty(OutputKeys.ENCODING, Constants.UTF_8); transformer.setOutputProperty(OutputKeys.INDENT, Constants.YES); @@ -91,9 +83,7 @@ public class SyncmlGenerator { try { transformer.transform(domSource, streamResult); } catch (TransformerException e) { - String message = "Error while transforming document to a string"; - log.error(message, e); - throw new SyncmlOperationException(message, e); + throw new SyncmlOperationException("Error occurred while transforming document to a string", e); } return stringWriter.toString(); } diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/util/SyncmlParser.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/util/SyncmlParser.java index 791e0e226..8d05c82d7 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/util/SyncmlParser.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/util/SyncmlParser.java @@ -1,17 +1,17 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ @@ -22,11 +22,9 @@ import org.w3c.dom.Document; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.wso2.carbon.mdm.mobileservices.windows.common.PluginConstants; -import org.wso2.carbon.mdm.mobileservices.windows.common.exceptions.SyncmlMessageFormatException; import org.wso2.carbon.mdm.mobileservices.windows.operations.*; import java.util.ArrayList; -import java.util.IllegalFormatCodePointException; import java.util.List; /** @@ -80,15 +78,17 @@ public class SyncmlParser { * @param syncmlPayload - Received SyncML XML payload * @return - SyncmlDocument object generated from the received payload */ - public static SyncmlDocument parseSyncmlPayload(Document syncmlPayload) throws SyncmlMessageFormatException { + public static SyncmlDocument parseSyncmlPayload(Document syncmlPayload) { SyncmlDocument syncmlDocument = new SyncmlDocument(); if (syncmlPayload.getElementsByTagName(SYNC_HEADER) == null) { - throw new SyncmlMessageFormatException(); + throw new IllegalStateException(); } NodeList syncHeaderList = syncmlPayload.getElementsByTagName(SYNC_HEADER); Node syncHeader = syncHeaderList.item(0); SyncmlHeader header = generateSyncmlHeader(syncHeader); - + if (syncmlPayload.getElementsByTagName(SYNC_BODY) == null) { + throw new IllegalStateException(); + } NodeList syncBodyList = syncmlPayload.getElementsByTagName(SYNC_BODY); Node syncBody = syncBodyList.item(0); SyncmlBody body = generateSyncmlBody(syncBody); @@ -108,9 +108,9 @@ public class SyncmlParser { String sessionID = null; String messageID = null; - Target target = null; - Source source = null; - Credential credential = null; + TargetTag target = null; + SourceTag source = null; + CredentialTag credential = null; SyncmlHeader header = new SyncmlHeader(); NodeList headerElements = syncHeader.getChildNodes(); @@ -122,31 +122,31 @@ public class SyncmlParser { if (SyncMLHeaderParameter.MSG_ID.getValue().equals(nodeName)) { if (node.getTextContent().trim() == null) { - throw new IllegalFormatCodePointException(2); + throw new IllegalStateException(); } else { messageID = node.getTextContent().trim(); } } else if (SyncMLHeaderParameter.SESSION_ID.getValue().equals(nodeName)) { if (node.getTextContent().trim() == null) { - throw new IllegalFormatCodePointException(2); + throw new IllegalStateException(); } else { sessionID = node.getTextContent().trim(); } } else if (SyncMLHeaderParameter.TARGET.getValue().equals(nodeName)) { if (node.getTextContent().trim() == null) { - throw new IllegalFormatCodePointException(2); + throw new IllegalStateException(); } else { target = generateTarget(node); } } else if (SyncMLHeaderParameter.SOURCE.getValue().equals(nodeName)) { if (node.getTextContent().trim() == null) { - throw new IllegalFormatCodePointException(2); + throw new IllegalStateException(); } else { source = generateSource(node); } } else if (SyncMLHeaderParameter.CRED.getValue().equals(nodeName)) { if (node.getTextContent().trim() == null) { - throw new IllegalFormatCodePointException(2); + throw new IllegalStateException(); } else { credential = generateCredential(node); } @@ -170,10 +170,10 @@ public class SyncmlParser { */ private static SyncmlBody generateSyncmlBody(Node syncBody) { - Alert alert = null; - Replace replace = null; - Results results = null; - List status = new ArrayList<>(); + AlertTag alert = null; + ReplaceTag replace = null; + ResultsTag results = null; + List status = new ArrayList<>(); NodeList bodyElements = syncBody.getChildNodes(); for (int i = 0; i < bodyElements.getLength(); i++) { @@ -207,9 +207,9 @@ public class SyncmlParser { * @param node - XML node which represents Source * @return - Source object */ - private static Source generateSource(Node node) { + private static SourceTag generateSource(Node node) { - Source source = new Source(); + SourceTag source = new SourceTag(); Node sourceURIItem = node.getChildNodes().item(0); Node sourceNameItem = node.getChildNodes().item(1); String sourceURI = null; @@ -232,9 +232,9 @@ public class SyncmlParser { * @param node - XML node which represents Target * @return - Target object */ - private static Target generateTarget(Node node) { + private static TargetTag generateTarget(Node node) { - Target target = new Target(); + TargetTag target = new TargetTag(); Node targetURIItem = node.getChildNodes().item(0); Node targetNameItem = node.getChildNodes().item(1); String targetURI = null; @@ -257,10 +257,10 @@ public class SyncmlParser { * @param node - XML node which represents Results * @return - Results object */ - private static Results generateResults(Node node) { + private static ResultsTag generateResults(Node node) { - Results results = new Results(); - List item = new ArrayList<>(); + ResultsTag results = new ResultsTag(); + List item = new ArrayList<>(); if (node.getNodeType() == Node.ELEMENT_NODE) { @@ -298,9 +298,9 @@ public class SyncmlParser { * @param node - XML node which represents Status * @return - Status object */ - private static Status generateStatus(Node node) { + private static StatusTag generateStatus(Node node) { - Status status = new Status(); + StatusTag status = new StatusTag(); for (int x = 0; x < node.getChildNodes().getLength(); x++) { String nodeName = node.getChildNodes().item(x).getNodeName(); switch (nodeName) { @@ -321,17 +321,17 @@ public class SyncmlParser { status.setCommand(command); break; case PluginConstants.SyncML.SYNCML_CHAL: - NodeList chalNodes = node.getChildNodes().item(x).getChildNodes(); + NodeList childNodes = node.getChildNodes().item(x).getChildNodes(); MetaTag meta = new MetaTag(); - ChallengeTag chal = new ChallengeTag(); - String format = chalNodes.item(0).getFirstChild().getTextContent(); + ChallengeTag challengeTag = new ChallengeTag(); + String format = childNodes.item(0).getFirstChild().getTextContent(); meta.setFormat(format); - String type = chalNodes.item(0).getFirstChild().getNextSibling().getTextContent(); + String type = childNodes.item(0).getFirstChild().getNextSibling().getTextContent(); meta.setType(type); - String nonce = chalNodes.item(0).getFirstChild().getNextSibling().getNextSibling().getTextContent(); + String nonce = childNodes.item(0).getFirstChild().getNextSibling().getNextSibling().getTextContent(); meta.setNextNonce(nonce); - chal.setMeta(meta); - status.setChallenge(chal); + challengeTag.setMeta(meta); + status.setChallenge(challengeTag); break; case PluginConstants.SyncML.SYNCML_DATA: String data = node.getChildNodes().item(x).getTextContent().trim(); @@ -352,11 +352,11 @@ public class SyncmlParser { * @param node - XML node which represents Replace * @return - Replace object */ - private static Replace generateReplace(Node node) { + private static ReplaceTag generateReplace(Node node) { - Replace replace = new Replace(); + ReplaceTag replace = new ReplaceTag(); String commandId = node.getChildNodes().item(0).getTextContent().trim(); - List items = new ArrayList<>(); + List items = new ArrayList<>(); for (int i = 0; i < node.getChildNodes().getLength() - 1; i++) { items.add(generateItem(node.getChildNodes().item(i + 1))); } @@ -371,8 +371,8 @@ public class SyncmlParser { * @param node - XML node which represents Alert * @return - Alert object */ - private static Alert generateAlert(Node node) { - Alert alert = new Alert(); + private static AlertTag generateAlert(Node node) { + AlertTag alert = new AlertTag(); String commandID = node.getChildNodes().item(0).getTextContent().trim(); String data = node.getChildNodes().item(1).getTextContent().trim(); alert.setCommandId(Integer.valueOf(commandID)); @@ -386,39 +386,41 @@ public class SyncmlParser { * @param node - XML node which represents Item * @return - Item object */ - private static Item generateItem(Node node) { - Item item = new Item(); - Source source = new Source(); + private static ItemTag generateItem(Node node) { + ItemTag item = new ItemTag(); + SourceTag source = new SourceTag(); String data; String nodeName; String childNodeName; String locUri; for (int x = 0; x < node.getChildNodes().getLength(); x++) { - if (node.getChildNodes().item(x).getNodeName() != null) { + Node itemNode; + itemNode = node.getChildNodes().item(x); + if (itemNode.getNodeName() != null) { nodeName = node.getChildNodes().item(x).getNodeName(); } else { - throw new IllegalFormatCodePointException(2); + throw new IllegalStateException(); } - if (nodeName == PluginConstants.SyncML.SYNCML_SOURCE) { - if (node.getChildNodes().item(x).getChildNodes().item(x).getNodeName() != null) { - childNodeName = node.getChildNodes().item(x).getChildNodes().item(x).getNodeName(); + if (PluginConstants.SyncML.SYNCML_SOURCE.equals(nodeName)) { + if (itemNode.getChildNodes().item(x).getNodeName() != null) { + childNodeName = itemNode.getChildNodes().item(x).getNodeName(); } else { - throw new IllegalFormatCodePointException(2); + throw new IllegalStateException(); } - if (childNodeName == PluginConstants.SyncML.SYNCML_LOCATION_URI) { - if (node.getChildNodes().item(x).getChildNodes().item(x).getTextContent().trim() != null) { - locUri = node.getChildNodes().item(x).getChildNodes().item(x).getTextContent().trim(); + if ((PluginConstants.SyncML.SYNCML_LOCATION_URI.equals(childNodeName))) { + if (itemNode.getChildNodes().item(x).getTextContent().trim() != null) { + locUri = itemNode.getChildNodes().item(x).getTextContent().trim(); } else { - throw new IllegalFormatCodePointException(2); + throw new IllegalStateException(); } source.setLocURI(locUri); item.setSource(source); } - } else if (nodeName == PluginConstants.SyncML.SYNCML_DATA) { - if (node.getChildNodes().item(x).getTextContent().trim() != null) { - data = node.getChildNodes().item(x).getTextContent().trim(); + } else if (PluginConstants.SyncML.SYNCML_DATA.equals(nodeName)) { + if (itemNode.getTextContent().trim() != null) { + data = itemNode.getTextContent().trim(); } else { - throw new IllegalFormatCodePointException(2); + throw new IllegalStateException(); } item.setData(data); } @@ -432,8 +434,8 @@ public class SyncmlParser { * @param node - XML node which represents Credential * @return - Credential object */ - private static Credential generateCredential(Node node) { - Credential credential = new Credential(); + private static CredentialTag generateCredential(Node node) { + CredentialTag credential = new CredentialTag(); MetaTag meta = generateMeta(node.getChildNodes().item(0)); String data = node.getChildNodes().item(1).getTextContent().trim(); credential.setMeta(meta); diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/util/TagUtil.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/util/TagUtil.java new file mode 100644 index 000000000..10eeeea84 --- /dev/null +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/operations/util/TagUtil.java @@ -0,0 +1,56 @@ +/* + * 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.mdm.mobileservices.windows.operations.util; + +import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; +import org.wso2.carbon.mdm.mobileservices.windows.operations.AddTag; +import org.wso2.carbon.mdm.mobileservices.windows.operations.ItemTag; +import org.wso2.carbon.mdm.mobileservices.windows.operations.MetaTag; +import org.wso2.carbon.mdm.mobileservices.windows.operations.TargetTag; + +import java.util.ArrayList; +import java.util.List; + +/** + * Contains utility methods which are used while creating Syncml Messages. + */ +public class TagUtil { + /** + * Build syncml AddTag for Device response message. + * + * @param operation Policy operation + * @param data Configuration service provider(CSP) data value 1/0 + * @return Syncml AddTag type object. + */ + public static AddTag buildAddTag(Operation operation, String data) { + TargetTag target = new TargetTag(); + MetaTag meta = new MetaTag(); + AddTag add = new AddTag(); + + List itemTags = new ArrayList<>(); + ItemTag itemTag = new ItemTag(); + itemTag.setTarget(target); + itemTag.setMeta(meta); + itemTag.setData(data); + itemTags.add(itemTag); + add.setCommandId(operation.getId()); + add.setItems(itemTags); + return add; + } +} diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/adminoperations/Operations.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/adminoperations/Operations.java index e868265f4..b96831f4b 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/adminoperations/Operations.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/adminoperations/Operations.java @@ -1,27 +1,23 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * 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. + * 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.mdm.mobileservices.windows.services.adminoperations; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; import org.wso2.carbon.mdm.mobileservices.windows.common.exceptions.WindowsDeviceEnrolmentException; import javax.ws.rs.*; @@ -32,8 +28,6 @@ import java.util.List; /** * Interface for Admin operations persisting. This interface accepts operations added via UI. */ - -@Api(value = "Operations", description = "Windows Device Management REST-API implementation.") @Path("/operation") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @@ -42,72 +36,22 @@ public interface Operations { @POST @Path("/devicelock") - @ApiOperation( - produces = MediaType.APPLICATION_JSON, - httpMethod = "POST", - value = "Adding a Device Lock on Windows Devices via the REST API", - notes = "Adding a Device lock operation to the windows device" - ) - @ApiResponses(value = { - @ApiResponse(code = 201, message = "Created"), - @ApiResponse(code = 500, message = "Internal Server error") - }) Response lock(@HeaderParam("Accept") String headerParam, List deviceids) throws WindowsDeviceEnrolmentException; @POST @Path("/devicedisenroll") - @ApiOperation( - produces = MediaType.APPLICATION_JSON, - httpMethod = "POST", - value = "Disenrolling Windows Devices via the REST API", - notes = "Enforcing Disenrolling operation to the windows device" - ) - @ApiResponses(value = { - @ApiResponse(code = 201, message = "Created"), - @ApiResponse(code = 500, message = "Internal Server error") - }) Response disenroll(@HeaderParam("Accept") String headerParam, List deviceids) throws WindowsDeviceEnrolmentException; @POST @Path("/devicewipe") - @ApiOperation( - produces = MediaType.APPLICATION_JSON, - httpMethod = "POST", - value = "Wiping Information off Windows Devices via the REST API", - notes = "Enforce wipe operation to the windows device" - ) - @ApiResponses(value = { - @ApiResponse(code = 201, message = "Created"), - @ApiResponse(code = 500, message = "Internal Server error") - }) Response wipe(@HeaderParam("Accept") String headerParam, List deviceids) throws WindowsDeviceEnrolmentException; @POST @Path("/devicering") - @ApiOperation( - produces = MediaType.APPLICATION_JSON, - httpMethod = "POST", - value = "Ringing Windows Devices via the Rest API", - notes = "Adding a Device ring operation to the windows device." - ) - @ApiResponses(value = { - @ApiResponse(code = 201, message = "Created"), - @ApiResponse(code = 500, message = "Internal Server error") - }) Response ring(@HeaderParam("Accept") String headerParam, List deviceids) throws WindowsDeviceEnrolmentException; @POST @Path("/lockreset") - @ApiOperation( - produces = MediaType.APPLICATION_JSON, - httpMethod = "POST", - value = "Resetting the Lock of Windows Devices via the REST API", - notes = "Adding a Device lock re-test operation to the windows device." - ) - @ApiResponses(value = { - @ApiResponse(code = 201, message = "Created"), - @ApiResponse(code = 500, message = "Internal Server error") - }) Response lockReset(@HeaderParam("Accept") String acceptHeader, 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/mdm/mobileservices/windows/services/adminoperations/beans/Device.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/adminoperations/beans/Device.java index e8b347fad..79a4af79c 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/adminoperations/beans/Device.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/adminoperations/beans/Device.java @@ -1,32 +1,28 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.wso2.carbon.mdm.mobileservices.windows.services.adminoperations.beans; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - /** * Class for get device IDS. */ -@ApiModel(value = "Device", description = "This class carries all information related to Device.") public class Device { - @ApiModelProperty(name = "id", value = "DeviceIDs.", required = true) + private String id; public String getID() { diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/adminoperations/beans/OperationRequest.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/adminoperations/beans/OperationRequest.java new file mode 100644 index 000000000..0745aa53a --- /dev/null +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/adminoperations/beans/OperationRequest.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2015, 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.mdm.mobileservices.windows.services.adminoperations.beans; + +import org.wso2.carbon.mdm.mobileservices.windows.services.syncml.beans.BasicOperation; + +import java.util.List; + +/** + * Class for set basic operations. + */ +public class OperationRequest { + + private List deviceList; + private BasicOperation basicOperation; + + public BasicOperation getBasicOperation() { + return basicOperation; + } + + public void setBasicOperation(BasicOperation basicOperation) { + this.basicOperation = basicOperation; + } + + public List getDeviceList() { + return deviceList; + } + + public void setDeviceList(List deviceList) { + this.deviceList = deviceList; + } + +} diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/adminoperations/impl/OperationsImpl.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/adminoperations/impl/OperationsImpl.java index 7a68711c4..afffe53c2 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/adminoperations/impl/OperationsImpl.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/adminoperations/impl/OperationsImpl.java @@ -1,17 +1,17 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ @@ -51,7 +51,7 @@ public class OperationsImpl implements Operations { * REST endpoint for the Device Lock operation * * @param acceptHeader header value of the request POST message. - * @param deviceIDs list of device ids to be add device lockOperationUpdate operation. + * @param deviceIDs list of device ids to be add device updateLockOperation operation. * @return Response object for client. * @throws WindowsDeviceEnrolmentException */ @@ -60,7 +60,7 @@ public class OperationsImpl implements Operations { public Response lock(@HeaderParam("Accept") String acceptHeader, List deviceIDs) throws WindowsDeviceEnrolmentException { if (log.isDebugEnabled()) { - log.debug("Invoking windows device lockOperationUpdate operation"); + log.debug("Invoking windows device updateLockOperation operation"); } MediaType responseMediaType = WindowsAPIUtils.getResponseMediaType(acceptHeader); Message message = new Message(); @@ -198,15 +198,15 @@ public class OperationsImpl implements Operations { } /** - * REST endpoint for the device lockOperationUpdate reset. - * Lock reset have to be done, when device user does not set PIN for the lockOperationUpdate screen. - * Admin set lockOperationUpdate operation for the specific device,If the device is in above scenario, + * REST endpoint for the device updateLockOperation reset. + * Lock reset have to be done, when device user does not set PIN for the updateLockOperation screen. + * Admin set updateLockOperation operation for the specific device,If the device is in above scenario, * admin will be notified.since - * admin have to set lockOperationUpdate reset operation to the device so that automatically generate PIN value for the - * lockOperationUpdate screen. + * admin have to set updateLockOperation reset operation to the device so that automatically generate PIN value for the + * updateLockOperation screen. * * @param acceptHeader POST message header value. - * @param deviceIDs Device ids to be lockOperationUpdate reset. + * @param deviceIDs Device ids to be updateLockOperation reset. * @return Response object for the client. * @throws WindowsDeviceEnrolmentException */ diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/adminoperations/util/OperationStore.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/adminoperations/util/OperationStore.java new file mode 100644 index 000000000..d41230425 --- /dev/null +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/adminoperations/util/OperationStore.java @@ -0,0 +1,112 @@ +/* + * Copyright (c) 2014, 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.mdm.mobileservices.windows.services.adminoperations.util; +// +//import com.google.gson.Gson; +//import org.apache.commons.logging.Log; +//import org.apache.commons.logging.LogFactory; +//import org.wso2.carbon.context.PrivilegedCarbonContext; +//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.operation.mgt.Operation; +//import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException; +//import org.wso2.carbon.device.mgt.core.operation.mgt.ConfigOperation; +//import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; +//import org.wso2.carbon.mdm.mobileservices.windows.common.SyncmlCommandType; +//import org.wso2.carbon.mdm.mobileservices.windows.common.exceptions.WindowsDeviceEnrolmentException; +//import org.wso2.carbon.mdm.mobileservices.windows.services.adminoperations.beans.Device; +//import org.wso2.carbon.mdm.mobileservices.windows.services.adminoperations.beans.OperationRequest; +//import org.wso2.carbon.mdm.mobileservices.windows.services.syncml.beans.Wifi; +// +//import java.util.ArrayList; +//import java.util.List; +// +//public class OperationStore { +// +// private static Log log = LogFactory.getLog(OperationStore.class); +// +// public static boolean storeOperation(OperationRequest operationRequest, Operation.Type type, +// String commandType) throws +// WindowsDeviceEnrolmentException { +// +// List devices = operationRequest.getDeviceList(); +// List deviceIdentifiers = new ArrayList(); +// DeviceIdentifier deviceIdentifier = new DeviceIdentifier(); +// +// Operation operation = transformBasicOperation(operationRequest, type, commandType); +// +// for (int i = 0; i < devices.size(); i++) { +// try { +// deviceIdentifier.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS); +// deviceIdentifier.setId(devices.get(i).getID()); +// deviceIdentifiers.add(deviceIdentifier); +// getDeviceManagementServiceProvider().getDevice(deviceIdentifier); +// +// } catch (DeviceManagementException e) { +// log.error("Cannot validate device ID: " + devices.get(i).getID()); +// deviceIdentifiers.remove(i); +// } +// } +// try { +// getDeviceManagementServiceProvider().addOperation(operation, deviceIdentifiers); +// } catch (OperationManagementException e) { +// String msg = "Failure occurred while storing command operation."; +// log.error(msg); +// return false; +// } +// return true; +// } +// +// private static DeviceManagementProviderService getDeviceManagementServiceProvider() { +// DeviceManagementProviderService deviceManager; +// PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); +// deviceManager = +// (DeviceManagementProviderService) ctx.getOSGiService(DeviceManagementProviderService.class, null); +// +// if (deviceManager == null) { +// String msg = "Device management service is not initialized."; +// log.error(msg); +// } +// return deviceManager; +// } +// +// private static Operation transformBasicOperation(OperationRequest operationRequest, Operation.Type type, +// String commandType) throws WindowsDeviceEnrolmentException { +// +// Operation operation = new Operation(); +// operation.setCode(commandType); +// operation.setType(type); +// Gson gson = new Gson(); +// +// if (commandType == SyncmlCommandType.WIFI.getValue()) { +// +// operation = new ConfigOperation(); +// operation.setCode(commandType); +// operation.setType(type); +// +// Wifi wifiObject = (Wifi) operationRequest.getBasicOperation(); +// operation.setPayLoad(gson.toJson(wifiObject)); +// } else { +// // no operation..... +// } +// +// return operation; +// } +//} diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/authbst/BSTProvider.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/authbst/BSTProvider.java index fda4845a3..42660faea 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/authbst/BSTProvider.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/authbst/BSTProvider.java @@ -1,27 +1,23 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.wso2.carbon.mdm.mobileservices.windows.services.authbst; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; import org.wso2.carbon.mdm.mobileservices.windows.common.exceptions.WindowsDeviceEnrolmentException; import org.wso2.carbon.mdm.mobileservices.windows.services.authbst.beans.Credentials; @@ -34,23 +30,11 @@ import javax.ws.rs.core.Response; /** * Interface for handling authentication request comes via MDM login page. */ -@Api(value = "BSTProvider", description = "Windows Device Management REST-API implementation.") @Path("/bst") public interface BSTProvider { @POST @Consumes(MediaType.APPLICATION_JSON) @Path("/authentication") - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - httpMethod = "POST", - value = "Getting Binary security token via the Rest API", - notes = "Getting binary security token to call next certificate endpoints.", - response = String.class - ) - @ApiResponses(value = { - @ApiResponse(code = 201, message = "Created"), - @ApiResponse(code = 500, message = "Internal Server error") - }) 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/mdm/mobileservices/windows/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/mdm/mobileservices/windows/services/authbst/beans/Credentials.java index 098aef301..24be2d06c 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/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/mdm/mobileservices/windows/services/authbst/beans/Credentials.java @@ -1,26 +1,23 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.wso2.carbon.mdm.mobileservices.windows.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; @@ -29,28 +26,18 @@ import javax.xml.bind.annotation.XmlRootElement; /** * This bean class is for credentials coming from wab page at federated authentication step. */ -@ApiModel(value = "Credentials", description = "This class carries all information related to Credentials.") @XmlRootElement(name = "credentials") @XmlAccessorType(XmlAccessType.FIELD) public class Credentials { - @ApiModelProperty(name = "username", value = "User name", required = true) @XmlElement(required = true, name = "username") private String username; - - @ApiModelProperty(name = "email", value = "Email Address of the user.", required = true) @XmlElement(required = true, name = "email") private String email; - - @ApiModelProperty(name = "password", value = "password of the user.", required = true) @XmlElement(required = true, name = "password") private String password; - - @ApiModelProperty(name = "ownership", value = "ownership of the user.(BYOD/COPE).", required = true) @XmlElement(required = true, name = "ownership") private String ownership; - - @ApiModelProperty(name = "usertoken", value = "User Token.", required = true) @XmlElement(required = true, name = "token") private String usertoken; diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/authbst/impl/BSTProviderImpl.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/authbst/impl/BSTProviderImpl.java index a5aca0495..da812cf21 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/authbst/impl/BSTProviderImpl.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/authbst/impl/BSTProviderImpl.java @@ -1,17 +1,17 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ @@ -19,12 +19,9 @@ package org.wso2.carbon.mdm.mobileservices.windows.services.authbst.impl; import org.apache.commons.codec.binary.Base64; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.json.JSONException; import org.json.JSONObject; import org.wso2.carbon.context.PrivilegedCarbonContext; -import org.wso2.carbon.device.mgt.common.DeviceManagementException; import org.wso2.carbon.mdm.mobileservices.windows.common.beans.Token; import org.wso2.carbon.mdm.mobileservices.windows.common.exceptions.AuthenticationException; import org.wso2.carbon.mdm.mobileservices.windows.common.exceptions.WindowsDeviceEnrolmentException; @@ -43,15 +40,12 @@ import javax.ws.rs.core.Response; */ public class BSTProviderImpl implements BSTProvider { - private static Log log = LogFactory.getLog(BSTProviderImpl.class); - private static final String DELIMITER = "@"; - /** * This method validates the device user, checking passed credentials and returns the corresponding * binary security token which is used in XCEP and WSTEP stages for authentication. * - * @param credentials - Credential object passes from the wab page - * @return - Response with binary security token + * @param credentials - Credential object passes from the wab page. + * @return - Response with binary security token. */ @Override public Response getBST(Credentials credentials) throws WindowsDeviceEnrolmentException { @@ -68,14 +62,9 @@ public class BSTProviderImpl implements BSTProvider { JSONObject tokenContent = new JSONObject(); tokenContent.put("UserToken", userToken); return Response.ok().entity(tokenContent.toString()).build(); - } catch (DeviceManagementException e) { - String msg = "Failure occurred in generating challenge token."; - log.error(msg, e); - throw new WindowsDeviceEnrolmentException(msg, e); } catch (JSONException e) { - String msg = "Failure occurred in generating challenge token Json."; - log.error(msg, e); - throw new WindowsDeviceEnrolmentException(msg, e); + throw new WindowsDeviceEnrolmentException( + "Failure occurred in generating Json payload for challenge token.", e); } } @@ -99,9 +88,7 @@ public class BSTProviderImpl implements BSTProvider { RealmService realmService = (RealmService) ctx.getOSGiService(RealmService.class, null); if (realmService == null) { - String msg = "RealmService not initialized."; - log.error(msg); - throw new AuthenticationException(msg); + throw new AuthenticationException("RealmService not initialized."); } int tenantId; @@ -112,17 +99,13 @@ public class BSTProviderImpl implements BSTProvider { } if (tenantId == MultitenantConstants.INVALID_TENANT_ID) { - String msg = "Invalid tenant domain " + tenantDomain; - log.error(msg); - throw new AuthenticationException(msg); + throw new AuthenticationException("Invalid tenant domain " + tenantDomain); } UserRealm userRealm = realmService.getTenantUserRealm(tenantId); return userRealm.getUserStoreManager().authenticate(username, password); } catch (UserStoreException e) { - String msg = "User store is not initialized."; - log.error(msg, e); - throw new AuthenticationException(msg, e); + throw new AuthenticationException("User store is not initialized.", e); } finally { PrivilegedCarbonContext.endTenantFlow(); } diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/configurationmgtservice/ConfigurationMgtService.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/configurationmgtservice/ConfigurationMgtService.java index 018db96e5..2c6dc4be7 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/configurationmgtservice/ConfigurationMgtService.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/configurationmgtservice/ConfigurationMgtService.java @@ -1,34 +1,40 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.wso2.carbon.mdm.mobileservices.windows.services.configurationmgtservice; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.device.mgt.common.DeviceManagementConstants; +import org.wso2.carbon.device.mgt.common.DeviceManagementException; +import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationEntry; import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration; +import org.wso2.carbon.device.mgt.common.license.mgt.License; +import org.wso2.carbon.mdm.mobileservices.windows.common.PluginConstants; import org.wso2.carbon.mdm.mobileservices.windows.common.exceptions.WindowsConfigurationException; import org.wso2.carbon.mdm.mobileservices.windows.common.util.Message; +import org.wso2.carbon.mdm.mobileservices.windows.common.util.WindowsAPIUtils; import javax.jws.WebService; import javax.ws.rs.*; -import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import java.util.ArrayList; +import java.util.List; /** * Windows Platform Configuration REST-API implementation. @@ -37,8 +43,9 @@ import javax.ws.rs.core.MediaType; @WebService @Produces({"application/json", "application/xml"}) @Consumes({"application/json", "application/xml"}) -@Api(value = "ConfigurationMgtService", description = "Windows Device Management REST-API implementation.") -public interface ConfigurationMgtService { +public class ConfigurationMgtService { + + private static Log log = LogFactory.getLog(ConfigurationMgtService.class); /** * Save Tenant configurations. @@ -48,17 +55,49 @@ public interface ConfigurationMgtService { * @throws WindowsConfigurationException */ @POST - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - httpMethod = "POST", - value = "Configuring Windows Platform Settings", - notes = "Configure the Windows platform settings using this REST API" - ) - @ApiResponses(value = { - @ApiResponse(code = 201, message = "Windows platform configuration saved successfully"), - @ApiResponse(code = 500, message = "Internal Server Error") - }) - Message ConfigureSettings(PlatformConfiguration configuration) throws WindowsConfigurationException; + public Message ConfigureSettings(PlatformConfiguration configuration) throws WindowsConfigurationException { + Message responseMsg = new Message(); + ConfigurationEntry licenseEntry = null; + String message; + + try { + configuration.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS); + if (!configuration.getConfiguration().isEmpty()) { + List configs = configuration.getConfiguration(); + for (ConfigurationEntry entry : configs) { + if (PluginConstants.TenantConfigProperties.LICENSE_KEY.equals(entry.getName())) { + License license = new License(); + license.setName(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS); + license.setLanguage(PluginConstants.TenantConfigProperties.LANGUAGE_US); + license.setVersion("1.0.0"); + license.setText(entry.getValue().toString()); + WindowsAPIUtils.getDeviceManagementService().addLicense(DeviceManagementConstants. + MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS, license); + licenseEntry = entry; + } + } + + if (licenseEntry != null) { + configs.remove(licenseEntry); + } + configuration.setConfiguration(configs); + WindowsAPIUtils.getDeviceManagementService().saveConfiguration(configuration); + Response.status(Response.Status.CREATED); + responseMsg.setResponseMessage("Windows platform configuration saved successfully."); + responseMsg.setResponseCode(Response.Status.CREATED.toString()); + return responseMsg; + } else { + Response.status(Response.Status.BAD_REQUEST); + responseMsg.setResponseMessage("Windows platform configuration can not be saved."); + responseMsg.setResponseCode(Response.Status.CREATED.toString()); + } + } catch (DeviceManagementException e) { + message = "Error Occurred while configuring Windows Platform."; + log.error(message, e); + throw new WindowsConfigurationException(message, e); + } + return responseMsg; + } /** * Retrieve Tenant configurations according to the device type. @@ -67,17 +106,39 @@ public interface ConfigurationMgtService { * @throws WindowsConfigurationException */ @GET - @ApiOperation( - httpMethod = "GET", - value = "Getting Windows Platform Configurations", - notes = "Get the Windows platform configuration details using this REST API", - response = PlatformConfiguration.class - ) - @ApiResponses(value = { - @ApiResponse(code = 200, message = "Get Windows Configurations"), - @ApiResponse(code = 500, message = "Server Error") - }) - PlatformConfiguration getConfiguration() throws WindowsConfigurationException; + public PlatformConfiguration getConfiguration() throws WindowsConfigurationException { + String msg; + PlatformConfiguration tenantConfiguration; + List configs; + try { + tenantConfiguration = WindowsAPIUtils.getDeviceManagementService(). + getConfiguration(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS); + if (tenantConfiguration != null) { + configs = tenantConfiguration.getConfiguration(); + } else { + tenantConfiguration = new PlatformConfiguration(); + configs = new ArrayList<>(); + } + + ConfigurationEntry entry = new ConfigurationEntry(); + License license = WindowsAPIUtils.getDeviceManagementService().getLicense( + DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS, + PluginConstants.TenantConfigProperties.LANGUAGE_US); + + if (license != null && configs != null) { + entry.setContentType(PluginConstants.TenantConfigProperties.CONTENT_TYPE_TEXT); + entry.setName(PluginConstants.TenantConfigProperties.LICENSE_KEY); + entry.setValue(license.getText()); + configs.add(entry); + tenantConfiguration.setConfiguration(configs); + } + } catch (DeviceManagementException e) { + msg = "Error occurred while retrieving the Windows tenant configuration"; + log.error(msg, e); + throw new WindowsConfigurationException(msg, e); + } + return tenantConfiguration; + } /** * Update Tenant Configurations for the specific Device type. @@ -87,17 +148,39 @@ public interface ConfigurationMgtService { * @throws WindowsConfigurationException */ @PUT - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - produces = MediaType.APPLICATION_JSON, - httpMethod = "PUT", - value = "Updating Windows Platform Configurations", - notes = "Update the Windows platform configurations using this REST API" - ) - @ApiResponses(value = { - @ApiResponse(code = 201, message = "Created"), - @ApiResponse(code = 500, message = "Error occurred while modifying configuration settings of " + - "windows platform") - }) - Message updateConfiguration(PlatformConfiguration configuration) throws WindowsConfigurationException; + public Message updateConfiguration(PlatformConfiguration configuration) throws WindowsConfigurationException { + String message; + Message responseMsg = new Message(); + ConfigurationEntry licenseEntry = null; + try { + configuration.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS); + List configs = configuration.getConfiguration(); + for (ConfigurationEntry entry : configs) { + if (PluginConstants.TenantConfigProperties.LICENSE_KEY.equals(entry.getName())) { + License license = new License(); + license.setName(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS); + license.setLanguage(PluginConstants.TenantConfigProperties.LANGUAGE_US); + license.setVersion("1.0.0"); + license.setText(entry.getValue().toString()); + WindowsAPIUtils.getDeviceManagementService().addLicense(DeviceManagementConstants. + MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS, license); + licenseEntry = entry; + } + } + + if (licenseEntry != null) { + configs.remove(licenseEntry); + } + 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); + } + return responseMsg; + } } diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/configurationmgtservice/impl/ConfigurationMgtServiceImpl.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/configurationmgtservice/impl/ConfigurationMgtServiceImpl.java deleted file mode 100644 index 1c7734d42..000000000 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/configurationmgtservice/impl/ConfigurationMgtServiceImpl.java +++ /dev/null @@ -1,182 +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.mdm.mobileservices.windows.services.configurationmgtservice.impl; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.device.mgt.common.DeviceManagementConstants; -import org.wso2.carbon.device.mgt.common.DeviceManagementException; -import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationEntry; -import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration; -import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration; -import org.wso2.carbon.device.mgt.common.license.mgt.License; -import org.wso2.carbon.mdm.mobileservices.windows.common.PluginConstants; -import org.wso2.carbon.mdm.mobileservices.windows.common.exceptions.WindowsConfigurationException; -import org.wso2.carbon.mdm.mobileservices.windows.common.util.Message; -import org.wso2.carbon.mdm.mobileservices.windows.common.util.WindowsAPIUtils; - -import javax.jws.WebService; -import javax.ws.rs.*; -import javax.ws.rs.core.Response; -import java.util.List; - -/** - * Windows Platform Configuration REST-API implementation. - * All end points supports JSON, XMl with content negotiation. - */ -@WebService -@Produces({"application/json", "application/xml"}) -@Consumes({"application/json", "application/xml"}) -public class ConfigurationMgtServiceImpl { - - private static Log log = LogFactory.getLog(ConfigurationMgtServiceImpl.class); - - /** - * Save Tenant configurations. - * - * @param configuration Tenant Configurations to be saved. - * @return Message type object for the provide save status. - * @throws WindowsConfigurationException - */ - @POST - public Message ConfigureSettings(PlatformConfiguration configuration) throws WindowsConfigurationException { - Message responseMsg = new Message(); - ConfigurationEntry licenseEntry = null; - String message; - - try { - configuration.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS); - if (!configuration.getConfiguration().isEmpty()) { - List configs = configuration.getConfiguration(); - for (ConfigurationEntry entry : configs) { - if (PluginConstants.TenantConfigProperties.LICENSE_KEY.equals(entry.getName())) { - License license = new License(); - license.setName(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS); - license.setLanguage(PluginConstants.TenantConfigProperties.LANGUAGE_US); - license.setVersion("1.0.0"); - license.setText(entry.getValue().toString()); - WindowsAPIUtils.getDeviceManagementService().addLicense(DeviceManagementConstants. - MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS, license); - licenseEntry = entry; - } - } - - if (licenseEntry != null) { - configs.remove(licenseEntry); - } - configuration.setConfiguration(configs); - WindowsAPIUtils.getDeviceManagementService().saveConfiguration(configuration); - Response.status(Response.Status.CREATED); - responseMsg.setResponseMessage("Windows platform configuration saved successfully."); - responseMsg.setResponseCode(Response.Status.CREATED.toString()); - return responseMsg; - } - else { - Response.status(Response.Status.BAD_REQUEST); - responseMsg.setResponseMessage("Windows platform configuration can not be saved."); - responseMsg.setResponseCode(Response.Status.CREATED.toString()); - } - } catch (DeviceManagementException e) { - message = "Error Occurred in while configuring Windows Platform."; - log.error(message, e); - throw new WindowsConfigurationException(message, e); - } - return responseMsg; - } - - /** - * Retrieve Tenant configurations according to the device type. - * - * @return Tenant configuration object contains specific tenant configurations. - * @throws WindowsConfigurationException - */ - @GET - public PlatformConfiguration getConfiguration() throws WindowsConfigurationException { - String msg; - PlatformConfiguration PlatformConfiguration = null; - try { - if (WindowsAPIUtils.getDeviceManagementService(). - getConfiguration(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS) != null) { - PlatformConfiguration = WindowsAPIUtils.getDeviceManagementService(). - getConfiguration(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS); - List configs = PlatformConfiguration.getConfiguration(); - ConfigurationEntry entry = new ConfigurationEntry(); - License license = WindowsAPIUtils.getDeviceManagementService().getLicense( - DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS, PluginConstants. - TenantConfigProperties.LANGUAGE_US); - if(license != null) { - entry.setContentType(PluginConstants.TenantConfigProperties.CONTENT_TYPE_TEXT); - entry.setName(PluginConstants.TenantConfigProperties.LICENSE_KEY); - entry.setValue(license.getText()); - configs.add(entry); - PlatformConfiguration.setConfiguration(configs); - } - } - } catch (DeviceManagementException e) { - msg = "Error occurred while retrieving the Windows tenant configuration"; - log.error(msg, e); - throw new WindowsConfigurationException(msg, e); - } - return PlatformConfiguration; - } - - /** - * Update Tenant Configurations for the specific Device type. - * - * @param configuration Tenant configurations to be updated. - * @return Response message. - * @throws WindowsConfigurationException - */ - @PUT - public Message updateConfiguration(PlatformConfiguration configuration) throws WindowsConfigurationException { - String message; - Message responseMsg = new Message(); - ConfigurationEntry licenseEntry = null; - try { - configuration.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS); - List configs = configuration.getConfiguration(); - for (ConfigurationEntry entry : configs) { - if (PluginConstants.TenantConfigProperties.LICENSE_KEY.equals(entry.getName())) { - License license = new License(); - license.setName(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS); - license.setLanguage(PluginConstants.TenantConfigProperties.LANGUAGE_US); - license.setVersion("1.0.0"); - license.setText(entry.getValue().toString()); - WindowsAPIUtils.getDeviceManagementService().addLicense(DeviceManagementConstants. - MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS, license); - licenseEntry = entry; - } - } - - if (licenseEntry != null) { - configs.remove(licenseEntry); - } - 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); - } - return responseMsg; - } -} diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/devicemgtservice/DeviceManagementService.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/devicemgtservice/DeviceManagementService.java index be175c9f1..ee83cc53f 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/devicemgtservice/DeviceManagementService.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/devicemgtservice/DeviceManagementService.java @@ -1,131 +1,154 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.wso2.carbon.mdm.mobileservices.windows.services.devicemgtservice; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; +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.mdm.mobileservices.windows.common.exceptions.WindowsConfigurationException; import org.wso2.carbon.mdm.mobileservices.windows.common.util.Message; +import org.wso2.carbon.mdm.mobileservices.windows.common.util.WindowsAPIUtils; +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. */ -@Api(value = "DeviceManagementService", description = "Windows Device Management REST-API implementation.") -@Produces({"application/json", "application/xml"}) -@Consumes({"application/json", "application/xml"}) -public interface DeviceManagementService { +@WebService +@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) +@Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) +public class DeviceManagementService { + + private static Log log = LogFactory.getLog(DeviceManagementService.class); /** * Get all devices.Returns list of Windows devices registered in MDM. * - * @return Device List - * @throws WindowsConfigurationException + * @return Returns retrieved devices. + * @throws WindowsConfigurationException occurred while retrieving all the devices from DB. */ @GET - @ApiOperation( - produces = MediaType.APPLICATION_JSON, - httpMethod = "GET", - value = "Getting Details of All Windows Devices", - notes = "Use this REST API to retrieve the details " + - "(e.g., the Android device type, serial number, International Mobile Station Equipment Identity " + - "(IMEI), owner, version, model etc.) of all Windows devices that are registered with WSO2 EMM.", - response = Device.class, - responseContainer = "List" - ) - @ApiResponses(value = { - @ApiResponse(code = 200, message = "List of Devices"), - @ApiResponse(code = 500, message = "Error occurred while fetching the device list") - }) - List getAllDevices() throws WindowsConfigurationException; + 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 id Device Id - * @return Device - * @throws WindowsConfigurationException + * @return Returns retrieved device. + * @throws WindowsConfigurationException occurred while getting device from DB. */ @GET @Path("{id}") - @ApiOperation( - produces = MediaType.APPLICATION_JSON, - httpMethod = "GET", - value = "Getting Details of an Windows Device", - notes = "Use this REST API to retrieve the details " + - "(e.g., the Android device type, serial number, International Mobile Station Equipment Identity " + - "(IMEI), owner, version, model etc.) of a specific Windows device that is registered with WSO2 EMM", - response = Device.class - ) - @ApiResponses(value = { - @ApiResponse(code = 200, message = "Information of the given device"), - @ApiResponse(code = 500, message = "Error occurred while fetching the device information") - }) - org.wso2.carbon.device.mgt.common.Device getDevice(@PathParam("id") String id) - throws WindowsConfigurationException; + public Device getDevice(@PathParam("id") String id) throws WindowsConfigurationException { + String msg; + Device device; + try { + DeviceIdentifier deviceIdentifier = WindowsAPIUtils.convertToDeviceIdentifierObject(id); + 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 id Device Id - * @param device Device Details - * @return Message - * @throws WindowsConfigurationException + * @param id 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 - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - httpMethod = "PUT", - value = "Updating the Details of an Windows Device", - notes = "Use this REST API to update the details of an Windows device" - ) - @ApiResponses(value = { - @ApiResponse(code = 202, message = "The device enrollment details has been updated successfully"), - @ApiResponse(code = 500, message = "Error occurred while modifying the device information"), - @ApiResponse(code = 304, message = "Device not found for the update") - }) @Path("{id}") - Message updateDevice(@PathParam("id") String id, Device device) throws WindowsConfigurationException; + public Message updateDevice(@PathParam("id") String id, Device device) throws WindowsConfigurationException { + String msg; + Message responseMessage = new Message(); + DeviceIdentifier deviceIdentifier = new DeviceIdentifier(); + deviceIdentifier.setId(id); + 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") - @ApiOperation( - produces = MediaType.APPLICATION_JSON, - httpMethod = "GET", - value = "Getting the License Agreement for Windows Device Registration", - notes = "Use this REST API to retrieve the license agreement that is used for the Windows device " + - "registration process", - response = String.class) - @ApiResponses(value = { - @ApiResponse(code = 200, message = "Licence agreement"), - @ApiResponse(code = 500, message = "Error occurred while retrieving the license configured for Windows " + - "device enrolment") - }) - License getLicense() throws WindowsConfigurationException; + 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/mdm/mobileservices/windows/services/devicemgtservice/impl/DeviceManagementServiceImpl.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/devicemgtservice/impl/DeviceManagementServiceImpl.java deleted file mode 100644 index 7e353f346..000000000 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/devicemgtservice/impl/DeviceManagementServiceImpl.java +++ /dev/null @@ -1,158 +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.mdm.mobileservices.windows.services.devicemgtservice.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.mdm.mobileservices.windows.common.exceptions.WindowsConfigurationException; -import org.wso2.carbon.mdm.mobileservices.windows.common.util.Message; -import org.wso2.carbon.mdm.mobileservices.windows.common.util.WindowsAPIUtils; - -import javax.jws.WebService; -import javax.ws.rs.*; -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({"application/json", "application/xml"}) -@Consumes({"application/json", "application/xml"}) -public class DeviceManagementServiceImpl { - - private static Log log = LogFactory.getLog(DeviceManagementServiceImpl.class); - - /** - * Get all devices.Returns list of Windows devices registered in MDM. - * - * @return Device List - * @throws WindowsConfigurationException - */ - @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 id Device Id - * @return Device - * @throws WindowsConfigurationException - */ - @GET - @Path("{id}") - public Device getDevice(@PathParam("id") String id) - throws WindowsConfigurationException { - - String msg; - Device device; - - try { - DeviceIdentifier deviceIdentifier = WindowsAPIUtils.convertToDeviceIdentifierObject(id); - device = WindowsAPIUtils.getDeviceManagementService().getDevice(deviceIdentifier); - if (device == null) { - Response.status(Response.Status.NOT_FOUND); - } - } catch (DeviceManagementException deviceMgtEx) { - msg = "Error occurred while fetching the device information."; - log.error(msg, deviceMgtEx); - throw new WindowsConfigurationException(msg, deviceMgtEx); - } - return device; - } - - /** - * Update Windows device details of given device id. - * - * @param id Device Id - * @param device Device Details - * @return Message - * @throws WindowsConfigurationException - */ - @PUT - @Path("{id}") - public Message updateDevice(@PathParam("id") String id, Device device) - throws WindowsConfigurationException { - String msg; - Message responseMessage = new Message(); - DeviceIdentifier deviceIdentifier = new DeviceIdentifier(); - deviceIdentifier.setId(id); - deviceIdentifier - .setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS); - boolean result; - try { - device.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS); - result = WindowsAPIUtils.getDeviceManagementService() - .updateDeviceInfo(deviceIdentifier, device); - if (result) { - 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; - } - - @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/mdm/mobileservices/windows/services/discovery/DiscoveryService.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/discovery/DiscoveryService.java index 3bd6c7cb6..c4b50e5ae 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/discovery/DiscoveryService.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/discovery/DiscoveryService.java @@ -1,28 +1,25 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.wso2.carbon.mdm.mobileservices.windows.services.discovery; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; import org.wso2.carbon.mdm.mobileservices.windows.common.PluginConstants; +import org.wso2.carbon.mdm.mobileservices.windows.common.exceptions.WindowsDeviceEnrolmentException; import org.wso2.carbon.mdm.mobileservices.windows.services.discovery.beans.DiscoveryRequest; import org.wso2.carbon.mdm.mobileservices.windows.services.discovery.beans.DiscoveryResponse; @@ -44,44 +41,23 @@ import javax.xml.ws.soap.SOAPBinding; @WebService(targetNamespace = PluginConstants.DISCOVERY_SERVICE_TARGET_NAMESPACE, name = "IDiscoveryService") @BindingType(value = SOAPBinding.SOAP12HTTP_BINDING) -@Api(value = "DiscoveryService", description = "Windows Device Management REST-API implementation.") public interface DiscoveryService { @POST @RequestWrapper(localName = "Discover", targetNamespace = PluginConstants.DISCOVERY_SERVICE_TARGET_NAMESPACE) @WebMethod(operationName = "Discover") @ResponseWrapper(localName = "DiscoverResponse", targetNamespace = PluginConstants.DISCOVERY_SERVICE_TARGET_NAMESPACE) - @ApiOperation( - httpMethod = "POST", - value = "Discover the EMM server via REST API.", - notes = "Request the server endpoints.", - response = DiscoveryResponse.class - ) - @ApiResponses(value = { - @ApiResponse(code = 200, - message = "Windows policy, policy endpoints, enrollment endpoints and authentication endpoint."), - @ApiResponse(code = 500, message = "Internal server error") - }) void discover( @WebParam(name = "request", targetNamespace = PluginConstants.DISCOVERY_SERVICE_TARGET_NAMESPACE) DiscoveryRequest request, @WebParam(mode = WebParam.Mode.OUT, name = "DiscoverResult", targetNamespace = PluginConstants.DISCOVERY_SERVICE_TARGET_NAMESPACE) javax.xml.ws.Holder response - ); + ) throws WindowsDeviceEnrolmentException; @GET @WebMethod @WebResult() - @ApiOperation( - httpMethod = "GET", - value = "Discover the EMM server via REST API.", - notes = "Check the server availability." - ) - @ApiResponses(value = { - @ApiResponse(code = 200, message = "Ok."), - @ApiResponse(code = 500, message = "Internal server error.") - }) Response discoverGet(); } \ No newline at end of file diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/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/mdm/mobileservices/windows/services/discovery/beans/DiscoveryRequest.java index 179e5d379..ce899bf6e 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/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/mdm/mobileservices/windows/services/discovery/beans/DiscoveryRequest.java @@ -1,26 +1,23 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.wso2.carbon.mdm.mobileservices.windows.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; @@ -30,20 +27,15 @@ import java.io.Serializable; @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "DiscoveryRequest") @SuppressWarnings("unused") -@ApiModel(value = "DiscoveryRequest", - description = "This class carries all information related to Discovery request.") public class DiscoveryRequest implements Serializable { @XmlElement(name = "EmailAddress", required = true) - @ApiModelProperty(name = "emailId", value = "Email ID.", required = true) private String emailId; @XmlElement(name = "RequestVersion") - @ApiModelProperty(name = "version", value = "Request Version.", required = true) private String version; @XmlElement(name = "DeviceType") - @ApiModelProperty(name = "deviceType", value = "Type of the Device.", required = true) private String deviceType; public String getEmailId() { diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/discovery/beans/DiscoveryResponse.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/discovery/beans/DiscoveryResponse.java index 6ca3a7a56..64ca1d7d6 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/discovery/beans/DiscoveryResponse.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/discovery/beans/DiscoveryResponse.java @@ -1,26 +1,23 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.wso2.carbon.mdm.mobileservices.windows.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; @@ -30,28 +27,18 @@ import java.io.Serializable; @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "DiscoveryResponse") @SuppressWarnings("unused") -@ApiModel(value = "DiscoveryResponse", - description = "This class carries all information related to DiscoverResponse.") public class DiscoveryResponse implements Serializable { @XmlElement(name = "AuthPolicy") - @ApiModelProperty(name = "authPolicy", - value = "Authentication policy(On-premise/Federated)", required = true) private String authPolicy; @XmlElement(name = "EnrollmentPolicyServiceUrl") - @ApiModelProperty(name = "enrollmentPolicyServiceUrl", - value = "Enrollment policy(XCEP) endpoint URL.", required = true) private String enrollmentPolicyServiceUrl; @XmlElement(name = "EnrollmentServiceUrl") - @ApiModelProperty(name = "enrollmentServiceUrl", - value = "Enrollment Service(WSTEP) endpoint URL.", required = true) private String enrollmentServiceUrl; @XmlElement(name = "AuthenticationServiceUrl") - @ApiModelProperty(name = "authenticationServiceUrl", - value = "SOAP request authentication service URL", required = true) private String authenticationServiceUrl; public void setAuthenticationServiceUrl(String authenticationServiceUrl) { diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/discovery/beans/package-info.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/discovery/beans/package-info.java index 7f29bd4e6..df5d15392 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/discovery/beans/package-info.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/discovery/beans/package-info.java @@ -1,20 +1,20 @@ /* - * 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. - */ +* Copyright (c) 2015, 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. +*/ @javax.xml.bind.annotation.XmlSchema(namespace = "http://schemas.microsoft.com/windows/management/2012/01/enrollment", diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/discovery/impl/DiscoveryServiceImpl.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/discovery/impl/DiscoveryServiceImpl.java index 46ec39f28..2e376dab9 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/discovery/impl/DiscoveryServiceImpl.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/discovery/impl/DiscoveryServiceImpl.java @@ -1,17 +1,17 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ @@ -20,22 +20,22 @@ package org.wso2.carbon.mdm.mobileservices.windows.services.discovery.impl; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.device.mgt.common.DeviceManagementException; +import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationEntry; import org.wso2.carbon.mdm.mobileservices.windows.common.PluginConstants; -import org.wso2.carbon.mdm.mobileservices.windows.common.beans.WindowsPluginProperties; -import org.wso2.carbon.mdm.mobileservices.windows.services.discovery.beans.DiscoveryRequest; +import org.wso2.carbon.mdm.mobileservices.windows.common.exceptions.WindowsDeviceEnrolmentException; +import org.wso2.carbon.mdm.mobileservices.windows.common.util.WindowsAPIUtils; import org.wso2.carbon.mdm.mobileservices.windows.services.discovery.DiscoveryService; +import org.wso2.carbon.mdm.mobileservices.windows.services.discovery.beans.DiscoveryRequest; import org.wso2.carbon.mdm.mobileservices.windows.services.discovery.beans.DiscoveryResponse; -import javax.annotation.Resource; import javax.jws.WebService; -import javax.servlet.ServletContext; import javax.ws.rs.core.Response; import javax.xml.ws.BindingType; import javax.xml.ws.Holder; -import javax.xml.ws.WebServiceContext; -import javax.xml.ws.handler.MessageContext; import javax.xml.ws.soap.Addressing; import javax.xml.ws.soap.SOAPBinding; +import java.util.List; /** * Implementation class of Discovery Request. This class implements the first two services @@ -48,9 +48,9 @@ import javax.xml.ws.soap.SOAPBinding; public class DiscoveryServiceImpl implements DiscoveryService { public static final String FEDERATED = "Federated"; + private static final String DELIMITER = "@"; + private static final int DOMAIN_SEGMENT = 1; private static Log log = LogFactory.getLog(DiscoveryServiceImpl.class); - @Resource - private WebServiceContext context; /** * This method returns the OnPremise AuthPolicy and next two endpoint the mobile device should @@ -61,35 +61,26 @@ public class DiscoveryServiceImpl implements DiscoveryService { * @param response - DiscoveryResponse bean for response */ @Override - public void discover(DiscoveryRequest discoveryRequest, Holder response) { + public void discover(DiscoveryRequest discoveryRequest, Holder response) + throws WindowsDeviceEnrolmentException { - ServletContext ctx = (ServletContext) context.getMessageContext().get(MessageContext.SERVLET_CONTEXT); - WindowsPluginProperties windowsPluginProperties = (WindowsPluginProperties) ctx.getAttribute( - PluginConstants.WINDOWS_PLUGIN_PROPERTIES); + String emailId = discoveryRequest.getEmailId(); + String[] userDomains = emailId.split(DELIMITER); + String domain = userDomains[DOMAIN_SEGMENT]; DiscoveryResponse discoveryResponse = new DiscoveryResponse(); - if (FEDERATED.equals(windowsPluginProperties.getAuthPolicy())) { - discoveryResponse.setAuthPolicy(windowsPluginProperties.getAuthPolicy()); - discoveryResponse.setEnrollmentPolicyServiceUrl(PluginConstants.Discovery.ENROLL_SUBDOMAIN + - windowsPluginProperties.getDomain() + PluginConstants.Discovery. + if (FEDERATED.equals(getAuthPolicy())) { + discoveryResponse.setAuthPolicy(FEDERATED); + discoveryResponse.setEnrollmentPolicyServiceUrl(PluginConstants.Discovery.DEVICE_ENROLLMENT_SUBDOMAIN + + domain + PluginConstants.Discovery. CERTIFICATE_ENROLLMENT_POLICY_SERVICE_URL); - discoveryResponse.setEnrollmentServiceUrl(PluginConstants.Discovery.ENROLL_SUBDOMAIN + - windowsPluginProperties.getDomain() + PluginConstants.Discovery. + discoveryResponse.setEnrollmentServiceUrl(PluginConstants.Discovery.DEVICE_ENROLLMENT_SUBDOMAIN + + domain + PluginConstants.Discovery. CERTIFICATE_ENROLLMENT_SERVICE_URL); - discoveryResponse.setAuthenticationServiceUrl(PluginConstants.Discovery.ENROLL_SUBDOMAIN + - windowsPluginProperties.getDomain() + PluginConstants.Discovery.WAB_URL); - } else { - discoveryResponse.setAuthPolicy(windowsPluginProperties.getAuthPolicy()); - discoveryResponse.setEnrollmentPolicyServiceUrl(PluginConstants.Discovery.ENROLL_SUBDOMAIN + - windowsPluginProperties.getDomain() + PluginConstants.Discovery. - ONPREMISE_CERTIFICATE_ENROLLMENT_POLICY); - discoveryResponse.setEnrollmentServiceUrl(PluginConstants.Discovery.ENROLL_SUBDOMAIN + - windowsPluginProperties.getDomain() + PluginConstants.Discovery. - ONPREMISE_CERTIFICATE_ENROLLMENT_SERVICE_URL); - discoveryResponse.setAuthenticationServiceUrl(null); + discoveryResponse.setAuthenticationServiceUrl(PluginConstants.Discovery.DEVICE_ENROLLMENT_SUBDOMAIN + + domain + PluginConstants.Discovery.WAB_URL); } response.value = discoveryResponse; - if (log.isDebugEnabled()) { log.debug("Discovery service end point was triggered via POST method"); } @@ -109,4 +100,37 @@ public class DiscoveryServiceImpl implements DiscoveryService { } return Response.ok().build(); } + + /** + * Get authentication policy from the tenant configuration, otherwise set default value as Federated. + * + * @return Authentication policy. + * @throws WindowsDeviceEnrolmentException + */ + public String getAuthPolicy() throws WindowsDeviceEnrolmentException { + String authPolicy = null; + List tenantConfigurations; + try { + if (WindowsAPIUtils.getTenantConfigurationData() != null) { + tenantConfigurations = WindowsAPIUtils.getTenantConfigurationData(); + + for (ConfigurationEntry configurationEntry : tenantConfigurations) { + if (PluginConstants.TenantConfigProperties.AUTH_POLICY.equals(configurationEntry.getName())) { + authPolicy = configurationEntry.getValue().toString(); + } else { + authPolicy = PluginConstants.TenantConfigProperties.DEFAULT_AUTH_POLICY; + } + } + } else { + authPolicy = PluginConstants.TenantConfigProperties.DEFAULT_AUTH_POLICY; + String msg = "Tenant configurations are not initialized yet."; + log.error(msg); + } + } catch (DeviceManagementException e) { + String msg = "Error occurred while getting tenant configurations."; + log.error(msg); + throw new WindowsDeviceEnrolmentException(msg, e); + } + return authPolicy; + } } diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/policymgtservice/PolicyMgtService.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/policymgtservice/PolicyMgtService.java index bb1ed19b0..cf013845f 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/policymgtservice/PolicyMgtService.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/policymgtservice/PolicyMgtService.java @@ -1,52 +1,71 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.wso2.carbon.mdm.mobileservices.windows.services.policymgtservice; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.mdm.mobileservices.windows.common.exceptions.WindowsConfigurationException; import org.wso2.carbon.mdm.mobileservices.windows.common.util.Message; +import org.wso2.carbon.mdm.mobileservices.windows.common.util.WindowsAPIUtils; +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.Response; /** * Endpoint for Enforce Effective Policy. */ -@Api(value = "PolicyMgtService", description = "Windows Device Management REST-API implementation.") +@WebService @Produces({"application/json", "application/xml"}) @Consumes({"application/json", "application/xml"}) -public interface PolicyMgtService { +public class PolicyMgtService { + private static Log log = LogFactory.getLog(PolicyMgtService.class); + @GET @Path("{id}") - @ApiOperation( - httpMethod = "GET", - value = "Identifying whether a Policy is Enforced on an Windows Device", - notes = "When a device registers with WSO2 EMM, a policy is enforced on the device based on the policy " + - "enforcement criteria. Using this API you are able to identify if a specific device has a policy " + - "enforced or if no policy is enforced on the device." - ) - @ApiResponses(value = { - @ApiResponse(code = 200, message = "Effective policy added to operation"), - @ApiResponse(code = 204, message = "No effective policy found") - }) - Message getEffectivePolicy(@HeaderParam("Accept") String acceptHeader, - @PathParam("id") String id) throws WindowsConfigurationException; + public Message getEffectivePolicy(@HeaderParam("Accept") String acceptHeader, + @PathParam("id") String id) throws WindowsConfigurationException { + + DeviceIdentifier deviceIdentifier = WindowsAPIUtils.convertToDeviceIdentifierObject(id); + 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/mdm/mobileservices/windows/services/policymgtservice/impl/PolicyMgtServiceImpl.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/policymgtservice/impl/PolicyMgtServiceImpl.java deleted file mode 100644 index 406d96e8f..000000000 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/policymgtservice/impl/PolicyMgtServiceImpl.java +++ /dev/null @@ -1,72 +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.mdm.mobileservices.windows.services.policymgtservice.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.mdm.mobileservices.windows.common.exceptions.WindowsConfigurationException; -import org.wso2.carbon.mdm.mobileservices.windows.common.util.Message; -import org.wso2.carbon.mdm.mobileservices.windows.common.util.WindowsAPIUtils; -import org.wso2.carbon.mdm.mobileservices.windows.services.policymgtservice.PolicyMgtService; -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.Response; - -/** - * Endpoint for Enforce Effective Policy. - */ - -@WebService -@Produces({"application/json", "application/xml"}) -@Consumes({"application/json", "application/xml"}) -public class PolicyMgtServiceImpl implements PolicyMgtService { - private static Log log = LogFactory.getLog(PolicyMgtServiceImpl.class); - - @GET - public Message getEffectivePolicy(@HeaderParam("Accept") String acceptHeader, - @PathParam("id") String id) throws WindowsConfigurationException { - - DeviceIdentifier deviceIdentifier = WindowsAPIUtils.convertToDeviceIdentifierObject(id); - 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/mdm/mobileservices/windows/services/syncml/SyncmlService.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/syncml/SyncmlService.java index b51f69644..9e79626e8 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/syncml/SyncmlService.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/syncml/SyncmlService.java @@ -1,27 +1,23 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.wso2.carbon.mdm.mobileservices.windows.services.syncml; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; import org.w3c.dom.Document; import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagementException; import org.wso2.carbon.mdm.mobileservices.windows.common.PluginConstants; @@ -39,7 +35,6 @@ import javax.ws.rs.core.Response; /** * Interface for Syncml message flow. */ -@Api(value = "SyncmlService", description = "Windows Device Management REST-API implementation.") @Path("/devicemanagement") public interface SyncmlService { @@ -47,17 +42,6 @@ public interface SyncmlService { @POST @Consumes({PluginConstants.SYNCML_MEDIA_TYPE, MediaType.APPLICATION_XML}) @Produces(PluginConstants.SYNCML_MEDIA_TYPE) - @ApiOperation( - consumes = "application/vnd.syncml.dm+xml;charset=utf-8", - produces = "application/vnd.syncml.dm+xml;charset=utf-8", - httpMethod = "POST", - value = "Windows Device Management service REST API", - notes = "Windows device management session" - ) - @ApiResponses(value = { - @ApiResponse(code = 200, message = "Successfully completed syncml session"), - @ApiResponse(code = 500, message = "Internal server error") - }) Response getResponse(Document request) throws WindowsDeviceEnrolmentException, WindowsOperationException, NotificationManagementException, WindowsConfigurationException; diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/syncml/beans/BasicOperation.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/syncml/beans/BasicOperation.java index cfa2cfbb9..53d265472 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/syncml/beans/BasicOperation.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/syncml/beans/BasicOperation.java @@ -1,33 +1,28 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.wso2.carbon.mdm.mobileservices.windows.services.syncml.beans; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - /** * Bean for get basic operations. */ -@ApiModel(value = "BasicOperation", - description = "This class carries all information related to Basic operation.") public class BasicOperation { - @ApiModelProperty(name = "name", value = "Name of the basic operation.", required = true) + private String name; public String getName() { diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/syncml/beans/PasscodePolicy.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/syncml/beans/PasscodePolicy.java index a25e19549..3e29cdc1c 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/syncml/beans/PasscodePolicy.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/syncml/beans/PasscodePolicy.java @@ -1,55 +1,36 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.wso2.carbon.mdm.mobileservices.windows.services.syncml.beans; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - /** - * Bean for device lockOperationUpdate screen passcode policy. + * Bean for device updateLockOperation screen passcode policy. */ -@ApiModel(value = "PasscodePolicy", - description = "This class carries all information related to Passcode Policy.") public class PasscodePolicy extends BasicOperation { - @ApiModelProperty(name = "maxFailedAttempts", value = "No of Max fail attempts.", required = true) private int maxFailedAttempts; - @ApiModelProperty(name = "minLength", value = "Minimum length of the Passcode.", required = true) private int minLength; - @ApiModelProperty(name = "pinHistory", - value = "The number of passwords Windows 10 Mobile remembers in the password history.", required = true) private int pinHistory; - @ApiModelProperty(name = "minComplexChars", - value = "The number of password element types (in other words, uppercase letters, lowercase letters, " + - "numbers, or punctuation) required to create strong passwords.", required = true) private int minComplexChars; - @ApiModelProperty(name = "maxPINAgeInDays", - value = "Number of Maximum days to expire the passcode.", required = true) private int maxPINAgeInDays; - @ApiModelProperty(name = "requireAlphanumeric", - value = "An integer value that specifies the complexity of the password or PIN allowed.", required = true) private boolean requireAlphanumeric; - @ApiModelProperty(name = "allowSimple", value = "Set boolean value to allow simple password.", required = true) private boolean allowSimple; - @ApiModelProperty(name = "enablePassword", value = "Set boolean value enable password.", required = true) private boolean enablePassword; - @ApiModelProperty(name = "maxInactiveTime", value = "Maximum Inactive time.", required = true) private int maxInactiveTime; public int getMaxInactiveTime() { diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/syncml/beans/Profile.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/syncml/beans/Profile.java index 4b8a361ae..ad3a702e6 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/syncml/beans/Profile.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/syncml/beans/Profile.java @@ -1,40 +1,31 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.wso2.carbon.mdm.mobileservices.windows.services.syncml.beans; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - /** * Class for contains device active policy. */ -@ApiModel(value = "Profile", - description = "This class carries all information related to Profile features.") public class Profile { - @ApiModelProperty(name = "featureCode", value = "Profile type operation feature code.", required = true) String featureCode; - @ApiModelProperty(name = "data", value = "Profile type operation data content..", required = true) String data; - @ApiModelProperty(name = "enable", value = "Status of the Profile operation.", required = true) boolean enable; - @ApiModelProperty(name = "compliance", value = "Status of the operation compliance.", required = true) boolean compliance; public boolean isCompliance() { diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/syncml/beans/Wifi.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/syncml/beans/Wifi.java index fc713077a..99979637f 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/syncml/beans/Wifi.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/syncml/beans/Wifi.java @@ -1,50 +1,36 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.wso2.carbon.mdm.mobileservices.windows.services.syncml.beans; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - /** * Bean for WIFI configurations. */ -@ApiModel(value = "Wifi", - description = "This class carries all information related to Wifi policy.") public class Wifi extends BasicOperation { - @ApiModelProperty(name = "networkName", value = "Name of the Wifi Network.", required = true) private String networkName; - @ApiModelProperty(name = "ssid", value = "SSID.", required = true) private String ssid; - @ApiModelProperty(name = "connectionType", value = "Type of the connection.", required = true) private String connectionType; - @ApiModelProperty(name = "connectionMode", value = "Connection mode.", required = true) private String connectionMode; - @ApiModelProperty(name = "authentication", value = "Authentication type.", required = true) private String authentication; - @ApiModelProperty(name = "encryption", value = "Encryption type.", required = true) private String encryption; - @ApiModelProperty(name = "keyType", value = "Key type.", required = true) private String keyType; - @ApiModelProperty(name = "protection", value = "Protection.", required = true) private String protection; - @ApiModelProperty(name = "keyMaterial", value = "Key Material.", required = true) private String keyMaterial; public String getNetworkName() { diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/syncml/beans/WindowsDevice.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/syncml/beans/WindowsDevice.java new file mode 100644 index 000000000..a796b1d16 --- /dev/null +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/syncml/beans/WindowsDevice.java @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2015, 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.mdm.mobileservices.windows.services.syncml.beans; + +/** + * Class for get windows device properties. + */ +public class WindowsDevice { + + private String deviceType; + private String deviceId; + private String osVersion; + private String imsi; + private String imei; + private String manufacturer; + private String model; + private String user; + + public String getImei() { + return imei; + } + + public void setImei(String imei) { + this.imei = imei; + } + + public String getDeviceType() { + return deviceType; + } + + public void setDeviceType(String deviceType) { + this.deviceType = deviceType; + } + + public String getDeviceId() { + return deviceId; + } + + public void setDeviceId(String deviceId) { + this.deviceId = deviceId; + } + + public String getOsVersion() { + return osVersion; + } + + public void setOsVersion(String osVersion) { + this.osVersion = osVersion; + } + + public String getImsi() { + return imsi; + } + + public void setImsi(String imsi) { + this.imsi = imsi; + } + + public String getManufacturer() { + return manufacturer; + } + + public void setManufacturer(String manufacturer) { + this.manufacturer = manufacturer; + } + + public String getModel() { + return model; + } + + public void setModel(String model) { + this.model = model; + } + + public String getUser() { + return user; + } + + public void setUser(String user) { + this.user = user; + } + + +} diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/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/mdm/mobileservices/windows/services/syncml/impl/SyncmlServiceImpl.java index 7754f41a7..b07f80c56 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/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/mdm/mobileservices/windows/services/syncml/impl/SyncmlServiceImpl.java @@ -1,17 +1,17 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ @@ -20,7 +20,6 @@ package org.wso2.carbon.mdm.mobileservices.windows.services.syncml.impl; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.json.JSONException; import org.w3c.dom.Document; import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.device.mgt.common.*; @@ -33,13 +32,14 @@ import org.wso2.carbon.mdm.mobileservices.windows.common.exceptions.SyncmlMessag import org.wso2.carbon.mdm.mobileservices.windows.common.exceptions.SyncmlOperationException; import org.wso2.carbon.mdm.mobileservices.windows.common.exceptions.WindowsConfigurationException; import org.wso2.carbon.mdm.mobileservices.windows.common.exceptions.WindowsDeviceEnrolmentException; +import org.wso2.carbon.mdm.mobileservices.windows.common.util.AuthenticationInfo; import org.wso2.carbon.mdm.mobileservices.windows.common.util.DeviceUtil; import org.wso2.carbon.mdm.mobileservices.windows.common.util.WindowsAPIUtils; import org.wso2.carbon.mdm.mobileservices.windows.operations.*; import org.wso2.carbon.mdm.mobileservices.windows.operations.util.*; import org.wso2.carbon.mdm.mobileservices.windows.services.syncml.SyncmlService; +import org.wso2.carbon.mdm.mobileservices.windows.services.syncml.beans.WindowsDevice; import org.wso2.carbon.policy.mgt.common.PolicyManagementException; -import org.wso2.carbon.policy.mgt.common.monitor.PolicyComplianceException; import org.wso2.carbon.policy.mgt.core.PolicyManagerService; import javax.ws.rs.core.Response; @@ -59,38 +59,32 @@ public class SyncmlServiceImpl implements SyncmlService { * This method is used to generate and return Device object from the received information at * the Syncml step. * - * @param deviceID - Unique device ID received from the Device - * @param osVersion - Device OS version - * @param imsi - Device IMSI - * @param imei - Device IMEI - * @param manufacturer - Device Manufacturer name - * @param model - Device Model - * @return - Generated device object + * @param windowsDevice Windows specific property object. + * @return - Generated device object. */ - private Device generateDevice(String type, String deviceID, String osVersion, String imsi, - String imei, String manufacturer, String model, String user) { + private Device generateDevice(WindowsDevice windowsDevice) { Device generatedDevice = new Device(); Device.Property OSVersionProperty = new Device.Property(); OSVersionProperty.setName(PluginConstants.SyncML.OS_VERSION); - OSVersionProperty.setValue(osVersion); + OSVersionProperty.setValue(windowsDevice.getOsVersion()); Device.Property IMSEIProperty = new Device.Property(); IMSEIProperty.setName(PluginConstants.SyncML.IMSI); - IMSEIProperty.setValue(imsi); + IMSEIProperty.setValue(windowsDevice.getImsi()); Device.Property IMEIProperty = new Device.Property(); IMEIProperty.setName(PluginConstants.SyncML.IMEI); - IMEIProperty.setValue(imei); + IMEIProperty.setValue(windowsDevice.getImei()); Device.Property DevManProperty = new Device.Property(); DevManProperty.setName(PluginConstants.SyncML.VENDOR); - DevManProperty.setValue(manufacturer); + DevManProperty.setValue(windowsDevice.getManufacturer()); Device.Property DevModProperty = new Device.Property(); DevModProperty.setName(PluginConstants.SyncML.MODEL); - DevModProperty.setValue(model); + DevModProperty.setValue(windowsDevice.getModel()); List propertyList = new ArrayList<>(); propertyList.add(OSVersionProperty); @@ -100,14 +94,14 @@ public class SyncmlServiceImpl implements SyncmlService { propertyList.add(DevModProperty); EnrolmentInfo enrolmentInfo = new EnrolmentInfo(); - enrolmentInfo.setOwner(user); + enrolmentInfo.setOwner(windowsDevice.getUser()); enrolmentInfo.setOwnership(EnrolmentInfo.OwnerShip.BYOD); enrolmentInfo.setStatus(EnrolmentInfo.Status.ACTIVE); generatedDevice.setEnrolmentInfo(enrolmentInfo); - generatedDevice.setDeviceIdentifier(deviceID); + generatedDevice.setDeviceIdentifier(windowsDevice.getDeviceId()); generatedDevice.setProperties(propertyList); - generatedDevice.setType(type); + generatedDevice.setType(windowsDevice.getDeviceType()); return generatedDevice; } @@ -133,48 +127,29 @@ public class SyncmlServiceImpl implements SyncmlService { SyncmlDocument syncmlDocument; List deviceInfoOperations; List pendingOperations; - OperationUtils operationUtils = new OperationUtils(); + OperationHandler operationHandler = new OperationHandler(); DeviceInfo deviceInfo = new DeviceInfo(); try { if (SyncmlParser.parseSyncmlPayload(request) != null) { - try { - syncmlDocument = SyncmlParser.parseSyncmlPayload(request); - } catch (SyncmlMessageFormatException e) { - String msg = "Error occurred due to bad syncml format."; - log.error(msg, e); - throw new SyncmlMessageFormatException(msg, e); - } + syncmlDocument = SyncmlParser.parseSyncmlPayload(request); SyncmlHeader syncmlHeader = syncmlDocument.getHeader(); sessionId = syncmlHeader.getSessionId(); user = syncmlHeader.getSource().getLocName(); - DeviceIdentifier deviceIdentifier = convertToDeviceIdentifierObject(syncmlHeader.getSource() - .getLocURI()); + DeviceIdentifier deviceIdentifier = convertToDeviceIdentifierObject(syncmlHeader.getSource(). + getLocURI()); msgId = syncmlHeader.getMsgID(); if ((PluginConstants.SyncML.SYNCML_FIRST_MESSAGE_ID == msgId) && (PluginConstants.SyncML.SYNCML_FIRST_SESSION_ID == sessionId)) { token = syncmlHeader.getCredential().getData(); CacheEntry cacheToken = (CacheEntry) DeviceUtil.getCacheEntry(token); - if (cacheToken.getUsername().equals(user)) { + if ((cacheToken.getUsername() != null) && (cacheToken.getUsername().equals(user))) { if (enrollDevice(request)) { deviceInfoOperations = deviceInfo.getDeviceInfo(); - try { - response = generateReply(syncmlDocument, deviceInfoOperations); - PolicyManagerService policyManagerService = WindowsAPIUtils.getPolicyManagerService(); - policyManagerService.getEffectivePolicy(deviceIdentifier); - return Response.status(Response.Status.OK).entity(response).build(); - } catch (PolicyManagementException e) { - String msg = "Error occurred in while getting effective policy."; - log.error(msg, e); - throw new WindowsConfigurationException(msg, e); - } catch (SyncmlOperationException e) { - String msg = "Error occurred in while generating hash value."; - log.error(msg, e); - throw new WindowsOperationException(msg, e); - } - + response = generateReply(syncmlDocument, deviceInfoOperations); + return Response.status(Response.Status.OK).entity(response).build(); } else { String msg = "Error occurred in device enrollment."; log.error(msg); @@ -187,15 +162,8 @@ public class SyncmlServiceImpl implements SyncmlService { } } else if (PluginConstants.SyncML.SYNCML_SECOND_MESSAGE_ID == msgId && PluginConstants.SyncML.SYNCML_FIRST_SESSION_ID == sessionId) { - if (enrollDevice(request)) { - try { - return Response.ok().entity(generateReply(syncmlDocument, null)).build(); - } catch (SyncmlOperationException e) { - String msg = "Error occurred in while getting effective feature"; - log.error(msg, e); - throw new WindowsOperationException(msg, e); - } + return Response.ok().entity(generateReply(syncmlDocument, null)).build(); } else { String msg = "Error occurred in modify enrollment."; log.error(msg); @@ -204,83 +172,21 @@ public class SyncmlServiceImpl implements SyncmlService { } else if (sessionId >= PluginConstants.SyncML.SYNCML_SECOND_SESSION_ID) { if ((syncmlDocument.getBody().getAlert() != null)) { if (!syncmlDocument.getBody().getAlert().getData().equals(Constants.DISENROLL_ALERT_DATA)) { - try { - pendingOperations = operationUtils.getPendingOperations(syncmlDocument); - return Response.ok().entity(generateReply(syncmlDocument, pendingOperations)).build(); - } catch (OperationManagementException e) { - String msg = "Cannot access operation management service."; - log.error(msg, e); - throw new WindowsOperationException(msg, e); - } catch (DeviceManagementException e) { - String msg = "Cannot access Device management service."; - log.error(msg, e); - throw new WindowsOperationException(msg, e); - } catch (FeatureManagementException e) { - String msg = "Error occurred in getting effective features. "; - log.error(msg, e); - throw new WindowsOperationException(msg, e); - } catch (PolicyComplianceException e) { - String msg = "Error occurred in setting policy compliance."; - log.error(msg, e); - throw new WindowsConfigurationException(msg, e); - } catch (NotificationManagementException e) { - String msg = "Error occurred in while getting notification service"; - throw new WindowsOperationException(msg, e); - } catch (SyncmlOperationException e) { - String msg = "Error occurred in while encoding hash value."; - log.error(msg, e); - throw new WindowsOperationException(msg, e); - } + pendingOperations = operationHandler.getPendingOperations(syncmlDocument); + return Response.ok().entity(generateReply(syncmlDocument, pendingOperations)).build(); } else { - try { - if (WindowsAPIUtils.getDeviceManagementService().getDevice(deviceIdentifier) != null) { - WindowsAPIUtils.getDeviceManagementService().disenrollDevice(deviceIdentifier); - return Response.ok().entity(generateReply(syncmlDocument, null)).build(); - } else { - String msg = "Enrolled device can not be found in the server."; - log.error(msg); - return Response.status(Response.Status.NOT_FOUND).entity(msg).build(); - } - } catch (DeviceManagementException e) { - String msg = "Failure occurred in dis-enrollment flow."; - log.error(msg, e); - throw new WindowsOperationException(msg, e); - } catch (SyncmlOperationException e) { - String msg = "Error occurred in while generating hash value."; - log.error(msg, e); - throw new WindowsOperationException(msg, e); + if (WindowsAPIUtils.getDeviceManagementService().getDevice(deviceIdentifier) != null) { + WindowsAPIUtils.getDeviceManagementService().disenrollDevice(deviceIdentifier); + return Response.ok().entity(generateReply(syncmlDocument, null)).build(); + } else { + String msg = "Enrolled device can not be found in the server."; + log.error(msg); + return Response.status(Response.Status.NOT_FOUND).entity(msg).build(); } } } else { - try { - pendingOperations = operationUtils.getPendingOperations(syncmlDocument); - return Response.ok().entity(generateReply(syncmlDocument, pendingOperations)) - .build(); - } catch (OperationManagementException e) { - String msg = "Cannot access operation management service."; - log.error(msg, e); - throw new WindowsOperationException(msg, e); - } catch (DeviceManagementException e) { - String msg = "Cannot access Device management service."; - log.error(msg, e); - throw new WindowsOperationException(msg, e); - } catch (FeatureManagementException e) { - String msg = "Error occurred in getting effective features. "; - log.error(msg, e); - throw new WindowsConfigurationException(msg, e); - } catch (PolicyComplianceException e) { - String msg = "Error occurred in setting policy compliance."; - log.error(msg, e); - throw new WindowsConfigurationException(msg, e); - } catch (NotificationManagementException e) { - String msg = "Error occurred in while getting notification service."; - log.error(msg, e); - throw new WindowsOperationException(msg, e); - } catch (SyncmlOperationException e) { - String msg = "Error occurred in while getting effective feature."; - log.error(msg, e); - throw new WindowsConfigurationException(msg, e); - } + pendingOperations = operationHandler.getPendingOperations(syncmlDocument); + return Response.ok().entity(generateReply(syncmlDocument, pendingOperations)).build(); } } else { String msg = "Failure occurred in Device request message."; @@ -289,7 +195,19 @@ public class SyncmlServiceImpl implements SyncmlService { } } } catch (SyncmlMessageFormatException e) { - String msg = "Error occurred in parsing syncml request."; + String msg = "Error occurred while parsing syncml request."; + log.error(msg, e); + throw new WindowsOperationException(msg, e); + } catch (OperationManagementException e) { + String msg = "Cannot access operation management service."; + log.error(msg, e); + throw new WindowsOperationException(msg, e); + } catch (SyncmlOperationException e) { + String msg = "Error occurred while getting effective feature."; + log.error(msg, e); + throw new WindowsConfigurationException(msg, e); + } catch (DeviceManagementException e) { + String msg = "Failure occurred in dis-enrollment flow."; log.error(msg, e); throw new WindowsOperationException(msg, e); } @@ -314,7 +232,7 @@ public class SyncmlServiceImpl implements SyncmlService { String devMan; String devMod; String devLang; - String vender; + String vendor; String macAddress; String resolution; String modVersion; @@ -328,40 +246,51 @@ public class SyncmlServiceImpl implements SyncmlService { syncmlDocument = SyncmlParser.parseSyncmlPayload(request); msgID = syncmlDocument.getHeader().getMsgID(); if (msgID == PluginConstants.SyncML.SYNCML_FIRST_MESSAGE_ID) { - Replace replace = syncmlDocument.getBody().getReplace(); - List itemList = replace.getItems(); + ReplaceTag replace = syncmlDocument.getBody().getReplace(); + List itemList = replace.getItems(); devID = itemList.get(PluginConstants.SyncML.DEVICE_ID_POSITION).getData(); devMan = itemList.get(PluginConstants.SyncML.DEVICE_MAN_POSITION).getData(); devMod = itemList.get(PluginConstants.SyncML.DEVICE_MODEL_POSITION).getData(); modVersion = itemList.get(PluginConstants.SyncML.DEVICE_MOD_VER_POSITION).getData(); devLang = itemList.get(PluginConstants.SyncML.DEVICE_LANG_POSITION).getData(); user = syncmlDocument.getHeader().getSource().getLocName(); + AuthenticationInfo authenticationInfo = new AuthenticationInfo(); + authenticationInfo.setUsername(user); + WindowsAPIUtils.startTenantFlow(authenticationInfo); if (log.isDebugEnabled()) { log.debug( "OS Version:" + modVersion + ", DevID: " + devID + ", DevMan: " + devMan + ", DevMod: " + devMod + ", DevLang: " + devLang); } - Device generateDevice = generateDevice(DeviceManagementConstants.MobileDeviceTypes. - MOBILE_DEVICE_TYPE_WINDOWS, devID, modVersion, imsi, imei, devMan, devMod, user); - status = WindowsAPIUtils.getDeviceManagementService().enrollDevice(generateDevice); - WindowsAPIUtils.startTenantFlow(user); + WindowsDevice windowsDevice = new WindowsDevice(); + windowsDevice.setDeviceType(DeviceManagementConstants.MobileDeviceTypes. + MOBILE_DEVICE_TYPE_WINDOWS); + windowsDevice.setDeviceId(devID); + windowsDevice.setImei(imei); + windowsDevice.setImsi(imsi); + windowsDevice.setManufacturer(devMan); + windowsDevice.setOsVersion(modVersion); + windowsDevice.setModel(devMod); + windowsDevice.setUser(user); + Device device = generateDevice(windowsDevice); + status = WindowsAPIUtils.getDeviceManagementService().enrollDevice(device); return status; } else if (msgID == PluginConstants.SyncML.SYNCML_SECOND_MESSAGE_ID) { - List itemList = syncmlDocument.getBody().getResults().getItem(); + + List itemList = syncmlDocument.getBody().getResults().getItem(); osVersion = itemList.get(PluginConstants.SyncML.OSVERSION_POSITION).getData(); imsi = itemList.get(PluginConstants.SyncML.IMSI_POSITION).getData(); imei = itemList.get(PluginConstants.SyncML.IMEI_POSITION).getData(); - vender = itemList.get(PluginConstants.SyncML.VENDER_POSITION).getData(); + vendor = itemList.get(PluginConstants.SyncML.VENDOR_POSITION).getData(); devMod = itemList.get(PluginConstants.SyncML.MODEL_POSITION).getData(); - macAddress = itemList.get(PluginConstants.SyncML.MACADDRESS_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()); Device existingDevice = WindowsAPIUtils.getDeviceManagementService().getDevice(deviceIdentifier); - if (!existingDevice.getProperties().isEmpty()) { List existingProperties = new ArrayList<>(); @@ -380,10 +309,10 @@ public class SyncmlServiceImpl implements SyncmlService { imsiProperty.setValue(imsi); existingProperties.add(imsiProperty); - Device.Property venderProperty = new Device.Property(); - venderProperty.setName(PluginConstants.SyncML.VENDOR); - venderProperty.setValue(vender); - existingProperties.add(venderProperty); + Device.Property vendorProperty = new Device.Property(); + vendorProperty.setName(PluginConstants.SyncML.VENDOR); + vendorProperty.setValue(vendor); + existingProperties.add(vendorProperty); Device.Property macAddressProperty = new Device.Property(); macAddressProperty.setName(PluginConstants.SyncML.MAC_ADDRESS); @@ -416,17 +345,9 @@ public class SyncmlServiceImpl implements SyncmlService { } } } catch (DeviceManagementException e) { - String msg = "Failure occurred in enrolling device."; - log.error(msg, e); - throw new WindowsDeviceEnrolmentException(msg, e); - } catch (SyncmlMessageFormatException e) { - String msg = "Error occurred in bad format of the syncml payload."; - log.error(msg, e); - throw new WindowsOperationException(msg, e); + throw new WindowsDeviceEnrolmentException("Failure occurred while enrolling device.", e); } catch (PolicyManagementException e) { - String msg = "Error occurred in getting effective policy."; - log.error(msg, e); - throw new WindowsOperationException(msg, e); + throw new WindowsOperationException("Error occurred while getting effective policy.", e); } finally { PrivilegedCarbonContext.endTenantFlow(); } @@ -436,11 +357,10 @@ public class SyncmlServiceImpl implements SyncmlService { /** * Generate Device payloads. * - * @param syncmlDocument parsed syncml payload from the syncml engine. - * @param operations operations for generate payload. + * @param syncmlDocument Parsed syncml payload from the syncml engine. + * @param operations Operations for generate payload. * @return String type syncml payload. * @throws WindowsOperationException - * @throws JSONException * @throws PolicyManagementException * @throws org.wso2.carbon.policy.mgt.common.FeatureManagementException */ diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/wstep/CertificateEnrollmentService.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/wstep/CertificateEnrollmentService.java index 95c4dcd28..e517672db 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/wstep/CertificateEnrollmentService.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/wstep/CertificateEnrollmentService.java @@ -1,17 +1,17 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/wstep/beans/AdditionalContext.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/wstep/beans/AdditionalContext.java index f0f4fca7a..8850d5afd 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/wstep/beans/AdditionalContext.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/wstep/beans/AdditionalContext.java @@ -1,17 +1,17 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/wstep/beans/BinarySecurityToken.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/wstep/beans/BinarySecurityToken.java index df3b13cdf..1df7bd445 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/wstep/beans/BinarySecurityToken.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/wstep/beans/BinarySecurityToken.java @@ -1,17 +1,17 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ @@ -20,11 +20,7 @@ package org.wso2.carbon.mdm.mobileservices.windows.services.wstep.beans; import org.wso2.carbon.mdm.mobileservices.windows.common.PluginConstants; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlType; -import javax.xml.bind.annotation.XmlValue; +import javax.xml.bind.annotation.*; @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "BinarySecurityToken", namespace = PluginConstants.WS_SECURITY_TARGET_NAMESPACE, diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/wstep/beans/ContextItem.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/wstep/beans/ContextItem.java index d88ad01ff..bfc450e55 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/wstep/beans/ContextItem.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/wstep/beans/ContextItem.java @@ -1,17 +1,17 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/wstep/beans/RequestSecurityToken.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/wstep/beans/RequestSecurityToken.java index 92dcd0252..74be950d1 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/wstep/beans/RequestSecurityToken.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/wstep/beans/RequestSecurityToken.java @@ -1,17 +1,17 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/wstep/beans/RequestSecurityTokenResponse.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/wstep/beans/RequestSecurityTokenResponse.java index e3eb12d87..14a72b8d0 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/wstep/beans/RequestSecurityTokenResponse.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/wstep/beans/RequestSecurityTokenResponse.java @@ -1,17 +1,17 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ @@ -37,7 +37,7 @@ public class RequestSecurityTokenResponse implements Serializable { @XmlElement(name = "RequestedSecurityToken", required = true, namespace = PluginConstants.WS_TRUST_TARGET_NAMESPACE) - private RequestedSecurityToken RequestedSecurityToken; + private org.wso2.carbon.mdm.mobileservices.windows.services.wstep.beans.RequestedSecurityToken RequestedSecurityToken; @XmlElement(name = "RequestID", namespace = PluginConstants.ENROLLMENT_POLICY_TARGET_NAMESPACE) private int RequestID; @@ -50,11 +50,11 @@ public class RequestSecurityTokenResponse implements Serializable { TokenType = tokenType; } - public RequestedSecurityToken getRequestedSecurityToken() { + public org.wso2.carbon.mdm.mobileservices.windows.services.wstep.beans.RequestedSecurityToken getRequestedSecurityToken() { return RequestedSecurityToken; } - public void setRequestedSecurityToken(RequestedSecurityToken requestedSecurityToken) { + public void setRequestedSecurityToken(org.wso2.carbon.mdm.mobileservices.windows.services.wstep.beans.RequestedSecurityToken requestedSecurityToken) { RequestedSecurityToken = requestedSecurityToken; } diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/wstep/beans/RequestedSecurityToken.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/wstep/beans/RequestedSecurityToken.java index 93d2e3f84..c448c14ce 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/wstep/beans/RequestedSecurityToken.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/wstep/beans/RequestedSecurityToken.java @@ -1,17 +1,17 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/wstep/beans/package-info.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/wstep/beans/package-info.java index 03610123c..47dd02949 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/wstep/beans/package-info.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/wstep/beans/package-info.java @@ -1,19 +1,19 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * 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. + * 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. */ @XmlSchema(namespace = "http://www.w3.org/2003/05/soap-envelope", diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/wstep/impl/CertificateEnrollmentServiceImpl.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/wstep/impl/CertificateEnrollmentServiceImpl.java index b21304e8d..f439620e0 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/wstep/impl/CertificateEnrollmentServiceImpl.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/wstep/impl/CertificateEnrollmentServiceImpl.java @@ -1,17 +1,17 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ @@ -32,7 +32,6 @@ import org.wso2.carbon.certificate.mgt.core.service.CertificateManagementService import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.device.mgt.common.DeviceManagementException; import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationEntry; -import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration; import org.wso2.carbon.mdm.mobileservices.windows.common.PluginConstants; import org.wso2.carbon.mdm.mobileservices.windows.common.beans.CacheEntry; import org.wso2.carbon.mdm.mobileservices.windows.common.exceptions.CertificateGenerationException; @@ -41,7 +40,7 @@ import org.wso2.carbon.mdm.mobileservices.windows.common.exceptions.WAPProvision import org.wso2.carbon.mdm.mobileservices.windows.common.exceptions.WindowsDeviceEnrolmentException; import org.wso2.carbon.mdm.mobileservices.windows.common.util.DeviceUtil; import org.wso2.carbon.mdm.mobileservices.windows.common.util.WindowsAPIUtils; -import org.wso2.carbon.mdm.mobileservices.windows.operations.util.SyncmlCredentials; +import org.wso2.carbon.mdm.mobileservices.windows.operations.util.SyncmlCredentialUtil; import org.wso2.carbon.mdm.mobileservices.windows.services.wstep.CertificateEnrollmentService; import org.wso2.carbon.mdm.mobileservices.windows.services.wstep.beans.AdditionalContext; import org.wso2.carbon.mdm.mobileservices.windows.services.wstep.beans.BinarySecurityToken; @@ -69,7 +68,6 @@ import javax.xml.ws.soap.SOAPBinding; import java.io.File; import java.io.IOException; import java.io.StringWriter; -import java.io.UnsupportedEncodingException; import java.security.cert.CertificateEncodingException; import java.security.cert.X509Certificate; import java.util.List; @@ -83,16 +81,11 @@ import java.util.List; @Addressing(enabled = true, required = true) @BindingType(value = SOAPBinding.SOAP12HTTP_BINDING) public class CertificateEnrollmentServiceImpl implements CertificateEnrollmentService { - - private static final int REQUEST_ID = 0; - private static final int CA_CERTIFICATE_POSITION = 0; - private static final int SIGNED_CERTIFICATE_POSITION = 1; - private static final int APPAUTH_USERNAME_POSITION = 21; - private static final int APPAUTH_PASSWORD_POSITION = 22; - private static final int POLLING_FREQUENCY_POSITION = 27; private static Log log = LogFactory.getLog(CertificateEnrollmentServiceImpl.class); private X509Certificate rootCACertificate; private String pollingFrequency; + private String provisioningURL; + private String domain; @Resource private WebServiceContext context; @@ -105,30 +98,44 @@ public class CertificateEnrollmentServiceImpl implements CertificateEnrollmentSe * @param binarySecurityToken - CSR from device * @param additionalContext - Device type and OS version is received * @param response - Response will include wap-provisioning xml + * @WindowsDeviceEnrolmentException - */ @Override - public void requestSecurityToken(String tokenType, String requestType, - String binarySecurityToken, + public void requestSecurityToken(String tokenType, String requestType, String binarySecurityToken, AdditionalContext additionalContext, Holder response) throws - WindowsDeviceEnrolmentException, UnsupportedEncodingException, WAPProvisioningException { + WindowsDeviceEnrolmentException { String headerBinarySecurityToken = null; + String headerTo = null; + String encodedWap; List
headers = getHeaders(); for (Header headerElement : headers != null ? headers : null) { String nodeName = headerElement.getName().getLocalPart(); - if (nodeName.equals(PluginConstants.SECURITY)) { + if (PluginConstants.SECURITY.equals(nodeName)) { Element element = (Element) headerElement.getObject(); headerBinarySecurityToken = element.getFirstChild().getNextSibling().getFirstChild().getTextContent(); } + if (PluginConstants.TO.equals(nodeName)) { + Element toElement = (Element) headerElement.getObject(); + headerTo = toElement.getFirstChild().getTextContent(); + } } - List tenantConfigurations = null; + + String[] splitEmail = headerTo.split("(/ENROLLMENTSERVER)"); + String email = splitEmail[PluginConstants.CertificateEnrolment.EMAIL_SEGMENT]; + + String[] splitDomain = email.split("(EnterpriseEnrollment.)"); + domain = splitDomain[PluginConstants.CertificateEnrolment.DOMAIN_SEGMENT]; + provisioningURL = PluginConstants.CertificateEnrolment.ENROLL_SUBDOMAIN + domain + + PluginConstants.CertificateEnrolment.SYNCML_PROVISIONING_SERVICE_URL; + + List tenantConfigurations; try { - if (getTenantConfigurationData() != null) { - tenantConfigurations = getTenantConfigurationData(); + if ((tenantConfigurations = WindowsAPIUtils.getTenantConfigurationData()) != null) { for (ConfigurationEntry configurationEntry : tenantConfigurations) { - if (configurationEntry.getName().equals(PluginConstants.TenantConfigProperties. - NOTIFIER_FREQUENCY)) { + if ((PluginConstants.TenantConfigProperties.NOTIFIER_FREQUENCY.equals( + configurationEntry.getName()))) { pollingFrequency = configurationEntry.getValue().toString(); } else { pollingFrequency = PluginConstants.TenantConfigProperties.DEFAULT_FREQUENCY; @@ -139,26 +146,19 @@ public class CertificateEnrollmentServiceImpl implements CertificateEnrollmentSe String msg = "Tenant configurations are not initialized yet."; log.error(msg); } - } catch (DeviceManagementException e) { - String msg = "Error occurred in while getting tenant configurations."; - log.error(msg); - throw new WindowsDeviceEnrolmentException(msg, e); - } - ServletContext ctx = - (ServletContext) context.getMessageContext().get(MessageContext.SERVLET_CONTEXT); - File wapProvisioningFile = (File) ctx.getAttribute(PluginConstants.CONTEXT_WAP_PROVISIONING_FILE); + ServletContext ctx = (ServletContext) context.getMessageContext(). + get(MessageContext.SERVLET_CONTEXT); + File wapProvisioningFile = (File) ctx.getAttribute(PluginConstants.CONTEXT_WAP_PROVISIONING_FILE); + if (log.isDebugEnabled()) { + log.debug("Received CSR from Device:" + binarySecurityToken); + } - if (log.isDebugEnabled()) { - log.debug("Received CSR from Device:" + binarySecurityToken); - } - String wapProvisioningFilePath = wapProvisioningFile.getPath(); - RequestSecurityTokenResponse requestSecurityTokenResponse = - new RequestSecurityTokenResponse(); - requestSecurityTokenResponse.setTokenType(PluginConstants.CertificateEnrolment.TOKEN_TYPE); - String encodedWap; - try { - encodedWap = prepareWapProvisioningXML(binarySecurityToken, - wapProvisioningFilePath, headerBinarySecurityToken); + String wapProvisioningFilePath = wapProvisioningFile.getPath(); + RequestSecurityTokenResponse requestSecurityTokenResponse = new RequestSecurityTokenResponse(); + requestSecurityTokenResponse.setTokenType(PluginConstants.CertificateEnrolment.TOKEN_TYPE); + + encodedWap = prepareWapProvisioningXML(binarySecurityToken, wapProvisioningFilePath, + headerBinarySecurityToken); RequestedSecurityToken requestedSecurityToken = new RequestedSecurityToken(); BinarySecurityToken binarySecToken = new BinarySecurityToken(); binarySecToken.setValueType(PluginConstants.CertificateEnrolment.VALUE_TYPE); @@ -166,16 +166,20 @@ public class CertificateEnrollmentServiceImpl implements CertificateEnrollmentSe binarySecToken.setToken(encodedWap); requestedSecurityToken.setBinarySecurityToken(binarySecToken); requestSecurityTokenResponse.setRequestedSecurityToken(requestedSecurityToken); - requestSecurityTokenResponse.setRequestID(REQUEST_ID); + requestSecurityTokenResponse.setRequestID(PluginConstants.CertificateEnrolment.REQUEST_ID); response.value = requestSecurityTokenResponse; } catch (CertificateGenerationException e) { - String msg = "Problem occurred in generating certificate."; + String msg = "Problem occurred while generating certificate."; log.error(msg, e); throw new WindowsDeviceEnrolmentException(msg, e); } catch (WAPProvisioningException e) { - String msg = "Problem occurred in generating wap-provisioning file."; + String msg = "Problem occurred while generating wap-provisioning file."; log.error(msg, e); - throw new WAPProvisioningException(msg, e); + throw new WindowsDeviceEnrolmentException(msg, e); + } catch (DeviceManagementException e) { + String msg = "Error occurred while getting tenant configurations."; + log.error(msg); + throw new WindowsDeviceEnrolmentException(msg, e); } finally { PrivilegedCarbonContext.endTenantFlow(); } @@ -200,7 +204,7 @@ public class CertificateEnrollmentServiceImpl implements CertificateEnrollmentSe } /** - * This method prepares the wap-provisioning file by including relevant certificates etc + * This method prepares the wap-provisioning file by including relevant certificates etc. * * @param binarySecurityToken - CSR from device * @param wapProvisioningFilePath - File path of wap-provisioning file @@ -208,56 +212,37 @@ public class CertificateEnrollmentServiceImpl implements CertificateEnrollmentSe * @throws CertificateGenerationException * @throws org.wso2.carbon.mdm.mobileservices.windows.common.exceptions.WAPProvisioningException */ - public String prepareWapProvisioningXML( - String binarySecurityToken, - String wapProvisioningFilePath, String headerBst) throws CertificateGenerationException, + private String prepareWapProvisioningXML(String binarySecurityToken, String wapProvisioningFilePath, + String headerBst) throws CertificateGenerationException, WAPProvisioningException, WindowsDeviceEnrolmentException { String rootCertEncodedString; String signedCertEncodedString; X509Certificate signedCertificate; + String provisioningXmlString; - CertificateManagementServiceImpl impl = CertificateManagementServiceImpl.getInstance(); + CertificateManagementServiceImpl certMgtServiceImpl = CertificateManagementServiceImpl.getInstance(); Base64 base64Encoder = new Base64(); try { - rootCACertificate = (X509Certificate) impl.getCACertificate(); + rootCACertificate = (X509Certificate) certMgtServiceImpl.getCACertificate(); rootCertEncodedString = base64Encoder.encodeToString(rootCACertificate.getEncoded()); - } catch (KeystoreException e) { - String msg = "CA certificate cannot be generated"; - log.error(msg, e); - throw new CertificateGenerationException(msg, e); - } catch (CertificateEncodingException e) { - String msg = "CA certificate cannot be encoded."; - log.error(msg, e); - throw new CertificateGenerationException(msg, e); - } - try { - signedCertificate = impl.getSignedCertificateFromCSR(binarySecurityToken); + + signedCertificate = certMgtServiceImpl.getSignedCertificateFromCSR(binarySecurityToken); signedCertEncodedString = base64Encoder.encodeToString(signedCertificate.getEncoded()); - } catch (CertificateEncodingException e) { - String msg = "Singed certificate cannot be encoded."; - log.error(msg, e); - throw new CertificateGenerationException(msg, e); - } catch (KeystoreException e) { - String msg = "CA certificate cannot be generated"; - log.error(msg, e); - throw new CertificateGenerationException(msg, e); - } - DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance(); - DocumentBuilder builder; - String wapProvisioningString = null; - try { - builder = domFactory.newDocumentBuilder(); + DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance(); + DocumentBuilder builder; + + builder = domFactory.newDocumentBuilder(); Document document = builder.parse(wapProvisioningFilePath); NodeList wapParm = document.getElementsByTagName(PluginConstants.CertificateEnrolment.PARM); - Node caCertificatePosition = wapParm.item(CA_CERTIFICATE_POSITION); + Node caCertificatePosition = wapParm.item(PluginConstants.CertificateEnrolment.CA_CERTIFICATE_POSITION); //Adding SHA1 CA certificate finger print to wap-provisioning xml. caCertificatePosition.getParentNode().getAttributes().getNamedItem(PluginConstants. CertificateEnrolment.TYPE).setTextContent(String.valueOf( - DigestUtils.sha512Hex(rootCACertificate.getEncoded())).toUpperCase()); + DigestUtils.sha256Hex(rootCACertificate.getEncoded())).toUpperCase()); //Adding encoded CA certificate to wap-provisioning file after removing new line // characters. NamedNodeMap rootCertAttributes = caCertificatePosition.getAttributes(); @@ -270,12 +255,13 @@ public class CertificateEnrollmentServiceImpl implements CertificateEnrollmentSe log.debug("Root certificate: " + rootCertEncodedString); } - Node signedCertificatePosition = wapParm.item(SIGNED_CERTIFICATE_POSITION); + Node signedCertificatePosition = wapParm.item(PluginConstants.CertificateEnrolment. + SIGNED_CERTIFICATE_POSITION); //Adding SHA1 signed certificate finger print to wap-provisioning xml. signedCertificatePosition.getParentNode().getAttributes().getNamedItem(PluginConstants. CertificateEnrolment.TYPE).setTextContent(String.valueOf( - DigestUtils.sha512Hex(signedCertificate.getEncoded())).toUpperCase()); + DigestUtils.sha256Hex(signedCertificate.getEncoded())).toUpperCase()); //Adding encoded signed certificate to wap-provisioning file after removing new line // characters. @@ -289,8 +275,21 @@ public class CertificateEnrollmentServiceImpl implements CertificateEnrollmentSe log.debug("Signed certificate: " + signedCertEncodedString); } - // Adding user name auth token to wap-provisioning xml - Node userNameAuthPosition = wapParm.item(APPAUTH_USERNAME_POSITION); + //Adding domainName to wap-provisioning xml. + Node domainPosition = wapParm.item(PluginConstants.CertificateEnrolment.DOMAIN_POSITION); + NamedNodeMap domainAttribute = domainPosition.getAttributes(); + Node domainNode = domainAttribute.getNamedItem(PluginConstants.CertificateEnrolment.VALUE); + domainNode.setTextContent(domain); + + //Adding Next provisioning service URL to wap-provisioning xml. + Node syncmlServicePosition = wapParm.item(PluginConstants.CertificateEnrolment. + SYNCML_PROVISIONING_ADDR_POSITION); + NamedNodeMap syncmlServiceAttribute = syncmlServicePosition.getAttributes(); + Node syncmlServiceNode = syncmlServiceAttribute.getNamedItem(PluginConstants.CertificateEnrolment.VALUE); + syncmlServiceNode.setTextContent(provisioningURL); + + // Adding user name auth token to wap-provisioning xml. + Node userNameAuthPosition = wapParm.item(PluginConstants.CertificateEnrolment.APPAUTH_USERNAME_POSITION); NamedNodeMap appServerAttribute = userNameAuthPosition.getAttributes(); Node authNameNode = appServerAttribute.getNamedItem(PluginConstants.CertificateEnrolment.VALUE); CacheEntry cacheEntry = (CacheEntry) DeviceUtil.getCacheEntry(headerBst); @@ -298,62 +297,42 @@ public class CertificateEnrollmentServiceImpl implements CertificateEnrollmentSe authNameNode.setTextContent(cacheEntry.getUsername()); DeviceUtil.removeToken(headerBst); String password = DeviceUtil.generateRandomToken(); - Node passwordAuthPosition = wapParm.item(APPAUTH_PASSWORD_POSITION); + Node passwordAuthPosition = wapParm.item(PluginConstants.CertificateEnrolment.APPAUTH_PASSWORD_POSITION); NamedNodeMap appSrvPasswordAttribute = passwordAuthPosition.getAttributes(); Node authPasswordNode = appSrvPasswordAttribute.getNamedItem(PluginConstants.CertificateEnrolment.VALUE); authPasswordNode.setTextContent(password); - String requestSecurityTokenResponse = new SyncmlCredentials().generateRST(userName, password); + String requestSecurityTokenResponse = SyncmlCredentialUtil.generateRST(userName, password); DeviceUtil.persistChallengeToken(requestSecurityTokenResponse, null, userName); // Get device polling frequency from the tenant Configurations. - Node numberOfFirstRetries = wapParm.item(POLLING_FREQUENCY_POSITION); + Node numberOfFirstRetries = wapParm.item(PluginConstants.CertificateEnrolment.POLLING_FREQUENCY_POSITION); NamedNodeMap pollingAttributes = numberOfFirstRetries.getAttributes(); Node pollValue = pollingAttributes.getNamedItem(PluginConstants.CertificateEnrolment.VALUE); pollValue.setTextContent(pollingFrequency); - if (log.isDebugEnabled()) { - log.debug("Username: " + userName + "Password: " + requestSecurityTokenResponse); - } - wapProvisioningString = convertDocumentToString(document); + provisioningXmlString = convertDocumentToString(document); + } catch (ParserConfigurationException e) { - String msg = "Problem occurred in parsing wap-provisioning.xml file."; - log.error(msg, e); - throw new WAPProvisioningException(msg, e); - } catch (DeviceManagementException e) { - String msg = "Error occurred in while getting CA and Root certificates."; - log.error(msg, e); - throw new WindowsDeviceEnrolmentException(msg, e); + throw new WAPProvisioningException("Problem occurred while creating configuration request", e); } catch (CertificateEncodingException e) { - String msg = "Error occurred in while encoding certificates."; - log.error(msg, e); - throw new WindowsDeviceEnrolmentException(msg, e); - } catch (UnsupportedEncodingException e) { - String msg = "Error occurred in while encoding wap-provisioning file."; - log.error(msg, e); - throw new WindowsDeviceEnrolmentException(msg, e); + throw new WindowsDeviceEnrolmentException("Error occurred while encoding certificates.", e); } catch (SAXException e) { - String msg = "Error occurred in while parsing wap-provisioning.xml file."; - log.error(msg, e); - throw new WAPProvisioningException(msg, e); + throw new WAPProvisioningException("Error occurred while parsing wap-provisioning.xml file.", e); } catch (TransformerException e) { - String msg = "Error occurred in while transforming wap-provisioning.xml file."; - log.error(msg, e); - throw new WAPProvisioningException(msg, e); + throw new WAPProvisioningException("Error occurred while transforming wap-provisioning.xml file.", e); } catch (IOException e) { - String msg = "Error occurred in while getting wap-provisioning.xml file."; - log.error(msg, e); - throw new WAPProvisioningException(msg, e); + throw new WAPProvisioningException("Error occurred while getting wap-provisioning.xml file.", e); } catch (SyncmlMessageFormatException e) { - String msg = "Error occurred in while getting CA and Root certificates."; - log.error(msg, e); - throw new WindowsDeviceEnrolmentException(msg, e); + throw new WindowsDeviceEnrolmentException("Error occurred while generating password hash value.", e); + } catch (KeystoreException e) { + throw new CertificateGenerationException("CA certificate cannot be generated.", e); } - return base64Encoder.encodeToString(wapProvisioningString.getBytes()); + return base64Encoder.encodeToString(provisioningXmlString.getBytes()); } /** - * This method get the soap request header contents + * This method get the soap request header contents. * - * @return Header object type,soap header tag list + * @return List of SOAP headers. */ private List
getHeaders() { MessageContext messageContext = context.getMessageContext(); @@ -363,19 +342,4 @@ public class CertificateEnrollmentServiceImpl implements CertificateEnrollmentSe Message message = ((WrappedMessageContext) messageContext).getWrappedMessage(); return CastUtils.cast((List) message.get(Header.HEADER_LIST)); } - - /** - * This method is used to get tenant configurations. - * - * @return List of Configurations entries. - * @throws DeviceManagementException - */ - private List getTenantConfigurationData() throws DeviceManagementException { - if (WindowsAPIUtils.getTenantConfiguration() != null) { - PlatformConfiguration configuration = WindowsAPIUtils.getTenantConfiguration(); - return configuration.getConfiguration(); - } else { - return null; - } - } } diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/wstep/util/CertificateSigningService.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/wstep/util/CertificateSigningService.java index d348170ae..a5c965fbc 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/wstep/util/CertificateSigningService.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/wstep/util/CertificateSigningService.java @@ -1,30 +1,26 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * 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. + * 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.mdm.mobileservices.windows.services.wstep.util; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.bouncycastle.asn1.x509.BasicConstraints; -import org.bouncycastle.asn1.x509.ExtendedKeyUsage; -import org.bouncycastle.asn1.x509.Extension; -import org.bouncycastle.asn1.x509.KeyPurposeId; -import org.bouncycastle.asn1.x509.KeyUsage; +import org.bouncycastle.asn1.x509.*; import org.bouncycastle.cert.CertIOException; import org.bouncycastle.cert.X509v3CertificateBuilder; import org.bouncycastle.cert.jcajce.JcaX509CertificateConverter; @@ -85,7 +81,7 @@ public class CertificateSigningService { public static X509Certificate signCSR(JcaPKCS10CertificationRequest jcaRequest, PrivateKey privateKey, X509Certificate caCert, List certParameterList) throws - CertificateGenerationException, WAPProvisioningException { + CertificateGenerationException, WAPProvisioningException { String commonName = (String) certParameterList.get(PropertyIndex.COMMON_NAME_INDEX.getValue()); diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/wstep/util/KeyStoreGenerator.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/wstep/util/KeyStoreGenerator.java index 9280d4e68..04c2168c3 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/wstep/util/KeyStoreGenerator.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/wstep/util/KeyStoreGenerator.java @@ -1,27 +1,27 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * 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. + * 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.mdm.mobileservices.windows.services.wstep.util; -import org.wso2.carbon.mdm.mobileservices.windows.common.PluginConstants; -import org.wso2.carbon.mdm.mobileservices.windows.common.exceptions.KeyStoreGenerationException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.mdm.mobileservices.windows.common.PluginConstants; +import org.wso2.carbon.mdm.mobileservices.windows.common.exceptions.KeyStoreGenerationException; import java.io.FileInputStream; import java.io.IOException; diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/wstep/util/MessageHandler.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/wstep/util/MessageHandler.java index 147a4dc6d..12147af53 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/wstep/util/MessageHandler.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/wstep/util/MessageHandler.java @@ -1,40 +1,32 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * 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. + * 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.mdm.mobileservices.windows.services.wstep.util; -import org.wso2.carbon.mdm.mobileservices.windows.common.PluginConstants; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.joda.time.DateTime; import org.joda.time.format.ISODateTimeFormat; +import org.wso2.carbon.mdm.mobileservices.windows.common.PluginConstants; import javax.ws.rs.core.Response; import javax.xml.namespace.QName; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import javax.xml.soap.Name; -import javax.xml.soap.SOAPEnvelope; -import javax.xml.soap.SOAPException; -import javax.xml.soap.SOAPFactory; -import javax.xml.soap.SOAPHeader; -import javax.xml.soap.SOAPHeaderElement; -import javax.xml.soap.SOAPMessage; +import javax.xml.soap.*; import javax.xml.ws.handler.MessageContext; import javax.xml.ws.handler.soap.SOAPHandler; import javax.xml.ws.handler.soap.SOAPMessageContext; diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/CertificateEnrollmentPolicyService.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/CertificateEnrollmentPolicyService.java index 350cb4966..74bf26c39 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/CertificateEnrollmentPolicyService.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/CertificateEnrollmentPolicyService.java @@ -1,17 +1,17 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ @@ -19,12 +19,7 @@ package org.wso2.carbon.mdm.mobileservices.windows.services.xcep; import org.wso2.carbon.mdm.mobileservices.windows.common.PluginConstants; -import org.wso2.carbon.mdm.mobileservices.windows.services.xcep.beans.CACollection; -import org.wso2.carbon.mdm.mobileservices.windows.services.xcep.beans.Client; -import org.wso2.carbon.mdm.mobileservices.windows.services.xcep.beans.OIDCollection; -import org.wso2.carbon.mdm.mobileservices.windows.services.xcep.beans.ObjectFactory; -import org.wso2.carbon.mdm.mobileservices.windows.services.xcep.beans.RequestFilter; -import org.wso2.carbon.mdm.mobileservices.windows.services.xcep.beans.Response; +import org.wso2.carbon.mdm.mobileservices.windows.services.xcep.beans.*; import javax.jws.WebMethod; import javax.jws.WebParam; diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/Attributes.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/Attributes.java index 5023c7ffa..e39ba5c98 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/Attributes.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/Attributes.java @@ -1,17 +1,17 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/CA.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/CA.java index dd19413ce..4b643f089 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/CA.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/CA.java @@ -1,17 +1,17 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/CACollection.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/CACollection.java index 67da97868..cc94b04db 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/CACollection.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/CACollection.java @@ -1,17 +1,17 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/CAReferenceCollection.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/CAReferenceCollection.java index 781aad80f..6199b4ee3 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/CAReferenceCollection.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/CAReferenceCollection.java @@ -1,17 +1,17 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/CAURI.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/CAURI.java index 61bdc2cc5..ee33ba079 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/CAURI.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/CAURI.java @@ -1,17 +1,17 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/CAURICollection.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/CAURICollection.java index c6527837a..6278311da 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/CAURICollection.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/CAURICollection.java @@ -1,17 +1,17 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/CertificateEnrollmentPolicy.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/CertificateEnrollmentPolicy.java index 58fa5fe89..4ce348190 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/CertificateEnrollmentPolicy.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/CertificateEnrollmentPolicy.java @@ -1,17 +1,17 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/CertificateValidity.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/CertificateValidity.java index c0d406966..41d77542c 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/CertificateValidity.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/CertificateValidity.java @@ -1,17 +1,17 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/Client.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/Client.java index 56bd765f5..685bfd522 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/Client.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/Client.java @@ -1,17 +1,17 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/CryptoProviders.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/CryptoProviders.java index 68b35587d..d483b7c47 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/CryptoProviders.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/CryptoProviders.java @@ -1,17 +1,17 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/EnrollmentPermission.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/EnrollmentPermission.java index ff59a3325..3a05b9d28 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/EnrollmentPermission.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/EnrollmentPermission.java @@ -1,17 +1,17 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/Extension.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/Extension.java index 4dbce0d96..7647d853a 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/Extension.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/Extension.java @@ -1,17 +1,17 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/ExtensionCollection.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/ExtensionCollection.java index 011773f9b..4e5422cbc 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/ExtensionCollection.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/ExtensionCollection.java @@ -1,17 +1,17 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/FilterOIDCollection.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/FilterOIDCollection.java index 4735e3448..a50dc51f2 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/FilterOIDCollection.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/FilterOIDCollection.java @@ -1,17 +1,17 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/GetPolicies.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/GetPolicies.java index a2370f98b..620716c1f 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/GetPolicies.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/GetPolicies.java @@ -1,28 +1,24 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.wso2.carbon.mdm.mobileservices.windows.services.xcep.beans; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; +import javax.xml.bind.annotation.*; /** *

Java class for anonymous complex type. diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/GetPoliciesResponse.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/GetPoliciesResponse.java index 7a80fa40e..ee7d69342 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/GetPoliciesResponse.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/GetPoliciesResponse.java @@ -1,28 +1,24 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.wso2.carbon.mdm.mobileservices.windows.services.xcep.beans; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; +import javax.xml.bind.annotation.*; /** *

Java class for anonymous complex type. diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/KeyArchivalAttributes.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/KeyArchivalAttributes.java index 2eb936d62..d48ebb386 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/KeyArchivalAttributes.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/KeyArchivalAttributes.java @@ -1,17 +1,17 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/OID.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/OID.java index 85d9d771d..7415bc68a 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/OID.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/OID.java @@ -1,17 +1,17 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/OIDCollection.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/OIDCollection.java index ce7cce5c1..54861d807 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/OIDCollection.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/OIDCollection.java @@ -1,17 +1,17 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/OIDReferenceCollection.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/OIDReferenceCollection.java index dcc18d829..9d095532e 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/OIDReferenceCollection.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/OIDReferenceCollection.java @@ -1,17 +1,17 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/ObjectFactory.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/ObjectFactory.java index b9bc5237e..83db64243 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/ObjectFactory.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/ObjectFactory.java @@ -1,17 +1,17 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/PolicyCollection.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/PolicyCollection.java index 7fb6dce14..2dbb7f7e0 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/PolicyCollection.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/PolicyCollection.java @@ -1,17 +1,17 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/PrivateKeyAttributes.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/PrivateKeyAttributes.java index 93858f132..f82a2fb55 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/PrivateKeyAttributes.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/PrivateKeyAttributes.java @@ -1,28 +1,24 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.wso2.carbon.mdm.mobileservices.windows.services.xcep.beans; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlSchemaType; -import javax.xml.bind.annotation.XmlType; +import javax.xml.bind.annotation.*; /** *

Java class for PrivateKeyAttributes complex type. diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/RARequirements.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/RARequirements.java index d57004602..dce723372 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/RARequirements.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/RARequirements.java @@ -1,28 +1,24 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.wso2.carbon.mdm.mobileservices.windows.services.xcep.beans; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlSchemaType; -import javax.xml.bind.annotation.XmlType; +import javax.xml.bind.annotation.*; /** *

Java class for RARequirements complex type. diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/RequestFilter.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/RequestFilter.java index d610c8fd3..b1e419806 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/RequestFilter.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/RequestFilter.java @@ -1,17 +1,17 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/Response.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/Response.java index e3e6ecd0c..90246f03c 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/Response.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/Response.java @@ -1,17 +1,17 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/Revision.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/Revision.java index 9b184add3..e838b4b26 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/Revision.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/Revision.java @@ -1,17 +1,17 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/SupersededPolicies.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/SupersededPolicies.java index 650997825..722950cea 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/SupersededPolicies.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/SupersededPolicies.java @@ -1,17 +1,17 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/package-info.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/package-info.java index 16a65c47e..f3c0f5b58 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/package-info.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/beans/package-info.java @@ -1,19 +1,19 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * 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. + * 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. */ @javax.xml.bind.annotation.XmlSchema(namespace = "http://schemas.microsoft" + diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/impl/CertificateEnrollmentPolicyServiceImpl.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/impl/CertificateEnrollmentPolicyServiceImpl.java index 244f3c140..9f9ee4fd1 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/impl/CertificateEnrollmentPolicyServiceImpl.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/services/xcep/impl/CertificateEnrollmentPolicyServiceImpl.java @@ -1,17 +1,17 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ @@ -66,7 +66,6 @@ public class CertificateEnrollmentPolicyServiceImpl implements CertificateEnroll CACollection caCollectionElement = new CACollection(); PolicyCollection policyCollectionElement = new PolicyCollection(); - CertificateEnrollmentPolicy certEnrollmentPolicyElement = new CertificateEnrollmentPolicy(); Attributes attributeElement = new Attributes(); PrivateKeyAttributes privateKeyAttributeElement = new PrivateKeyAttributes(); @@ -94,7 +93,6 @@ public class CertificateEnrollmentPolicyServiceImpl implements CertificateEnroll oidCollectionElement.getOID().add(oidElement); caCollection.value = caCollectionElement; oidCollection.value = oidCollectionElement; - PrivilegedCarbonContext.endTenantFlow(); } 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 b19ad6fa7..ad2863d95 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 @@ -197,11 +197,11 @@ class="org.wso2.carbon.mdm.mobileservices.windows.services.wstep.util.MessageHandler"/> + class="org.wso2.carbon.mdm.mobileservices.windows.services.configurationmgtservice.ConfigurationMgtService"/> + class="org.wso2.carbon.mdm.mobileservices.windows.services.policymgtservice.PolicyMgtService"/> + class="org.wso2.carbon.mdm.mobileservices.windows.services.devicemgtservice.DeviceManagementService"/> 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 55931077e..e9f5de0f8 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 @@ -28,7 +28,7 @@ - org.wso2.carbon.mdm.mobileservices.windows.common.util.ConfigInitializerContextListener + org.wso2.carbon.mdm.mobileservices.windows.common.util.ContextInitializer diff --git a/pom.xml b/pom.xml index fd6c28023..7dd072ed3 100644 --- a/pom.xml +++ b/pom.xml @@ -309,6 +309,11 @@ org.wso2.carbon.apimgt.annotations ${carbon.devicemgt.version} + + org.wso2.carbon.devicemgt + org.wso2.carbon.webapp.authenticator.framework + ${carbon.devicemgt.version} + org.wso2.carbon.commons From 16e306268f9c431c8d7937233419d6ce8496b6e1 Mon Sep 17 00:00:00 2001 From: hasuniea Date: Thu, 4 Aug 2016 16:35:31 +0530 Subject: [PATCH 6/6] fixing javax cache issue --- .../mdm/mobileservices/windows/common/util/DeviceUtil.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/util/DeviceUtil.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/util/DeviceUtil.java index 5f1c90b1b..e014cdcb1 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/util/DeviceUtil.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/mdm/mobileservices/windows/common/util/DeviceUtil.java @@ -54,7 +54,7 @@ public class DeviceUtil { if (deviceID != null) { cacheEntry.setDeviceID(deviceID); } - getTokenCache().put(token, cacheEntry); + getTokenCache().put(token.trim(), cacheEntry); } public static void removeToken(String token) {