From a905f22651b806c74ce61e89f202b519c929f345 Mon Sep 17 00:00:00 2001 From: Hasunie Date: Wed, 11 Jan 2017 09:03:03 +0530 Subject: [PATCH 01/21] fixing Windows gatway issues --- .../device/mgt/mobile/windows/api/common/PluginConstants.java | 2 +- .../mobile/windows/api/services/DeviceManagementService.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/common/PluginConstants.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/common/PluginConstants.java index b44bee037..27a7b479e 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/common/PluginConstants.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/common/PluginConstants.java @@ -68,7 +68,7 @@ public final class PluginConstants { public static final String CXF_REQUEST_URI = "org.apache.cxf.request.uri"; //Web services media types - public static final String SYNCML_MEDIA_TYPE = "application/vnd.syncml.dm+xml;charset=utf-8"; + public static final String SYNCML_MEDIA_TYPE = "application/vnd.syncml.dm+xml"; /** * Discovery service related other constants diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/DeviceManagementService.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/DeviceManagementService.java index 7a08827df..06ff00717 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/DeviceManagementService.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/DeviceManagementService.java @@ -46,7 +46,7 @@ import javax.ws.rs.core.Response; @Extension(properties = { @ExtensionProperty(name = "name", value = "Windows 10 Device management"), @ExtensionProperty(name = "context", - value = "/api/device-mgt/windows/v1.0/management"), + value = "/api/device-mgt/windows/v1.0/management/devicemgt"), }) } ), From 32d99bcab6d798cd6031efed4de6b8dec3e52a70 Mon Sep 17 00:00:00 2001 From: Hasunie Date: Wed, 11 Jan 2017 14:13:08 +0530 Subject: [PATCH 02/21] fixing jira IOTS-378 --- .../public/js/load-map.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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.device-view/public/js/load-map.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.device-view/public/js/load-map.js index 895f75b94..c09ab8ddb 100755 --- 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.device-view/public/js/load-map.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.device-view/public/js/load-map.js @@ -45,7 +45,7 @@ $(document).ready(function () { var url = $(this).prop("href"); var hash = url.substring(url.indexOf("#") + 1); - if (hash == "device_location") { + if (hash == "device_location_tab") { if (!map) { loadLeafletMap(); } From 76f52af4a5e965633f284e0d2960920f64f59966 Mon Sep 17 00:00:00 2001 From: Milan Perera Date: Wed, 11 Jan 2017 15:44:50 +0530 Subject: [PATCH 03/21] Refactored android sense agent --- .../iot/android/sense/RegisterActivity.java | 4 +- .../data/publisher/DataPublisherService.java | 21 ++- .../streams/location/LocationDataReader.java | 4 +- .../realtimeviewer/ActivitySelectSensor.java | 152 +++++++++--------- .../sense/util/SenseClientAsyncExecutor.java | 3 +- .../sense/util/dto/TokenIssuerService.java | 2 +- .../layout/app_bar_activity_select_sensor.xml | 84 ++++++---- .../layout/content_activity_select_sensor.xml | 14 +- ...activity_activity_select_sensor_drawer.xml | 4 +- .../build.gradle | 2 +- .../gradle/wrapper/gradle-wrapper.properties | 4 +- .../resources/devicetypes/android_sense.xml | 30 ++-- 12 files changed, 174 insertions(+), 150 deletions(-) diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/RegisterActivity.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/RegisterActivity.java index 0ef131041..5354cc1ae 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/RegisterActivity.java +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/RegisterActivity.java @@ -54,6 +54,7 @@ public class RegisterActivity extends Activity { private EditText mHostView; private View mProgressView; private View mLoginFormView; + private Button deviceRegisterButton; private Handler mUiHandler = new Handler(); @Override @@ -73,7 +74,7 @@ public class RegisterActivity extends Activity { AvailableSensorsInDevice availableSensorsInDevice = new AvailableSensorsInDevice(getApplicationContext()); availableSensorsInDevice.setContent(); - Button deviceRegisterButton = (Button) findViewById(R.id.device_register_button); + deviceRegisterButton = (Button) findViewById(R.id.device_register_button); deviceRegisterButton.setOnClickListener(new OnClickListener() { @@ -204,6 +205,7 @@ public class RegisterActivity extends Activity { // and hide the relevant UI components. mProgressView.setVisibility(show ? View.VISIBLE : View.GONE); mLoginFormView.setVisibility(show ? View.GONE : View.VISIBLE); + deviceRegisterButton.setVisibility(show? View.VISIBLE : View.GONE); } } diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/data/publisher/DataPublisherService.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/data/publisher/DataPublisherService.java index 0335ffe50..ecff96371 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/data/publisher/DataPublisherService.java +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/data/publisher/DataPublisherService.java @@ -52,11 +52,8 @@ import java.util.List; * This is an android service which publishes the data to the server. */ public class DataPublisherService extends Service { - private static final String TAG = DataPublisherService.class.getName(); - private static String KEY_TAG = "key"; - private static String TIME_TAG = "time"; - private static String VALUE_TAG = "value"; - public static Context context; + private final String TAG = DataPublisherService.class.getName(); + private Context context; @Nullable @Override @@ -68,9 +65,9 @@ public class DataPublisherService extends Service { public int onStartCommand(Intent intent, int flags, int startId) { context = this; Log.d(TAG, "service started"); - Runnable runnable = new Runnable() { - @Override - public void run() { +// Runnable runnable = new Runnable() { +// @Override +// public void run() { try { List events = new ArrayList<>(); //retrieve sensor data. @@ -315,10 +312,10 @@ public class DataPublisherService extends Service { } catch (TransportHandlerException e) { Log.e(TAG, "Data Publish Failed", e); } - } - }; - Thread dataUploaderThread = new Thread(runnable); - dataUploaderThread.start(); +// } +// }; +// Thread dataUploaderThread = new Thread(runnable); +// dataUploaderThread.start(); return Service.START_NOT_STICKY; } } \ No newline at end of file diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/location/LocationDataReader.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/location/LocationDataReader.java index 976e6d0bd..f79cc64f5 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/location/LocationDataReader.java +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/location/LocationDataReader.java @@ -183,8 +183,8 @@ public class LocationDataReader extends DataReader implements LocationListener { double distance =CalculationByDistance(latitude, longitude, lat_old, lon_old)/1000; speed = (float)distance/(float)time; - Toast.makeText(mContext, longitude+"\n"+latitude+"\nDistance is: " - +distance+"\nSpeed is: "+speed , Toast.LENGTH_SHORT).show(); +// Toast.makeText(mContext, longitude+"\n"+latitude+"\nDistance is: " +// +distance+"\nSpeed is: "+speed , Toast.LENGTH_SHORT).show(); Intent intent = new Intent("speedUpdate"); diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/ActivitySelectSensor.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/ActivitySelectSensor.java index f8d658f69..fd7bf2ae9 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/ActivitySelectSensor.java +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/ActivitySelectSensor.java @@ -73,7 +73,7 @@ public class ActivitySelectSensor extends AppCompatActivity private ListView listView; private SensorManager sensorManager; private ArrayList sensors = new ArrayList<>(); - private EditText sessionIdText; +// private EditText sessionIdText; private RealTimeSensorReader sensorReader = null; private RealTimeSensorChangeReceiver realTimeSensorChangeReceiver = new RealTimeSensorChangeReceiver(); private SupportedSensors supportedSensors = SupportedSensors.getInstance(); @@ -87,21 +87,21 @@ public class ActivitySelectSensor extends AppCompatActivity Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); sensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE); - sessionIdText = (EditText) findViewById(R.id.sessionId); - sessionIdText.setCursorVisible(false); + //sessionIdText = (EditText) findViewById(R.id.sessionId); +// sessionIdText.setCursorVisible(false); listView = (ListView) findViewById(R.id.senseListContainer); - verifyBluetooth(); + //verifyBluetooth(); registerReceiver(realTimeSensorChangeReceiver, new IntentFilter("sensorDataMap")); - sessionIdText.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - sessionIdText.setCursorVisible(true); - - } - }); +// sessionIdText.setOnClickListener(new View.OnClickListener() { +// @Override +// public void onClick(View v) { +// sessionIdText.setCursorVisible(true); +// +// } +// }); //Publish data FloatingActionButton fbtnPublishData = (FloatingActionButton) findViewById(R.id.publish); @@ -126,33 +126,33 @@ public class ActivitySelectSensor extends AppCompatActivity } }); - FloatingActionButton fbtnSpeechRecongnizer = (FloatingActionButton) findViewById(R.id.speech); - fbtnSpeechRecongnizer.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - String sessionId = sessionIdText.getText().toString(); - if (!sessionId.isEmpty()) { - Intent intent = new Intent(getApplicationContext(), WordRecognitionActivity.class); - intent.putExtra("sessionId", sessionId); - startActivity(intent); - } else { - Toast.makeText(ActivitySelectSensor.this, "Please type a session id value", Toast.LENGTH_SHORT) - .show(); - } + //FloatingActionButton fbtnSpeechRecongnizer = (FloatingActionButton) findViewById(R.id.speech); +// fbtnSpeechRecongnizer.setOnClickListener(new View.OnClickListener() { +// @Override +// public void onClick(View v) { +// String sessionId = sessionIdText.getText().toString(); +// if (!sessionId.isEmpty()) { +// Intent intent = new Intent(getApplicationContext(), WordRecognitionActivity.class); +// intent.putExtra("sessionId", sessionId); +// startActivity(intent); +// } else { +// Toast.makeText(ActivitySelectSensor.this, "Please type a session id value", Toast.LENGTH_SHORT) +// .show(); +// } +// +// } +// }); - } - }); - - FloatingActionButton fbtnBeaconMonitor = (FloatingActionButton) findViewById(R.id.beacon); - fbtnBeaconMonitor.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - Intent intent = new Intent(getApplicationContext(), BeaconMonitoringActivity.class); - startActivity(intent); - - - } - }); +// FloatingActionButton fbtnBeaconMonitor = (FloatingActionButton) findViewById(R.id.beacon); +// fbtnBeaconMonitor.setOnClickListener(new View.OnClickListener() { +// @Override +// public void onClick(View v) { +// Intent intent = new Intent(getApplicationContext(), BeaconMonitoringActivity.class); +// startActivity(intent); +// +// +// } +// }); sharedPreferences = getSharedPreferences(SupportedSensors.SELECTED_SENSORS, 0); @@ -313,43 +313,43 @@ public class ActivitySelectSensor extends AppCompatActivity unregisterReceiver(realTimeSensorChangeReceiver); } - private void verifyBluetooth() { - - try { - if (!BeaconManager.getInstanceForApplication(this).checkAvailability()) { - final AlertDialog.Builder builder = new AlertDialog.Builder(this); - builder.setTitle("Bluetooth not enabled"); - builder.setMessage("Please enable bluetooth in settings and restart this application."); - builder.setPositiveButton(android.R.string.ok, null); - builder.setOnDismissListener(new DialogInterface.OnDismissListener() { - - @Override - public void onDismiss(DialogInterface dialog) { - finish(); - System.exit(0); - } - - }); - builder.show(); - - } - } catch (RuntimeException e) { - final AlertDialog.Builder builder = new AlertDialog.Builder(this); - builder.setTitle("Bluetooth LE not available"); - builder.setMessage("Sorry, this device does not support Bluetooth LE."); - builder.setPositiveButton(android.R.string.ok, null); - builder.setOnDismissListener(new DialogInterface.OnDismissListener() { - - @Override - public void onDismiss(DialogInterface dialog) { - finish(); - System.exit(0); - } - - }); - builder.show(); - - } - - } +// private void verifyBluetooth() { +// +// try { +// if (!BeaconManager.getInstanceForApplication(this).checkAvailability()) { +// final AlertDialog.Builder builder = new AlertDialog.Builder(this); +// builder.setTitle("Bluetooth not enabled"); +// builder.setMessage("Please enable bluetooth in settings and restart this application."); +// builder.setPositiveButton(android.R.string.ok, null); +// builder.setOnDismissListener(new DialogInterface.OnDismissListener() { +// +// @Override +// public void onDismiss(DialogInterface dialog) { +// finish(); +// System.exit(0); +// } +// +// }); +// builder.show(); +// +// } +// } catch (RuntimeException e) { +// final AlertDialog.Builder builder = new AlertDialog.Builder(this); +// builder.setTitle("Bluetooth LE not available"); +// builder.setMessage("Sorry, this device does not support Bluetooth LE."); +// builder.setPositiveButton(android.R.string.ok, null); +// builder.setOnDismissListener(new DialogInterface.OnDismissListener() { +// +// @Override +// public void onDismiss(DialogInterface dialog) { +// finish(); +// System.exit(0); +// } +// +// }); +// builder.show(); +// +// } +// +// } } diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/SenseClientAsyncExecutor.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/SenseClientAsyncExecutor.java index 9289a29a8..6b1591ce9 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/SenseClientAsyncExecutor.java +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/SenseClientAsyncExecutor.java @@ -57,6 +57,7 @@ public class SenseClientAsyncExecutor extends AsyncTask + android:layout_height="100dp" + android:layout_margin="20dp" + android:orientation="horizontal"> - + + + + + + + + + + + + - + + - + + + + + + + + + + + + + - - + + + - - diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/layout/content_activity_select_sensor.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/layout/content_activity_select_sensor.xml index e431b902a..d3d332de3 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/layout/content_activity_select_sensor.xml +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/layout/content_activity_select_sensor.xml @@ -11,18 +11,18 @@ tools:context="org.wso2.carbon.iot.android.sense.realtimeviewer.ActivitySelectSensor" android:id="@+id/parentContainer"> - + + + + + + + > diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/menu/activity_activity_select_sensor_drawer.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/menu/activity_activity_select_sensor_drawer.xml index 861bf44cd..cdcb37580 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/menu/activity_activity_select_sensor_drawer.xml +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/menu/activity_activity_select_sensor_drawer.xml @@ -3,8 +3,8 @@ - + + diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/build.gradle b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/build.gradle index 83876c80a..b3722d082 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/build.gradle +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/build.gradle @@ -6,7 +6,7 @@ buildscript { maven { url 'https://repo.eclipse.org/content/repositories/paho-releases/' } } dependencies { - classpath 'com.android.tools.build:gradle:2.1.0' + classpath 'com.android.tools.build:gradle:2.2.0' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/gradle/wrapper/gradle-wrapper.properties b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/gradle/wrapper/gradle-wrapper.properties index e7ff442f3..f88c58d1a 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/gradle/wrapper/gradle-wrapper.properties +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Wed May 11 14:40:10 IST 2016 +#Mon Jan 09 12:13:26 IST 2017 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip diff --git a/features/device-types-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/devicetypes/android_sense.xml b/features/device-types-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/devicetypes/android_sense.xml index d06d6ccce..e01a8a4a7 100644 --- a/features/device-types-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/devicetypes/android_sense.xml +++ b/features/device-types-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/devicetypes/android_sense.xml @@ -22,29 +22,29 @@ Add Keywords Send keywords to the device - - - keywords - - + + + + + Add Threshold Send Threshold to the device - - - threshold - - + + + + + Remove words Remove Threshold from the device - - - words - - + + + + + From 466c2b1151b0c91eebdb03c9c017a377174da0c8 Mon Sep 17 00:00:00 2001 From: ayyoob Date: Thu, 12 Jan 2017 19:29:59 +0530 Subject: [PATCH 04/21] moved to gateway mode --- .../src/main/webapp/WEB-INF/web.xml | 4 - .../src/main/webapp/WEB-INF/web.xml | 4 - .../src/main/webapp/WEB-INF/web.xml | 4 - .../src/main/webapp/WEB-INF/web.xml | 8 -- .../authorization/DeviceAuthorizer.java | 5 ++ .../authorization/PermissionUtil.java | 76 +++++++++++++++++++ ...ebsocketEventAdaptorServiceDataHolder.java | 13 ++++ ...cketLocalEventAdapterServiceComponent.java | 31 ++++++++ .../client/OAuthRequestInterceptor.java | 3 +- .../client/dto/TokenIssuerService.java | 6 ++ .../src/main/webapp/WEB-INF/web.xml | 5 -- .../src/main/webapp/WEB-INF/web.xml | 4 - 12 files changed, 133 insertions(+), 30 deletions(-) create mode 100644 components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/authorization/PermissionUtil.java diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/webapp/WEB-INF/web.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/webapp/WEB-INF/web.xml index be0eee231..2c66f5c1d 100644 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/webapp/WEB-INF/web.xml +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/webapp/WEB-INF/web.xml @@ -16,10 +16,6 @@ CXFServlet /* - - isAdminService - false - doAuthentication true diff --git a/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/webapp/WEB-INF/web.xml b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/webapp/WEB-INF/web.xml index a137eb9cc..96122464a 100644 --- a/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/webapp/WEB-INF/web.xml +++ b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/webapp/WEB-INF/web.xml @@ -16,10 +16,6 @@ CXFServlet /* - - isAdminService - false - doAuthentication true diff --git a/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/webapp/WEB-INF/web.xml b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/webapp/WEB-INF/web.xml index 975eb808a..e6b97eaed 100644 --- a/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/webapp/WEB-INF/web.xml +++ b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/webapp/WEB-INF/web.xml @@ -16,10 +16,6 @@ CXFServlet /* - - isAdminService - false - doAuthentication true diff --git a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/webapp/WEB-INF/web.xml b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/webapp/WEB-INF/web.xml index eb4a397bf..4337c5720 100644 --- a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/webapp/WEB-INF/web.xml +++ b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/webapp/WEB-INF/web.xml @@ -16,18 +16,10 @@ CXFServlet /* - - isAdminService - false - doAuthentication true - - providerTenantDomain - carbon.super - diff --git a/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/authorization/DeviceAuthorizer.java b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/authorization/DeviceAuthorizer.java index d8e779491..0edea4d1e 100644 --- a/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/authorization/DeviceAuthorizer.java +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/authorization/DeviceAuthorizer.java @@ -61,6 +61,11 @@ public class DeviceAuthorizer implements Authorizer { @Override public void init(Map globalProperties) { statPermissions = getPermissions(globalProperties); + if (statPermissions != null && !statPermissions.isEmpty()) { + for (String permission : statPermissions) { + PermissionUtil.putPermission(permission); + } + } try { deviceAccessAuthorizationAdminService = Feign.builder() .requestInterceptor(new OAuthRequestInterceptor(globalProperties)) diff --git a/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/authorization/PermissionUtil.java b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/authorization/PermissionUtil.java new file mode 100644 index 000000000..cab25a8c4 --- /dev/null +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/authorization/PermissionUtil.java @@ -0,0 +1,76 @@ +/* + * 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.device.mgt.output.adapter.websocket.authorization; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.base.MultitenantConstants; +import org.wso2.carbon.device.mgt.output.adapter.websocket.internal.WebsocketEventAdaptorServiceDataHolder; +import org.wso2.carbon.registry.api.Resource; +import org.wso2.carbon.registry.core.Registry; +import org.wso2.carbon.registry.core.exceptions.RegistryException; + +import java.util.StringTokenizer; + +/** + * Utility class which holds necessary utility methods required for persisting permissions in + * registry. + */ +public class PermissionUtil { + + public static final String PERMISSION_PROPERTY_NAME = "name"; + private static Log log = LogFactory.getLog(DeviceAuthorizer.class); + + public static void putPermission(String permission) { + try { + StringTokenizer tokenizer = new StringTokenizer(permission, "/"); + String lastToken = "", currentToken, tempPath; + while (tokenizer.hasMoreTokens()) { + currentToken = tokenizer.nextToken(); + tempPath = lastToken + "/" + currentToken; + if (!checkResourceExists(tempPath)) { + createRegistryCollection(tempPath, currentToken); + + } + lastToken = tempPath; + } + } catch (org.wso2.carbon.registry.api.RegistryException e) { + log.error("Failed to creation permission in registry" + permission, e); + } + } + + public static void createRegistryCollection(String path, String resourceName) + throws org.wso2.carbon.registry.api.RegistryException { + Resource resource = getGovernanceRegistry().newCollection(); + resource.addProperty(PERMISSION_PROPERTY_NAME, resourceName); + getGovernanceRegistry().beginTransaction(); + getGovernanceRegistry().put(path, resource); + getGovernanceRegistry().commitTransaction(); + } + + public static boolean checkResourceExists(String path) + throws RegistryException { + return getGovernanceRegistry().resourceExists(path); + } + + public static Registry getGovernanceRegistry() throws RegistryException { + return WebsocketEventAdaptorServiceDataHolder.getRegistryService() + .getGovernanceSystemRegistry(MultitenantConstants.SUPER_TENANT_ID); + } + +} diff --git a/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/internal/WebsocketEventAdaptorServiceDataHolder.java b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/internal/WebsocketEventAdaptorServiceDataHolder.java index 0485b0710..7cf22b0a2 100644 --- a/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/internal/WebsocketEventAdaptorServiceDataHolder.java +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/internal/WebsocketEventAdaptorServiceDataHolder.java @@ -20,6 +20,7 @@ package org.wso2.carbon.device.mgt.output.adapter.websocket.internal; import org.wso2.carbon.device.mgt.output.adapter.websocket.WebsocketOutputCallbackControllerServiceImpl; import org.wso2.carbon.event.stream.core.EventStreamService; +import org.wso2.carbon.registry.core.service.RegistryService; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.LinkedBlockingDeque; @@ -35,6 +36,7 @@ public final class WebsocketEventAdaptorServiceDataHolder { private static ConcurrentHashMap>> tenantSpecificStreamEventMap = new ConcurrentHashMap<>(); private static EventStreamService eventStreamService; + private static RegistryService registryService; public static void registerEventStreamService(EventStreamService eventBuilderService) { WebsocketEventAdaptorServiceDataHolder.eventStreamService = eventBuilderService; @@ -63,4 +65,15 @@ public final class WebsocketEventAdaptorServiceDataHolder { getTenantSpecificStreamEventMap() { return tenantSpecificStreamEventMap; } + + public static RegistryService getRegistryService() { + if (registryService == null) { + throw new IllegalStateException("Registry service is not initialized properly"); + } + return registryService; + } + + public static void setRegistryService(RegistryService registryService) { + WebsocketEventAdaptorServiceDataHolder.registryService = registryService; + } } diff --git a/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/internal/WebsocketLocalEventAdapterServiceComponent.java b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/internal/WebsocketLocalEventAdapterServiceComponent.java index 4820d46e6..9425f9cda 100644 --- a/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/internal/WebsocketLocalEventAdapterServiceComponent.java +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/internal/WebsocketLocalEventAdapterServiceComponent.java @@ -26,12 +26,19 @@ import org.wso2.carbon.device.mgt.output.adapter.websocket.WebsocketOutputCallba import org.wso2.carbon.event.output.adapter.core.OutputEventAdapterFactory; import org.wso2.carbon.device.mgt.output.adapter.websocket.WebsocketOutputCallbackControllerService; import org.wso2.carbon.event.stream.core.EventStreamService; +import org.wso2.carbon.registry.core.service.RegistryService; /** * @scr.component component.name="output.extensions.secured.websocket.AdapterService.component" immediate="true" * @scr.reference name="eventStreamService.service" * interface="org.wso2.carbon.event.stream.core.EventStreamService" cardinality="1..1" * policy="dynamic" bind="setEventStreamService" unbind="unsetEventStreamService" + * @scr.reference name="registry.service" + * interface="org.wso2.carbon.registry.core.service.RegistryService" + * cardinality="1..1" + * policy="dynamic" + * bind="setRegistryService" + * unbind="unsetRegistryService" */ public class WebsocketLocalEventAdapterServiceComponent { @@ -80,4 +87,28 @@ public class WebsocketLocalEventAdapterServiceComponent { } WebsocketEventAdaptorServiceDataHolder.registerEventStreamService(null); } + + /** + * Sets Registry Service. + * + * @param registryService An instance of RegistryService + */ + protected void setRegistryService(RegistryService registryService) { + if (log.isDebugEnabled()) { + log.debug("Setting Registry Service"); + } + WebsocketEventAdaptorServiceDataHolder.setRegistryService(registryService); + } + + /** + * Unsets Registry Service. + * + * @param registryService An instance of RegistryService + */ + protected void unsetRegistryService(RegistryService registryService) { + if (log.isDebugEnabled()) { + log.debug("Un setting Registry Service"); + } + WebsocketEventAdaptorServiceDataHolder.setRegistryService(null); + } } diff --git a/components/extensions/mb-extensions/org.wso2.carbon.andes.extensions.device.mgt.mqtt.authorization/src/main/java/org/wso2/carbon/andes/extensions/device/mgt/mqtt/authorization/client/OAuthRequestInterceptor.java b/components/extensions/mb-extensions/org.wso2.carbon.andes.extensions.device.mgt.mqtt.authorization/src/main/java/org/wso2/carbon/andes/extensions/device/mgt/mqtt/authorization/client/OAuthRequestInterceptor.java index 886daa912..9a29d0026 100755 --- a/components/extensions/mb-extensions/org.wso2.carbon.andes.extensions.device.mgt.mqtt.authorization/src/main/java/org/wso2/carbon/andes/extensions/device/mgt/mqtt/authorization/client/OAuthRequestInterceptor.java +++ b/components/extensions/mb-extensions/org.wso2.carbon.andes.extensions.device.mgt.mqtt.authorization/src/main/java/org/wso2/carbon/andes/extensions/device/mgt/mqtt/authorization/client/OAuthRequestInterceptor.java @@ -40,6 +40,7 @@ public class OAuthRequestInterceptor implements RequestInterceptor { private static final String APPLICATION_NAME = "mqtt_broker"; private static final String PASSWORD_GRANT_TYPE = "password"; private static final String REFRESH_GRANT_TYPE = "refresh_token"; + private static final String REQUIRED_SCOPE = "perm:authorization:verify"; private ApiApplicationRegistrationService apiApplicationRegistrationService; private TokenIssuerService tokenIssuerService; @@ -76,7 +77,7 @@ public class OAuthRequestInterceptor implements RequestInterceptor { new BasicAuthRequestInterceptor(consumerKey, consumerSecret)) .contract(new JAXRSContract()).encoder(new GsonEncoder()).decoder(new GsonDecoder()) .target(TokenIssuerService.class, AuthorizationConfigurationManager.getInstance().getTokenEndpoint()); - tokenInfo = tokenIssuerService.getToken(PASSWORD_GRANT_TYPE, username, password); + tokenInfo = tokenIssuerService.getToken(PASSWORD_GRANT_TYPE, username, password, REQUIRED_SCOPE); tokenInfo.setExpires_in(System.currentTimeMillis() + tokenInfo.getExpires_in()); } synchronized (this) { diff --git a/components/extensions/mb-extensions/org.wso2.carbon.andes.extensions.device.mgt.mqtt.authorization/src/main/java/org/wso2/carbon/andes/extensions/device/mgt/mqtt/authorization/client/dto/TokenIssuerService.java b/components/extensions/mb-extensions/org.wso2.carbon.andes.extensions.device.mgt.mqtt.authorization/src/main/java/org/wso2/carbon/andes/extensions/device/mgt/mqtt/authorization/client/dto/TokenIssuerService.java index 3e8413b45..5938587f3 100755 --- a/components/extensions/mb-extensions/org.wso2.carbon.andes.extensions.device.mgt.mqtt.authorization/src/main/java/org/wso2/carbon/andes/extensions/device/mgt/mqtt/authorization/client/dto/TokenIssuerService.java +++ b/components/extensions/mb-extensions/org.wso2.carbon.andes.extensions.device.mgt.mqtt.authorization/src/main/java/org/wso2/carbon/andes/extensions/device/mgt/mqtt/authorization/client/dto/TokenIssuerService.java @@ -33,6 +33,12 @@ public interface TokenIssuerService { AccessTokenInfo getToken(@QueryParam("grant_type") String grant, @QueryParam("username") String username, @QueryParam("password") String password); + @POST + @Produces(MediaType.APPLICATION_JSON) + @Consumes(MediaType.APPLICATION_FORM_URLENCODED) + AccessTokenInfo getToken(@QueryParam("grant_type") String grant, @QueryParam("username") String username, + @QueryParam("password") String password, @QueryParam("scopes") String scopes); + @POST @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_FORM_URLENCODED) diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/webapp/WEB-INF/web.xml b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/webapp/WEB-INF/web.xml index 63510fe9b..b22bd2b5d 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/webapp/WEB-INF/web.xml +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/webapp/WEB-INF/web.xml @@ -42,11 +42,6 @@ 60 - - - isAdminService - false - managed-api-enabled true 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 8dbd5e352..6ea6be132 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 @@ -48,10 +48,6 @@ 60 - - isAdminService - false - managed-api-enabled true From 09f7fb3a5f7ef6c99b58c8f791d7d9453207e283 Mon Sep 17 00:00:00 2001 From: ayyoob Date: Fri, 13 Jan 2017 04:49:35 +0530 Subject: [PATCH 05/21] moved the traffic through the gateway --- .../service/impl/AndroidSenseServiceImpl.java | 1 - .../impl/constants/AndroidSenseConstants.java | 2 +- .../service/impl/util/APIUtil.java | 11 +++--- .../private/config.json | 5 ++- .../arduino/service/impl/util/ZipUtil.java | 21 ++++++------ .../private/config.json | 6 +++- .../service/impl/util/ZipUtil.java | 34 +++++++------------ .../private/config.json | 5 ++- .../agent/core/AgentUtilOperations.java | 2 +- .../service/impl/util/ZipUtil.java | 27 ++++++--------- .../private/config.json | 3 ++ .../adapter/mqtt/i18n/Resources.properties | 2 +- .../client/OAuthRequestInterceptor.java | 13 ++----- .../client/dto/TokenIssuerService.java | 3 +- .../client/OAuthRequestInterceptor.java | 6 ++-- .../client/dto/TokenIssuerService.java | 2 +- .../private/config.json | 3 ++ .../private/config.json | 3 ++ 18 files changed, 73 insertions(+), 76 deletions(-) diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/AndroidSenseServiceImpl.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/AndroidSenseServiceImpl.java index 5a4b65ddb..d4d117f18 100644 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/AndroidSenseServiceImpl.java +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/AndroidSenseServiceImpl.java @@ -48,7 +48,6 @@ import java.util.Properties; public class AndroidSenseServiceImpl implements AndroidSenseService { private static Log log = LogFactory.getLog(AndroidSenseServiceImpl.class); - private static String DEFAULT_MQTT_ENDPOINT = "tcp://localhost:1886"; @Path("device/{deviceId}/words") @POST diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/constants/AndroidSenseConstants.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/constants/AndroidSenseConstants.java index 68678d000..3c1e93a5c 100644 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/constants/AndroidSenseConstants.java +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/constants/AndroidSenseConstants.java @@ -40,7 +40,7 @@ public class AndroidSenseConstants { public static final String HOST_NAME = "HostName"; public static final String LOCALHOST = "localhost"; public static final String CONFIG_TYPE = "general"; - public static final String DEFAULT_ENDPOINT = "tcp://localhost:1886"; + public static final String DEFAULT_ENDPOINT = "tcp://${mqtt.broker.host}:${mqtt.broker.port}"; public static final String SCOPE = "scope"; diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/util/APIUtil.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/util/APIUtil.java index 850b766c8..aa8fda595 100644 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/util/APIUtil.java +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/util/APIUtil.java @@ -13,6 +13,7 @@ import org.wso2.carbon.apimgt.application.extension.APIManagementProviderService import org.wso2.carbon.base.ServerConfiguration; import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.context.PrivilegedCarbonContext; +import org.wso2.carbon.core.util.Utils; import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorizationService; import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationEntry; import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationManagementException; @@ -205,7 +206,7 @@ public class APIUtil { } public static String getMqttEndpoint() throws ConfigurationManagementException { - String iotServerIP = AndroidSenseConstants.DEFAULT_ENDPOINT; + String iotServerIP = Utils.replaceSystemProperty(AndroidSenseConstants.DEFAULT_ENDPOINT); iotServerIP = iotServerIP.replace(AndroidSenseConstants.LOCALHOST, getServerUrl());; PlatformConfiguration configuration = APIUtil.getTenantConfigurationManagementService().getConfiguration( AndroidSenseConstants.CONFIG_TYPE); @@ -224,15 +225,11 @@ public class APIUtil { } public static String getServerUrl() { - String hostName = ServerConfiguration.getInstance().getFirstProperty(AndroidSenseConstants.HOST_NAME); try { - if (hostName == null) { - hostName = NetworkUtils.getLocalHostname(); - } + return org.apache.axis2.util.Utils.getIpAddress(); } catch (SocketException e) { - hostName = "localhost"; log.warn("Failed retrieving the hostname, therefore set to localhost", e); + return "localhost"; } - return hostName; } } diff --git a/components/device-types/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/private/config.json b/components/device-types/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/private/config.json index 7975a2cba..957ec1811 100644 --- a/components/device-types/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/private/config.json +++ b/components/device-types/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/private/config.json @@ -1,6 +1,9 @@ { "deviceType": { "label": "Android Sense", - "category": "iot" + "category": "iot", + "scopes" : [ + "perm:android-sense:enroll" + ] } } \ No newline at end of file diff --git a/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/util/ZipUtil.java b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/util/ZipUtil.java index 414b24847..627ced256 100644 --- a/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/util/ZipUtil.java +++ b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/util/ZipUtil.java @@ -24,6 +24,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.base.MultitenantConstants; import org.wso2.carbon.base.ServerConfiguration; +import org.wso2.carbon.core.util.Utils; 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.ConfigurationManagementException; @@ -59,7 +60,9 @@ public class ZipUtil { private static final String HTTP_PORT_PROPERTY = "httpPort"; private static final String CONFIG_TYPE = "general"; private static final Log log = LogFactory.getLog(ZipUtil.class); - public static final String HOST_NAME = "HostName"; + private static final String LOCALHOST = "localhost"; + private static final String HTTP_PROTOCOL_HOST = "${iot.gateway.host}"; + private static final String HTTP_PROTOCOL_PORT = "${iot.gateway.http.port}"; public ZipArchive createZipFile(String owner, String tenantDomain, String deviceType, String deviceId, String deviceName, String token, @@ -72,8 +75,10 @@ public class ZipUtil { String iotServerIP; try { - iotServerIP = getServerUrl(); - String httpServerPort = System.getProperty(HTTP_PORT_PROPERTY); + iotServerIP = Utils.replaceSystemProperty(HTTP_PROTOCOL_HOST); + String serverIpAddress = getServerUrl(); + iotServerIP = iotServerIP.replace(LOCALHOST, serverIpAddress); + String httpServerPort = Utils.replaceSystemProperty(HTTP_PROTOCOL_PORT); Map contextParams = new HashMap<>(); @@ -117,17 +122,13 @@ public class ZipUtil { } } - private static String getServerUrl() { - String hostName = ServerConfiguration.getInstance().getFirstProperty(HOST_NAME); + public static String getServerUrl() { try { - if (hostName == null) { - hostName = NetworkUtils.getLocalHostname(); - } + return org.apache.axis2.util.Utils.getIpAddress(); } catch (SocketException e) { - hostName = "localhost"; log.warn("Failed retrieving the hostname, therefore set to localhost", e); + return "localhost"; } - return hostName; } private static ZipArchive getSketchArchive(String archivesPath, String templateSketchPath, Map contextParams diff --git a/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.type-view/private/config.json b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.type-view/private/config.json index e85ea2bc6..74d66878d 100644 --- a/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.type-view/private/config.json +++ b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.type-view/private/config.json @@ -2,6 +2,10 @@ "deviceType": { "label": "Arduino", "category": "iot", - "downloadAgentUri": "arduino/device/download" + "downloadAgentUri": "arduino/device/download", + "category": "iot", + "scopes" : [ + "perm:arduino:enroll" + ] } } \ No newline at end of file diff --git a/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/util/ZipUtil.java b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/util/ZipUtil.java index d8c955a15..e902609de 100644 --- a/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/util/ZipUtil.java +++ b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/util/ZipUtil.java @@ -23,6 +23,7 @@ import org.apache.commons.io.IOUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.base.ServerConfiguration; +import org.wso2.carbon.core.util.Utils; 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.ConfigurationManagementException; @@ -56,15 +57,12 @@ import java.util.zip.ZipOutputStream; public class ZipUtil { private static final Log log = LogFactory.getLog(ZipUtil.class); - public static final String HOST_NAME = "HostName"; - private static final String HTTPS_PORT_PROPERTY = "httpsPort"; - private static final String HTTP_PORT_PROPERTY = "httpPort"; private static final String LOCALHOST = "localhost"; - private static final String HTTPS_PROTOCOL_APPENDER = "https://"; - private static final String HTTP_PROTOCOL_APPENDER = "http://"; + private static final String HTTPS_PROTOCOL_URL = "https://${iot.gateway.host}:${iot.gateway.https.port}"; + private static final String HTTP_PROTOCOL_URL = "http://${iot.gateway.host}:${iot.gateway.http.port}"; private static final String CONFIG_TYPE = "general"; - private static final String DEFAULT_MQTT_ENDPOINT = "tcp://localhost:1886"; + private static final String DEFAULT_MQTT_ENDPOINT = "tcp://${mqtt.broker.host}:${mqtt.broker.port}"; public ZipArchive createZipFile(String owner, String tenantDomain, String deviceType, String deviceId, String deviceName, String token, @@ -78,16 +76,14 @@ public class ZipUtil { try { iotServerIP = getServerUrl(); - String httpsServerPort = System.getProperty(HTTPS_PORT_PROPERTY); - String httpServerPort = System.getProperty(HTTP_PORT_PROPERTY); - String httpsServerEP = HTTPS_PROTOCOL_APPENDER + iotServerIP + ":" + httpsServerPort; - String httpServerEP = HTTP_PROTOCOL_APPENDER + iotServerIP + ":" + httpServerPort; - String apimEndpoint = httpsServerEP; - String mqttEndpoint = DEFAULT_MQTT_ENDPOINT; + String httpsServerEP = Utils.replaceSystemProperty(HTTPS_PROTOCOL_URL); + String httpServerEP = Utils.replaceSystemProperty(HTTP_PROTOCOL_URL); + String mqttEndpoint = Utils.replaceSystemProperty(DEFAULT_MQTT_ENDPOINT); if (mqttEndpoint.contains(LOCALHOST)) { mqttEndpoint = mqttEndpoint.replace(LOCALHOST, iotServerIP); + httpsServerEP = httpsServerEP.replace(LOCALHOST, iotServerIP); + httpServerEP = httpServerEP.replace(LOCALHOST, iotServerIP); } - PlatformConfiguration configuration = APIUtil.getTenantConfigurationManagementService().getConfiguration( CONFIG_TYPE); if (configuration != null && configuration.getConfiguration() != null && configuration @@ -115,7 +111,7 @@ public class ZipUtil { contextParams.put("DEVICE_NAME", deviceName); contextParams.put("HTTPS_EP", httpsServerEP); contextParams.put("HTTP_EP", httpServerEP); - contextParams.put("APIM_EP", apimEndpoint); + contextParams.put("APIM_EP", httpsServerEP); contextParams.put("MQTT_EP", mqttEndpoint); contextParams.put("DEVICE_TOKEN", token); contextParams.put("DEVICE_REFRESH_TOKEN", refreshToken); @@ -130,17 +126,13 @@ public class ZipUtil { } } - private static String getServerUrl() { - String hostName = ServerConfiguration.getInstance().getFirstProperty(HOST_NAME); + public static String getServerUrl() { try { - if (hostName == null) { - hostName = NetworkUtils.getLocalHostname(); - } + return org.apache.axis2.util.Utils.getIpAddress(); } catch (SocketException e) { - hostName = "localhost"; log.warn("Failed retrieving the hostname, therefore set to localhost", e); + return "localhost"; } - return hostName; } private static ZipArchive getSketchArchive(String archivesPath, String templateSketchPath, Map contextParams diff --git a/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.type-view/private/config.json b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.type-view/private/config.json index f19ba0341..224f055c3 100644 --- a/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.type-view/private/config.json +++ b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.type-view/private/config.json @@ -2,6 +2,9 @@ "deviceType": { "label": "Raspberry Pi", "category": "iot", - "downloadAgentUri": "raspberrypi/device/download" + "downloadAgentUri": "raspberrypi/device/download", + "scopes" : [ + "perm:raspberrypi:enroll" + ] } } \ No newline at end of file diff --git a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/core/AgentUtilOperations.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/core/AgentUtilOperations.java index 7a365174b..8f6fe409b 100644 --- a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/core/AgentUtilOperations.java +++ b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/core/AgentUtilOperations.java @@ -437,7 +437,7 @@ public class AgentUtilOperations { } private class APIManagerTokenUtils { - public static final String TOKEN_ENDPOINT = "/oauth2/token"; + public static final String TOKEN_ENDPOINT = "/token"; public static final String GRANT_TYPE = "grant_type"; public static final String ACCESS_TOKEN = "access_token"; public static final String REFRESH_TOKEN = "refresh_token"; diff --git a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/util/ZipUtil.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/util/ZipUtil.java index 39e938f2b..e9bcb6c60 100644 --- a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/util/ZipUtil.java +++ b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/util/ZipUtil.java @@ -25,14 +25,13 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.json.JSONObject; import org.wso2.carbon.apimgt.application.extension.constants.ApiApplicationConstants; -import org.wso2.carbon.base.ServerConfiguration; +import org.wso2.carbon.core.util.Utils; 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.ConfigurationManagementException; import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration; import org.wso2.carbon.device.mgt.iot.virtualfirealarm.service.impl.xmpp.XmppConfig; import org.wso2.carbon.utils.CarbonUtils; -import org.wso2.carbon.utils.NetworkUtils; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; @@ -64,10 +63,10 @@ public class ZipUtil { private static final String HTTP_PORT_PROPERTY = "httpPort"; private static final String LOCALHOST = "localhost"; - private static final String HTTPS_PROTOCOL_APPENDER = "https://"; - private static final String HTTP_PROTOCOL_APPENDER = "http://"; + private static final String HTTPS_PROTOCOL_URL = "https://${iot.gateway.host}:${iot.gateway.https.port}"; + private static final String HTTP_PROTOCOL_URL = "http://${iot.gateway.host}:${iot.gateway.http.port}"; private static final String CONFIG_TYPE = "general"; - private static final String DEFAULT_MQTT_ENDPOINT = "tcp://localhost:1886"; + private static final String DEFAULT_MQTT_ENDPOINT = "tcp://${mqtt.broker.host}:${mqtt.broker.port}"; public static final String HOST_NAME = "HostName"; public ZipArchive createZipFile(String owner, String deviceType, String deviceId, String deviceName, @@ -83,13 +82,13 @@ public class ZipUtil { try { iotServerIP = getServerUrl(); - String httpsServerPort = System.getProperty(HTTPS_PORT_PROPERTY); - String httpServerPort = System.getProperty(HTTP_PORT_PROPERTY); - String httpsServerEP = HTTPS_PROTOCOL_APPENDER + iotServerIP + ":" + httpsServerPort; - String httpServerEP = HTTP_PROTOCOL_APPENDER + iotServerIP + ":" + httpServerPort; - String mqttEndpoint = DEFAULT_MQTT_ENDPOINT; + String httpsServerEP = Utils.replaceSystemProperty(HTTPS_PROTOCOL_URL); + String httpServerEP = Utils.replaceSystemProperty(HTTP_PROTOCOL_URL); + String mqttEndpoint = Utils.replaceSystemProperty(DEFAULT_MQTT_ENDPOINT); if (mqttEndpoint.contains(LOCALHOST)) { mqttEndpoint = mqttEndpoint.replace(LOCALHOST, iotServerIP); + httpsServerEP = httpsServerEP.replace(LOCALHOST, iotServerIP); + httpServerEP = httpServerEP.replace(LOCALHOST, iotServerIP); } String xmppEndpoint = ""; @@ -161,16 +160,12 @@ public class ZipUtil { } public static String getServerUrl() { - String hostName = ServerConfiguration.getInstance().getFirstProperty(HOST_NAME); try { - if (hostName == null) { - hostName = NetworkUtils.getLocalHostname(); - } + return org.apache.axis2.util.Utils.getIpAddress(); } catch (SocketException e) { - hostName = "localhost"; log.warn("Failed retrieving the hostname, therefore set to localhost", e); + return "localhost"; } - return hostName; } public static ZipArchive getSketchArchive(String archivesPath, String templateSketchPath, Map contextParams diff --git a/components/device-types/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.type-view/private/config.json b/components/device-types/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.type-view/private/config.json index 5867d81e9..5252c8694 100644 --- a/components/device-types/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.type-view/private/config.json +++ b/components/device-types/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.type-view/private/config.json @@ -3,6 +3,9 @@ "label": "Virtual Firealarm", "category": "virtual", "downloadAgentUri": "virtual_firealarm/device/download", + "scopes" : [ + "perm:firealarm:enroll" + ], "features": { "buzz": { "icon" : "fw-dial-up" diff --git a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/resources/org/wso2/carbon/device/mgt/input/adapter/mqtt/i18n/Resources.properties b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/resources/org/wso2/carbon/device/mgt/input/adapter/mqtt/i18n/Resources.properties index a2d877419..38cfcf7c6 100644 --- a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/resources/org/wso2/carbon/device/mgt/input/adapter/mqtt/i18n/Resources.properties +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/resources/org/wso2/carbon/device/mgt/input/adapter/mqtt/i18n/Resources.properties @@ -31,7 +31,7 @@ dcrUrl=dcrUrl dcrUrl.hint=dynamic client registration endpoint URL to create application (if required) eg: https://localhost:9443/dynamic-client-web/register contentValidator=contentValidation contentValidator.hint=Class Name of the content Validation or 'default' to set default class, required to implement (if required) -url.hint=MQTT broker url tcp://localhost:1886 +url.hint=MQTT broker url tcp://localhost:1883 cleanSession=Clean Session cleanSession.hint=Persist topic subscriptions and ack positions across client sessions keepAlive=Keep Alive (In seconds) diff --git a/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/authorization/client/OAuthRequestInterceptor.java b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/authorization/client/OAuthRequestInterceptor.java index 8ab7db938..ffae0b797 100755 --- a/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/authorization/client/OAuthRequestInterceptor.java +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/authorization/client/OAuthRequestInterceptor.java @@ -45,6 +45,7 @@ public class OAuthRequestInterceptor implements RequestInterceptor { private static final String APPLICATION_NAME = "websocket-app"; private static final String PASSWORD_GRANT_TYPE = "password"; private static final String REFRESH_GRANT_TYPE = "refresh_token"; + private static final String REQUIRED_SCOPE = "perm:authorization:verify"; private ApiApplicationRegistrationService apiApplicationRegistrationService; private TokenIssuerService tokenIssuerService; @@ -76,7 +77,6 @@ public class OAuthRequestInterceptor implements RequestInterceptor { username = getUsername(globalProperties); password = getPassword(globalProperties); tokenEndpoint = getTokenEndpoint(globalProperties); - scopes = getScopes(globalProperties); apiApplicationRegistrationService = Feign.builder().requestInterceptor( new BasicAuthRequestInterceptor(username, password)) .contract(new JAXRSContract()).encoder(new GsonEncoder()).decoder(new GsonDecoder()) @@ -104,11 +104,7 @@ public class OAuthRequestInterceptor implements RequestInterceptor { new BasicAuthRequestInterceptor(consumerKey, consumerSecret)) .contract(new JAXRSContract()).encoder(new GsonEncoder()).decoder(new GsonDecoder()) .target(TokenIssuerService.class, tokenEndpoint); - if (scopes == null || scopes.isEmpty()) { - tokenInfo = tokenIssuerService.getToken(PASSWORD_GRANT_TYPE, username, password); - } else { - tokenInfo = tokenIssuerService.getToken(PASSWORD_GRANT_TYPE, username, password, scopes); - } + tokenInfo = tokenIssuerService.getToken(PASSWORD_GRANT_TYPE, username, password, REQUIRED_SCOPE); tokenInfo.setExpires_in(System.currentTimeMillis() + tokenInfo.getExpires_in()); } synchronized(this) { @@ -163,9 +159,4 @@ public class OAuthRequestInterceptor implements RequestInterceptor { return refreshTimeOffset; } - private String getScopes(Map globalProperties) { - return globalProperties.get(TOKEN_SCOPES); - } - - } diff --git a/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/authorization/client/dto/TokenIssuerService.java b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/authorization/client/dto/TokenIssuerService.java index 046184559..679d06883 100755 --- a/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/authorization/client/dto/TokenIssuerService.java +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/authorization/client/dto/TokenIssuerService.java @@ -27,6 +27,7 @@ package org.wso2.carbon.device.mgt.output.adapter.websocket.authorization.client.dto; import javax.ws.rs.Consumes; +import javax.ws.rs.FormParam; import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.Produces; @@ -48,7 +49,7 @@ public interface TokenIssuerService { @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_FORM_URLENCODED) AccessTokenInfo getToken(@QueryParam("grant_type") String grant, @QueryParam("username") String username, - @QueryParam("password") String password, @QueryParam("scopes") String scopes); + @QueryParam("password") String password, @QueryParam("scope") String scopes); @POST @Produces(MediaType.APPLICATION_JSON) diff --git a/components/extensions/mb-extensions/org.wso2.carbon.andes.extensions.device.mgt.mqtt.authorization/src/main/java/org/wso2/carbon/andes/extensions/device/mgt/mqtt/authorization/client/OAuthRequestInterceptor.java b/components/extensions/mb-extensions/org.wso2.carbon.andes.extensions.device.mgt.mqtt.authorization/src/main/java/org/wso2/carbon/andes/extensions/device/mgt/mqtt/authorization/client/OAuthRequestInterceptor.java index 9a29d0026..f6cbd1c30 100755 --- a/components/extensions/mb-extensions/org.wso2.carbon.andes.extensions.device.mgt.mqtt.authorization/src/main/java/org/wso2/carbon/andes/extensions/device/mgt/mqtt/authorization/client/OAuthRequestInterceptor.java +++ b/components/extensions/mb-extensions/org.wso2.carbon.andes.extensions.device.mgt.mqtt.authorization/src/main/java/org/wso2/carbon/andes/extensions/device/mgt/mqtt/authorization/client/OAuthRequestInterceptor.java @@ -18,6 +18,8 @@ import feign.Feign; import feign.RequestInterceptor; import feign.RequestTemplate; import feign.auth.BasicAuthRequestInterceptor; +import feign.codec.EncodeException; +import feign.codec.Encoder; import feign.gson.GsonDecoder; import feign.gson.GsonEncoder; import feign.jaxrs.JAXRSContract; @@ -76,7 +78,8 @@ public class OAuthRequestInterceptor implements RequestInterceptor { tokenIssuerService = Feign.builder().requestInterceptor( new BasicAuthRequestInterceptor(consumerKey, consumerSecret)) .contract(new JAXRSContract()).encoder(new GsonEncoder()).decoder(new GsonDecoder()) - .target(TokenIssuerService.class, AuthorizationConfigurationManager.getInstance().getTokenEndpoint()); + .target(TokenIssuerService.class, + AuthorizationConfigurationManager.getInstance().getTokenEndpoint()); tokenInfo = tokenIssuerService.getToken(PASSWORD_GRANT_TYPE, username, password, REQUIRED_SCOPE); tokenInfo.setExpires_in(System.currentTimeMillis() + tokenInfo.getExpires_in()); } @@ -90,5 +93,4 @@ public class OAuthRequestInterceptor implements RequestInterceptor { template.header("Authorization", headerValue); } - } diff --git a/components/extensions/mb-extensions/org.wso2.carbon.andes.extensions.device.mgt.mqtt.authorization/src/main/java/org/wso2/carbon/andes/extensions/device/mgt/mqtt/authorization/client/dto/TokenIssuerService.java b/components/extensions/mb-extensions/org.wso2.carbon.andes.extensions.device.mgt.mqtt.authorization/src/main/java/org/wso2/carbon/andes/extensions/device/mgt/mqtt/authorization/client/dto/TokenIssuerService.java index 5938587f3..7af04744a 100755 --- a/components/extensions/mb-extensions/org.wso2.carbon.andes.extensions.device.mgt.mqtt.authorization/src/main/java/org/wso2/carbon/andes/extensions/device/mgt/mqtt/authorization/client/dto/TokenIssuerService.java +++ b/components/extensions/mb-extensions/org.wso2.carbon.andes.extensions.device.mgt.mqtt.authorization/src/main/java/org/wso2/carbon/andes/extensions/device/mgt/mqtt/authorization/client/dto/TokenIssuerService.java @@ -37,7 +37,7 @@ public interface TokenIssuerService { @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_FORM_URLENCODED) AccessTokenInfo getToken(@QueryParam("grant_type") String grant, @QueryParam("username") String username, - @QueryParam("password") String password, @QueryParam("scopes") String scopes); + @QueryParam("password") String password, @QueryParam("scope") String scopes); @POST @Produces(MediaType.APPLICATION_JSON) 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/private/config.json 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/private/config.json index 230cb4a93..c7150900b 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/private/config.json +++ 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/private/config.json @@ -4,6 +4,9 @@ "category": "mobile", "analyticsEnabled": "false", "groupingEnabled": "false", + "scopes" : [ + "perm:android:enroll" + ], "features": { "DEVICE_RING": { "icon": "fw-dial-up", 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/private/config.json 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/private/config.json index 5d6857828..ed2bc42ca 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/private/config.json +++ 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/private/config.json @@ -2,6 +2,9 @@ "deviceType": { "label": "Windows", "category": "mobile", + "scopes" : [ + "perm:windows:enroll" + ], "analyticsEnabled": "false", "groupingEnabled": "false", "features": { From 429266d9d2677995e4152a7c4c9db9e077e38f08 Mon Sep 17 00:00:00 2001 From: Hasunie Date: Fri, 13 Jan 2017 09:07:33 +0530 Subject: [PATCH 06/21] adding windows synaps configs --- .../windows/api/common/PluginConstants.java | 1 + .../api/services/DeviceManagementService.java | 4 +- .../discovery/impl/DiscoveryServiceImpl.java | 6 +- .../enrollment/EnrollmentService.java | 4 +- .../admin--Windows_10_Device_management.xml | 56 ++++++ ...n--Windows_10_Device_management_v1.0.0.xml | 52 ++++++ .../admin--Windows_10_Enrollment_Service.xml | 56 ++++++ ...--Windows_10_Enrollment_Service_v1.0.0.xml | 44 +++++ ...-Windows_8.1_Device_Management_Service.xml | 54 ++++++ ...s_8.1_Device_Management_Service_v1.0.0.xml | 42 +++++ .../admin--Windows_8.1_Enrollment_Service.xml | 54 ++++++ ...-Windows_8.1_Enrollment_Service_v1.0.0.xml | 42 +++++ ...-Windows_Binary_Security_Token_Service.xml | 54 ++++++ ...s_Binary_Security_Token_Service_v1.0.0.xml | 42 +++++ ...dmin--Windows_Configuration_Management.xml | 54 ++++++ ...indows_Configuration_Management_v1.0.0.xml | 64 +++++++ ...vice_Management_Administrative_Service.xml | 54 ++++++ ...nagement_Administrative_Service_v1.0.0.xml | 174 ++++++++++++++++++ .../apis/admin--Windows_Discovery_Service.xml | 56 ++++++ ...dmin--Windows_Discovery_Service_v1.0.0.xml | 44 +++++ ...min--Windows_Enrollment_policy_Service.xml | 56 ++++++ ...ndows_Enrollment_policy_Service_v1.0.0.xml | 44 +++++ .../main/resources/devicetypes/windows.xml | 7 + .../src/main/resources/p2.inf | 13 +- 24 files changed, 1068 insertions(+), 9 deletions(-) create mode 100644 features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/apis/admin--Windows_10_Device_management.xml create mode 100644 features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/apis/admin--Windows_10_Device_management_v1.0.0.xml create mode 100644 features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/apis/admin--Windows_10_Enrollment_Service.xml create mode 100644 features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/apis/admin--Windows_10_Enrollment_Service_v1.0.0.xml create mode 100644 features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/apis/admin--Windows_8.1_Device_Management_Service.xml create mode 100644 features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/apis/admin--Windows_8.1_Device_Management_Service_v1.0.0.xml create mode 100644 features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/apis/admin--Windows_8.1_Enrollment_Service.xml create mode 100644 features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/apis/admin--Windows_8.1_Enrollment_Service_v1.0.0.xml create mode 100644 features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/apis/admin--Windows_Binary_Security_Token_Service.xml create mode 100644 features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/apis/admin--Windows_Binary_Security_Token_Service_v1.0.0.xml create mode 100644 features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/apis/admin--Windows_Configuration_Management.xml create mode 100644 features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/apis/admin--Windows_Configuration_Management_v1.0.0.xml create mode 100644 features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/apis/admin--Windows_Device_Management_Administrative_Service.xml create mode 100644 features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/apis/admin--Windows_Device_Management_Administrative_Service_v1.0.0.xml create mode 100644 features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/apis/admin--Windows_Discovery_Service.xml create mode 100644 features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/apis/admin--Windows_Discovery_Service_v1.0.0.xml create mode 100644 features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/apis/admin--Windows_Enrollment_policy_Service.xml create mode 100644 features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/apis/admin--Windows_Enrollment_policy_Service_v1.0.0.xml diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/common/PluginConstants.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/common/PluginConstants.java index 27a7b479e..bebdafe00 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/common/PluginConstants.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/common/PluginConstants.java @@ -342,6 +342,7 @@ public final class PluginConstants { } public static final String REQUESTED_WIN10_VERSION = "3.0"; public static final String REQUESTED_WIN81_VERSION = "2.0"; + public static final String OS_VERSION = "10"; } /** diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/DeviceManagementService.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/DeviceManagementService.java index 06ff00717..081158f30 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/DeviceManagementService.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/DeviceManagementService.java @@ -54,8 +54,8 @@ import javax.ws.rs.core.Response; @Tag(name = "windows", description = "") } ) -@Api(value = "Windows 10 Device management", - description = "This carries all the resources related to Windows 10 management session message flow.") +//@Api(value = "Windows 10 Device management", +// description = "This carries all the resources related to Windows 10 management session message flow.") @Path("/devicemgt") public interface DeviceManagementService { @Path("/pending-operations") diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/discovery/impl/DiscoveryServiceImpl.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/discovery/impl/DiscoveryServiceImpl.java index 08e69af07..da50c09c9 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/discovery/impl/DiscoveryServiceImpl.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/discovery/impl/DiscoveryServiceImpl.java @@ -68,9 +68,11 @@ public class DiscoveryServiceImpl implements DiscoveryService { String emailId = discoveryRequest.getEmailId(); String[] userDomains = emailId.split(DELIMITER); String domain = userDomains[DOMAIN_SEGMENT]; + String osVersion = discoveryRequest.getOsEdition(); + String[] osVersions = osVersion .split("."); + String os = osVersions[0]; DiscoveryResponse discoveryResponse; - if (PluginConstants.WindowsVersionProperties.REQUESTED_WIN10_VERSION.equals(discoveryRequest.getVersion()) && - FEDERATED.equals(getAuthPolicy())) { + if (PluginConstants.WindowsVersionProperties.OS_VERSION.equals(os) && FEDERATED.equals(getAuthPolicy())) { discoveryResponse = new DiscoveryResponse(); discoveryResponse.setAuthPolicy(FEDERATED); diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/enrollment/EnrollmentService.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/enrollment/EnrollmentService.java index 42af80541..2d2586c86 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/enrollment/EnrollmentService.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/enrollment/EnrollmentService.java @@ -51,8 +51,8 @@ import java.io.UnsupportedEncodingException; @Tag(name = "windows", description = "") } ) -@Api(value = "Windows 10 Enrollment Service", - description = "This carries all the resources related to Windows enrollment.") +//@Api(value = "Windows 10 Enrollment Service", +// description = "This carries all the resources related to Windows enrollment.") @WebService(targetNamespace = PluginConstants.DEVICE_ENROLLMENT_SERVICE_TARGET_NAMESPACE, name = "enrollment") @BindingType(value = SOAPBinding.SOAP12HTTP_BINDING) diff --git a/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/apis/admin--Windows_10_Device_management.xml b/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/apis/admin--Windows_10_Device_management.xml new file mode 100644 index 000000000..84586a896 --- /dev/null +++ b/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/apis/admin--Windows_10_Device_management.xml @@ -0,0 +1,56 @@ + + + + + + + + + + + + + 500 + Status report + Internal Server Error + Faulty invoking through default API + + + + + + +
+ + + + + + + + +
+ + + + + + 60000 + fault + + + + + + + + + + + + + + + + + diff --git a/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/apis/admin--Windows_10_Device_management_v1.0.0.xml b/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/apis/admin--Windows_10_Device_management_v1.0.0.xml new file mode 100644 index 000000000..2081ae6ef --- /dev/null +++ b/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/apis/admin--Windows_10_Device_management_v1.0.0.xml @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/apis/admin--Windows_10_Enrollment_Service.xml b/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/apis/admin--Windows_10_Enrollment_Service.xml new file mode 100644 index 000000000..e901919e3 --- /dev/null +++ b/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/apis/admin--Windows_10_Enrollment_Service.xml @@ -0,0 +1,56 @@ + + + + + + + + + + + + + 500 + Status report + Internal Server Error + Faulty invoking through default API + + + + + + +
+ + + + + + + + +
+ + + + + + 60000 + fault + + + + + + + + + + + + + + + + + diff --git a/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/apis/admin--Windows_10_Enrollment_Service_v1.0.0.xml b/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/apis/admin--Windows_10_Enrollment_Service_v1.0.0.xml new file mode 100644 index 000000000..ced6d1129 --- /dev/null +++ b/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/apis/admin--Windows_10_Enrollment_Service_v1.0.0.xml @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/apis/admin--Windows_8.1_Device_Management_Service.xml b/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/apis/admin--Windows_8.1_Device_Management_Service.xml new file mode 100644 index 000000000..e8756d3bd --- /dev/null +++ b/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/apis/admin--Windows_8.1_Device_Management_Service.xml @@ -0,0 +1,54 @@ + + + + + + + + + + + + + 500 + Status report + Internal Server Error + Faulty invoking through default API + + + + + + +
+ + + + + + + + +
+ + + + + + 60000 + fault + + + + + + + + + + + + + + + diff --git a/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/apis/admin--Windows_8.1_Device_Management_Service_v1.0.0.xml b/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/apis/admin--Windows_8.1_Device_Management_Service_v1.0.0.xml new file mode 100644 index 000000000..771f35509 --- /dev/null +++ b/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/apis/admin--Windows_8.1_Device_Management_Service_v1.0.0.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/apis/admin--Windows_8.1_Enrollment_Service.xml b/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/apis/admin--Windows_8.1_Enrollment_Service.xml new file mode 100644 index 000000000..57c18f375 --- /dev/null +++ b/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/apis/admin--Windows_8.1_Enrollment_Service.xml @@ -0,0 +1,54 @@ + + + + + + + + + + + + + 500 + Status report + Internal Server Error + Faulty invoking through default API + + + + + + +
+ + + + + + + + +
+ + + + + + 60000 + fault + + + + + + + + + + + + + + + diff --git a/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/apis/admin--Windows_8.1_Enrollment_Service_v1.0.0.xml b/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/apis/admin--Windows_8.1_Enrollment_Service_v1.0.0.xml new file mode 100644 index 000000000..2be45de64 --- /dev/null +++ b/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/apis/admin--Windows_8.1_Enrollment_Service_v1.0.0.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/apis/admin--Windows_Binary_Security_Token_Service.xml b/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/apis/admin--Windows_Binary_Security_Token_Service.xml new file mode 100644 index 000000000..640df9ea0 --- /dev/null +++ b/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/apis/admin--Windows_Binary_Security_Token_Service.xml @@ -0,0 +1,54 @@ + + + + + + + + + + + + + 500 + Status report + Internal Server Error + Faulty invoking through default API + + + + + + +
+ + + + + + + + +
+ + + + + + 60000 + fault + + + + + + + + + + + + + + + diff --git a/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/apis/admin--Windows_Binary_Security_Token_Service_v1.0.0.xml b/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/apis/admin--Windows_Binary_Security_Token_Service_v1.0.0.xml new file mode 100644 index 000000000..830055ddf --- /dev/null +++ b/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/apis/admin--Windows_Binary_Security_Token_Service_v1.0.0.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/apis/admin--Windows_Configuration_Management.xml b/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/apis/admin--Windows_Configuration_Management.xml new file mode 100644 index 000000000..ecabcf446 --- /dev/null +++ b/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/apis/admin--Windows_Configuration_Management.xml @@ -0,0 +1,54 @@ + + + + + + + + + + + + + 500 + Status report + Internal Server Error + Faulty invoking through default API + + + + + + +
+ + + + + + + + +
+ + + + + + 60000 + fault + + + + + + + + + + + + + + + diff --git a/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/apis/admin--Windows_Configuration_Management_v1.0.0.xml b/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/apis/admin--Windows_Configuration_Management_v1.0.0.xml new file mode 100644 index 000000000..2f5edcf76 --- /dev/null +++ b/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/apis/admin--Windows_Configuration_Management_v1.0.0.xml @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/apis/admin--Windows_Device_Management_Administrative_Service.xml b/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/apis/admin--Windows_Device_Management_Administrative_Service.xml new file mode 100644 index 000000000..93a2834aa --- /dev/null +++ b/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/apis/admin--Windows_Device_Management_Administrative_Service.xml @@ -0,0 +1,54 @@ + + + + + + + + + + + + + 500 + Status report + Internal Server Error + Faulty invoking through default API + + + + + + +
+ + + + + + + + +
+ + + + + + 60000 + fault + + + + + + + + + + + + + + + diff --git a/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/apis/admin--Windows_Device_Management_Administrative_Service_v1.0.0.xml b/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/apis/admin--Windows_Device_Management_Administrative_Service_v1.0.0.xml new file mode 100644 index 000000000..73e001e5c --- /dev/null +++ b/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/apis/admin--Windows_Device_Management_Administrative_Service_v1.0.0.xml @@ -0,0 +1,174 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/apis/admin--Windows_Discovery_Service.xml b/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/apis/admin--Windows_Discovery_Service.xml new file mode 100644 index 000000000..63b9966e2 --- /dev/null +++ b/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/apis/admin--Windows_Discovery_Service.xml @@ -0,0 +1,56 @@ + + + + + + + + + + + + + 500 + Status report + Internal Server Error + Faulty invoking through default API + + + + + + +
+ + + + + + + + +
+ + + + + + 60000 + fault + + + + + + + + + + + + + + + + + diff --git a/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/apis/admin--Windows_Discovery_Service_v1.0.0.xml b/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/apis/admin--Windows_Discovery_Service_v1.0.0.xml new file mode 100644 index 000000000..7bab00a0f --- /dev/null +++ b/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/apis/admin--Windows_Discovery_Service_v1.0.0.xml @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/apis/admin--Windows_Enrollment_policy_Service.xml b/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/apis/admin--Windows_Enrollment_policy_Service.xml new file mode 100644 index 000000000..9e2e438d6 --- /dev/null +++ b/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/apis/admin--Windows_Enrollment_policy_Service.xml @@ -0,0 +1,56 @@ + + + + + + + + + + + + + 500 + Status report + Internal Server Error + Faulty invoking through default API + + + + + + +
+ + + + + + + + +
+ + + + + + 60000 + fault + + + + + + + + + + + + + + + + + diff --git a/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/apis/admin--Windows_Enrollment_policy_Service_v1.0.0.xml b/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/apis/admin--Windows_Enrollment_policy_Service_v1.0.0.xml new file mode 100644 index 000000000..4b6e550a6 --- /dev/null +++ b/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/apis/admin--Windows_Enrollment_policy_Service_v1.0.0.xml @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/devicetypes/windows.xml b/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/devicetypes/windows.xml index 517a9fe0b..a20e4ec38 100644 --- a/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/devicetypes/windows.xml +++ b/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/devicetypes/windows.xml @@ -120,6 +120,13 @@ type="application/json"> + + Reboot + Reboot the device + + + Device info Request device information diff --git a/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/p2.inf b/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/p2.inf index 2888d1ef1..e284e15ab 100644 --- a/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/p2.inf +++ b/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/p2.inf @@ -7,7 +7,15 @@ org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../data org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.windows_${feature.version}/database/,target:${installFolder}/../../database/,overwrite:true);\ org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/devicetypes/);\ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.windows_${feature.version}/devicetypes/,target:${installFolder}/../../deployment/server/devicetypes/,overwrite:true);\ - +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.windows_${feature.version}/apis/admin--Windows_Discovery_Service.xml,target:${installFolder}/../../deployment/server/synapse-configs/default/api/admin--Windows_Discovery_Service.xml,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.windows_${feature.version}/apis/admin--Windows_Discovery_Service_v1.0.0.xml,target:${installFolder}/../../deployment/server/synapse-configs/default/api/admin--Windows_Discovery_Service_v1.0.0.xml,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.windows_${feature.version}/apis/admin--Windows_Enrollment_policy_Service.xml,target:${installFolder}/../../deployment/server/synapse-configs/default/api/admin--Windows_Enrollment_policy_Service.xml,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.windows_${feature.version}/apis/admin--Windows_Enrollment_policy_Service_v1.0.0.xml,target:${installFolder}/../../deployment/server/synapse-configs/default/api/admin--Windows_Enrollment_policy_Service_v1.0.0.xml,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.windows_${feature.version}/apis/admin--Windows_10_Enrollment_Service.xml,target:${installFolder}/../../deployment/server/synapse-configs/default/api/admin--Windows_10_Enrollment_Service.xml,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.windows_${feature.version}/apis/admin--Windows_10_Enrollment_Service_v1.0.0.xml,target:${installFolder}/../../deployment/server/synapse-configs/default/api/admin--Windows_10_Enrollment_Service_v1.0.0.xml,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.windows_${feature.version}/apis/admin--Windows_10_Device_management.xml,target:${installFolder}/../../deployment/server/synapse-configs/default/api/admin--Windows_10_Device_management.xml,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.windows_${feature.version}/apis/admin--Windows_10_Device_management_v1.0.0.xml,target:${installFolder}/../../deployment/server/synapse-configs/default/api/admin--Windows_10_Device_management_v1.0.0.xml,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.windows_${feature.version}/apis/admin--Windows_10_Device_management.xml,target:${installFolder}/../../deployment/server/synapse-configs/default/api/admin--Windows_10_Device_management.xml,overwrite:true);\ instructions.unconfigure = \ org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/webapps/api#device-mgt#windows#v1.0.war);\ @@ -27,5 +35,4 @@ org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../dep org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.date-range-picker);\ org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../../dbscripts/cdm/plugins/windows);\ org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../database/WSO2MobileWindows_DB.h2.db);\ -org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../. -./deployment/server/devicetypes/windows.xml);\ \ No newline at end of file +org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/devicetypes/windows.xml);\ \ No newline at end of file From 8655da595e85aefcaf5b9ddd2230943ca535b47b Mon Sep 17 00:00:00 2001 From: Hasunie Date: Fri, 13 Jan 2017 16:05:10 +0530 Subject: [PATCH 07/21] removing swagger definition from the soap endpoints --- .../api/services/DeviceManagementService.java | 41 ++++++++----------- .../services/discovery/DiscoveryService.java | 19 +-------- .../discovery/beans/DiscoveryRequest.java | 11 ++++- .../enrollment/EnrollmentService.java | 19 --------- .../api/services/syncml/SyncmlService.java | 19 +-------- .../CertificateEnrollmentPolicyService.java | 18 -------- 6 files changed, 28 insertions(+), 99 deletions(-) diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/DeviceManagementService.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/DeviceManagementService.java index 081158f30..602403cd6 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/DeviceManagementService.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/DeviceManagementService.java @@ -21,11 +21,14 @@ package org.wso2.carbon.device.mgt.mobile.windows.api.services; import io.swagger.annotations.*; import org.w3c.dom.Document; +import org.wso2.carbon.apimgt.annotations.api.Scope; +import org.wso2.carbon.apimgt.annotations.api.Scopes; import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagementException; import org.wso2.carbon.device.mgt.mobile.windows.api.common.PluginConstants; import org.wso2.carbon.device.mgt.mobile.windows.api.common.exceptions.WindowsConfigurationException; import org.wso2.carbon.device.mgt.mobile.windows.api.common.exceptions.WindowsDeviceEnrolmentException; import org.wso2.carbon.device.mgt.mobile.windows.api.operations.WindowsOperationException; +import org.wso2.carbon.device.mgt.mobile.windows.api.operations.util.Constants; import javax.ws.rs.Consumes; import javax.ws.rs.POST; @@ -38,25 +41,17 @@ import javax.ws.rs.core.Response; /** * Interface for Windows 10 Device management phase. */ -@SwaggerDefinition( - info = @Info( - version = "1.0.0", - title = "", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = "name", value = "Windows 10 Device management"), - @ExtensionProperty(name = "context", - value = "/api/device-mgt/windows/v1.0/management/devicemgt"), - }) - } - ), - tags = { - @Tag(name = "windows", description = "") +@Path("/devicemgt") +@Scopes( + scopes = { + @Scope( + name = "Pending operations", + description = "Register an Android device", + key = "perm:windows:enroll", + permissions = {"/device-mgt/devices/enroll/windows"} + ) } ) -//@Api(value = "Windows 10 Device management", -// description = "This carries all the resources related to Windows 10 management session message flow.") -@Path("/devicemgt") public interface DeviceManagementService { @Path("/pending-operations") @POST @@ -68,14 +63,10 @@ public interface DeviceManagementService { notes = "Using this API to fetching more information to enroll the Device and " + "getting pending operations.", tags = "Windows Device Management Administrative Service", - authorizations = { - @Authorization( - value = "permission", - scopes = {@AuthorizationScope( - scope = "/device-mgt/devices/enroll/windows", - description = "Getting pending operations and " + - "device information to enroll the device")} - ) + extensions = { + @Extension(properties = { + @ExtensionProperty(name = Constants.SCOPE, value = "perm:android:enroll") + }) } ) @ApiResponses(value = { diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/discovery/DiscoveryService.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/discovery/DiscoveryService.java index db9a8125d..2b856cb85 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/discovery/DiscoveryService.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/discovery/DiscoveryService.java @@ -42,24 +42,7 @@ import javax.xml.ws.soap.SOAPBinding; /** * Interface for Discovery service related operations. */ -@SwaggerDefinition( - info = @Info( - version = "1.0.0", - title = "", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = "name", value = "Windows Discovery Service"), - @ExtensionProperty(name = "context", - value = "/api/device-mgt/windows/v1.0/discovery/post"), - }) - } - ), - tags = { - @Tag(name = "windows", description = "") - } -) -@Api(value = "Windows Discovery Service", - description = "This carries all the resources related to Windows Discovery service.") + @WebService(targetNamespace = PluginConstants.DISCOVERY_SERVICE_TARGET_NAMESPACE, name = "IDiscoveryService") @BindingType(value = SOAPBinding.SOAP12HTTP_BINDING) diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/discovery/beans/DiscoveryRequest.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/discovery/beans/DiscoveryRequest.java index 2c8260fb9..d6e3a185e 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/discovery/beans/DiscoveryRequest.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/discovery/beans/DiscoveryRequest.java @@ -86,4 +86,13 @@ public class DiscoveryRequest implements Serializable { this.osEdition = osEdition; } -} \ No newline at end of file + public String getApplicationVersion() { + return applicationVersion; + } + + public void setApplicationVersion(String applicationVersion) { + this.applicationVersion = applicationVersion; + } + + +} diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/enrollment/EnrollmentService.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/enrollment/EnrollmentService.java index 2d2586c86..cb3e38091 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/enrollment/EnrollmentService.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/enrollment/EnrollmentService.java @@ -35,25 +35,6 @@ import javax.xml.ws.ResponseWrapper; import javax.xml.ws.soap.SOAPBinding; import java.io.UnsupportedEncodingException; -@SwaggerDefinition( - info = @Info( - version = "1.0.0", - title = "", - extensions = { - @io.swagger.annotations.Extension(properties = { - @ExtensionProperty(name = "name", value = "Windows 10 Enrollment Service"), - @ExtensionProperty(name = "context", - value = "/api/device-mgt/windows/v1.0/deviceenrolment/enrollment"), - }) - } - ), - tags = { - @Tag(name = "windows", description = "") - } -) -//@Api(value = "Windows 10 Enrollment Service", -// description = "This carries all the resources related to Windows enrollment.") - @WebService(targetNamespace = PluginConstants.DEVICE_ENROLLMENT_SERVICE_TARGET_NAMESPACE, name = "enrollment") @BindingType(value = SOAPBinding.SOAP12HTTP_BINDING) public interface EnrollmentService { diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/syncml/SyncmlService.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/syncml/SyncmlService.java index 7ba8c570b..d165763ae 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/syncml/SyncmlService.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/syncml/SyncmlService.java @@ -37,24 +37,7 @@ import javax.ws.rs.core.Response; /** * Interface for Windows 8.1 enrollment flow. */ -@SwaggerDefinition( - info = @Info( - version = "1.0.0", - title = "", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = "name", value = "Windows 8.1 Device Management Service"), - @ExtensionProperty(name = "context", - value = "/api/device-mgt/windows/v1.0/syncml"), - }) - } - ), - tags = { - @Tag(name = "windows", description = "") - } -) -@Api(value = "Windows 8.1 Device Management Service", - description = "This carries all the resources related to Windows syncml message flow.") + @Path("/devicemanagement") public interface SyncmlService { diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/xcep/CertificateEnrollmentPolicyService.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/xcep/CertificateEnrollmentPolicyService.java index 0934824c9..91cb4de1c 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/xcep/CertificateEnrollmentPolicyService.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/xcep/CertificateEnrollmentPolicyService.java @@ -41,24 +41,6 @@ import javax.xml.ws.soap.SOAPBinding; * Interface for MS-XCEP implementation. */ -@SwaggerDefinition( - info = @Info( - version = "1.0.0", - title = "", - extensions = { - @io.swagger.annotations.Extension(properties = { - @ExtensionProperty(name = "name", value = "Windows Enrollment policy Service"), - @ExtensionProperty(name = "context", - value = "/api/device-mgt/windows/v1.0/certificatepolicy/xcep"), - }) - } - ), - tags = { - @Tag(name = "windows", description = "") - } -) -@Api(value = "Windows Enrollment policy Service", - description = "This carries all the resources related to Windows enrollment policy.") @WebService(targetNamespace = PluginConstants.CERTIFICATE_ENROLLMENT_POLICY_SERVICE_TARGET_NAMESPACE, name = "IPolicy") @BindingType(value = SOAPBinding.SOAP12HTTP_BINDING) From 4c4fd0059342ca31b08a2ead2bdd23256b5dde53 Mon Sep 17 00:00:00 2001 From: Hasunie Date: Fri, 13 Jan 2017 16:06:31 +0530 Subject: [PATCH 08/21] fixing issue in different type of windows device payloads --- .../api/services/discovery/impl/DiscoveryServiceImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/discovery/impl/DiscoveryServiceImpl.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/discovery/impl/DiscoveryServiceImpl.java index da50c09c9..2ba4c9abc 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/discovery/impl/DiscoveryServiceImpl.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/discovery/impl/DiscoveryServiceImpl.java @@ -68,8 +68,8 @@ public class DiscoveryServiceImpl implements DiscoveryService { String emailId = discoveryRequest.getEmailId(); String[] userDomains = emailId.split(DELIMITER); String domain = userDomains[DOMAIN_SEGMENT]; - String osVersion = discoveryRequest.getOsEdition(); - String[] osVersions = osVersion .split("."); + String applicationVersion = discoveryRequest.getApplicationVersion(); + String[] osVersions = applicationVersion .split("\\."); String os = osVersions[0]; DiscoveryResponse discoveryResponse; if (PluginConstants.WindowsVersionProperties.OS_VERSION.equals(os) && FEDERATED.equals(getAuthPolicy())) { From a2ae12f9d18349a7ee0951fea3f1ab398e0a5245 Mon Sep 17 00:00:00 2001 From: Hasunie Date: Fri, 13 Jan 2017 16:08:58 +0530 Subject: [PATCH 09/21] adding windows 10 updates 1607/1511 changes --- .../impl/DeviceManagementServiceImpl.java | 19 +++++++++++++------ .../wstep/CertificateEnrollmentService.java | 19 +------------------ 2 files changed, 14 insertions(+), 24 deletions(-) diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/impl/DeviceManagementServiceImpl.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/impl/DeviceManagementServiceImpl.java index f754ff80c..38dfde51d 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/impl/DeviceManagementServiceImpl.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/impl/DeviceManagementServiceImpl.java @@ -89,7 +89,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { if (modifyEnrollWithMoreDetail(request)) { pendingOperations = operationHandler.getPendingOperations(syncmlDocument); - response = operationReply.generateReply(syncmlDocument,pendingOperations); + response = operationReply.generateReply(syncmlDocument, pendingOperations); return Response.status(Response.Status.OK).entity(response).build(); } else { String msg = "Error occurred in while modify the enrollment."; @@ -101,7 +101,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { log.error(msg); return Response.status(Response.Status.UNAUTHORIZED).entity(msg).build(); } - } else { + } else { if ((syncmlDocument.getBody().getAlert() != null)) { if (!syncmlDocument.getBody().getAlert().getData().equals(Constants.DISENROLL_ALERT_DATA)) { pendingOperations = operationHandler.getPendingOperations(syncmlDocument); @@ -155,8 +155,8 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { private boolean modifyEnrollWithMoreDetail(Document request) throws WindowsDeviceEnrolmentException, WindowsOperationException { - String devMan; - String devMod; + String devMan = null; + String devMod = null; boolean status = false; String user; SyncmlDocument syncmlDocument; @@ -165,8 +165,15 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { syncmlDocument = SyncmlParser.parseSyncmlPayload(request); ReplaceTag replace = syncmlDocument.getBody().getReplace(); List itemList = replace.getItems(); - devMan = itemList.get(PluginConstants.SyncML.DEVICE_MAN_POSITION).getData(); - devMod = itemList.get(PluginConstants.SyncML.DEVICE_MODEL_POSITION).getData(); + for (ItemTag itemTag : itemList) { + String locURI = itemTag.getSource().getLocURI(); + if (OperationCode.Info.MANUFACTURER.getCode().equals(locURI)) { + devMan = itemTag.getData(); + } + if (OperationCode.Info.DEVICE_MODEL.getCode().equals(locURI)) { + devMod = itemTag.getData(); + } + } user = syncmlDocument.getHeader().getSource().getLocName(); AuthenticationInfo authenticationInfo = new AuthenticationInfo(); authenticationInfo.setUsername(user); diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/wstep/CertificateEnrollmentService.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/wstep/CertificateEnrollmentService.java index eb6f7001a..1b29298b3 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/wstep/CertificateEnrollmentService.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/wstep/CertificateEnrollmentService.java @@ -41,24 +41,7 @@ import java.io.UnsupportedEncodingException; /** * Interface of WSTEP implementation. */ -@SwaggerDefinition( - info = @Info( - version = "1.0.0", - title = "", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = "name", value = "Windows 8.1 Enrollment Service"), - @ExtensionProperty(name = "context", - value = "/api/device-mgt/windows/v1.0/deviceenrolment/wstep"), - }) - } - ), - tags = { - @Tag(name = "windows", description = "") - } -) -@Api(value = "Windows Enrollment service Management", - description = "This carries all the resources related to Windows enrollment service.") + @WebService(targetNamespace = PluginConstants.DEVICE_ENROLLMENT_SERVICE_TARGET_NAMESPACE, name = "wstep") @BindingType(value = SOAPBinding.SOAP12HTTP_BINDING) public interface CertificateEnrollmentService { From 97705311b9b1458cd2994a95e0169b230fa30405 Mon Sep 17 00:00:00 2001 From: Hasunie Date: Fri, 13 Jan 2017 16:09:45 +0530 Subject: [PATCH 10/21] removing install app tab from the device view --- .../cdmf.unit.device.type.windows.device-view/device-view.hbs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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.device-view/device-view.hbs 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.device-view/device-view.hbs index cb00b423a..18345645a 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.device-view/device-view.hbs +++ 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.device-view/device-view.hbs @@ -140,12 +140,12 @@ class="hidden-sm">Device Location -