user management

4.x.x
manoj 10 years ago
parent d790d343a9
commit 78959f0cfb

@ -29,6 +29,7 @@ import org.wso2.carbon.device.mgt.core.dao.util.DeviceManagementDAOUtil;
import org.wso2.carbon.device.mgt.core.dto.*; import org.wso2.carbon.device.mgt.core.dto.*;
import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManagementException; import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManagementException;
import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManager; import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManager;
import org.wso2.carbon.device.mgt.core.internal.EmailServiceDataHolder;
import org.wso2.carbon.device.mgt.core.license.mgt.LicenseManagerImpl; import org.wso2.carbon.device.mgt.core.license.mgt.LicenseManagerImpl;
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; 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.operation.mgt.OperationManagementException;
@ -211,6 +212,13 @@ public class DeviceManagementServiceProviderImpl implements DeviceManagementServ
return devicesOfUser; return devicesOfUser;
} }
@Override
public void sendEnrollInvitation(String emailAddress) throws DeviceManagementException {
EmailMessageProperties emailMessageProperties = new EmailMessageProperties();
emailMessageProperties.setSubject("");
// EmailServiceDataHolder.getInstance().getEmailServiceProvider().sendEmail();
}
@Override @Override
public Device getDevice(DeviceIdentifier deviceId) throws DeviceManagementException { public Device getDevice(DeviceIdentifier deviceId) throws DeviceManagementException {
DeviceManager dms = DeviceManager dms =

@ -38,4 +38,6 @@ public interface DeviceManagementService extends DeviceManager, LicenseManager,
List<Device> getDeviceListOfUser(String username) throws DeviceManagementException; List<Device> getDeviceListOfUser(String username) throws DeviceManagementException;
void sendEnrollInvitation(String emailAddress) throws DeviceManagementException;
} }

@ -26,6 +26,7 @@ import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManagementException;
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; 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.operation.mgt.OperationManagementException;
import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder; import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder;
import org.wso2.carbon.device.mgt.core.internal.EmailServiceDataHolder;
import java.util.List; import java.util.List;
@ -85,6 +86,11 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
return DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().getDeviceListOfUser(username); return DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().getDeviceListOfUser(username);
} }
@Override
public void sendEnrollInvitation(String emailAddress) throws DeviceManagementException {
DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().sendEnrollInvitation(emailAddress);
}
@Override @Override
public org.wso2.carbon.device.mgt.common.Device getDevice(DeviceIdentifier deviceId) public org.wso2.carbon.device.mgt.common.Device getDevice(DeviceIdentifier deviceId)
throws DeviceManagementException { throws DeviceManagementException {

@ -146,5 +146,5 @@ public final class DeviceManagerUtil {
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
return ctx.getTenantId(); return ctx.getTenantId();
} }
} }

@ -24,6 +24,29 @@ public class User {
private String userName; private String userName;
private String roleName; 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<Claims> claimList; private ArrayList<Claims> claimList;
public User(String userName) { public User(String userName) {
@ -58,4 +81,172 @@ public class User {
public void setClaimList(ArrayList<Claims> claimList) { public void setClaimList(ArrayList<Claims> claimList) {
this.claimList = 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;
}
} }

@ -28,14 +28,45 @@ import org.wso2.carbon.device.mgt.user.core.internal.DeviceMgtUserDataHolder;
import org.wso2.carbon.user.api.Claim; 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 java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map;
public class UserManagerImpl implements UserManager { public class UserManagerImpl implements UserManager {
private static Log log = LogFactory.getLog(UserManagerImpl.class); 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 @Override
public List<User> getUsersForTenantAndRole(int tenantId, String roleName) throws UserManagementException { public List<User> getUsersForTenantAndRole(int tenantId, String roleName) throws UserManagementException {
@ -51,7 +82,8 @@ public class UserManagerImpl implements UserManager {
User newUser; User newUser;
for (String userName : userNames) { for (String userName : userNames) {
newUser = new User(userName); newUser = new User(userName);
setUserClaims(newUser, userStoreManager.getUserClaimValues(userName, null)); setUserClaims(newUser, userStoreManager.getUserClaimValues(userName, DEFAULT_CLAIM_ARR,
UserCoreConstants.DEFAULT_PROFILE));
usersList.add(newUser); usersList.add(newUser);
} }
} catch (UserStoreException userStoreEx) { } catch (UserStoreException userStoreEx) {
@ -103,7 +135,8 @@ public class UserManagerImpl implements UserManager {
User newUser; User newUser;
for (String userName : userNames) { for (String userName : userNames) {
newUser = new User(userName); newUser = new User(userName);
setUserClaims(newUser, userStoreManager.getUserClaimValues(userName, null)); setUserClaims(newUser, userStoreManager.getUserClaimValues(userName, DEFAULT_CLAIM_ARR,
UserCoreConstants.DEFAULT_PROFILE));
usersList.add(newUser); usersList.add(newUser);
} }
} catch (UserStoreException userStoreEx) { } catch (UserStoreException userStoreEx) {
@ -115,19 +148,30 @@ public class UserManagerImpl implements UserManager {
return usersList; return usersList;
} }
private void setUserClaims(User newUser, Claim[] userClaimValues) { private void setUserClaims(User newUser, Map<String, String> claimMap) {
Claims userClaims; newUser.setRoleName(UserCoreConstants.ClaimTypeURIs.ROLE);
ArrayList<Claims> claimsList = new ArrayList<Claims>(); newUser.setAccountStatus(claimMap.get(ACCOUNT_STATUS));
for (Claim claim : userClaimValues) { newUser.setChallengeQuestion(claimMap.get(CHALLENGE_QUESTION_URI));
userClaims = new Claims(); newUser.setCountry(claimMap.get(COUNTRY));
userClaims.setClaimUrl(claim.getClaimUri()); newUser.setDateOfBirth(claimMap.get(DATE_OF_BIRTH));
userClaims.setDescription(claim.getDescription()); newUser.setEmail(claimMap.get(EMAIL_ADDRESS));
userClaims.setDialectUrl(claim.getDialectURI()); newUser.setFirstName(claimMap.get(GIVEN_NAME));
userClaims.setValue(claim.getValue()); newUser.setGender(claimMap.get(GENDER));
claimsList.add(userClaims); newUser.setHone(claimMap.get(HONE));
} newUser.setIm(claimMap.get(IM));
newUser.setClaimList(claimsList); 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));
} }
} }

@ -1,22 +1,20 @@
<?xml version="1.0" encoding="ISO-8859-1"?> <?xml version="1.0" encoding="ISO-8859-1"?>
<!-- <!--
~ Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
~ ~
~ 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
~ WSO2 Inc. licenses this file to you under the Apache License, ~ in compliance with the License.
~ Version 2.0 (the "License"); you may not use this file except ~ you may obtain a copy of the License at
~ in compliance with the License.
~ You may obtain a copy of the License at
~ ~
~ http://www.apache.org/licenses/LICENSE-2.0 ~ http://www.apache.org/licenses/LICENSE-2.0
~ ~
~ Unless required by applicable law or agreed to in writing, ~ Unless required by applicable law or agreed to in writing,
~ software distributed under the License is distributed on an ~ software distributed under the License is distributed on an
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~ KIND, either express or implied. See the License for the ~ KIND, either express or implied. See the License for the
~ specific language governing permissions and limitations ~ specific language governing permissions and limitations
~ under the License. ~ under the License.
~
--> -->
<LicenseConfig> <LicenseConfig>

Loading…
Cancel
Save