From ca95d19663755176470bc7f9eca707ad1bce68f9 Mon Sep 17 00:00:00 2001 From: nuwandiw Date: Fri, 15 May 2015 12:12:22 +0530 Subject: [PATCH 1/2] fix for IDENTITY-3246 --- .../UserStoreBasedIdentityDataStore.java | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/components/identity-mgt/org.wso2.carbon.identity.mgt/src/main/java/org/wso2/carbon/identity/mgt/store/UserStoreBasedIdentityDataStore.java b/components/identity-mgt/org.wso2.carbon.identity.mgt/src/main/java/org/wso2/carbon/identity/mgt/store/UserStoreBasedIdentityDataStore.java index d138713be0..add3852c27 100644 --- a/components/identity-mgt/org.wso2.carbon.identity.mgt/src/main/java/org/wso2/carbon/identity/mgt/store/UserStoreBasedIdentityDataStore.java +++ b/components/identity-mgt/org.wso2.carbon.identity.mgt/src/main/java/org/wso2/carbon/identity/mgt/store/UserStoreBasedIdentityDataStore.java @@ -123,6 +123,9 @@ public UserIdentityClaimsDO load(String userName, UserStoreManager userStoreMana userDataMap.put(claimUri, claim.getValue()); } } + } else { + // null is returned when the user doesn't exist + return null; } } catch (UserStoreException e) { // ignore may be user is not exist @@ -133,19 +136,16 @@ public UserIdentityClaimsDO load(String userName, UserStoreManager userStoreMana } userStoreInvoked.set("FALSE"); } - // if user is exiting there must be at least one user attribute. - if (userDataMap != null && userDataMap.size() > 0) { - userIdentityDTO = new UserIdentityClaimsDO(userName, userDataMap); - int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); - userIdentityDTO.setTenantId(tenantId); - Cache cache = getCache(); - if (cache != null) { - cache.put(tenantId + userName, userIdentityDTO); - } - return userIdentityDTO; + userIdentityDTO = new UserIdentityClaimsDO(userName, userDataMap); + int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); + userIdentityDTO.setTenantId(tenantId); + + Cache cache = getCache(); + if (cache != null) { + cache.put(tenantId + userName, userIdentityDTO); } - return null; + return userIdentityDTO; } } From eaf63fbd0a319f99e612dbd95af9dbafa968ca8c Mon Sep 17 00:00:00 2001 From: nuwandiw Date: Fri, 15 May 2015 12:39:55 +0530 Subject: [PATCH 2/2] fix for IDENTITY-3246 --- .../identity/mgt/store/UserStoreBasedIdentityDataStore.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/identity-mgt/org.wso2.carbon.identity.mgt/src/main/java/org/wso2/carbon/identity/mgt/store/UserStoreBasedIdentityDataStore.java b/components/identity-mgt/org.wso2.carbon.identity.mgt/src/main/java/org/wso2/carbon/identity/mgt/store/UserStoreBasedIdentityDataStore.java index add3852c27..e14dd6de8d 100644 --- a/components/identity-mgt/org.wso2.carbon.identity.mgt/src/main/java/org/wso2/carbon/identity/mgt/store/UserStoreBasedIdentityDataStore.java +++ b/components/identity-mgt/org.wso2.carbon.identity.mgt/src/main/java/org/wso2/carbon/identity/mgt/store/UserStoreBasedIdentityDataStore.java @@ -128,7 +128,8 @@ public UserIdentityClaimsDO load(String userName, UserStoreManager userStoreMana return null; } } catch (UserStoreException e) { - // ignore may be user is not exist + log.error("Error while reading user claim values"); + return null; } finally { // reset to initial value if (log.isDebugEnabled()) {