+ *
+ *
+ */
+@XmlRootElement(name = "InitialOperationConfig")
+public class InitialOperationConfig {
+
+ private List operations;
+
+ @XmlElementWrapper(name = "Operations", required = true)
+ @XmlElement(name = "Operation", required = true)
+ public List getOperations() {
+ return operations;
+ }
+
+ public void setOperationsll(List operations) {
+ this.operations = operations;
+ }
+}
diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/DeviceTypeManager.java b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/DeviceTypeManager.java
index eba2f18721..98c5ef2870 100644
--- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/DeviceTypeManager.java
+++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/DeviceTypeManager.java
@@ -65,6 +65,7 @@ public class DeviceTypeManager implements DeviceManager {
private LicenseManager licenseManager;
private boolean propertiesExist;
private boolean requiredDeviceTypeAuthorization;
+ private boolean claimable;
private FeatureManager featureManager;
@@ -101,8 +102,13 @@ public class DeviceTypeManager implements DeviceManager {
String msg = "Error occurred while adding default license for " + deviceType + " devices";
throw new DeviceTypeDeployerFileException(msg, e);
}
+ claimable = false;
+ if (deviceTypeConfiguration.getClaimable() != null ) {
+ claimable = deviceTypeConfiguration.getClaimable().isEnabled();
+ }
DeviceDetails deviceDetails = deviceTypeConfiguration.getDeviceDetails();
+
if (deviceDetails != null) {
//Check whether device dao definition exist.
@@ -341,7 +347,7 @@ public class DeviceTypeManager implements DeviceManager {
@Override
public boolean isClaimable(DeviceIdentifier deviceIdentifier) throws DeviceManagementException {
- return false;
+ return claimable;
}
@Override
diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/DeviceTypeManagerService.java b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/DeviceTypeManagerService.java
index c7720093a6..64398d3715 100644
--- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/DeviceTypeManagerService.java
+++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/DeviceTypeManagerService.java
@@ -20,11 +20,7 @@ package org.wso2.carbon.device.mgt.extensions.device.type.deployer.template;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.device.mgt.common.DeviceManagementException;
-import org.wso2.carbon.device.mgt.common.DeviceManager;
-import org.wso2.carbon.device.mgt.common.MonitoringOperation;
-import org.wso2.carbon.device.mgt.common.OperationMonitoringTaskConfig;
-import org.wso2.carbon.device.mgt.common.ProvisioningConfig;
+import org.wso2.carbon.device.mgt.common.*;
import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManager;
import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationEntry;
import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration;
@@ -57,6 +53,8 @@ public class DeviceTypeManagerService implements DeviceManagementService {
private OperationMonitoringTaskConfig operationMonitoringConfigs;
private List monitoringOperations;
private PolicyMonitoringManager policyMonitoringManager;
+ private InitialOperationConfig initialOperationConfig;
+ private List operations;
public DeviceTypeManagerService(DeviceTypeConfigIdentifier deviceTypeConfigIdentifier,
DeviceTypeConfiguration deviceTypeConfiguration) {
@@ -66,6 +64,7 @@ public class DeviceTypeManagerService implements DeviceManagementService {
this.populatePushNotificationConfig(deviceTypeConfiguration.getPushNotificationProvider());
this.operationMonitoringConfigs = new OperationMonitoringTaskConfig();
this.setOperationMonitoringConfig(deviceTypeConfiguration);
+ this.setInitialOperationConfig(deviceTypeConfiguration);
if (deviceTypeConfiguration.getPolicyMonitoring() != null && deviceTypeConfiguration.getPolicyMonitoring()
.isEnabled()) {
this.policyMonitoringManager = new DefaultPolicyMonitoringManager();
@@ -157,6 +156,11 @@ public class DeviceTypeManagerService implements DeviceManagementService {
return policyMonitoringManager;
}
+ @Override
+ public InitialOperationConfig getInitialOperationConfig() {
+ return initialOperationConfig;
+ }
+
private void setProvisioningConfig(String tenantDomain, DeviceTypeConfiguration deviceTypeConfiguration) {
if (deviceTypeConfiguration.getProvisioningConfig() != null) {
boolean sharedWithAllTenants = deviceTypeConfiguration.getProvisioningConfig().isSharedWithAllTenants();
@@ -166,6 +170,15 @@ public class DeviceTypeManagerService implements DeviceManagementService {
}
}
+ protected void setInitialOperationConfig(DeviceTypeConfiguration deviceTypeConfiguration) {
+ if (deviceTypeConfiguration.getOperations() != null) {
+ List ops = deviceTypeConfiguration.getOperations();
+ if (ops != null && !ops.isEmpty()) {
+ initialOperationConfig.setOperations(ops);
+ }
+ }
+ }
+
private void setType(String type) {
this.type = type;
}
diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/test/resources/sample.xml b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/test/resources/sample.xml
index aa18e5d03b..414bcaa8dd 100644
--- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/test/resources/sample.xml
+++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/test/resources/sample.xml
@@ -36,10 +36,12 @@
-
+
false
diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm/pom.xml b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm/pom.xml
similarity index 94%
rename from components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm/pom.xml
rename to components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm/pom.xml
index 014435e721..10f89f5d1b 100644
--- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm/pom.xml
+++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm/pom.xml
@@ -22,15 +22,15 @@
device-mgt-extensionsorg.wso2.carbon.devicemgt
- 2.0.18-SNAPSHOT
+ 2.0.37-SNAPSHOT../pom.xml4.0.0
- org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm
+ org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcmbundle
- WSO2 Carbon - GCM Based Push Notification Provider Implementation
- WSO2 Carbon - GCM Based Push Notification Provider Implementation
+ WSO2 Carbon - FCM Based Push Notification Provider Implementation
+ WSO2 Carbon - FCM Based Push Notification Provider Implementationhttp://wso2.org
@@ -128,10 +128,10 @@
${project.artifactId}${project.artifactId}${carbon.device.mgt.version}
- GCM Based Push Notification Provider Bundle
+ FCM Based Push Notification Provider Bundle
- !org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm.internal,
- org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm.*
+ !org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm.internal,
+ org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm.*
com.google.gson,
diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/gcm/GCMBasedPushNotificationProvider.java b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/fcm/FCMBasedPushNotificationProvider.java
similarity index 84%
rename from components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/gcm/GCMBasedPushNotificationProvider.java
rename to components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/fcm/FCMBasedPushNotificationProvider.java
index 5168e25e25..30affceb27 100644
--- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/gcm/GCMBasedPushNotificationProvider.java
+++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/fcm/FCMBasedPushNotificationProvider.java
@@ -16,24 +16,24 @@
* under the License.
*
*/
-package org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm;
+package org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm;
import org.wso2.carbon.device.mgt.common.push.notification.NotificationStrategy;
import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationConfig;
import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationProvider;
-public class GCMBasedPushNotificationProvider implements PushNotificationProvider {
+public class FCMBasedPushNotificationProvider implements PushNotificationProvider {
- private static final String PS_PROVIDER_GCM = "GCM";
+ private static final String PS_PROVIDER_FCM = "FCM";
@Override
public String getType() {
- return PS_PROVIDER_GCM;
+ return PS_PROVIDER_FCM;
}
@Override
public NotificationStrategy getNotificationStrategy(PushNotificationConfig config) {
- return new GCMNotificationStrategy(config);
+ return new FCMNotificationStrategy(config);
}
}
diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/gcm/GCMNotificationStrategy.java b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/fcm/FCMNotificationStrategy.java
similarity index 76%
rename from components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/gcm/GCMNotificationStrategy.java
rename to components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/fcm/FCMNotificationStrategy.java
index af93b692a4..6dd66f0836 100644
--- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/gcm/GCMNotificationStrategy.java
+++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/fcm/FCMNotificationStrategy.java
@@ -16,7 +16,7 @@
* under the License.
*
*/
-package org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm;
+package org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
@@ -27,7 +27,7 @@ import org.wso2.carbon.device.mgt.common.push.notification.NotificationContext;
import org.wso2.carbon.device.mgt.common.push.notification.NotificationStrategy;
import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationConfig;
import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationExecutionFailedException;
-import org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm.internal.GCMDataHolder;
+import org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm.internal.FCMDataHolder;
import java.io.IOException;
import java.io.OutputStream;
@@ -35,16 +35,16 @@ import java.net.HttpURLConnection;
import java.net.URL;
import java.util.List;
-public class GCMNotificationStrategy implements NotificationStrategy {
+public class FCMNotificationStrategy implements NotificationStrategy {
- private static final String GCM_TOKEN = "GCM_TOKEN";
- private final static String GCM_ENDPOINT = "https://fcm.googleapis.com/fcm/send";
- private static final String GCM_API_KEY = "gcmAPIKey";
+ private static final String FCM_TOKEN = "FCM_TOKEN";
+ private static final String FCM_ENDPOINT = "https://fcm.googleapis.com/fcm/send";
+ private static final String FCM_API_KEY = "fcmAPIKey";
private static final int TIME_TO_LIVE = 60;
private static final int HTTP_STATUS_CODE_OK = 200;
private PushNotificationConfig config;
- public GCMNotificationStrategy(PushNotificationConfig config) {
+ public FCMNotificationStrategy(PushNotificationConfig config) {
this.config = config;
}
@@ -57,7 +57,7 @@ public class GCMNotificationStrategy implements NotificationStrategy {
public void execute(NotificationContext ctx) throws PushNotificationExecutionFailedException {
try {
Device device =
- GCMDataHolder.getInstance().getDeviceManagementProviderService().getDevice(ctx.getDeviceId());
+ FCMDataHolder.getInstance().getDeviceManagementProviderService().getDevice(ctx.getDeviceId());
this.sendWakeUpCall(ctx.getOperation().getCode(), device);
} catch (DeviceManagementException e) {
throw new PushNotificationExecutionFailedException("Error occurred while retrieving device information", e);
@@ -79,13 +79,13 @@ public class GCMNotificationStrategy implements NotificationStrategy {
private void sendWakeUpCall(String message,
Device device) throws IOException, PushNotificationExecutionFailedException {
OutputStream os = null;
- byte[] bytes = getGCMRequest(message, getGCMToken(device.getProperties())).getBytes();
+ byte[] bytes = getFCMRequest(message, getFCMToken(device.getProperties())).getBytes();
HttpURLConnection conn = null;
try {
- conn = (HttpURLConnection) new URL(GCM_ENDPOINT).openConnection();
+ conn = (HttpURLConnection) new URL(FCM_ENDPOINT).openConnection();
conn.setRequestProperty("Content-Type", "application/json");
- conn.setRequestProperty("Authorization", "key=" + config.getProperty(GCM_API_KEY));
+ conn.setRequestProperty("Authorization", "key=" + config.getProperty(FCM_API_KEY));
conn.setRequestMethod("POST");
conn.setDoOutput(true);
os = conn.getOutputStream();
@@ -102,35 +102,35 @@ public class GCMNotificationStrategy implements NotificationStrategy {
}
}
- private static String getGCMRequest(String message, String registrationId) {
- JsonObject gcmRequest = new JsonObject();
- gcmRequest.addProperty("delay_while_idle", false);
- gcmRequest.addProperty("time_to_live", TIME_TO_LIVE);
+ private static String getFCMRequest(String message, String registrationId) {
+ JsonObject fcmRequest = new JsonObject();
+ fcmRequest.addProperty("delay_while_idle", false);
+ fcmRequest.addProperty("time_to_live", TIME_TO_LIVE);
- //Add message to GCM request
+ //Add message to FCM request
JsonObject data = new JsonObject();
if (message != null && !message.isEmpty()) {
data.addProperty("data", message);
- gcmRequest.add("data", data);
+ fcmRequest.add("data", data);
}
//Set device reg-id
JsonArray regIds = new JsonArray();
regIds.add(new JsonPrimitive(registrationId));
- gcmRequest.add("registration_ids", regIds);
- return gcmRequest.toString();
+ fcmRequest.add("registration_ids", regIds);
+ return fcmRequest.toString();
}
- private static String getGCMToken(List properties) {
- String gcmToken = null;
+ private static String getFCMToken(List properties) {
+ String fcmToken = null;
for (Device.Property property : properties) {
- if (GCM_TOKEN.equals(property.getName())) {
- gcmToken = property.getValue();
+ if (FCM_TOKEN.equals(property.getName())) {
+ fcmToken = property.getValue();
break;
}
}
- return gcmToken;
+ return fcmToken;
}
}
diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/gcm/internal/GCMDataHolder.java b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/fcm/internal/FCMDataHolder.java
similarity index 88%
rename from components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/gcm/internal/GCMDataHolder.java
rename to components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/fcm/internal/FCMDataHolder.java
index 67b44109af..64569d7fb6 100644
--- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/gcm/internal/GCMDataHolder.java
+++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/fcm/internal/FCMDataHolder.java
@@ -16,16 +16,16 @@
* under the License.
*
*/
-package org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm.internal;
+package org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm.internal;
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
-public class GCMDataHolder {
+public class FCMDataHolder {
private DeviceManagementProviderService deviceManagementProviderService;
- private static GCMDataHolder thisInstance = new GCMDataHolder();
+ private static FCMDataHolder thisInstance = new FCMDataHolder();
- public static GCMDataHolder getInstance() {
+ public static FCMDataHolder getInstance() {
return thisInstance;
}
diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/gcm/internal/GCMPushNotificationServiceComponent.java b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/fcm/internal/FCMPushNotificationServiceComponent.java
similarity index 78%
rename from components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/gcm/internal/GCMPushNotificationServiceComponent.java
rename to components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/fcm/internal/FCMPushNotificationServiceComponent.java
index 6e5171ec4b..8993e6928a 100644
--- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/gcm/internal/GCMPushNotificationServiceComponent.java
+++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/fcm/internal/FCMPushNotificationServiceComponent.java
@@ -16,7 +16,7 @@
* under the License.
*
*/
-package org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm.internal;
+package org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm.internal;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -24,7 +24,7 @@ import org.osgi.service.component.ComponentContext;
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
/**
- * @scr.component name="org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm.internal.GCMPushNotificationServiceComponent" immediate="true"
+ * @scr.component name="org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm.internal.FCMPushNotificationServiceComponent" immediate="true"
* @scr.reference name="carbon.device.mgt.provider"
* interface="org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService"
* cardinality="1..1"
@@ -32,23 +32,20 @@ import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
* bind="setDeviceManagementProviderService"
* unbind="unsetDeviceManagementProviderService"
*/
-public class GCMPushNotificationServiceComponent {
+public class FCMPushNotificationServiceComponent {
- private static final Log log = LogFactory.getLog(GCMPushNotificationServiceComponent.class);
+ private static final Log log = LogFactory.getLog(FCMPushNotificationServiceComponent.class);
@SuppressWarnings("unused")
protected void activate(ComponentContext componentContext) {
try {
- if (log.isDebugEnabled()) {
- log.debug("Initializing GCM based push notification provider implementation bundle");
- }
//Do nothing
if (log.isDebugEnabled()) {
- log.debug("GCM based push notification provider implementation bundle has been successfully " +
+ log.debug("FCM based push notification provider implementation bundle has been successfully " +
"initialized");
}
} catch (Throwable e) {
- log.error("Error occurred while initializing GCM based push notification provider " +
+ log.error("Error occurred while initializing FCM based push notification provider " +
"implementation bundle", e);
}
}
@@ -59,12 +56,12 @@ public class GCMPushNotificationServiceComponent {
protected void setDeviceManagementProviderService(
DeviceManagementProviderService deviceManagementProviderService) {
- GCMDataHolder.getInstance().setDeviceManagementProviderService(deviceManagementProviderService);
+ FCMDataHolder.getInstance().setDeviceManagementProviderService(deviceManagementProviderService);
}
protected void unsetDeviceManagementProviderService(
DeviceManagementProviderService deviceManagementProviderService) {
- GCMDataHolder.getInstance().setDeviceManagementProviderService(deviceManagementProviderService);
+ FCMDataHolder.getInstance().setDeviceManagementProviderService(deviceManagementProviderService);
}
}
diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt/pom.xml b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt/pom.xml
index 9a747bf07c..b4753e7ea5 100644
--- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt/pom.xml
+++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt/pom.xml
@@ -22,7 +22,7 @@
device-mgt-extensionsorg.wso2.carbon.devicemgt
- 2.0.18-SNAPSHOT
+ 2.0.37-SNAPSHOT../pom.xml
diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp/pom.xml b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp/pom.xml
index 29678ac31f..0e20bfd521 100644
--- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp/pom.xml
+++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp/pom.xml
@@ -22,7 +22,7 @@
device-mgt-extensionsorg.wso2.carbon.devicemgt
- 2.0.18-SNAPSHOT
+ 2.0.37-SNAPSHOT../pom.xml
diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/xmpp/internal/XMPPPushNotificationServiceComponent.java b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/xmpp/internal/XMPPPushNotificationServiceComponent.java
index 7085191dc8..71dada3b66 100644
--- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/xmpp/internal/XMPPPushNotificationServiceComponent.java
+++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/xmpp/internal/XMPPPushNotificationServiceComponent.java
@@ -25,7 +25,7 @@ import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
import org.wso2.carbon.event.output.adapter.core.OutputEventAdapterService;
/**
- * @scr.component name="org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm.internal.XMPPPushNotificationServiceComponent" immediate="true"
+ * @scr.component name="org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm.internal.XMPPPushNotificationServiceComponent" immediate="true"
* @scr.reference name="carbon.device.mgt.provider"
* interface="org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService"
* cardinality="1..1"
diff --git a/components/device-mgt-extensions/pom.xml b/components/device-mgt-extensions/pom.xml
index 418369abfd..08bd64adb0 100644
--- a/components/device-mgt-extensions/pom.xml
+++ b/components/device-mgt-extensions/pom.xml
@@ -22,7 +22,7 @@
carbon-devicemgtorg.wso2.carbon.devicemgt
- 2.0.18-SNAPSHOT
+ 2.0.37-SNAPSHOT../../pom.xml
@@ -34,7 +34,7 @@
http://wso2.org
- org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm
+ org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcmorg.wso2.carbon.device.mgt.extensions.push.notification.provider.mqttorg.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpporg.wso2.carbon.device.mgt.extensions.device.type.deployer
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/pom.xml
index bc4290bd74..739046f85b 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/pom.xml
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/pom.xml
@@ -3,7 +3,7 @@
org.wso2.carbon.devicemgtdevice-mgt
- 2.0.18-SNAPSHOT
+ 2.0.37-SNAPSHOT../pom.xml
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/pom.xml
index c93ba47588..0dd15957ef 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/pom.xml
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/pom.xml
@@ -22,7 +22,7 @@
org.wso2.carbon.devicemgtdevice-mgt
- 2.0.18-SNAPSHOT
+ 2.0.37-SNAPSHOT../pom.xml
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.api/pom.xml
index 8ac9e1b58f..1470d02951 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.api/pom.xml
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/pom.xml
@@ -22,7 +22,7 @@
device-mgtorg.wso2.carbon.devicemgt
- 2.0.18-SNAPSHOT
+ 2.0.37-SNAPSHOT../pom.xml
@@ -281,6 +281,23 @@
javax.ws.rsjavax.ws.rs-api
+
+ org.wso2.carbon.commons
+ org.wso2.carbon.application.mgt.stub
+ provided
+
+
+ org.wso2.carbon.devicemgt
+ org.wso2.carbon.identity.jwt.client.extension
+ provided
+
+
+ org.wso2.carbon.identity.framework
+ org.wso2.carbon.identity.user.store.count
+ ${carbon.identity.framework.version}
+ provided
+
+
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/BasePaginatedResult.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/BasePaginatedResult.java
index 8d1c82d8d7..5c2936a1a3 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/BasePaginatedResult.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/BasePaginatedResult.java
@@ -30,13 +30,13 @@ public class BasePaginatedResult {
value = "Number of total resources.",
example = "1")
@JsonProperty("count")
- private int count;
+ private long count;
- public int getCount() {
+ public long getCount() {
return count;
}
- public void setCount(int count) {
+ public void setCount(long count) {
this.count = count;
}
}
\ No newline at end of file
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceManagementService.java
index 46ffac27e3..ddbdfcdc08 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceManagementService.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceManagementService.java
@@ -423,6 +423,83 @@ public interface DeviceManagementService {
@HeaderParam("If-Modified-Since")
String ifModifiedSince);
+
+ @GET
+ @Path("/{type}/{id}/location")
+ @ApiOperation(
+ produces = MediaType.APPLICATION_JSON,
+ httpMethod = "GET",
+ value = "Getting Location Details of a Device",
+ notes = "Get the location details of a device by specifying the device type and device identifier.",
+ tags = "Device Management",
+ extensions = {
+ @Extension(properties = {
+ @ExtensionProperty(name = Constants.SCOPE, value = "perm:devices:details")
+ })
+ }
+ )
+ @ApiResponses(
+ value = {
+ @ApiResponse(
+ code = 200,
+ message = "OK. \n Successfully fetched the location details of the device.",
+ response = Device.class,
+ responseHeaders = {
+ @ResponseHeader(
+ name = "Content-Type",
+ description = "The content type of the body"),
+ @ResponseHeader(
+ name = "ETag",
+ description = "Entity Tag of the response resource.\n" +
+ "Used by caches, or in conditional requests."),
+ @ResponseHeader(
+ name = "Last-Modified",
+ description = "Date and time the resource was last modified.\n" +
+ "Used by caches, or in conditional requests."),
+ }),
+ @ApiResponse(
+ code = 304,
+ message = "Not Modified. Empty body because the client already has the latest version" +
+ " of the requested resource.\n"),
+ @ApiResponse(
+ code = 400,
+ message = "Bad Request. \n Invalid request or validation error.",
+ response = ErrorResponse.class),
+ @ApiResponse(
+ code = 404,
+ message = "Not Found. \n Location data for the specified device was not found.",
+ response = ErrorResponse.class),
+ @ApiResponse(
+ code = 500,
+ message = "Internal Server Error. \n " +
+ "Server error occurred while retrieving the device details.",
+ response = ErrorResponse.class)
+ })
+ Response getDeviceLocation(
+ @ApiParam(
+ name = "type",
+ value = "The device type name, such as ios, android, windows or fire-alarm.",
+ required = true)
+ @PathParam("type")
+ @Size(max = 45)
+ String type,
+ @ApiParam(
+ name = "id",
+ value = "The device identifier of the device you want ot get details.",
+ required = true)
+ @PathParam("id")
+ @Size(max = 45)
+ String id,
+ @ApiParam(
+ name = "If-Modified-Since",
+ value = "Checks if the requested variant was modified, since the specified date-time. \n" +
+ "Provide the value in the following format: EEE, d MMM yyyy HH:mm:ss Z. \n" +
+ "Example: Mon, 05 Jan 2014 15:10:00 +0200",
+ required = false)
+ @HeaderParam("If-Modified-Since")
+ String ifModifiedSince);
+
+
//device rename request would looks like follows
//POST devices/type/virtual_firealarm/id/us06ww93auzp/rename
@POST
@@ -575,7 +652,7 @@ public interface DeviceManagementService {
produces = MediaType.APPLICATION_JSON,
httpMethod = "GET",
value = "Getting Feature Details of a Device",
- notes = "WSO2 EMM features enable you to carry out many operations based on the device platform. " +
+ notes = "WSO2 IoTS features enable you to carry out many operations based on the device platform. " +
"Using this REST API you can get the features that can be carried out on a preferred device type," +
" such as iOS, Android or Windows.",
tags = "Device Management",
@@ -644,7 +721,7 @@ public interface DeviceManagementService {
@ApiParam(
name = "id",
value = "The device identifier of the device.\n" +
- "INFO: Make sure to add the ID of a device that is already registered with WSO2 EMM.",
+ "INFO: Make sure to add the ID of a device that is already registered with WSO2 IoTS.",
required = true)
@PathParam("id")
@Size(max = 45)
@@ -911,7 +988,7 @@ public interface DeviceManagementService {
@ApiParam(
name = "id",
value = "The device identifier of the device you wish to get details.\n" +
- "INFO: Make sure to add the ID of a device that is already registered with WSO2 EMM.",
+ "INFO: Make sure to add the ID of a device that is already registered with WSO2 IoTS.",
required = true)
@PathParam("id")
@Size(max = 45)
@@ -952,8 +1029,8 @@ public interface DeviceManagementService {
produces = MediaType.APPLICATION_JSON,
httpMethod = "GET",
value = "Get the details of the policy that is enforced on a device.",
- notes = "A policy is enforced on all the devices that register with WSO2 EMM." +
- "WSO2 EMM filters the policies based on the device platform (device type)," +
+ notes = "A policy is enforced on all the devices that register with WSO2 IoTS." +
+ "WSO2 IoTS filters the policies based on the device platform (device type)," +
"the device ownership type, the user role or name and finally, the policy that matches these filters will be enforced on the device.",
tags = "Device Management",
extensions = {
@@ -1041,7 +1118,7 @@ public interface DeviceManagementService {
produces = MediaType.APPLICATION_JSON,
httpMethod = "GET",
value = "Getting Policy Compliance Details of a Device",
- notes = "A policy is enforced on the devices that register with WSO2 EMM. " +
+ notes = "A policy is enforced on the devices that register with WSO2 IoTS. " +
"The server checks if the settings in the device comply with the policy that is enforced on the device using this REST API.",
tags = "Device Management",
extensions = {
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/RoleManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/RoleManagementService.java
index e330d7d3d3..295fb47555 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/RoleManagementService.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/RoleManagementService.java
@@ -18,17 +18,7 @@
*/
package org.wso2.carbon.device.mgt.jaxrs.service.api;
-import io.swagger.annotations.SwaggerDefinition;
-import io.swagger.annotations.Info;
-import io.swagger.annotations.ExtensionProperty;
-import io.swagger.annotations.Extension;
-import io.swagger.annotations.Tag;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import io.swagger.annotations.ApiParam;
-import io.swagger.annotations.ApiResponse;
-import io.swagger.annotations.ApiResponses;
-import io.swagger.annotations.ResponseHeader;
+import io.swagger.annotations.*;
import org.wso2.carbon.apimgt.annotations.api.Scope;
import org.wso2.carbon.apimgt.annotations.api.Scopes;
import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse;
@@ -120,20 +110,20 @@ public interface RoleManagementService {
produces = MediaType.APPLICATION_JSON,
httpMethod = "GET",
value = "Getting the List of Roles",
- notes = "WSO2 EMM supports role-based access control (RBAC) and role management. Using this API you can the list of roles that are in WSO2 EMM.\n" +
+ notes = "WSO2 IoTS supports role-based access control (RBAC) and role management. Using this API you can the list of roles that are in WSO2 IoTS.\n" +
"Note: Internal roles, roles created for service-providers, and application related roles will not be given in the output.",
tags = "Role Management",
extensions = {
- @Extension(properties = {
- @ExtensionProperty(name = Constants.SCOPE, value = "perm:roles:view")
- })
+ @Extension(properties = {
+ @ExtensionProperty(name = Constants.SCOPE, value = "perm:roles:view")
+ })
}
)
@ApiResponses(
value = {
@ApiResponse(
code = 200,
- message = "OK. \n Successfully fetched the list of roles in WSO2 EMM.",
+ message = "OK. \n Successfully fetched the list of roles in WSO2 IoTS.",
response = RoleList.class,
responseHeaders = {
@ResponseHeader(
@@ -190,467 +180,549 @@ public interface RoleManagementService {
defaultValue = "5")
@QueryParam("limit") int limit);
- @GET
- @Path("/{roleName}/permissions")
- @ApiOperation(
- produces = MediaType.APPLICATION_JSON,
- httpMethod = "GET",
- value = "Getting Permission Details of a Role",
- notes = "An individual is associated a with set of responsibilities based on their " +
- "role. In WSO2 EMM you are able to configure permissions based on the responsibilities carried " +
- "out by various roles. Therefore, if you wish to retrieve the permission details of a role, you can do " +
- "so using this REST API.",
- response = UIPermissionNode.class,
- responseContainer = "List",
- tags = "Role Management",
- extensions = {
- @Extension(properties = {
- @ExtensionProperty(name = Constants.SCOPE, value = "perm:roles:permissions")
+ @GET
+ @Path("/filter/{prefix}")
+ @ApiOperation(
+ produces = MediaType.APPLICATION_JSON,
+ httpMethod = "GET",
+ value = "Getting the List of Roles filtered by the given prefix",
+ notes = "WSO2 IoTS supports role-based access control (RBAC) and role management. Using this API you can the list of roles that are in WSO2 IoTS.\n" +
+ "Note: Internal roles, roles created for service-providers, and application related roles will not be given in the output.",
+ tags = "Role Management",
+ extensions = {
+ @Extension(properties = {
+ @ExtensionProperty(name = Constants.SCOPE, value = "perm:roles:view")
+ })
+ }
+ )
+ @ApiResponses(
+ value = {
+ @ApiResponse(
+ code = 200,
+ message = "OK. \n Successfully fetched the list of roles in WSO2 IoTS.",
+ response = RoleList.class,
+ responseHeaders = {
+ @ResponseHeader(
+ name = "Content-Type",
+ description = "The content type of the body"),
+ @ResponseHeader(
+ name = "ETag",
+ description = "Entity Tag of the response resource.\n" +
+ "Used by caches, or in conditional requests."),
+ @ResponseHeader(
+ name = "Last-Modified",
+ description = "Date and time the resource has been modified the last time.\n" +
+ "Used by caches, or in conditional requests."),
+ }),
+ @ApiResponse(
+ code = 304,
+ message = "Not Modified. \n Empty body because the client already has the latest version of the requested resource."),
+ @ApiResponse(
+ code = 406,
+ message = "Not Acceptable.\n The requested media type is not supported"),
+ @ApiResponse(
+ code = 500,
+ message = "Internal Server Error. \n Server error occurred while fetching list of roles.",
+ response = ErrorResponse.class)
})
- }
- )
- @ApiResponses(
- value = {
- @ApiResponse(
- code = 200,
- message = "OK. \n Successfully fetched the permissions details for the specified role.",
- response = UIPermissionNode.class,
- responseContainer = "List",
- responseHeaders = {
- @ResponseHeader(
- name = "Content-Type",
- description = "The content type of the body"),
- @ResponseHeader(
- name = "ETag",
- description = "Entity Tag of the response resource.\n" +
- "Used by caches, or in conditional requests."),
- @ResponseHeader(
- name = "Last-Modified",
- description = "Date and time the resource has been modified the last time.\n" +
- "Used by caches, or in conditional requests."),
- }),
- @ApiResponse(
- code = 304,
- message = "Not Modified. \n Empty body because the client already has the latest version of the requested resource.\n"),
- @ApiResponse(
- code = 400,
- message = "Bad Request. \n Invalid request or validation error.",
- response = ErrorResponse.class),
- @ApiResponse(
- code = 404,
- message = "Not Found. \n The specified role does not exist.",
- response = ErrorResponse.class),
- @ApiResponse(
- code = 406,
- message = "Not Acceptable.\n The requested media type is not supported",
- response = ErrorResponse.class),
- @ApiResponse(
- code = 500,
- message = "Internal Server ErrorResponse. \n Server error occurred while fetching the permission list for the requested role.",
- response = ErrorResponse.class)
- })
- Response getPermissionsOfRole(
- @ApiParam(
- name = "roleName",
- value = "The name of the role.",
- required = true,
- defaultValue = "Engineer")
- @PathParam("roleName") String roleName,
- @ApiParam(
- name = "user-store",
- value = "The name of the user store from which you wish to get the permission of role.",
- required = false)
- @QueryParam("user-store") String userStoreName,
- @ApiParam(
- name = "If-Modified-Since",
- value = "Checks if the requested variant was modified, since the specified date-time." +
- "Provide the value in the following format: EEE, d MMM yyyy HH:mm:ss Z.\n" +
- "Example: Mon, 05 Jan 2014 15:10:00 +0200",
- required = false)
- @HeaderParam("If-Modified-Since") String ifModifiedSince);
+ Response getFilteredRoles(
+ @ApiParam(
+ name = "prefix",
+ value = "Filtering prefix of the role.",
+ required = true,
+ defaultValue = "")
+ @PathParam("prefix") String prefix,
+ @ApiParam(
+ name = "filter",
+ value = "Provide a character or a few characters in the role name.",
+ required = false)
+ @QueryParam("filter") String filter,
+ @ApiParam(
+ name = "user-store",
+ value = "The name of the UserStore you wish to get the list of roles.",
+ required = false)
+ @QueryParam("user-store") String userStoreName,
+ @ApiParam(
+ name = "If-Modified-Since",
+ value = "Checks if the requested variant was modified, since the specified date-time." +
+ "Provide the value in the following format: EEE, d MMM yyyy HH:mm:ss Z.\n" +
+ "Example: Mon, 05 Jan 2014 15:10:00 +0200",
+ required = false)
+ @HeaderParam("If-Modified-Since") String ifModifiedSince,
+ @ApiParam(
+ name = "offset",
+ value = "The starting pagination index for the complete list of qualified items.",
+ required = false,
+ defaultValue = "0")
+ @QueryParam("offset") int offset,
+ @ApiParam(
+ name = "limit",
+ value = "Provide how many role details you require from the starting pagination index/offset.",
+ required = false,
+ defaultValue = "5")
+ @QueryParam("limit") int limit);
- @GET
- @Path("/{roleName}")
- @ApiOperation(
- produces = MediaType.APPLICATION_JSON,
- httpMethod = "GET",
- value = "Getting Details of a Role",
- notes = "Get the permissions associated with a role and role specific details using this REST API.",
- response = RoleInfo.class,
- tags = "Role Management",
- extensions = {
- @Extension(properties = {
- @ExtensionProperty(name = Constants.SCOPE, value = "perm:roles:details")
+ @GET
+ @Path("/{roleName}/permissions")
+ @ApiOperation(
+ produces = MediaType.APPLICATION_JSON,
+ httpMethod = "GET",
+ value = "Getting Permission Details of a Role",
+ notes = "An individual is associated a with set of responsibilities based on their " +
+ "role. In WSO2 IoTS you are able to configure permissions based on the responsibilities carried " +
+ "out by various roles. Therefore, if you wish to retrieve the permission details of a role, you can do " +
+ "so using this REST API.",
+ response = UIPermissionNode.class,
+ responseContainer = "List",
+ tags = "Role Management",
+ extensions = {
+ @Extension(properties = {
+ @ExtensionProperty(name = Constants.SCOPE, value = "perm:roles:permissions")
+ })
+ }
+ )
+ @ApiResponses(
+ value = {
+ @ApiResponse(
+ code = 200,
+ message = "OK. \n Successfully fetched the permissions details for the specified role.",
+ response = UIPermissionNode.class,
+ responseContainer = "List",
+ responseHeaders = {
+ @ResponseHeader(
+ name = "Content-Type",
+ description = "The content type of the body"),
+ @ResponseHeader(
+ name = "ETag",
+ description = "Entity Tag of the response resource.\n" +
+ "Used by caches, or in conditional requests."),
+ @ResponseHeader(
+ name = "Last-Modified",
+ description = "Date and time the resource has been modified the last time.\n" +
+ "Used by caches, or in conditional requests."),
+ }),
+ @ApiResponse(
+ code = 304,
+ message = "Not Modified. \n Empty body because the client already has the latest version of the requested resource.\n"),
+ @ApiResponse(
+ code = 400,
+ message = "Bad Request. \n Invalid request or validation error.",
+ response = ErrorResponse.class),
+ @ApiResponse(
+ code = 404,
+ message = "Not Found. \n The specified role does not exist.",
+ response = ErrorResponse.class),
+ @ApiResponse(
+ code = 406,
+ message = "Not Acceptable.\n The requested media type is not supported",
+ response = ErrorResponse.class),
+ @ApiResponse(
+ code = 500,
+ message = "Internal Server ErrorResponse. \n Server error occurred while fetching the permission list for the requested role.",
+ response = ErrorResponse.class)
})
- }
- )
- @ApiResponses(
- value = {
- @ApiResponse(
- code = 200,
- message = "OK. \n Successfully fetched the details of the role.",
- response = RoleInfo.class,
- responseHeaders = {
- @ResponseHeader(
- name = "Content-Type",
- description = "The content type of the body"),
- @ResponseHeader(
- name = "ETag",
- description = "Entity Tag of the response resource.\n" +
- "Used by caches, or in conditional requests."),
- @ResponseHeader(
- name = "Last-Modified",
- description = "Date and time the resource has been modified the last time.\n" +
- "Used by caches, or in conditional requests."),
- }),
- @ApiResponse(
- code = 304,
- message = "Not Modified. \n Empty body because the client already has the latest version of the requested resource."),
- @ApiResponse(
- code = 400,
- message = "Bad Request. \n Invalid request or validation error.",
- response = ErrorResponse.class),
- @ApiResponse(
- code = 404,
- message = "Not Found. \n The specified role does not exist.",
- response = ErrorResponse.class),
- @ApiResponse(
- code = 406,
- message = "Not Acceptable.\n The requested media type is not supported",
- response = ErrorResponse.class),
- @ApiResponse(
- code = 500,
- message = "Internal Server Error. \n Server error occurred while fetching the details of" +
- "requested role.",
- response = ErrorResponse.class)
- })
- Response getRole(
- @ApiParam(
- name = "roleName",
- value = "The name of the role.",
- required = true,
- defaultValue = "admin")
- @PathParam("roleName") String roleName,
- @ApiParam(
- name = "user-store",
- value = "The name of the user store which the particular of role resides in",
- required = false)
- @QueryParam("user-store") String userStoreName,
- @ApiParam(
- name = "If-Modified-Since",
- value = "Checks if the requested variant was modified, since the specified date-time." +
- "Provide the value in the following format: EEE, d MMM yyyy HH:mm:ss Z.\n" +
- "Example: Mon, 05 Jan 2014 15:10:00 +0200",
- required = false)
- @HeaderParam("If-Modified-Since") String ifModifiedSince);
+ Response getPermissionsOfRole(
+ @ApiParam(
+ name = "roleName",
+ value = "The name of the role.",
+ required = true,
+ defaultValue = "Engineer")
+ @PathParam("roleName") String roleName,
+ @ApiParam(
+ name = "user-store",
+ value = "The name of the user store from which you wish to get the permission of role.",
+ required = false)
+ @QueryParam("user-store") String userStoreName,
+ @ApiParam(
+ name = "If-Modified-Since",
+ value = "Checks if the requested variant was modified, since the specified date-time." +
+ "Provide the value in the following format: EEE, d MMM yyyy HH:mm:ss Z.\n" +
+ "Example: Mon, 05 Jan 2014 15:10:00 +0200",
+ required = false)
+ @HeaderParam("If-Modified-Since") String ifModifiedSince);
- @POST
- @ApiOperation(
- consumes = MediaType.APPLICATION_JSON,
- produces = MediaType.APPLICATION_JSON,
- httpMethod = "POST",
- value = "Adding a Role",
- notes = "WSO2 EMM supports role-based access control (RBAC) and role management. Add a new role to WSO2 EMM using this REST API.",
- tags = "Role Management",
- extensions = {
- @Extension(properties = {
- @ExtensionProperty(name = Constants.SCOPE, value = "perm:roles:add")
+ @GET
+ @Path("/{roleName}")
+ @ApiOperation(
+ produces = MediaType.APPLICATION_JSON,
+ httpMethod = "GET",
+ value = "Getting Details of a Role",
+ notes = "Get the permissions associated with a role and role specific details using this REST API.",
+ response = RoleInfo.class,
+ tags = "Role Management",
+ extensions = {
+ @Extension(properties = {
+ @ExtensionProperty(name = Constants.SCOPE, value = "perm:roles:details")
+ })
+ }
+ )
+ @ApiResponses(
+ value = {
+ @ApiResponse(
+ code = 200,
+ message = "OK. \n Successfully fetched the details of the role.",
+ response = RoleInfo.class,
+ responseHeaders = {
+ @ResponseHeader(
+ name = "Content-Type",
+ description = "The content type of the body"),
+ @ResponseHeader(
+ name = "ETag",
+ description = "Entity Tag of the response resource.\n" +
+ "Used by caches, or in conditional requests."),
+ @ResponseHeader(
+ name = "Last-Modified",
+ description = "Date and time the resource has been modified the last time.\n" +
+ "Used by caches, or in conditional requests."),
+ }),
+ @ApiResponse(
+ code = 304,
+ message = "Not Modified. \n Empty body because the client already has the latest version of the requested resource."),
+ @ApiResponse(
+ code = 400,
+ message = "Bad Request. \n Invalid request or validation error.",
+ response = ErrorResponse.class),
+ @ApiResponse(
+ code = 404,
+ message = "Not Found. \n The specified role does not exist.",
+ response = ErrorResponse.class),
+ @ApiResponse(
+ code = 406,
+ message = "Not Acceptable.\n The requested media type is not supported",
+ response = ErrorResponse.class),
+ @ApiResponse(
+ code = 500,
+ message = "Internal Server Error. \n Server error occurred while fetching the details of" +
+ "requested role.",
+ response = ErrorResponse.class)
})
- }
- )
- @ApiResponses(value = {
- @ApiResponse(
- code = 201,
- message = "Created. \n Successfully created the role.",
- responseHeaders = {
- @ResponseHeader(
- name = "Content-Location",
- description = "The URL to the newly added role."),
- @ResponseHeader(
- name = "Content-Type",
- description = "The content type of the body"),
- @ResponseHeader(
- name = "ETag",
- description = "Entity Tag of the response resource.\n" +
- "Used by caches, or in conditional requests."),
- @ResponseHeader(
- name = "Last-Modified",
- description = "Date and time the resource has been modified the last time.\n" +
- "Used by caches, or in conditional requests.")}),
- @ApiResponse(
- code = 303,
- message = "See Other. \n The source can be retrieved from the URL specified in the location header.",
- responseHeaders = {
- @ResponseHeader(
- name = "Content-Location",
- description = "The Source URL of the document.")}),
- @ApiResponse(
- code = 400,
- message = "Bad Request. \n Invalid request or validation error.",
- response = ErrorResponse.class),
- @ApiResponse(
- code = 415,
- message = "Unsupported media type. \n The format of the requested entity was not supported.",
- response = ErrorResponse.class),
- @ApiResponse(
- code = 500,
- message = "Internal Server Error. \n Server error occurred while adding a new role.",
- response = ErrorResponse.class)
- })
- Response addRole(
- @ApiParam(
- name = "role",
- value = "The properties required to add a new role.",
- required = true) RoleInfo role);
+ Response getRole(
+ @ApiParam(
+ name = "roleName",
+ value = "The name of the role.",
+ required = true,
+ defaultValue = "admin")
+ @PathParam("roleName") String roleName,
+ @ApiParam(
+ name = "user-store",
+ value = "The name of the user store which the particular of role resides in",
+ required = false)
+ @QueryParam("user-store") String userStoreName,
+ @ApiParam(
+ name = "If-Modified-Since",
+ value = "Checks if the requested variant was modified, since the specified date-time." +
+ "Provide the value in the following format: EEE, d MMM yyyy HH:mm:ss Z.\n" +
+ "Example: Mon, 05 Jan 2014 15:10:00 +0200",
+ required = false)
+ @HeaderParam("If-Modified-Since") String ifModifiedSince);
- @POST
- @Path("/create-combined-role/{roleName}")
- @ApiOperation(
- consumes = MediaType.APPLICATION_JSON,
- produces = MediaType.APPLICATION_JSON,
- httpMethod = "POST",
- value = "Adding a combined Role",
- notes = "WSO2 EMM supports role-based access control (RBAC) and role management. Add a new combined role to WSO2 EMM using this REST API.",
- tags = "Role Management",
- extensions = {
- @Extension(properties = {
- @ExtensionProperty(name = Constants.SCOPE, value = "perm:roles:create-combined-role")
- })
- }
- )
- @ApiResponses(value = {
- @ApiResponse(
- code = 201,
- message = "Created. \n Successfully created the role.",
- responseHeaders = {
- @ResponseHeader(
- name = "Content-Location",
- description = "The URL to the newly added role."),
- @ResponseHeader(
- name = "Content-Type",
- description = "The content type of the body"),
- @ResponseHeader(
- name = "ETag",
- description = "Entity Tag of the response resource.\n" +
- "Used by caches, or in conditional requests."),
- @ResponseHeader(
- name = "Last-Modified",
- description = "Date and time the resource has been modified the last time.\n" +
- "Used by caches, or in conditional requests.")}),
- @ApiResponse(
- code = 303,
- message = "See Other. \n The source can be retrieved from the URL specified in the location header.",
- responseHeaders = {
- @ResponseHeader(
- name = "Content-Location",
- description = "The Source URL of the document.")}),
- @ApiResponse(
- code = 400,
- message = "Bad Request. \n Invalid request or validation error.",
- response = ErrorResponse.class),
- @ApiResponse(
- code = 415,
- message = "Unsupported media type. \n The format of the requested entity was not supported.",
- response = ErrorResponse.class),
- @ApiResponse(
- code = 500,
- message = "Internal Server Error. \n Server error occurred while adding a new role.",
- response = ErrorResponse.class)
- })
- Response addCombinedRole(
- @ApiParam(
- name = "roles",
- value = "List of roles names required to add a new combined role.",
- required = true) List roles,
- @PathParam("roleName") String roleName,
- @QueryParam("user-store") String userStoreName);
+ @POST
+ @ApiOperation(
+ consumes = MediaType.APPLICATION_JSON,
+ produces = MediaType.APPLICATION_JSON,
+ httpMethod = "POST",
+ value = "Adding a Role",
+ notes = "WSO2 IoTS supports role-based access control (RBAC) and role management. Add a new role to WSO2 IoTS using this REST API.",
+ tags = "Role Management",
+ extensions = {
+ @Extension(properties = {
+ @ExtensionProperty(name = Constants.SCOPE, value = "perm:roles:add")
+ })
+ }
+ )
+ @ApiResponses(value = {
+ @ApiResponse(
+ code = 201,
+ message = "Created. \n Successfully created the role.",
+ responseHeaders = {
+ @ResponseHeader(
+ name = "Content-Location",
+ description = "The URL to the newly added role."),
+ @ResponseHeader(
+ name = "Content-Type",
+ description = "The content type of the body"),
+ @ResponseHeader(
+ name = "ETag",
+ description = "Entity Tag of the response resource.\n" +
+ "Used by caches, or in conditional requests."),
+ @ResponseHeader(
+ name = "Last-Modified",
+ description = "Date and time the resource has been modified the last time.\n" +
+ "Used by caches, or in conditional requests.")}),
+ @ApiResponse(
+ code = 303,
+ message = "See Other. \n The source can be retrieved from the URL specified in the location header.",
+ responseHeaders = {
+ @ResponseHeader(
+ name = "Content-Location",
+ description = "The Source URL of the document.")}),
+ @ApiResponse(
+ code = 400,
+ message = "Bad Request. \n Invalid request or validation error.",
+ response = ErrorResponse.class),
+ @ApiResponse(
+ code = 415,
+ message = "Unsupported media type. \n The format of the requested entity was not supported.",
+ response = ErrorResponse.class),
+ @ApiResponse(
+ code = 500,
+ message = "Internal Server Error. \n Server error occurred while adding a new role.",
+ response = ErrorResponse.class)
+ })
+ Response addRole(
+ @ApiParam(
+ name = "role",
+ value = "The properties required to add a new role.",
+ required = true) RoleInfo role);
- @PUT
- @Path("/{roleName}")
- @ApiOperation(
- consumes = MediaType.APPLICATION_JSON,
- produces = MediaType.APPLICATION_JSON,
- httpMethod = "PUT",
- value = "Updating Role Details",
- notes = "There will be situations where you need to update the role details, such as the permissions" +
- " or the role name. Update the role details using this REST API.",
- tags = "Role Management",
- extensions = {
- @Extension(properties = {
- @ExtensionProperty(name = Constants.SCOPE, value = "perm:roles:update")
- })
- }
- )
- @ApiResponses(value = {
- @ApiResponse(
- code = 200,
- message = "OK. \n Successfully updated the specified role.",
- responseHeaders = {
- @ResponseHeader(
- name = "Content-Type",
- description = "Content type of the body"),
- @ResponseHeader(
- name = "ETag",
- description = "Entity Tag of the response resource.\n" +
- "Used by caches, or in conditional requests."),
- @ResponseHeader(
- name = "Last-Modified",
- description = "Date and time the resource was last modified.\n" +
- "Used by caches, or in conditional requests.")}),
- @ApiResponse(
- code = 400,
- message = "Bad Request. \n Invalid request or validation error.",
- response = ErrorResponse.class),
- @ApiResponse(
- code = 404,
- message = "Not Found. \n The specified role does not exist.",
- response = ErrorResponse.class),
- @ApiResponse(
- code = 415,
- message = "Unsupported media type. \n The format of the requested entity was not supported.\n",
- response = ErrorResponse.class),
- @ApiResponse(
- code = 500,
- message = "Internal Server Error. \n Server error occurred while updating the role.",
- response = ErrorResponse.class)
- })
- Response updateRole(
- @ApiParam(
- name = "roleName",
- value = "The name of the role.",
- required = true,
- defaultValue = "admin")
- @PathParam("roleName") String roleName,
- @ApiParam(
- name = "role",
- value = "The properties required to update a role.\n" +
- "NOTE: Don't change the role and the permissions of the admin user. " +
- "If you want to try out this API by updating all the properties, create a new role and update the properties accordingly.",
- required = true) RoleInfo role,
- @ApiParam(
- name = "user-store",
- value = "The name of the user store which the particular role resides in.",
- required = false)
- @QueryParam("user-store") String userStoreName);
+ @POST
+ @Path("/create-combined-role/{roleName}")
+ @ApiOperation(
+ consumes = MediaType.APPLICATION_JSON,
+ produces = MediaType.APPLICATION_JSON,
+ httpMethod = "POST",
+ value = "Adding a combined Role",
+ notes = "WSO2 IoTS supports role-based access control (RBAC) and role management. Add a new combined role to WSO2 IoTS using this REST API.",
+ tags = "Role Management",
+ extensions = {
+ @Extension(properties = {
+ @ExtensionProperty(name = Constants.SCOPE, value = "perm:roles:create-combined-role")
+ })
+ }
+ )
+ @ApiResponses(value = {
+ @ApiResponse(
+ code = 201,
+ message = "Created. \n Successfully created the role.",
+ responseHeaders = {
+ @ResponseHeader(
+ name = "Content-Location",
+ description = "The URL to the newly added role."),
+ @ResponseHeader(
+ name = "Content-Type",
+ description = "The content type of the body"),
+ @ResponseHeader(
+ name = "ETag",
+ description = "Entity Tag of the response resource.\n" +
+ "Used by caches, or in conditional requests."),
+ @ResponseHeader(
+ name = "Last-Modified",
+ description = "Date and time the resource has been modified the last time.\n" +
+ "Used by caches, or in conditional requests.")}),
+ @ApiResponse(
+ code = 303,
+ message = "See Other. \n The source can be retrieved from the URL specified in the location header.",
+ responseHeaders = {
+ @ResponseHeader(
+ name = "Content-Location",
+ description = "The Source URL of the document.")}),
+ @ApiResponse(
+ code = 400,
+ message = "Bad Request. \n Invalid request or validation error.",
+ response = ErrorResponse.class),
+ @ApiResponse(
+ code = 415,
+ message = "Unsupported media type. \n The format of the requested entity was not supported.",
+ response = ErrorResponse.class),
+ @ApiResponse(
+ code = 500,
+ message = "Internal Server Error. \n Server error occurred while adding a new role.",
+ response = ErrorResponse.class)
+ })
+ Response addCombinedRole(
+ @ApiParam(
+ name = "roles",
+ value = "List of roles names required to add a new combined role.",
+ required = true) List roles,
+ @PathParam("roleName") String roleName,
+ @QueryParam("user-store") String userStoreName);
- @DELETE
- @Path("/{roleName}")
- @ApiOperation(
- httpMethod = "DELETE",
- value = "Deleting a Role",
- notes = "Roles become obsolete over time due to various reasons. In a situation where your Organization identifies that a specific role is no longer required, you " +
- "can delete a role using this REST API.",
- tags = "Role Management",
- extensions = {
- @Extension(properties = {
- @ExtensionProperty(name = Constants.SCOPE, value = "perm:roles:delete")
- })
- }
- )
- @ApiResponses(value = {
- @ApiResponse(
- code = 200,
- message = "OK. \n Successfully removed the specified role."),
- @ApiResponse(
- code = 400,
- message = "Bad Request. \n Invalid request or validation error.",
- response = ErrorResponse.class),
- @ApiResponse(
- code = 404,
- message = "Not Found. \n The specified role does not exist.",
- response = ErrorResponse.class),
- @ApiResponse(
- code = 500,
- message = "Internal Server Error. \n Server error occurred while removing the role.",
- response = ErrorResponse.class)
- })
- Response deleteRole(
- @ApiParam(
- name = "roleName",
- value = "The name of the role that needs to de deleted.\n" +
- "NOTE: Don't delete the admin role",
- required = true)
- @PathParam("roleName") String roleName,
- @ApiParam(
- name = "user-store",
- value = "The name of the user store which the particular role resides in.",
- required = false)
- @QueryParam("user-store") String userStoreName);
+ @PUT
+ @Path("/{roleName}")
+ @ApiOperation(
+ consumes = MediaType.APPLICATION_JSON,
+ produces = MediaType.APPLICATION_JSON,
+ httpMethod = "PUT",
+ value = "Updating Role Details",
+ notes = "There will be situations where you need to update the role details, such as the permissions" +
+ " or the role name. Update the role details using this REST API.",
+ tags = "Role Management",
+ extensions = {
+ @Extension(properties = {
+ @ExtensionProperty(name = Constants.SCOPE, value = "perm:roles:update")
+ })
+ }
+ )
+ @ApiResponses(value = {
+ @ApiResponse(
+ code = 200,
+ message = "OK. \n Successfully updated the specified role.",
+ responseHeaders = {
+ @ResponseHeader(
+ name = "Content-Type",
+ description = "Content type of the body"),
+ @ResponseHeader(
+ name = "ETag",
+ description = "Entity Tag of the response resource.\n" +
+ "Used by caches, or in conditional requests."),
+ @ResponseHeader(
+ name = "Last-Modified",
+ description = "Date and time the resource was last modified.\n" +
+ "Used by caches, or in conditional requests.")}),
+ @ApiResponse(
+ code = 400,
+ message = "Bad Request. \n Invalid request or validation error.",
+ response = ErrorResponse.class),
+ @ApiResponse(
+ code = 404,
+ message = "Not Found. \n The specified role does not exist.",
+ response = ErrorResponse.class),
+ @ApiResponse(
+ code = 415,
+ message = "Unsupported media type. \n The format of the requested entity was not supported.\n",
+ response = ErrorResponse.class),
+ @ApiResponse(
+ code = 500,
+ message = "Internal Server Error. \n Server error occurred while updating the role.",
+ response = ErrorResponse.class)
+ })
+ Response updateRole(
+ @ApiParam(
+ name = "roleName",
+ value = "The name of the role.",
+ required = true,
+ defaultValue = "admin")
+ @PathParam("roleName") String roleName,
+ @ApiParam(
+ name = "role",
+ value = "The properties required to update a role.\n" +
+ "NOTE: Don't change the role and the permissions of the admin user. " +
+ "If you want to try out this API by updating all the properties, create a new role and update the properties accordingly.",
+ required = true) RoleInfo role,
+ @ApiParam(
+ name = "user-store",
+ value = "The name of the user store which the particular role resides in.",
+ required = false)
+ @QueryParam("user-store") String userStoreName);
- @PUT
- @Path("/{roleName}/users")
- @ApiOperation(
- consumes = MediaType.APPLICATION_JSON,
- produces = MediaType.APPLICATION_JSON,
- httpMethod = "PUT",
- value = "Adding Users to a Role",
- notes = "Defining users to a role at the point of creating a new role is optional. " +
- "You can update the users that belong to a given role after you have created " +
- "a role using this REST API.\n" +
- "Example: Your Organization hires 30 new engineers. Updating the role details for each user can " +
- "be cumbersome. Therefore, you can define all the new employees that belong to the engineering " +
- "role using this API.",
- tags = "Role Management",
- extensions = {
- @Extension(properties = {
- @ExtensionProperty(name = Constants.SCOPE, value = "perm:roles:add-users")
+ @DELETE
+ @Path("/{roleName}")
+ @ApiOperation(
+ httpMethod = "DELETE",
+ value = "Deleting a Role",
+ notes = "Roles become obsolete over time due to various reasons. In a situation where your Organization identifies that a specific role is no longer required, you " +
+ "can delete a role using this REST API.",
+ tags = "Role Management",
+ extensions = {
+ @Extension(properties = {
+ @ExtensionProperty(name = Constants.SCOPE, value = "perm:roles:delete")
+ })
+ }
+ )
+ @ApiResponses(value = {
+ @ApiResponse(
+ code = 200,
+ message = "OK. \n Successfully removed the specified role."),
+ @ApiResponse(
+ code = 400,
+ message = "Bad Request. \n Invalid request or validation error.",
+ response = ErrorResponse.class),
+ @ApiResponse(
+ code = 404,
+ message = "Not Found. \n The specified role does not exist.",
+ response = ErrorResponse.class),
+ @ApiResponse(
+ code = 500,
+ message = "Internal Server Error. \n Server error occurred while removing the role.",
+ response = ErrorResponse.class)
+ })
+ Response deleteRole(
+ @ApiParam(
+ name = "roleName",
+ value = "The name of the role that needs to de deleted.\n" +
+ "NOTE: Don't delete the admin role",
+ required = true)
+ @PathParam("roleName") String roleName,
+ @ApiParam(
+ name = "user-store",
+ value = "The name of the user store which the particular role resides in.",
+ required = false)
+ @QueryParam("user-store") String userStoreName);
+
+ @PUT
+ @Path("/{roleName}/users")
+ @ApiOperation(
+ consumes = MediaType.APPLICATION_JSON,
+ produces = MediaType.APPLICATION_JSON,
+ httpMethod = "PUT",
+ value = "Adding Users to a Role",
+ notes = "Defining users to a role at the point of creating a new role is optional. " +
+ "You can update the users that belong to a given role after you have created " +
+ "a role using this REST API.\n" +
+ "Example: Your Organization hires 30 new engineers. Updating the role details for each user can " +
+ "be cumbersome. Therefore, you can define all the new employees that belong to the engineering " +
+ "role using this API.",
+ tags = "Role Management",
+ extensions = {
+ @Extension(properties = {
+ @ExtensionProperty(name = Constants.SCOPE, value = "perm:roles:add-users")
+ })
+ }
+ )
+ @ApiResponses(
+ value = {
+ @ApiResponse(
+ code = 200,
+ message = "OK. \n Successfully added the users to the specified role.",
+ responseHeaders = {
+ @ResponseHeader(
+ name = "Content-Type",
+ description = "Content type of the body"),
+ @ResponseHeader(
+ name = "ETag",
+ description = "Entity Tag of the response resource.\n" +
+ "Used by caches, or in conditional requests."),
+ @ResponseHeader(
+ name = "Last-Modified",
+ description = "Date and time the resource has been modified the last time.\n" +
+ "Used by caches, or in conditional requests.")}),
+ @ApiResponse(
+ code = 400,
+ message = "Bad Request. \n Invalid request or validation error.",
+ response = ErrorResponse.class),
+ @ApiResponse(
+ code = 404,
+ message = "Not Found. \n The specified role does not exist.",
+ response = ErrorResponse.class),
+ @ApiResponse(
+ code = 415,
+ message = "Unsupported media type. \n The format of the requested entity was not supported.\n" +
+ "supported format.",
+ response = ErrorResponse.class),
+ @ApiResponse(
+ code = 500,
+ message = "Internal Server Error. \n " +
+ "Server error occurred while adding the user to the specified role.",
+ response = ErrorResponse.class)
})
- }
- )
- @ApiResponses(
- value = {
- @ApiResponse(
- code = 200,
- message = "OK. \n Successfully added the users to the specified role.",
- responseHeaders = {
- @ResponseHeader(
- name = "Content-Type",
- description = "Content type of the body"),
- @ResponseHeader(
- name = "ETag",
- description = "Entity Tag of the response resource.\n" +
- "Used by caches, or in conditional requests."),
- @ResponseHeader(
- name = "Last-Modified",
- description = "Date and time the resource has been modified the last time.\n" +
- "Used by caches, or in conditional requests.")}),
- @ApiResponse(
- code = 400,
- message = "Bad Request. \n Invalid request or validation error.",
- response = ErrorResponse.class),
- @ApiResponse(
- code = 404,
- message = "Not Found. \n The specified role does not exist.",
- response = ErrorResponse.class),
- @ApiResponse(
- code = 415,
- message = "Unsupported media type. \n The format of the requested entity was not supported.\n" +
- "supported format.",
- response = ErrorResponse.class),
- @ApiResponse(
- code = 500,
- message = "Internal Server Error. \n " +
- "Server error occurred while adding the user to the specified role.",
- response = ErrorResponse.class)
- })
- Response updateUsersOfRole(
- @ApiParam(
- name = "roleName",
- value = "The name of the role.",
- required = true,
- defaultValue = "admin")
- @PathParam("roleName") String roleName,
- @ApiParam(
- name = "user-store",
- value = "The name of the user store which the particular role resides in.",
- required = false)
- @QueryParam("user-store") String userStoreName,
- @ApiParam(
- name = "users",
- value = "Define the users that belong to the role.\n" +
- "Multiple users can be added to a role by using comma separated values. ",
- required = true,
- defaultValue = "[admin]"
- ) List users);
+ Response updateUsersOfRole(
+ @ApiParam(
+ name = "roleName",
+ value = "The name of the role.",
+ required = true,
+ defaultValue = "admin")
+ @PathParam("roleName") String roleName,
+ @ApiParam(
+ name = "user-store",
+ value = "The name of the user store which the particular role resides in.",
+ required = false)
+ @QueryParam("user-store") String userStoreName,
+ @ApiParam(
+ name = "users",
+ value = "Define the users that belong to the role.\n" +
+ "Multiple users can be added to a role by using comma separated values. ",
+ required = true,
+ defaultValue = "[admin]"
+ ) List users);
-}
+ }
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/admin/DeviceTypePublisherAdminService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/admin/DeviceTypePublisherAdminService.java
new file mode 100644
index 0000000000..7914f9d071
--- /dev/null
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/admin/DeviceTypePublisherAdminService.java
@@ -0,0 +1,148 @@
+/*
+ * Copyright (c) 2017, 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.jaxrs.service.api.admin;
+
+
+import io.swagger.annotations.*;
+import org.wso2.carbon.apimgt.annotations.api.Scope;
+import org.wso2.carbon.apimgt.annotations.api.Scopes;
+import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse;
+import org.wso2.carbon.device.mgt.jaxrs.util.Constants;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.Response;
+
+@SwaggerDefinition(
+ info = @Info(
+ version = "1.0.0",
+ title = "",
+ extensions = {
+ @Extension(properties = {
+ @ExtensionProperty(name = "name", value = "DeviceTypePublisherAdminService"),
+ @ExtensionProperty(name = "context", value = "/api/device-mgt/v1.0/admin/devicetype"),
+ })
+ }
+ ),
+ tags = {
+ @Tag(name = "device_management", description = "")
+ }
+)
+@Path("/admin/devicetype")
+@Api(value = "Devicetype deployment Administrative Service", description = "This an API intended to be used to " +
+ "deploy device type components" +
+ "Further, this is strictly restricted to admin users only ")
+@Scopes(
+ scopes = {
+ @Scope(
+ name = "Devicetype deployment",
+ description = "Deploy devicetype",
+ key = "perm:devicetype:deployment",
+ permissions = {"/device-mgt/devicetype/deploy"}
+ )
+ }
+)
+
+public interface DeviceTypePublisherAdminService {
+
+ @POST
+ @Path("/deploy/{type}")
+ @ApiOperation(
+ httpMethod = "POST",
+ value = "Deploy device type\n",
+ notes = "This is an API that can be used to deploy existing device type artifact for tenant",
+ response = Response.class,
+ tags = "Devicetype Deployment Service",
+ extensions = {
+ @Extension(properties = {
+ @ExtensionProperty(name = Constants.SCOPE, value = "perm:devicetype:deployment")
+ })
+ })
+
+ @ApiResponses(value = {
+ @ApiResponse(
+ code = 201,
+ message = "OK. \n Successfully deployed the artifacts.",
+ response = Response.class),
+ @ApiResponse(
+ code = 400,
+ message = "Bad Request. \n Invalid request or validation error.",
+ response = ErrorResponse.class),
+ @ApiResponse(
+ code = 404,
+ message = "Not Found. \n The specified resource does not exist."),
+ @ApiResponse(
+ code = 415,
+ message = "Unsupported media type. \n The entity of the request was in a not supported format."),
+ @ApiResponse(
+ code = 500,
+ message = "Internal Server Error. \n Server error occurred while checking the authorization" +
+ " for a specified set of devices.",
+ response = ErrorResponse.class)
+ })
+
+ Response doPublish(
+ @ApiParam(name = "type",
+ value = "The type of deployment." +
+ "INFO: Deploy artifact with given type.",
+ required = true)
+ @PathParam("type") String type);
+
+ @GET
+ @Path("/deploy/{type}/status")
+ @ApiOperation(
+ httpMethod = "GET",
+ value = "Check the status of device type artifact\n",
+ notes = "This is an API that can be used to check the status of the artifact",
+ response = Response.class,
+ tags = "Devicetype Status Service",
+ extensions = {
+ @Extension(properties = {
+ @ExtensionProperty(name = Constants.SCOPE, value = "perm:devicetype:deployment")
+ })
+ })
+
+ @ApiResponses(value = {
+ @ApiResponse(
+ code = 201,
+ message = "OK. \n Successfully deployed the artifacts.",
+ response = Response.class),
+ @ApiResponse(
+ code = 400,
+ message = "Bad Request. \n Invalid request or validation error.",
+ response = ErrorResponse.class),
+ @ApiResponse(
+ code = 404,
+ message = "Not Found. \n The specified resource does not exist."),
+ @ApiResponse(
+ code = 415,
+ message = "Unsupported media type. \n The entity of the request was in a not supported format."),
+ @ApiResponse(
+ code = 500,
+ message = "Internal Server Error. \n Server error occurred while checking the authorization" +
+ " for a specified set of devices.",
+ response = ErrorResponse.class)
+ })
+
+ Response getStatus(@PathParam("type") String deviceType);
+
+}
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java
index 9b56130540..3f3185a30d 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java
@@ -18,6 +18,7 @@
*/
package org.wso2.carbon.device.mgt.jaxrs.service.impl;
+import io.swagger.annotations.ApiParam;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -34,6 +35,7 @@ import org.wso2.carbon.device.mgt.common.app.mgt.Application;
import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManagementException;
import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorizationException;
import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorizationService;
+import org.wso2.carbon.device.mgt.common.device.details.DeviceLocation;
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException;
import org.wso2.carbon.device.mgt.common.policy.mgt.Policy;
@@ -41,6 +43,8 @@ import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.NonComplianceData;
import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.PolicyComplianceException;
import org.wso2.carbon.device.mgt.common.search.SearchContext;
import org.wso2.carbon.device.mgt.core.app.mgt.ApplicationManagementProviderService;
+import org.wso2.carbon.device.mgt.core.device.details.mgt.DeviceDetailsMgtException;
+import org.wso2.carbon.device.mgt.core.device.details.mgt.DeviceInformationManager;
import org.wso2.carbon.device.mgt.core.search.mgt.SearchManagerService;
import org.wso2.carbon.device.mgt.core.search.mgt.SearchMgtException;
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
@@ -99,8 +103,8 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
if (!StringUtils.isEmpty(name) && !StringUtils.isEmpty(role)) {
return Response.status(Response.Status.BAD_REQUEST).entity(
new ErrorResponse.ErrorResponseBuilder().setMessage("Request contains both name and role " +
- "parameters. Only one is allowed " +
- "at once.").build()).build();
+ "parameters. Only one is allowed " +
+ "at once.").build()).build();
}
// RequestValidationUtil.validateSelectionCriteria(type, user, roleName, ownership, status);
RequestValidationUtil.validatePaginationParameters(offset, limit);
@@ -110,7 +114,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
if (deviceAccessAuthorizationService == null) {
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
new ErrorResponse.ErrorResponseBuilder().setMessage("Device access authorization service is " +
- "failed").build()).build();
+ "failed").build()).build();
}
PaginationRequest request = new PaginationRequest(offset, limit);
PaginationResult result;
@@ -133,7 +137,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
RequestValidationUtil.validateStatus(status);
request.setStatus(status);
}
- if (groupId != 0 ) {
+ if (groupId != 0) {
request.setGroupId(groupId);
}
if (role != null && !role.isEmpty()) {
@@ -155,7 +159,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
request.setOwner(user);
} else {
String msg = "User '" + authorizedUser + "' is not authorized to retrieve devices of '" + user
- + "' user";
+ + "' user";
log.error(msg);
return Response.status(Response.Status.UNAUTHORIZED).entity(
new ErrorResponse.ErrorResponseBuilder().setCode(401l).setMessage(msg).build()).build();
@@ -330,12 +334,12 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
} catch (ParseException e) {
return Response.status(Response.Status.BAD_REQUEST).entity(
new ErrorResponse.ErrorResponseBuilder().setMessage("Invalid date " +
- "string is provided in 'If-Modified-Since' header").build()).build();
+ "string is provided in 'If-Modified-Since' header").build()).build();
}
device = dms.getDevice(new DeviceIdentifier(id, type), sinceDate);
if (device == null) {
return Response.status(Response.Status.NOT_MODIFIED).entity("No device is modified " +
- "after the timestamp provided in 'If-Modified-Since' header").build();
+ "after the timestamp provided in 'If-Modified-Since' header").build();
}
} else {
device = dms.getDevice(new DeviceIdentifier(id, type));
@@ -359,6 +363,32 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
return Response.status(Response.Status.OK).entity(device).build();
}
+ @GET
+ @Path("/{type}/{id}/location")
+ @Override
+ public Response getDeviceLocation(
+ @PathParam("type") @Size(max = 45) String type,
+ @PathParam("id") @Size(max = 45) String id,
+ @HeaderParam("If-Modified-Since") String ifModifiedSince) {
+ DeviceInformationManager informationManager;
+ DeviceLocation deviceLocation;
+ try {
+ DeviceIdentifier deviceIdentifier = new DeviceIdentifier();
+ deviceIdentifier.setId(id);
+ deviceIdentifier.setType(type);
+ informationManager = DeviceMgtAPIUtils.getDeviceInformationManagerService();
+ deviceLocation = informationManager.getDeviceLocation(deviceIdentifier);
+
+ } catch (DeviceDetailsMgtException e) {
+ String msg = "Error occurred while getting the device location.";
+ log.error(msg, e);
+ return Response.serverError().entity(
+ new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
+ }
+ return Response.status(Response.Status.OK).entity(deviceLocation).build();
+
+ }
+
@GET
@Path("/{type}/{id}/features")
@Override
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/RoleManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/RoleManagementServiceImpl.java
index dd6932981f..e947c258c0 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/RoleManagementServiceImpl.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/RoleManagementServiceImpl.java
@@ -30,37 +30,20 @@ import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.FilteringUtil;
import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.RequestValidationUtil;
import org.wso2.carbon.device.mgt.jaxrs.util.DeviceMgtAPIUtils;
import org.wso2.carbon.device.mgt.jaxrs.util.SetReferenceTransformer;
-import org.wso2.carbon.user.api.AuthorizationManager;
-import org.wso2.carbon.user.api.Permission;
-import org.wso2.carbon.user.api.UserRealm;
-import org.wso2.carbon.user.api.UserStoreException;
-import org.wso2.carbon.user.api.UserStoreManager;
+import org.wso2.carbon.user.api.*;
import org.wso2.carbon.user.core.common.AbstractUserStoreManager;
import org.wso2.carbon.user.mgt.UserRealmProxy;
import org.wso2.carbon.user.mgt.common.UIPermissionNode;
import org.wso2.carbon.user.mgt.common.UserAdminException;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
-import javax.ws.rs.HeaderParam;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
+import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.io.UnsupportedEncodingException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URLEncoder;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
+import java.util.*;
import static org.wso2.carbon.device.mgt.jaxrs.util.Constants.PRIMARY_USER_STORE;
@@ -105,6 +88,48 @@ public class RoleManagementServiceImpl implements RoleManagementService {
}
}
+ @GET
+ @Path("/filter/{prefix}")
+ @Override
+ public Response getFilteredRoles(
+ @PathParam("prefix") String prefix,
+ @QueryParam("filter") String filter,
+ @QueryParam("user-store") String userStore,
+ @HeaderParam("If-Modified-Since") String ifModifiedSince,
+ @QueryParam("offset") int offset, @QueryParam("limit") int limit) {
+ RequestValidationUtil.validatePaginationParameters(offset, limit);
+ List finalRoleList;
+ RoleList targetRoles = new RoleList();
+
+ //if user store is null set it to primary
+ if (userStore == null || "".equals(userStore)) {
+ userStore = PRIMARY_USER_STORE;
+ }
+
+ try {
+
+ //Get the total role count that matches the given filter
+ List filteredRoles = getRolesFromUserStore(filter, userStore);
+ finalRoleList = new ArrayList();
+
+ filteredRoles = FilteringUtil.getFilteredList(getRolesFromUserStore(filter, userStore), offset, limit);
+ for (String rolename : filteredRoles){
+ if (rolename.startsWith(prefix)){
+ finalRoleList.add(rolename);
+ }
+ }
+ targetRoles.setCount(finalRoleList.size());
+ targetRoles.setList(finalRoleList);
+
+ return Response.ok().entity(targetRoles).build();
+ } catch (UserStoreException e) {
+ String msg = "Error occurred while retrieving roles from the underlying user stores";
+ log.error(msg, e);
+ return Response.serverError().entity(
+ new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
+ }
+ }
+
@GET
@Path("/{roleName}/permissions")
@Override
@@ -208,7 +233,7 @@ public class RoleManagementServiceImpl implements RoleManagementService {
if (!userStoreManager.isExistingRole(roleName)) {
return Response.status(404).entity(
new ErrorResponse.ErrorResponseBuilder().setMessage("No role exists with the name '" +
- roleName + "'").build()).build();
+ roleName + "'").build()).build();
}
roleInfo.setRoleName(roleName);
roleInfo.setUsers(userStoreManager.getUserListOfRole(roleName));
@@ -275,7 +300,7 @@ public class RoleManagementServiceImpl implements RoleManagementService {
//TODO fix what's returned in the entity
return Response.created(new URI(API_BASE_PATH + "/" + URLEncoder.encode(roleInfo.getRoleName(), "UTF-8"))).
entity("Role '" + roleInfo.getRoleName() + "' has " + "successfully been"
- + " added").build();
+ + " added").build();
} catch (UserStoreException e) {
String msg = "Error occurred while adding role '" + roleInfo.getRoleName() + "'";
log.error(msg, e);
@@ -335,7 +360,7 @@ public class RoleManagementServiceImpl implements RoleManagementService {
//TODO fix what's returned in the entity
return Response.created(new URI(API_BASE_PATH + "/" + URLEncoder.encode(roleName, "UTF-8"))).
entity("Role '" + roleName + "' has " + "successfully been"
- + " added").build();
+ + " added").build();
} catch (UserAdminException e) {
String msg = "Error occurred while retrieving the permissions of role '" + roleName + "'";
log.error(msg, e);
@@ -376,7 +401,7 @@ public class RoleManagementServiceImpl implements RoleManagementService {
if (!userStoreManager.isExistingRole(roleName)) {
return Response.status(404).entity(
new ErrorResponse.ErrorResponseBuilder().setMessage("No role exists with the name '" +
- roleName + "'").build()).build();
+ roleName + "'").build()).build();
}
final AuthorizationManager authorizationManager = userRealm.getAuthorizationManager();
@@ -392,7 +417,7 @@ public class RoleManagementServiceImpl implements RoleManagementService {
if (roleInfo.getUsers() != null) {
SetReferenceTransformer transformer = new SetReferenceTransformer<>();
transformer.transform(Arrays.asList(userStoreManager.getUserListOfRole(newRoleName)),
- Arrays.asList(roleInfo.getUsers()));
+ Arrays.asList(roleInfo.getUsers()));
final String[] usersToAdd = transformer.getObjectsToAdd().toArray(new String[transformer
.getObjectsToAdd().size()]);
final String[] usersToDelete = transformer.getObjectsToRemove().toArray(new String[transformer
@@ -404,7 +429,7 @@ public class RoleManagementServiceImpl implements RoleManagementService {
// Get all role permissions
final UIPermissionNode rolePermissions = this.getAllRolePermissions(roleName, userRealm);
List permissions = new ArrayList();
- final UIPermissionNode emmRolePermissions = (UIPermissionNode)this.getRolePermissions(roleName);
+ final UIPermissionNode emmRolePermissions = (UIPermissionNode) this.getRolePermissions(roleName);
List emmConsolePermissions = new ArrayList();
this.getAuthorizedPermissions(emmRolePermissions, emmConsolePermissions);
emmConsolePermissions.removeAll(new ArrayList(Arrays.asList(roleInfo.getPermissions())));
@@ -413,7 +438,7 @@ public class RoleManagementServiceImpl implements RoleManagementService {
permissions.add(permission);
}
permissions.removeAll(emmConsolePermissions);
- String [] allApplicablePerms = new String[permissions.size()];
+ String[] allApplicablePerms = new String[permissions.size()];
allApplicablePerms = permissions.toArray(allApplicablePerms);
roleInfo.setPermissions(allApplicablePerms);
@@ -428,7 +453,7 @@ public class RoleManagementServiceImpl implements RoleManagementService {
}
//TODO: Need to send the updated role information in the entity back to the client
return Response.status(Response.Status.OK).entity("Role '" + roleInfo.getRoleName() + "' has " +
- "successfully been updated").build();
+ "successfully been updated").build();
} catch (UserStoreException e) {
String msg = "Error occurred while updating role '" + roleName + "'";
log.error(msg, e);
@@ -456,7 +481,7 @@ public class RoleManagementServiceImpl implements RoleManagementService {
if (!userStoreManager.isExistingRole(roleName)) {
return Response.status(404).entity(
new ErrorResponse.ErrorResponseBuilder().setMessage("No role exists with the name '" +
- roleName + "'").build()).build();
+ roleName + "'").build()).build();
}
final AuthorizationManager authorizationManager = userRealm.getAuthorizationManager();
@@ -493,7 +518,7 @@ public class RoleManagementServiceImpl implements RoleManagementService {
}
SetReferenceTransformer transformer = new SetReferenceTransformer<>();
transformer.transform(Arrays.asList(userStoreManager.getUserListOfRole(roleName)),
- users);
+ users);
final String[] usersToAdd = transformer.getObjectsToAdd().toArray(new String[transformer
.getObjectsToAdd().size()]);
final String[] usersToDelete = transformer.getObjectsToRemove().toArray(new String[transformer
@@ -502,7 +527,7 @@ public class RoleManagementServiceImpl implements RoleManagementService {
userStoreManager.updateUserListOfRole(roleName, usersToDelete, usersToAdd);
return Response.status(Response.Status.OK).entity("Role '" + roleName + "' has " +
- "successfully been updated with the user list")
+ "successfully been updated with the user list")
.build();
} catch (UserStoreException e) {
String msg = "Error occurred while updating the users of the role '" + roleName + "'";
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/UserManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/UserManagementServiceImpl.java
index 2b5a2e8d45..ca1ad45d1d 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/UserManagementServiceImpl.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/UserManagementServiceImpl.java
@@ -38,6 +38,8 @@ import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.RequestValidationUtil;
import org.wso2.carbon.device.mgt.jaxrs.util.Constants;
import org.wso2.carbon.device.mgt.jaxrs.util.CredentialManagementResponseBuilder;
import org.wso2.carbon.device.mgt.jaxrs.util.DeviceMgtAPIUtils;
+import org.wso2.carbon.identity.user.store.count.UserStoreCountRetriever;
+import org.wso2.carbon.identity.user.store.count.exception.UserStoreCounterException;
import org.wso2.carbon.user.api.UserStoreException;
import org.wso2.carbon.user.api.UserStoreManager;
import org.wso2.carbon.utils.CarbonUtils;
@@ -395,6 +397,30 @@ public class UserManagementServiceImpl implements UserManagementService {
@Path("/count")
@Override
public Response getUserCount() {
+ try {
+ UserStoreCountRetriever userStoreCountRetrieverService = DeviceMgtAPIUtils.getUserStoreCountRetrieverService();
+ if (userStoreCountRetrieverService != null) {
+ long count = userStoreCountRetrieverService.countUsers("");
+ if (count != -1) {
+ BasicUserInfoList result = new BasicUserInfoList();
+ result.setCount(count);
+ return Response.status(Response.Status.OK).entity(result).build();
+ }
+ }
+ } catch (UserStoreCounterException e) {
+ String msg =
+ "Error occurred while retrieving the count of users that exist within the current tenant";
+ log.error(msg, e);
+ }
+ return getUserCountViaUserStoreManager();
+ }
+
+ /**
+ * This method returns the count of users using UserStoreManager.
+ *
+ * @return user count
+ */
+ private Response getUserCountViaUserStoreManager() {
if (log.isDebugEnabled()) {
log.debug("Getting the user count");
}
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/admin/DeviceTypePublisherAdminServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/admin/DeviceTypePublisherAdminServiceImpl.java
new file mode 100644
index 0000000000..0efa036da0
--- /dev/null
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/admin/DeviceTypePublisherAdminServiceImpl.java
@@ -0,0 +1,311 @@
+/*
+ * Copyright (c) 2017, 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.jaxrs.service.impl.admin;
+
+import org.apache.axis2.client.Options;
+import org.apache.axis2.java.security.SSLProtocolSocketFactory;
+import org.apache.axis2.transport.http.HTTPConstants;
+import org.apache.commons.codec.binary.Base64;
+import org.apache.commons.httpclient.Header;
+import org.apache.commons.httpclient.protocol.Protocol;
+import org.apache.commons.httpclient.protocol.ProtocolSocketFactory;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.wso2.carbon.application.mgt.stub.upload.CarbonAppUploaderStub;
+import org.wso2.carbon.application.mgt.stub.upload.types.carbon.UploadedFileItem;
+import org.wso2.carbon.base.ServerConfiguration;
+import org.wso2.carbon.context.PrivilegedCarbonContext;
+import org.wso2.carbon.core.util.Utils;
+import org.wso2.carbon.device.mgt.jaxrs.service.api.admin.DeviceTypePublisherAdminService;
+import org.wso2.carbon.device.mgt.jaxrs.util.DeviceMgtAPIUtils;
+import org.wso2.carbon.identity.jwt.client.extension.JWTClient;
+import org.wso2.carbon.registry.core.Registry;
+import org.wso2.carbon.registry.core.Resource;
+import org.wso2.carbon.registry.core.ResourceImpl;
+import org.wso2.carbon.registry.core.exceptions.RegistryException;
+import org.wso2.carbon.utils.CarbonUtils;
+
+import javax.activation.DataHandler;
+import javax.net.ssl.KeyManagerFactory;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.TrustManagerFactory;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.core.Response;
+import java.io.*;
+import java.security.KeyManagementException;
+import java.security.KeyStore;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.security.UnrecoverableKeyException;
+import java.security.cert.CertificateException;
+import java.util.ArrayList;
+import java.util.List;
+
+@Path("/admin/devicetype")
+public class DeviceTypePublisherAdminServiceImpl implements DeviceTypePublisherAdminService {
+
+ /**
+ * required soap header for authorization
+ */
+ private static final String AUTHORIZATION_HEADER = "Authorization";
+
+ /**
+ * required soap header value for mutualSSL
+ */
+ private static final String AUTHORIZATION_HEADER_VALUE = "Bearer";
+
+ private static final String KEY_STORE_TYPE = "JKS";
+ /**
+ * Default truststore type of the client
+ */
+ private static final String TRUST_STORE_TYPE = "JKS";
+ /**
+ * Default keymanager type of the client
+ */
+ private static final String KEY_MANAGER_TYPE = "SunX509"; //Default Key Manager Type
+ /**
+ * Default trustmanager type of the client
+ */
+ private static final String TRUST_MANAGER_TYPE = "SunX509"; //Default Trust Manager Type
+
+ private static final String SSLV3 = "SSLv3";
+
+ private KeyStore keyStore;
+ private KeyStore trustStore;
+ private char[] keyStorePassword;
+ private SSLContext sslContext;
+
+ private static final Log log = LogFactory.getLog(DeviceTypePublisherAdminServiceImpl.class);
+ private static final String DEFAULT_RESOURCE_LOCATION = "/resources/devicetypes";
+ private static final String CAR_FILE_LOCATION = CarbonUtils.getCarbonHome() + File.separator + "repository" +
+ File.separator + "resources" + File.separator + "devicetypes";
+ private static final String DAS_PORT = "${iot.analytics.https.port}";
+ private static final String DAS_HOST_NAME = "${iot.analytics.host}";
+ private static final String DEFAULT_HTTP_PROTOCOL = "https";
+ private static final String IOT_MGT_PORT = "${iot.manager.https.port}";
+ private static final String IOT_MGT_HOST_NAME = "${iot.manager.host}";
+ private static final String DAS_URL = DEFAULT_HTTP_PROTOCOL + "://" + DAS_HOST_NAME
+ + ":" + DAS_PORT + "/services/CarbonAppUploader" + "/";
+ private static final String IOT_MGT_URL = DEFAULT_HTTP_PROTOCOL + "://" + IOT_MGT_HOST_NAME
+ + ":" + IOT_MGT_PORT + "/services/CarbonAppUploader" + "/";
+ private static final String MEDIA_TYPE_XML = "application/xml";
+ private static final String DEVICE_MANAGEMENT_TYPE = "device_management";
+
+ @Override
+ @POST
+ @Path("/deploy/{type}")
+ public Response doPublish(@PathParam("type") String type) {
+
+ try {
+ //Getting the tenant Domain
+ String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain();
+ String username = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
+ String tenantAdminUser = username + "@" + tenantDomain;
+
+ String keyStorePassword = ServerConfiguration.getInstance().getFirstProperty("Security.KeyStore.Password");
+ String trustStorePassword = ServerConfiguration.getInstance().getFirstProperty(
+ "Security.TrustStore.Password");
+ String keyStoreLocation = ServerConfiguration.getInstance().getFirstProperty("Security.KeyStore.Location");
+ String trustStoreLocation = ServerConfiguration.getInstance().getFirstProperty(
+ "Security.TrustStore.Location");
+
+ //Call to load the keystore.
+ loadKeyStore(keyStoreLocation, keyStorePassword);
+ //Call to load the TrustStore.
+ loadTrustStore(trustStoreLocation, trustStorePassword);
+ //Create the SSL context with the loaded TrustStore/keystore.
+ initSSLConnection();
+ JWTClient jwtClient = DeviceMgtAPIUtils.getJWTClientManagerService().getJWTClient();
+
+ String authValue = AUTHORIZATION_HEADER_VALUE + " " + new String(Base64.encodeBase64(
+ jwtClient.getJwtToken(tenantAdminUser).getBytes()));
+
+ List list = new ArrayList();
+ Header httpHeader = new Header();
+ httpHeader.setName(AUTHORIZATION_HEADER);
+ httpHeader.setValue(authValue);
+ list.add(httpHeader);//"https"
+
+ File directory = new File(CAR_FILE_LOCATION + File.separator + type);
+ if (directory.isDirectory() && directory.exists()) {
+ UploadedFileItem[] uploadedFileItems = loadCappFromFileSystem(type);
+ if (uploadedFileItems.length > 0) {
+ CarbonAppUploaderStub carbonAppUploaderStub = new CarbonAppUploaderStub(Utils.replaceSystemProperty(
+ IOT_MGT_URL));
+ Options appUploaderOptions = carbonAppUploaderStub._getServiceClient().getOptions();
+ if (appUploaderOptions == null) {
+ appUploaderOptions = new Options();
+ }
+ appUploaderOptions.setProperty(HTTPConstants.HTTP_HEADERS, list);
+ appUploaderOptions.setProperty(HTTPConstants.CUSTOM_PROTOCOL_HANDLER
+ , new Protocol(DEFAULT_HTTP_PROTOCOL, (ProtocolSocketFactory) new SSLProtocolSocketFactory
+ (sslContext), Integer.parseInt(Utils.replaceSystemProperty(IOT_MGT_PORT))));
+
+ carbonAppUploaderStub._getServiceClient().setOptions(appUploaderOptions);
+ carbonAppUploaderStub.uploadApp(uploadedFileItems);
+
+ if (!DEVICE_MANAGEMENT_TYPE.equals(type.toLowerCase())) {
+ carbonAppUploaderStub = new CarbonAppUploaderStub(Utils.replaceSystemProperty(DAS_URL));
+ appUploaderOptions = carbonAppUploaderStub._getServiceClient().getOptions();
+ if (appUploaderOptions == null) {
+ appUploaderOptions = new Options();
+ }
+ appUploaderOptions.setProperty(HTTPConstants.HTTP_HEADERS, list);
+ appUploaderOptions.setProperty(HTTPConstants.CUSTOM_PROTOCOL_HANDLER
+ , new Protocol(DEFAULT_HTTP_PROTOCOL
+ , (ProtocolSocketFactory) new SSLProtocolSocketFactory(sslContext)
+ , Integer.parseInt(Utils.replaceSystemProperty(DAS_PORT))));
+
+ carbonAppUploaderStub._getServiceClient().setOptions(appUploaderOptions);
+ carbonAppUploaderStub.uploadApp(uploadedFileItems);
+ }
+ int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
+ Registry registry = DeviceMgtAPIUtils.getRegistryService().getConfigSystemRegistry(tenantId);
+ if (!registry.resourceExists(DEFAULT_RESOURCE_LOCATION + type + ".exist")) {
+ Resource resource = new ResourceImpl();
+ resource.setContent("");
+ resource.setMediaType(MEDIA_TYPE_XML);
+ registry.put(DEFAULT_RESOURCE_LOCATION + type + ".exist", resource);
+ }
+ }
+ } else {
+ return Response.status(Response.Status.BAD_REQUEST)
+ .entity("\"Error, Artifact does not exist.\"").build();
+ }
+
+ } catch (Exception e) {
+ log.error("Capp deployment failed due to " + e.getMessage(), e);
+ return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
+ "\"Error, Artifact deployment has failed\"").build();
+ }
+
+ return Response.status(Response.Status.CREATED).entity("\"OK. \\n Successfully uploaded the artifacts.\"")
+ .build();
+ }
+
+ @GET
+ @Path("/deploy/{type}/status")
+ @Override
+ public Response getStatus(@PathParam("type") String deviceType) {
+ int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
+ Registry registry = null;
+ try {
+ registry = DeviceMgtAPIUtils.getRegistryService().getConfigSystemRegistry(tenantId);
+ if (registry.resourceExists(DEFAULT_RESOURCE_LOCATION + deviceType + ".exist")) {
+ return Response.status(Response.Status.OK).entity("Exist").build();
+ } else {
+ return Response.status(Response.Status.NO_CONTENT).entity("Does not Exist").build();
+ }
+ } catch (RegistryException e) {
+ log.error("Registry failed to load." + e.getMessage(), e);
+ return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
+ "\"Error, Artifact status check has failed\"").build();
+ }
+ }
+
+ private UploadedFileItem[] loadCappFromFileSystem(String deviceType) throws IOException {
+
+ File directory = new File(CAR_FILE_LOCATION + File.separator + deviceType);
+ File[] carFiles = directory.listFiles(new FilenameFilter() {
+ @Override
+ public boolean accept(File dir, String name) {
+ return name.toLowerCase().endsWith(".car");
+ }
+ });
+ List uploadedFileItemLis = new ArrayList<>();
+ if (carFiles != null) {
+
+ for (File carFile : carFiles) {
+ UploadedFileItem uploadedFileItem = new UploadedFileItem();
+ DataHandler param = new DataHandler(carFile.toURI().toURL());
+ uploadedFileItem.setDataHandler(param);
+ uploadedFileItem.setFileName(carFile.getName());
+ uploadedFileItem.setFileType("jar");
+ uploadedFileItemLis.add(uploadedFileItem);
+ }
+ }
+ UploadedFileItem[] fileItems = new UploadedFileItem[uploadedFileItemLis.size()];
+ fileItems = uploadedFileItemLis.toArray(fileItems);
+ return fileItems;
+ }
+
+ /**
+ * Loads the keystore.
+ *
+ * @param keyStorePath - the path of the keystore
+ * @param ksPassword - the keystore password
+ */
+ private void loadKeyStore(String keyStorePath, String ksPassword)
+ throws KeyStoreException, IOException, CertificateException, NoSuchAlgorithmException {
+ InputStream fis = null;
+ try {
+ keyStorePassword = ksPassword.toCharArray();
+ keyStore = KeyStore.getInstance(KEY_STORE_TYPE);
+ fis = new FileInputStream(keyStorePath);
+ keyStore.load(fis, keyStorePassword);
+ } finally {
+ if (fis != null) {
+ fis.close();
+ }
+ }
+ }
+
+ /**
+ * Loads the trustore
+ *
+ * @param trustStorePath - the trustore path in the filesystem.
+ * @param tsPassword - the truststore password
+ */
+ private void loadTrustStore(String trustStorePath, String tsPassword)
+ throws KeyStoreException, IOException, CertificateException, NoSuchAlgorithmException {
+
+ InputStream fis = null;
+ try {
+ trustStore = KeyStore.getInstance(TRUST_STORE_TYPE);
+ fis = new FileInputStream(trustStorePath);
+ trustStore.load(fis, tsPassword.toCharArray());
+ } finally {
+ if (fis != null) {
+ fis.close();
+ }
+ }
+ }
+
+ /**
+ * Initializes the SSL Context
+ */
+ private void initSSLConnection() throws NoSuchAlgorithmException, UnrecoverableKeyException,
+ KeyStoreException, KeyManagementException {
+ KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance(KEY_MANAGER_TYPE);
+ keyManagerFactory.init(keyStore, keyStorePassword);
+ TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TRUST_MANAGER_TYPE);
+ trustManagerFactory.init(trustStore);
+
+ // Create and initialize SSLContext for HTTPS communication
+ sslContext = SSLContext.getInstance(SSLV3);
+ sslContext.init(keyManagerFactory.getKeyManagers(), trustManagerFactory.getTrustManagers(), null);
+ SSLContext.setDefault(sslContext);
+ }
+
+
+}
+
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/DeviceMgtAPIUtils.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/DeviceMgtAPIUtils.java
index afc03336d5..888b1c42ee 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/DeviceMgtAPIUtils.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/DeviceMgtAPIUtils.java
@@ -29,7 +29,6 @@ import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationEntry;
import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration;
import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfigurationManagementService;
import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagementService;
-import org.wso2.carbon.device.mgt.common.scope.mgt.ScopeManagementService;
import org.wso2.carbon.device.mgt.core.app.mgt.ApplicationManagementProviderService;
import org.wso2.carbon.device.mgt.core.device.details.mgt.DeviceInformationManager;
import org.wso2.carbon.device.mgt.core.search.mgt.SearchManagerService;
@@ -37,13 +36,22 @@ import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
import org.wso2.carbon.device.mgt.core.service.GroupManagementProviderService;
import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse;
import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.InputValidationException;
+import org.wso2.carbon.identity.jwt.client.extension.service.JWTClientManagerService;
+import org.wso2.carbon.identity.user.store.count.AbstractCountRetrieverFactory;
+import org.wso2.carbon.identity.user.store.count.UserStoreCountRetriever;
+import org.wso2.carbon.identity.user.store.count.exception.UserStoreCounterException;
+import org.wso2.carbon.identity.user.store.count.jdbc.JDBCCountRetrieverFactory;
+import org.wso2.carbon.identity.user.store.count.jdbc.internal.InternalCountRetrieverFactory;
import org.wso2.carbon.policy.mgt.common.PolicyMonitoringTaskException;
import org.wso2.carbon.policy.mgt.core.PolicyManagerService;
import org.wso2.carbon.policy.mgt.core.task.TaskScheduleService;
+import org.wso2.carbon.registry.core.service.RegistryService;
import org.wso2.carbon.user.api.AuthorizationManager;
+import org.wso2.carbon.user.api.RealmConfiguration;
import org.wso2.carbon.user.api.UserRealm;
import org.wso2.carbon.user.api.UserStoreException;
import org.wso2.carbon.user.api.UserStoreManager;
+import org.wso2.carbon.user.core.jdbc.JDBCUserStoreManager;
import org.wso2.carbon.user.core.service.RealmService;
import javax.ws.rs.core.MediaType;
@@ -105,6 +113,32 @@ public class DeviceMgtAPIUtils {
return deviceManagementProviderService;
}
+ public static UserStoreCountRetriever getUserStoreCountRetrieverService()
+ throws UserStoreCounterException {
+ PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
+ List