Adding the user core changes

merge-requests/7/head
geethkokila 9 years ago
parent 782b4ac27d
commit 4a4349382a

@ -0,0 +1,25 @@
/*
* 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.policy.mgt.common;
public interface PolicyVerficationPoint {
boolean verifyPolicyOfDevice();
}

@ -0,0 +1,57 @@
/*
* 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.policy.mgt.common;
public class PolicyVerificationException extends Exception {
private String policyVerificationErrorMessage;
public String getPolicyVerificationErrorMessage() {
return policyVerificationErrorMessage;
}
public void setPolicyVerificationErrorMessage(String policyVerificationErrorMessage) {
this.policyVerificationErrorMessage = policyVerificationErrorMessage;
}
public PolicyVerificationException(String message) {
super(message);
setPolicyVerificationErrorMessage(message);
}
public PolicyVerificationException(String message, Exception ex) {
super(message, ex);
setPolicyVerificationErrorMessage(message);
}
public PolicyVerificationException(String message, Throwable cause) {
super(message, cause);
setPolicyVerificationErrorMessage(message);
}
public PolicyVerificationException() {
super();
}
public PolicyVerificationException(Throwable cause) {
super(cause);
}
}

@ -56,6 +56,7 @@
<Import-Package>
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.*,

@ -24,11 +24,13 @@ 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;
@ -59,9 +61,9 @@ public class UserManagerImpl implements UserManager {
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};
// 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_
@ -80,8 +82,14 @@ public class UserManagerImpl implements UserManager {
User newUser;
for (String userName : userNames) {
newUser = new User(userName);
setUserClaims(newUser, userStoreManager.getUserClaimValues(userName, DEFAULT_CLAIM_ARR,
UserCoreConstants.DEFAULT_PROFILE));
Claim[] claims = userStoreManager.getUserClaimValues(userName, null);
Map<String,String> claimMap = new HashMap<String, String>();
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) {
@ -129,12 +137,18 @@ public class UserManagerImpl implements UserManager {
userStoreManager = DeviceMgtUserDataHolder.getInstance().getRealmService().getTenantUserRealm(tenantId)
.getUserStoreManager();
userNames = userStoreManager.listUsers("",-1);
userNames = userStoreManager.listUsers("", -1);
User newUser;
for (String userName : userNames) {
newUser = new User(userName);
setUserClaims(newUser, userStoreManager.getUserClaimValues(userName, DEFAULT_CLAIM_ARR,
UserCoreConstants.DEFAULT_PROFILE));
Claim[] claims = userStoreManager.getUserClaimValues(userName, null);
Map<String,String> claimMap = new HashMap<String, String>();
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) {
@ -153,8 +167,16 @@ public class UserManagerImpl implements UserManager {
userStoreManager = DeviceMgtUserDataHolder.getInstance().getRealmService().getTenantUserRealm(tenantId)
.getUserStoreManager();
user = new User(username);
setUserClaims(user, userStoreManager
.getUserClaimValues(username, DEFAULT_CLAIM_ARR, UserCoreConstants.DEFAULT_PROFILE));
Claim[] claims = userStoreManager.getUserClaimValues(username, null);
Map<String,String> claimMap = new HashMap<String, String>();
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);

Loading…
Cancel
Save