diff --git a/components/user-mgt/org.wso2.carbon.device.mgt.user.common/pom.xml b/components/user-mgt/org.wso2.carbon.device.mgt.user.common/pom.xml
new file mode 100644
index 0000000000..25ee050fe3
--- /dev/null
+++ b/components/user-mgt/org.wso2.carbon.device.mgt.user.common/pom.xml
@@ -0,0 +1,60 @@
+
+
+
+
+
+ user-mgt
+ org.wso2.carbon.devicemgt
+ 0.9.2-SNAPSHOT
+ ../pom.xml
+
+ 4.0.0
+
+ org.wso2.carbon.devicemgt
+ org.wso2.carbon.device.mgt.user.common
+ 0.9.2-SNAPSHOT
+ bundle
+
+
+
+ org.apache.felix
+ maven-bundle-plugin
+ 1.4.0
+ true
+
+
+ ${project.artifactId}
+ ${project.artifactId}
+ ${carbon.device.mgt.version}
+ Device Management User Common Bundle
+
+ org.wso2.carbon.device.mgt.user.common.*
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/components/user-mgt/org.wso2.carbon.device.mgt.user.common/src/main/java/org/wso2/carbon/device/mgt/user/common/Claims.java b/components/user-mgt/org.wso2.carbon.device.mgt.user.common/src/main/java/org/wso2/carbon/device/mgt/user/common/Claims.java
new file mode 100644
index 0000000000..b398522c45
--- /dev/null
+++ b/components/user-mgt/org.wso2.carbon.device.mgt.user.common/src/main/java/org/wso2/carbon/device/mgt/user/common/Claims.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+
+package org.wso2.carbon.device.mgt.user.common;
+
+public class Claims {
+
+ private String dialectUrl;
+ private String description;
+ private String claimUrl;
+ private String value;
+
+ public String getDialectUrl() {
+ return dialectUrl;
+ }
+
+ public void setDialectUrl(String dialectUrl) {
+ this.dialectUrl = dialectUrl;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public String getClaimUrl() {
+ return claimUrl;
+ }
+
+ public void setClaimUrl(String claimUrl) {
+ this.claimUrl = claimUrl;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+}
diff --git a/components/user-mgt/org.wso2.carbon.device.mgt.user.common/src/main/java/org/wso2/carbon/device/mgt/user/common/Role.java b/components/user-mgt/org.wso2.carbon.device.mgt.user.common/src/main/java/org/wso2/carbon/device/mgt/user/common/Role.java
new file mode 100644
index 0000000000..76ea260813
--- /dev/null
+++ b/components/user-mgt/org.wso2.carbon.device.mgt.user.common/src/main/java/org/wso2/carbon/device/mgt/user/common/Role.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.wso2.carbon.device.mgt.user.common;
+
+public class Role {
+
+ private String roleName;
+
+ public Role(String roleName) {
+ this.roleName = roleName;
+ }
+
+ public String getRoleName() {
+ return roleName;
+ }
+
+ public void setRoleName(String roleName) {
+ this.roleName = roleName;
+ }
+
+}
diff --git a/components/user-mgt/org.wso2.carbon.device.mgt.user.common/src/main/java/org/wso2/carbon/device/mgt/user/common/User.java b/components/user-mgt/org.wso2.carbon.device.mgt.user.common/src/main/java/org/wso2/carbon/device/mgt/user/common/User.java
new file mode 100644
index 0000000000..19e8682fb5
--- /dev/null
+++ b/components/user-mgt/org.wso2.carbon.device.mgt.user.common/src/main/java/org/wso2/carbon/device/mgt/user/common/User.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.wso2.carbon.device.mgt.user.common;
+
+import java.util.ArrayList;
+
+public class User {
+
+ private String userName;
+ private String roleName;
+ private ArrayList claimList;
+
+ public User(String userName) {
+ this.userName = userName;
+ }
+
+ public User(String userName, String roleName) {
+ this.userName = userName;
+ this.roleName = roleName;
+ }
+
+ public String getUserName() {
+ return userName;
+ }
+
+ public void setUserName(String userName) {
+ this.userName = userName;
+ }
+
+ public String getRoleName() {
+ return roleName;
+ }
+
+ public void setRoleName(String roleName) {
+ this.roleName = roleName;
+ }
+
+ public ArrayList getClaimList() {
+ return claimList;
+ }
+
+ public void setClaimList(ArrayList claimList) {
+ this.claimList = claimList;
+ }
+}
diff --git a/components/user-mgt/org.wso2.carbon.device.mgt.user.common/src/main/java/org/wso2/carbon/device/mgt/user/common/UserManagementException.java b/components/user-mgt/org.wso2.carbon.device.mgt.user.common/src/main/java/org/wso2/carbon/device/mgt/user/common/UserManagementException.java
new file mode 100644
index 0000000000..45989b1908
--- /dev/null
+++ b/components/user-mgt/org.wso2.carbon.device.mgt.user.common/src/main/java/org/wso2/carbon/device/mgt/user/common/UserManagementException.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.wso2.carbon.device.mgt.user.common;
+
+public class UserManagementException extends Exception{
+
+ private static final long serialVersionUID = -312678248574816874L;
+ private String errorMessage;
+
+ public String getErrorMessage() {
+ return errorMessage;
+ }
+
+ public void setErrorMessage(String errorMessage) {
+ this.errorMessage = errorMessage;
+ }
+
+ public UserManagementException(String msg, Exception nestedEx) {
+ super(msg, nestedEx);
+ setErrorMessage(msg);
+ }
+
+ public UserManagementException(String message, Throwable cause) {
+ super(message, cause);
+ setErrorMessage(message);
+ }
+
+ public UserManagementException(String msg) {
+ super(msg);
+ setErrorMessage(msg);
+ }
+
+ public UserManagementException() {
+ super();
+ }
+
+ public UserManagementException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/components/user-mgt/org.wso2.carbon.device.mgt.user.core/pom.xml b/components/user-mgt/org.wso2.carbon.device.mgt.user.core/pom.xml
new file mode 100644
index 0000000000..d7fdee7ade
--- /dev/null
+++ b/components/user-mgt/org.wso2.carbon.device.mgt.user.core/pom.xml
@@ -0,0 +1,116 @@
+
+
+
+
+ user-mgt
+ org.wso2.carbon.devicemgt
+ 0.9.2-SNAPSHOT
+ ../pom.xml
+
+ 4.0.0
+
+ org.wso2.carbon.devicemgt
+ org.wso2.carbon.device.mgt.user.core
+ 0.9.2-SNAPSHOT
+ bundle
+ WSO2 Carbon - Device Management user core
+ WSO2 Carbon - Device Management user core
+ http://wso2.org
+
+
+
+
+ org.apache.felix
+ maven-scr-plugin
+
+
+ org.apache.felix
+ maven-bundle-plugin
+ 1.4.0
+ true
+
+
+ ${project.artifactId}
+ ${project.artifactId}
+ ${carbon.device.mgt.version}
+ Device Management Core User Bundle
+ org.wso2.carbon.device.mgt.user.core.internal
+
+ org.wso2.carbon.device.mgt.user.common.*,
+ org.wso2.carbon.user.core.*,
+ org.apache.commons.logging.*,
+ org.osgi.framework.*,
+ org.osgi.service.component.*,
+ org.wso2.carbon.user.api.*
+
+
+ !org.wso2.carbon.device.mgt.user.core.internal,
+ org.wso2.carbon.device.mgt.user.core.*
+
+
+
+
+
+
+
+
+
+ org.wso2.carbon.devicemgt
+ org.wso2.carbon.device.mgt.user.common
+
+
+ org.wso2.carbon
+ org.wso2.carbon.user.core
+
+
+ org.wso2.carbon
+ org.wso2.carbon.logging
+
+
+ org.eclipse.osgi
+ org.eclipse.osgi
+
+
+ org.wso2.carbon.devicemgt
+ org.wso2.carbon.device.mgt.common
+
+
+ org.wso2.carbon
+ org.wso2.carbon.utils
+
+
+ org.wso2.carbon
+ org.wso2.carbon.core
+
+
+ org.wso2.carbon
+ org.wso2.carbon.user.core
+
+
+ org.wso2.carbon
+ org.wso2.carbon.user.api
+
+
+ org.wso2.carbon
+ org.wso2.carbon.base
+
+
+
\ No newline at end of file
diff --git a/components/user-mgt/org.wso2.carbon.device.mgt.user.core/src/main/java/org/wso2/carbon/device/mgt/user/core/UserManager.java b/components/user-mgt/org.wso2.carbon.device.mgt.user.core/src/main/java/org/wso2/carbon/device/mgt/user/core/UserManager.java
new file mode 100644
index 0000000000..f73be18c56
--- /dev/null
+++ b/components/user-mgt/org.wso2.carbon.device.mgt.user.core/src/main/java/org/wso2/carbon/device/mgt/user/core/UserManager.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.wso2.carbon.device.mgt.user.core;
+
+import org.wso2.carbon.device.mgt.user.common.Role;
+import org.wso2.carbon.device.mgt.user.common.User;
+import org.wso2.carbon.device.mgt.user.common.UserManagementException;
+
+import java.util.List;
+
+public interface UserManager {
+ public List getUsersForTenantAndRole(int tenantId, String roleName) throws UserManagementException;
+ public List getRolesForTenant(int tenantId) throws UserManagementException;
+ public List getUsersForTenant(int tenantId) throws UserManagementException;
+}
diff --git a/components/user-mgt/org.wso2.carbon.device.mgt.user.core/src/main/java/org/wso2/carbon/device/mgt/user/core/UserManagerImpl.java b/components/user-mgt/org.wso2.carbon.device.mgt.user.core/src/main/java/org/wso2/carbon/device/mgt/user/core/UserManagerImpl.java
new file mode 100644
index 0000000000..fc7a2d3210
--- /dev/null
+++ b/components/user-mgt/org.wso2.carbon.device.mgt.user.core/src/main/java/org/wso2/carbon/device/mgt/user/core/UserManagerImpl.java
@@ -0,0 +1,133 @@
+/*
+ * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+package org.wso2.carbon.device.mgt.user.core;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.wso2.carbon.device.mgt.user.common.Claims;
+import org.wso2.carbon.device.mgt.user.common.Role;
+import org.wso2.carbon.device.mgt.user.common.User;
+import org.wso2.carbon.device.mgt.user.common.UserManagementException;
+import org.wso2.carbon.device.mgt.user.core.internal.DeviceMgtUserDataHolder;
+import org.wso2.carbon.user.api.Claim;
+import org.wso2.carbon.user.api.UserStoreException;
+import org.wso2.carbon.user.api.UserStoreManager;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class UserManagerImpl implements UserManager {
+
+ private static Log log = LogFactory.getLog(UserManagerImpl.class);
+
+ @Override
+ public List getUsersForTenantAndRole(int tenantId, String roleName) throws UserManagementException {
+
+ UserStoreManager userStoreManager;
+ String[] userNames;
+ ArrayList usersList = new ArrayList();
+
+ try {
+ userStoreManager = DeviceMgtUserDataHolder.getInstance().getRealmService().getTenantUserRealm(tenantId)
+ .getUserStoreManager();
+
+ userNames = userStoreManager.getUserListOfRole(roleName);
+ User newUser;
+ for (String userName : userNames) {
+ newUser = new User(userName);
+ setUserClaims(newUser, userStoreManager.getUserClaimValues(userName, null));
+ usersList.add(newUser);
+ }
+ } catch (UserStoreException userStoreEx) {
+ String errorMsg = "User store error in fetching user list for role and tenant tenant id:" + tenantId
+ + " role name:" + roleName;
+ log.error(errorMsg, userStoreEx);
+ throw new UserManagementException(errorMsg, userStoreEx);
+ }
+ return usersList;
+ }
+
+ @Override
+ public List getRolesForTenant(int tenantId) throws UserManagementException {
+
+ String[] roleNames;
+ ArrayList rolesList = new ArrayList();
+ Role newRole;
+ try {
+ UserStoreManager userStoreManager = DeviceMgtUserDataHolder.getInstance().getRealmService()
+ .getTenantUserRealm(tenantId)
+ .getUserStoreManager();
+
+ roleNames = userStoreManager.getRoleNames();
+ for (String roleName : roleNames) {
+ newRole = new Role(roleName);
+ rolesList.add(newRole);
+ }
+
+ } catch (UserStoreException userStoreEx) {
+ String errorMsg = "User store error in fetching user list for role and tenant tenant id:" + tenantId;
+ log.error(errorMsg, userStoreEx);
+ throw new UserManagementException(errorMsg, userStoreEx);
+ }
+ return rolesList;
+ }
+
+ @Override
+ public List getUsersForTenant(int tenantId) throws UserManagementException {
+
+ UserStoreManager userStoreManager;
+ String[] userNames;
+ ArrayList usersList = new ArrayList();
+
+ try {
+ userStoreManager = DeviceMgtUserDataHolder.getInstance().getRealmService().getTenantUserRealm(tenantId)
+ .getUserStoreManager();
+
+ userNames = userStoreManager.listUsers("",-1);
+ User newUser;
+ for (String userName : userNames) {
+ newUser = new User(userName);
+ setUserClaims(newUser, userStoreManager.getUserClaimValues(userName, null));
+ usersList.add(newUser);
+ }
+ } catch (UserStoreException userStoreEx) {
+ String errorMsg = "User store error in fetching user list for tenant id:" + tenantId;
+ log.error(errorMsg, userStoreEx);
+ throw new UserManagementException(errorMsg, userStoreEx);
+ }
+
+ return usersList;
+ }
+
+ private void setUserClaims(User newUser, Claim[] userClaimValues) {
+
+ Claims userClaims;
+ ArrayList claimsList = new ArrayList();
+ for (Claim claim : userClaimValues) {
+ userClaims = new Claims();
+ userClaims.setClaimUrl(claim.getClaimUri());
+ userClaims.setDescription(claim.getDescription());
+ userClaims.setDialectUrl(claim.getDialectURI());
+ userClaims.setValue(claim.getValue());
+ claimsList.add(userClaims);
+ }
+ newUser.setClaimList(claimsList);
+ }
+
+}
diff --git a/components/user-mgt/org.wso2.carbon.device.mgt.user.core/src/main/java/org/wso2/carbon/device/mgt/user/core/internal/DeviceMgtUserDataHolder.java b/components/user-mgt/org.wso2.carbon.device.mgt.user.core/src/main/java/org/wso2/carbon/device/mgt/user/core/internal/DeviceMgtUserDataHolder.java
new file mode 100644
index 0000000000..70e31cb3a1
--- /dev/null
+++ b/components/user-mgt/org.wso2.carbon.device.mgt.user.core/src/main/java/org/wso2/carbon/device/mgt/user/core/internal/DeviceMgtUserDataHolder.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.wso2.carbon.device.mgt.user.core.internal;
+
+import org.wso2.carbon.device.mgt.user.core.UserManager;
+import org.wso2.carbon.user.core.service.RealmService;
+import org.wso2.carbon.user.core.tenant.TenantManager;
+
+public class DeviceMgtUserDataHolder {
+
+ private RealmService realmService;
+ private TenantManager tenantManager;
+ private static DeviceMgtUserDataHolder thisInstance = new DeviceMgtUserDataHolder();
+ private UserManager userManager;
+
+ private DeviceMgtUserDataHolder() {
+ }
+
+ public static DeviceMgtUserDataHolder getInstance() {
+ return thisInstance;
+ }
+
+ public RealmService getRealmService() {
+ return realmService;
+ }
+
+ private void setTenantManager(RealmService realmService) {
+ if (realmService == null) {
+ throw new IllegalStateException("Realm service is not initialized properly");
+ }
+ this.tenantManager = realmService.getTenantManager();
+ }
+
+ public void setRealmService(RealmService realmService) {
+ this.realmService = realmService;
+ this.setTenantManager(realmService);
+ }
+
+ public TenantManager getTenantManager() {
+ return tenantManager;
+ }
+
+ public UserManager getUserManager() {
+ return userManager;
+ }
+
+ public void setUserManager(UserManager userManager) {
+ this.userManager = userManager;
+ }
+}
diff --git a/components/user-mgt/org.wso2.carbon.device.mgt.user.core/src/main/java/org/wso2/carbon/device/mgt/user/core/internal/DeviceMgtUserServiceComponent.java b/components/user-mgt/org.wso2.carbon.device.mgt.user.core/src/main/java/org/wso2/carbon/device/mgt/user/core/internal/DeviceMgtUserServiceComponent.java
new file mode 100644
index 0000000000..ceb7137a02
--- /dev/null
+++ b/components/user-mgt/org.wso2.carbon.device.mgt.user.core/src/main/java/org/wso2/carbon/device/mgt/user/core/internal/DeviceMgtUserServiceComponent.java
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.wso2.carbon.device.mgt.user.core.internal;
+
+
+import org.osgi.service.component.ComponentContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.osgi.framework.BundleContext;
+import org.wso2.carbon.device.mgt.user.core.UserManager;
+import org.wso2.carbon.device.mgt.user.core.UserManagerImpl;
+import org.wso2.carbon.device.mgt.user.core.service.UserManagementService;
+import org.wso2.carbon.user.core.service.RealmService;
+
+
+/**
+ * @scr.component name="org.wso2.carbon.device.manager" immediate="true"
+ * @scr.reference name="user.realmservice.default"
+ * interface="org.wso2.carbon.user.core.service.RealmService"
+ * cardinality="1..1"
+ * policy="dynamic"
+ * bind="setRealmService"
+ * unbind="unsetRealmService"
+ */
+public class DeviceMgtUserServiceComponent {
+
+ private static Log log = LogFactory.getLog(DeviceMgtUserServiceComponent.class);
+
+ protected void activate(ComponentContext componentContext) {
+ try {
+ if (log.isDebugEnabled()) {
+ log.debug("Initializing user management core bundle");
+ }
+
+ UserManager userMgr = new UserManagerImpl();
+ DeviceMgtUserDataHolder.getInstance().setUserManager(userMgr);
+
+ if (log.isDebugEnabled()) {
+ log.debug("Registering OSGi service User Management Service");
+ }
+ /* Registering User Management service */
+ BundleContext bundleContext = componentContext.getBundleContext();
+ bundleContext.registerService(UserManagementService.class.getName(),
+ new UserManagementService(), null);
+ if (log.isDebugEnabled()) {
+ log.debug("User management core bundle has been successfully initialized");
+ }
+ } catch (Throwable e) {
+ String msg = "Error occurred while initializing user management core bundle";
+ log.error(msg, e);
+ }
+ }
+ /**
+ * Sets Realm Service.
+ *
+ * @param realmService An instance of RealmService
+ */
+ protected void setRealmService(RealmService realmService) {
+ DeviceMgtUserDataHolder.getInstance().setRealmService(realmService);
+ }
+
+ /**
+ * Un sets Realm Service.
+ *
+ * @param realmService An instance of RealmService
+ */
+ protected void unsetRealmService(RealmService realmService) {
+ DeviceMgtUserDataHolder.getInstance().setRealmService(null);
+ }
+
+}
diff --git a/components/user-mgt/org.wso2.carbon.device.mgt.user.core/src/main/java/org/wso2/carbon/device/mgt/user/core/service/UserManagementService.java b/components/user-mgt/org.wso2.carbon.device.mgt.user.core/src/main/java/org/wso2/carbon/device/mgt/user/core/service/UserManagementService.java
new file mode 100644
index 0000000000..5e051f2640
--- /dev/null
+++ b/components/user-mgt/org.wso2.carbon.device.mgt.user.core/src/main/java/org/wso2/carbon/device/mgt/user/core/service/UserManagementService.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+
+package org.wso2.carbon.device.mgt.user.core.service;
+
+import org.wso2.carbon.device.mgt.user.common.Role;
+import org.wso2.carbon.device.mgt.user.common.User;
+import org.wso2.carbon.device.mgt.user.common.UserManagementException;
+import org.wso2.carbon.device.mgt.user.core.UserManager;
+import org.wso2.carbon.device.mgt.user.core.internal.DeviceMgtUserDataHolder;
+
+import java.util.List;
+
+public class UserManagementService implements UserManager{
+
+ @Override
+ public List getUsersForTenantAndRole(int tenantId, String roleName) throws UserManagementException {
+ return DeviceMgtUserDataHolder.getInstance().getUserManager().getUsersForTenantAndRole(tenantId, roleName);
+ }
+
+ @Override
+ public List getRolesForTenant(int tenantId) throws UserManagementException {
+ return DeviceMgtUserDataHolder.getInstance().getUserManager().getRolesForTenant(tenantId);
+ }
+
+ @Override
+ public List getUsersForTenant(int tenantId) throws UserManagementException {
+ return DeviceMgtUserDataHolder.getInstance().getUserManager().getUsersForTenant(tenantId);
+ }
+}
diff --git a/components/user-mgt/pom.xml b/components/user-mgt/pom.xml
new file mode 100644
index 0000000000..3c0e10a272
--- /dev/null
+++ b/components/user-mgt/pom.xml
@@ -0,0 +1,61 @@
+
+
+
+
+ carbon-devicemgt
+ org.wso2.carbon.devicemgt
+ 0.9.2-SNAPSHOT
+ ../../pom.xml
+
+ 4.0.0
+
+ org.wso2.carbon.devicemgt
+ user-mgt
+ pom
+ 0.9.2-SNAPSHOT
+ WSO2 Carbon - Device Management User Component
+ http://wso2.org
+
+
+ org.wso2.carbon.device.mgt.user.common
+ org.wso2.carbon.device.mgt.user.core
+
+
+
+
+
+
+ org.apache.felix
+ maven-scr-plugin
+ 1.7.2
+
+
+ generate-scr-scrdescriptor
+
+ scr
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/features/user-mgt/org.wso2.carbon.devicemgt.user.server.feature/pom.xml b/features/user-mgt/org.wso2.carbon.devicemgt.user.server.feature/pom.xml
new file mode 100644
index 0000000000..ace0db9693
--- /dev/null
+++ b/features/user-mgt/org.wso2.carbon.devicemgt.user.server.feature/pom.xml
@@ -0,0 +1,117 @@
+
+
+
+
+
+ user-mgt-feature
+ org.wso2.carbon.devicemgt
+ 0.9.2-SNAPSHOT
+ ../pom.xml
+
+ 4.0.0
+
+ org.wso2.carbon.devicemgt
+ org.wso2.carbon.devicemgt.user.server.feature
+ pom
+ 0.9.2-SNAPSHOT
+ WSO2 Carbon - User Management Server Feature
+ http://wso2.org
+ This feature contains the core bundles required for Back-end Device Management User
+ related functionality
+
+
+
+
+ org.wso2.carbon.devicemgt
+ org.wso2.carbon.device.mgt.user.core
+
+
+ org.wso2.carbon.devicemgt
+ org.wso2.carbon.device.mgt.user.common
+
+
+
+
+
+
+ maven-resources-plugin
+ 2.6
+
+
+ copy-resources
+ generate-resources
+
+ copy-resources
+
+
+ src/main/resources
+
+
+ resources
+
+ build.properties
+ p2.inf
+
+
+
+
+
+
+
+
+ org.wso2.maven
+ carbon-p2-plugin
+ ${carbon.p2.plugin.version}
+
+
+ p2-feature-generation
+ package
+
+ p2-feature-gen
+
+
+ org.wso2.carbon.devicemgt.user.server
+ ../../../features/etc/feature.properties
+
+
+ org.wso2.carbon.p2.category.type:server
+ org.eclipse.equinox.p2.type.group:false
+
+
+
+ org.wso2.carbon.devicemgt:org.wso2.carbon.device.mgt.user.core:${carbon.device.mgt.version}
+
+ org.wso2.carbon.devicemgt:org.wso2.carbon.device.mgt.user.common:${carbon.device.mgt.version}
+
+
+
+ org.wso2.carbon.core.server:${carbon.kernel.version}
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/features/user-mgt/org.wso2.carbon.devicemgt.user.server.feature/src/main/resources/build.properties b/features/user-mgt/org.wso2.carbon.devicemgt.user.server.feature/src/main/resources/build.properties
new file mode 100644
index 0000000000..9c86577d76
--- /dev/null
+++ b/features/user-mgt/org.wso2.carbon.devicemgt.user.server.feature/src/main/resources/build.properties
@@ -0,0 +1 @@
+custom = true
diff --git a/features/user-mgt/org.wso2.carbon.devicemgt.user.server.feature/src/main/resources/p2.inf b/features/user-mgt/org.wso2.carbon.devicemgt.user.server.feature/src/main/resources/p2.inf
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/features/user-mgt/pom.xml b/features/user-mgt/pom.xml
new file mode 100644
index 0000000000..1f916bd68a
--- /dev/null
+++ b/features/user-mgt/pom.xml
@@ -0,0 +1,47 @@
+
+
+
+
+
+ org.wso2.carbon.devicemgt
+ carbon-devicemgt
+ 0.9.2-SNAPSHOT
+ ../../pom.xml
+
+ 4.0.0
+
+ org.wso2.carbon.devicemgt
+ user-mgt-feature
+ 0.9.2-SNAPSHOT
+
+ pom
+ WSO2 Carbon - User Management Feature
+ http://wso2.org
+
+
+
+ org.wso2.carbon.devicemgt.user.server.feature
+
+
+
\ No newline at end of file