revert-70aa11f8
prabathabey 10 years ago
commit 9a776b15dc

@ -28,4 +28,5 @@ public interface UserManager {
public List<User> getUsersForTenantAndRole(int tenantId, String roleName) throws UserManagementException; public List<User> getUsersForTenantAndRole(int tenantId, String roleName) throws UserManagementException;
public List<Role> getRolesForTenant(int tenantId) throws UserManagementException; public List<Role> getRolesForTenant(int tenantId) throws UserManagementException;
public List<User> getUsersForTenant(int tenantId) throws UserManagementException; public List<User> getUsersForTenant(int tenantId) throws UserManagementException;
public User getUser(String username, int tenantId) throws UserManagementException;
} }

@ -20,12 +20,10 @@ package org.wso2.carbon.device.mgt.user.core;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; 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.Role;
import org.wso2.carbon.device.mgt.user.common.User; 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.common.UserManagementException;
import org.wso2.carbon.device.mgt.user.core.internal.DeviceMgtUserDataHolder; 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.UserStoreException;
import org.wso2.carbon.user.api.UserStoreManager; import org.wso2.carbon.user.api.UserStoreManager;
import org.wso2.carbon.user.core.UserCoreConstants; import org.wso2.carbon.user.core.UserCoreConstants;
@ -148,8 +146,24 @@ public class UserManagerImpl implements UserManager {
return usersList; return usersList;
} }
private void setUserClaims(User newUser, Map<String, String> claimMap) { @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);
setUserClaims(user, userStoreManager
.getUserClaimValues(username, DEFAULT_CLAIM_ARR, UserCoreConstants.DEFAULT_PROFILE));
} 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<String, String> claimMap) {
newUser.setRoleName(UserCoreConstants.ClaimTypeURIs.ROLE); newUser.setRoleName(UserCoreConstants.ClaimTypeURIs.ROLE);
newUser.setAccountStatus(claimMap.get(ACCOUNT_STATUS)); newUser.setAccountStatus(claimMap.get(ACCOUNT_STATUS));
newUser.setChallengeQuestion(claimMap.get(CHALLENGE_QUESTION_URI)); newUser.setChallengeQuestion(claimMap.get(CHALLENGE_QUESTION_URI));

@ -43,4 +43,9 @@ public class UserManagementService implements UserManager{
public List<User> getUsersForTenant(int tenantId) throws UserManagementException { public List<User> getUsersForTenant(int tenantId) throws UserManagementException {
return DeviceMgtUserDataHolder.getInstance().getUserManager().getUsersForTenant(tenantId); return DeviceMgtUserDataHolder.getInstance().getUserManager().getUsersForTenant(tenantId);
} }
@Override public User getUser(String username, int tenantId) throws UserManagementException {
return DeviceMgtUserDataHolder.getInstance().getUserManager().getUser(username, tenantId);
}
} }

Loading…
Cancel
Save