diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml index 8b7f1a2d67c..1031b7c57a4 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml @@ -83,8 +83,6 @@ org.wso2.carbon.identity.oauth.stub, org.wso2.carbon.identity.oauth.stub.dto, org.wso2.carbon.ndatasource.core, - org.wso2.carbon.device.mgt.user.core.*, - org.wso2.carbon.device.mgt.user.common, !org.wso2.carbon.device.mgt.core.internal, @@ -124,14 +122,6 @@ org.wso2.carbon.devicemgt org.wso2.carbon.device.mgt.common - - org.wso2.carbon.devicemgt - org.wso2.carbon.device.mgt.user.core - - - org.wso2.carbon.devicemgt - org.wso2.carbon.device.mgt.user.common - org.wso2.carbon org.wso2.carbon.logging diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementDataHolder.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementDataHolder.java index 2677e7704c4..c7b10f63040 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementDataHolder.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementDataHolder.java @@ -26,7 +26,6 @@ import org.wso2.carbon.device.mgt.core.api.mgt.APIPublisherService; import org.wso2.carbon.device.mgt.core.app.mgt.config.AppManagementConfig; import org.wso2.carbon.device.mgt.core.config.license.LicenseConfig; import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; -import org.wso2.carbon.device.mgt.user.core.UserManager; import org.wso2.carbon.registry.core.service.RegistryService; import org.wso2.carbon.user.core.service.RealmService; import org.wso2.carbon.user.core.tenant.TenantManager; @@ -43,7 +42,6 @@ public class DeviceManagementDataHolder { private ApplicationManager appManager; private AppManagementConfig appManagerConfig; private OperationManager operationManager; - private UserManager userManager; private static DeviceManagementDataHolder thisInstance = new DeviceManagementDataHolder(); @@ -138,12 +136,4 @@ public class DeviceManagementDataHolder { this.operationManager = operationManager; } - - public UserManager getUserManager() { - return userManager; - } - - public void setUserManager(UserManager userManager) { - this.userManager = userManager; - } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java index a9dfd64fe77..38d6a6f8f23 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java @@ -38,6 +38,7 @@ import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder; import org.wso2.carbon.device.mgt.core.internal.DeviceManagementServiceComponent; import org.wso2.carbon.device.mgt.core.internal.EmailServiceDataHolder; import org.wso2.carbon.device.mgt.core.internal.PluginInitializationListener; +import org.wso2.carbon.user.api.UserStoreException; import java.io.IOException; import java.net.URLDecoder; @@ -537,31 +538,28 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv } @Override - public List getAllDevicesOfRole(String roleName) throws DeviceManagementException { + public List getAllDevicesOfRole(String role) throws DeviceManagementException { List devices = new ArrayList(); - List users; + String[] users; int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); - //Obtaining the list of users of role try { - users = DeviceManagementDataHolder.getInstance().getUserManager().getUsersForTenantAndRole( - tenantId, roleName); - } catch (org.wso2.carbon.device.mgt.user.common.UserManagementException e) { - throw new DeviceManagementException("Error occurred while obtaining the users of role '" - + roleName + "'", e); + users = + DeviceManagementDataHolder.getInstance().getRealmService().getTenantUserRealm( + tenantId).getUserStoreManager().getUserListOfRole(role); + } catch (UserStoreException e) { + throw new DeviceManagementException("Error occurred while obtaining the users, who are assigned " + + "with the role '"+ role + "'", e); } - //Obtaining the devices per user List userDevices; - for (org.wso2.carbon.device.mgt.user.common.User user : users) { - String username = null; + for (String user : users) { userDevices = new ArrayList(); try { DeviceManagementDAOFactory.getConnection(); - username = user.getUserName(); - userDevices = deviceDAO.getDeviceListOfUser(username, tenantId); + userDevices = deviceDAO.getDeviceListOfUser(user, tenantId); } catch (DeviceManagementDAOException e) { - log.error("Error occurred while obtaining the devices of user '" + username + "'", e); + log.error("Error occurred while obtaining the devices of user '" + user + "'", e); } finally { try { DeviceManagementDAOFactory.closeConnection(); @@ -577,7 +575,6 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv device.setProperties(dmsDevice.getProperties()); devices.add(device); } - } return devices; } 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 deleted file mode 100644 index 1bd80d2e0ce..00000000000 --- a/components/user-mgt/org.wso2.carbon.device.mgt.user.common/pom.xml +++ /dev/null @@ -1,57 +0,0 @@ - - - - - - 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 deleted file mode 100644 index b398522c450..00000000000 --- a/components/user-mgt/org.wso2.carbon.device.mgt.user.common/src/main/java/org/wso2/carbon/device/mgt/user/common/Claims.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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 deleted file mode 100644 index 76ea260813b..00000000000 --- a/components/user-mgt/org.wso2.carbon.device.mgt.user.common/src/main/java/org/wso2/carbon/device/mgt/user/common/Role.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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 deleted file mode 100644 index 057bd2019f5..00000000000 --- a/components/user-mgt/org.wso2.carbon.device.mgt.user.common/src/main/java/org/wso2/carbon/device/mgt/user/common/User.java +++ /dev/null @@ -1,252 +0,0 @@ -/* - * 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 String firstName; - private String email; - private String lastName; - private String streatAddress; - private String locality; - private String region; - private String postalCode; - private String country; - private String hone; - private String im; - private String organization; - private String url; - private String title; - private String mobile; - private String nickName; - private String dateOfBirth; - private String gender; - private String accountStatus; - private String challengeQuestion; - private String identityClaimUri; - private String tempEmailAddress; - - - 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; - } - - public String getFirstName() { - return firstName; - } - - public void setFirstName(String firstName) { - this.firstName = firstName; - } - - public String getEmail() { - return email; - } - - public void setEmail(String email) { - this.email = email; - } - - public String getLastName() { - return lastName; - } - - public void setLastName(String lastName) { - this.lastName = lastName; - } - - public String getStreatAddress() { - return streatAddress; - } - - public void setStreatAddress(String streatAddress) { - this.streatAddress = streatAddress; - } - - public String getLocality() { - return locality; - } - - public void setLocality(String locality) { - this.locality = locality; - } - - public String getRegion() { - return region; - } - - public void setRegion(String region) { - this.region = region; - } - - public String getPostalCode() { - return postalCode; - } - - public void setPostalCode(String postalCode) { - this.postalCode = postalCode; - } - - public String getCountry() { - return country; - } - - public void setCountry(String country) { - this.country = country; - } - - public String getHone() { - return hone; - } - - public void setHone(String hone) { - this.hone = hone; - } - - public String getIm() { - return im; - } - - public void setIm(String im) { - this.im = im; - } - - public String getOrganization() { - return organization; - } - - public void setOrganization(String organization) { - this.organization = organization; - } - - public String getUrl() { - return url; - } - - public void setUrl(String url) { - this.url = url; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getMobile() { - return mobile; - } - - public void setMobile(String mobile) { - this.mobile = mobile; - } - - public String getNickName() { - return nickName; - } - - public void setNickName(String nickName) { - this.nickName = nickName; - } - - public String getDateOfBirth() { - return dateOfBirth; - } - - public void setDateOfBirth(String dateOfBirth) { - this.dateOfBirth = dateOfBirth; - } - - public String getGender() { - return gender; - } - - public void setGender(String gender) { - this.gender = gender; - } - - public String getAccountStatus() { - return accountStatus; - } - - public void setAccountStatus(String accountStatus) { - this.accountStatus = accountStatus; - } - - public String getChallengeQuestion() { - return challengeQuestion; - } - - public void setChallengeQuestion(String challengeQuestion) { - this.challengeQuestion = challengeQuestion; - } - - public String getIdentityClaimUri() { - return identityClaimUri; - } - - public void setIdentityClaimUri(String identityClaimUri) { - this.identityClaimUri = identityClaimUri; - } - - public String getTempEmailAddress() { - return tempEmailAddress; - } - - public void setTempEmailAddress(String tempEmailAddress) { - this.tempEmailAddress = tempEmailAddress; - } -} 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 deleted file mode 100644 index 45989b1908a..00000000000 --- a/components/user-mgt/org.wso2.carbon.device.mgt.user.common/src/main/java/org/wso2/carbon/device/mgt/user/common/UserManagementException.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * 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 deleted file mode 100644 index ab732588c0e..00000000000 --- a/components/user-mgt/org.wso2.carbon.device.mgt.user.core/pom.xml +++ /dev/null @@ -1,117 +0,0 @@ - - - - - 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.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.eclipse.osgi - org.eclipse.osgi - - - org.eclipse.osgi - org.eclipse.osgi.services - - - 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.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.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 deleted file mode 100644 index 8fa3e3b4c3f..00000000000 --- a/components/user-mgt/org.wso2.carbon.device.mgt.user.core/src/main/java/org/wso2/carbon/device/mgt/user/core/UserManager.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * 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; - public User getUser(String username, 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 deleted file mode 100644 index 65656401ffa..00000000000 --- a/components/user-mgt/org.wso2.carbon.device.mgt.user.core/src/main/java/org/wso2/carbon/device/mgt/user/core/UserManagerImpl.java +++ /dev/null @@ -1,213 +0,0 @@ -/* - * 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.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 org.wso2.carbon.user.core.UserCoreConstants; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -public class UserManagerImpl implements UserManager { - - private static Log log = LogFactory.getLog(UserManagerImpl.class); - - public static final String GIVEN_NAME = UserCoreConstants.ClaimTypeURIs.GIVEN_NAME; - public static final String EMAIL_ADDRESS = UserCoreConstants.ClaimTypeURIs.EMAIL_ADDRESS; - public static final String SURNAME = UserCoreConstants.ClaimTypeURIs.SURNAME; - public static final String STREET_ADDRESS = UserCoreConstants.ClaimTypeURIs.STREET_ADDRESS; - public static final String LOCALITY = UserCoreConstants.ClaimTypeURIs.LOCALITY; - public static final String REGION = UserCoreConstants.ClaimTypeURIs.REGION; - public static final String POSTAL_CODE = UserCoreConstants.ClaimTypeURIs.POSTAL_CODE; - public static final String COUNTRY = UserCoreConstants.ClaimTypeURIs.COUNTRY; - public static final String HONE = UserCoreConstants.ClaimTypeURIs.HONE; - public static final String IM = UserCoreConstants.ClaimTypeURIs.IM; - public static final String ORGANIZATION = UserCoreConstants.ClaimTypeURIs.ORGANIZATION; - public static final String URL = UserCoreConstants.ClaimTypeURIs.URL; - public static final String TITLE = UserCoreConstants.ClaimTypeURIs.TITLE; - public static final String ROLE = UserCoreConstants.ClaimTypeURIs.ROLE; - public static final String MOBILE = UserCoreConstants.ClaimTypeURIs.MOBILE; - public static final String NICKNAME = UserCoreConstants.ClaimTypeURIs.NICKNAME; - public static final String DATE_OF_BIRTH = UserCoreConstants.ClaimTypeURIs.DATE_OF_BIRTH; - public static final String GENDER = UserCoreConstants.ClaimTypeURIs.GENDER; - public static final String ACCOUNT_STATUS = UserCoreConstants.ClaimTypeURIs.ACCOUNT_STATUS; - public static final String CHALLENGE_QUESTION_URI = UserCoreConstants.ClaimTypeURIs.CHALLENGE_QUESTION_URI; - public static final String IDENTITY_CLAIM_URI = UserCoreConstants.ClaimTypeURIs.IDENTITY_CLAIM_URI; - public static final String TEMPORARY_EMAIL_ADDRESS = UserCoreConstants.ClaimTypeURIs.TEMPORARY_EMAIL_ADDRESS; - -// public static final String[] DEFAULT_CLAIM_ARR = new String[]{GIVEN_NAME,EMAIL_ADDRESS,SURNAME,STREET_ADDRESS, -// LOCALITY,REGION,REGION,POSTAL_CODE,COUNTRY,HONE,IM,ORGANIZATION,URL,TITLE,ROLE,MOBILE,NICKNAME, -// DATE_OF_BIRTH,GENDER,ACCOUNT_STATUS,CHALLENGE_QUESTION_URI,IDENTITY_CLAIM_URI,TEMPORARY_EMAIL_ADDRESS}; - - // private static final String CLAIM_URL_ - - @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); - Claim[] claims = userStoreManager.getUserClaimValues(userName, null); - Map claimMap = new HashMap(); - for(Claim claim:claims){ - String claimURI = claim.getClaimUri(); - String value = claim.getValue(); - claimMap.put(claimURI, value); - } - setUserClaims(newUser, claimMap); - 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); - Claim[] claims = userStoreManager.getUserClaimValues(userName, null); - Map claimMap = new HashMap(); - for(Claim claim:claims){ - String claimURI = claim.getClaimUri(); - String value = claim.getValue(); - claimMap.put(claimURI, value); - } - setUserClaims(newUser, claimMap); - 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; - } - - @Override public User getUser(String username, int tenantId) throws UserManagementException { - UserStoreManager userStoreManager; - User user; - try { - userStoreManager = DeviceMgtUserDataHolder.getInstance().getRealmService().getTenantUserRealm(tenantId) - .getUserStoreManager(); - user = new User(username); - - Claim[] claims = userStoreManager.getUserClaimValues(username, null); - Map claimMap = new HashMap(); - for(Claim claim:claims){ - String claimURI = claim.getClaimUri(); - String value = claim.getValue(); - claimMap.put(claimURI, value); - } - - setUserClaims(user, claimMap); - } catch (UserStoreException userStoreEx) { - String errorMsg = "User store error in fetching user " + username; - log.error(errorMsg, userStoreEx); - throw new UserManagementException(errorMsg, userStoreEx); - } - return user; - } - - private void setUserClaims(User newUser, Map claimMap) { - newUser.setRoleName(UserCoreConstants.ClaimTypeURIs.ROLE); - newUser.setAccountStatus(claimMap.get(ACCOUNT_STATUS)); - newUser.setChallengeQuestion(claimMap.get(CHALLENGE_QUESTION_URI)); - newUser.setCountry(claimMap.get(COUNTRY)); - newUser.setDateOfBirth(claimMap.get(DATE_OF_BIRTH)); - newUser.setEmail(claimMap.get(EMAIL_ADDRESS)); - newUser.setFirstName(claimMap.get(GIVEN_NAME)); - newUser.setGender(claimMap.get(GENDER)); - newUser.setHone(claimMap.get(HONE)); - newUser.setIm(claimMap.get(IM)); - newUser.setIdentityClaimUri(claimMap.get(IDENTITY_CLAIM_URI)); - newUser.setLastName(claimMap.get(SURNAME)); - newUser.setLocality(claimMap.get(LOCALITY)); - newUser.setEmail(claimMap.get(EMAIL_ADDRESS)); - newUser.setMobile(claimMap.get(MOBILE)); - newUser.setNickName(claimMap.get(NICKNAME)); - newUser.setOrganization(claimMap.get(ORGANIZATION)); - newUser.setPostalCode(claimMap.get(POSTAL_CODE)); - newUser.setRegion(claimMap.get(REGION)); - newUser.setStreatAddress(claimMap.get(STREET_ADDRESS)); - newUser.setTitle(claimMap.get(TITLE)); - newUser.setTempEmailAddress(claimMap.get(TEMPORARY_EMAIL_ADDRESS)); - } - -} 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 deleted file mode 100644 index 70e31cb3a15..00000000000 --- a/components/user-mgt/org.wso2.carbon.device.mgt.user.core/src/main/java/org/wso2/carbon/device/mgt/user/core/internal/DeviceMgtUserDataHolder.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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 deleted file mode 100644 index 86c92c3be31..00000000000 --- a/components/user-mgt/org.wso2.carbon.device.mgt.user.core/src/main/java/org/wso2/carbon/device/mgt/user/core/internal/DeviceMgtUserServiceComponent.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * 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.usermanager" 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(org.wso2.carbon.device.mgt.user.core.UserManager.class.getName(), - new org.wso2.carbon.device.mgt.user.core.service.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 deleted file mode 100644 index 6d2740d5db4..00000000000 --- a/components/user-mgt/org.wso2.carbon.device.mgt.user.core/src/main/java/org/wso2/carbon/device/mgt/user/core/service/UserManagementService.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * 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); - } - - @Override public User getUser(String username, int tenantId) throws UserManagementException { - return DeviceMgtUserDataHolder.getInstance().getUserManager().getUser(username, tenantId); - } - -} diff --git a/components/user-mgt/pom.xml b/components/user-mgt/pom.xml deleted file mode 100644 index 3c0e10a2726..00000000000 --- a/components/user-mgt/pom.xml +++ /dev/null @@ -1,61 +0,0 @@ - - - - - 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.device.mgt.user.server.feature/pom.xml b/features/user-mgt/org.wso2.carbon.device.mgt.user.server.feature/pom.xml deleted file mode 100644 index 889c4667c55..00000000000 --- a/features/user-mgt/org.wso2.carbon.device.mgt.user.server.feature/pom.xml +++ /dev/null @@ -1,117 +0,0 @@ - - - - - - user-mgt-feature - org.wso2.carbon.devicemgt - 0.9.2-SNAPSHOT - ../pom.xml - - 4.0.0 - - org.wso2.carbon.devicemgt - org.wso2.carbon.device.mgt.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.device.mgt.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.device.mgt.user.server.feature/src/main/resources/build.properties b/features/user-mgt/org.wso2.carbon.device.mgt.user.server.feature/src/main/resources/build.properties deleted file mode 100644 index 9c86577d768..00000000000 --- a/features/user-mgt/org.wso2.carbon.device.mgt.user.server.feature/src/main/resources/build.properties +++ /dev/null @@ -1 +0,0 @@ -custom = true diff --git a/features/user-mgt/org.wso2.carbon.device.mgt.user.server.feature/src/main/resources/p2.inf b/features/user-mgt/org.wso2.carbon.device.mgt.user.server.feature/src/main/resources/p2.inf deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/features/user-mgt/pom.xml b/features/user-mgt/pom.xml deleted file mode 100644 index 2dd255a300b..00000000000 --- a/features/user-mgt/pom.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - 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.device.mgt.user.server.feature - - - \ No newline at end of file diff --git a/pom.xml b/pom.xml index 558ff162fc1..2aee3e9fbbb 100644 --- a/pom.xml +++ b/pom.xml @@ -37,12 +37,10 @@ components/device-mgt components/policy-mgt - components/user-mgt components/webapp-authenticator-framework components/oauth-extensions features/device-mgt features/policy-mgt - features/user-mgt features/webapp-authenticator-framework @@ -151,17 +149,6 @@ org.wso2.carbon.policy.information.point ${carbon.device.mgt.version} - - 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.identity org.wso2.carbon.identity.oauth.stub