private void addMultiAttributeSperatorToRequestedClaims(AuthenticatedUser authenticatedUser, org.wso2.carbon.user.core.UserStoreManager userStore, Map<String, String> spRequestedClaims) { if (!spRequestedClaims.isEmpty()) { RealmConfiguration realmConfiguration = userStore.getRealmConfiguration(); String claimSeparator = realmConfiguration.getUserStoreProperty(IdentityCoreConstants .MULTI_ATTRIBUTE_SEPARATOR); if (StringUtils.isNotBlank(claimSeparator)) { spRequestedClaims.put(IdentityCoreConstants.MULTI_ATTRIBUTE_SEPARATOR, claimSeparator); } } }
private void addMultiAttributeSperatorToRequestedClaims(AuthenticatedUser authenticatedUser, org.wso2.carbon.user.core.UserStoreManager userStore, Map<String, String> spRequestedClaims) { if (!spRequestedClaims.isEmpty()) { RealmConfiguration realmConfiguration = userStore.getRealmConfiguration(); String claimSeparator = realmConfiguration.getUserStoreProperty(IdentityCoreConstants .MULTI_ATTRIBUTE_SEPARATOR); if (StringUtils.isNotBlank(claimSeparator)) { spRequestedClaims.put(IdentityCoreConstants.MULTI_ATTRIBUTE_SEPARATOR, claimSeparator); } } }
private void addMultiAttributeSperatorToRequestedClaims(AuthenticatedUser authenticatedUser, org.wso2.carbon.user.core.UserStoreManager userStore, Map<String, String> spRequestedClaims) { if (!spRequestedClaims.isEmpty()) { RealmConfiguration realmConfiguration = userStore.getRealmConfiguration(); String claimSeparator = realmConfiguration.getUserStoreProperty(IdentityCoreConstants .MULTI_ATTRIBUTE_SEPARATOR); if (StringUtils.isNotBlank(claimSeparator)) { spRequestedClaims.put(IdentityCoreConstants.MULTI_ATTRIBUTE_SEPARATOR, claimSeparator); } } }
protected String getUserStoreDomainName(UserStoreManager userStoreManager) { return UserCoreUtil.getDomainName(userStoreManager.getRealmConfiguration()); }
/** * Get maximum user limit to retrieve. * * @return */ private int getMaxLimit() { int givenMax; try { givenMax = Integer.parseInt(carbonUM.getRealmConfiguration().getUserStoreProperty( "MaxUserNameListLength")); } catch (Exception e) { givenMax = UserCoreConstants.MAX_USER_ROLE_LIST; } return givenMax; }
/** * Returns whether the passed operation is supported by userstore or not * * @param userStoreManager User Store * @param operation Operation name * @return true if the operation is supported by userstore. False if it doesnt */ public static boolean isSupportedByUserStore(UserStoreManager userStoreManager, String operation) { boolean isOperationSupported = true; if (userStoreManager != null) { String isOperationSupportedProperty = userStoreManager.getRealmConfiguration().getUserStoreProperty (operation); if (StringUtils.isNotBlank(isOperationSupportedProperty)) { isOperationSupported = Boolean.parseBoolean(isOperationSupportedProperty); } } return isOperationSupported; }
/** * Check the case sensitivity of the user store. * * @param userStoreManager * @return */ public static boolean isUserStoreCaseSensitive(UserStoreManager userStoreManager) { if (userStoreManager == null) { //this is done to handle federated scenarios. For federated scenarios, there is no user store manager for // the user return true; } String caseInsensitiveUsername = userStoreManager.getRealmConfiguration() .getUserStoreProperty(IdentityCoreConstants.CASE_INSENSITIVE_USERNAME); if (caseInsensitiveUsername == null && log.isDebugEnabled()) { log.debug("Error while reading user store property CaseInsensitiveUsername. Considering as case sensitive" + "."); } return !Boolean.parseBoolean(caseInsensitiveUsername); }
/** * Check the case sensitivity of the user store. * * @param userStoreManager * @return */ public static boolean isUserStoreCaseSensitive(UserStoreManager userStoreManager) { if (userStoreManager == null) { //this is done to handle federated scenarios. For federated scenarios, there is no user store manager for // the user return true; } String caseInsensitiveUsername = userStoreManager.getRealmConfiguration() .getUserStoreProperty(IdentityCoreConstants.CASE_INSENSITIVE_USERNAME); if (caseInsensitiveUsername == null && log.isDebugEnabled()) { log.debug("Error while reading user store property CaseInsensitiveUsername. Considering as case sensitive" + "."); } return !Boolean.parseBoolean(caseInsensitiveUsername); }
/** * Returns whether the passed operation is supported by userstore or not * * @param userStoreManager User Store * @param operation Operation name * @return true if the operation is supported by userstore. False if it doesnt */ public static boolean isSupportedByUserStore(UserStoreManager userStoreManager, String operation) { boolean isOperationSupported = true; if (userStoreManager != null) { String isOperationSupportedProperty = userStoreManager.getRealmConfiguration().getUserStoreProperty (operation); if (StringUtils.isNotBlank(isOperationSupportedProperty)) { isOperationSupported = Boolean.parseBoolean(isOperationSupportedProperty); } } return isOperationSupported; }
public static String getUserStoreDomainName(UserStoreManager userStoreManager) { String domainNameProperty = null; if(userStoreManager instanceof org.wso2.carbon.user.core.UserStoreManager) { domainNameProperty = ((org.wso2.carbon.user.core.UserStoreManager) userStoreManager).getRealmConfiguration() .getUserStoreProperty(UserCoreConstants.RealmConfig.PROPERTY_DOMAIN_NAME); if(StringUtils.isBlank(domainNameProperty)) { domainNameProperty = IdentityUtil.getPrimaryDomainName(); } } return domainNameProperty; }
public static String getUserStoreDomainName(UserStoreManager userStoreManager) { String domainNameProperty = null; if(userStoreManager instanceof org.wso2.carbon.user.core.UserStoreManager) { domainNameProperty = ((org.wso2.carbon.user.core.UserStoreManager) userStoreManager).getRealmConfiguration() .getUserStoreProperty(UserCoreConstants.RealmConfig.PROPERTY_DOMAIN_NAME); if(StringUtils.isBlank(domainNameProperty)) { domainNameProperty = IdentityUtil.getPrimaryDomainName(); } } return domainNameProperty; }
public static String getUserStoreDomainName(UserStoreManager userStoreManager) { String domainNameProperty = null; if(userStoreManager instanceof org.wso2.carbon.user.core.UserStoreManager) { domainNameProperty = ((org.wso2.carbon.user.core.UserStoreManager) userStoreManager).getRealmConfiguration() .getUserStoreProperty(UserCoreConstants.RealmConfig.PROPERTY_DOMAIN_NAME); if(StringUtils.isBlank(domainNameProperty)) { domainNameProperty = IdentityUtil.getPrimaryDomainName(); } } return domainNameProperty; }
/** * This method will append the user store domain with user/role name. * * @param entity Entity that need to modified. * @param userStoreManager UserStore Manager particular user/role handled by. * @return UserStoreDomain/UserName or UserStoreDomain/RoleName */ public static String getEntityWithUserStoreDomain(String entity, UserStoreManager userStoreManager) { String entityWithUserStoreDomain = entity; if (StringUtils.isNotEmpty(entity) && userStoreManager != null) { String userStoreDomain = UserCoreUtil.getDomainName(userStoreManager.getRealmConfiguration()); entityWithUserStoreDomain = UserCoreUtil.addDomainToName(entity, userStoreDomain); } return entityWithUserStoreDomain; } }
protected User getUser(Map eventProperties, UserStoreManager userStoreManager){ String userName = (String) eventProperties.get(IdentityEventConstants.EventProperty.USER_NAME); String tenantDomain = (String) eventProperties.get(IdentityEventConstants.EventProperty.TENANT_DOMAIN); String domainName = userStoreManager.getRealmConfiguration().getUserStoreProperty(UserCoreConstants.RealmConfig.PROPERTY_DOMAIN_NAME); User user = new User(); user.setUserName(userName); user.setTenantDomain(tenantDomain); user.setUserStoreDomain(domainName); return user; }
/** * Remove user claims from ClaimCache * * @param userName */ private boolean removeUserClaimsFromCache(String userName, UserStoreManager userStoreManager) throws UserStoreException { ClaimCache claimCache = ClaimCache.getInstance(); AuthenticatedUser authenticatedUser = new AuthenticatedUser(); authenticatedUser.setUserName(userName); authenticatedUser.setTenantDomain(IdentityTenantUtil.getTenantDomain(userStoreManager.getTenantId())); authenticatedUser.setUserStoreDomain(UserCoreUtil.getDomainName(userStoreManager.getRealmConfiguration())); ClaimCacheKey cacheKey = new ClaimCacheKey(authenticatedUser); if (cacheKey != null) { claimCache.clearCacheEntry(cacheKey); } return true; }
/** * Remove user claims from ClaimCache * * @param userName */ private boolean removeUserClaimsFromCache(String userName, UserStoreManager userStoreManager) throws UserStoreException { ClaimCache claimCache = ClaimCache.getInstance(); AuthenticatedUser authenticatedUser = new AuthenticatedUser(); authenticatedUser.setUserName(userName); authenticatedUser.setTenantDomain(IdentityTenantUtil.getTenantDomain(userStoreManager.getTenantId())); authenticatedUser.setUserStoreDomain(UserCoreUtil.getDomainName(userStoreManager.getRealmConfiguration())); ClaimCacheKey cacheKey = new ClaimCacheKey(authenticatedUser); if (cacheKey != null) { claimCache.clearCacheEntry(cacheKey); } return true; }
private void removeTokensFromCache(String userName, UserStoreManager userStoreManager) throws UserStoreException { String userStoreDomain = UserCoreUtil.getDomainName(userStoreManager.getRealmConfiguration()); String tenantDomain = IdentityTenantUtil.getTenantDomain(userStoreManager.getTenantId()); Set<String> accessTokens; Set<String> authorizationCodes; AuthenticatedUser authenticatedUser = new AuthenticatedUser(); authenticatedUser.setUserStoreDomain(userStoreDomain); authenticatedUser.setTenantDomain(tenantDomain); authenticatedUser.setUserName(userName); try { accessTokens = OAuthTokenPersistenceFactory.getInstance().getAccessTokenDAO().getAccessTokensByUser(authenticatedUser); authorizationCodes = OAuthTokenPersistenceFactory.getInstance() .getAuthorizationCodeDAO().getAuthorizationCodesByUser(authenticatedUser); removeAccessTokensFromCache(accessTokens); removeAuthzCodesFromCache(authorizationCodes); } catch (IdentityOAuth2Exception e) { String errorMsg = "Error occurred while retrieving access tokens issued for user : " + userName; log.error(errorMsg, e); } }
/** * Remove ClaimCache Entry if available. * * @param username * @param userStoreManager */ private void removeClaimCacheEntry(String username, UserStoreManager userStoreManager) throws UserStoreException { AuthenticatedUser authenticatedUser = new AuthenticatedUser(); authenticatedUser.setUserName(username); authenticatedUser.setTenantDomain(IdentityTenantUtil.getTenantDomain(userStoreManager.getTenantId())); authenticatedUser.setUserStoreDomain(UserCoreUtil.getDomainName(userStoreManager.getRealmConfiguration())); ClaimMetaDataCacheEntry cacheEntry = ClaimMetaDataCache.getInstance().getValueFromCache( new ClaimMetaDataCacheKey(authenticatedUser)); if(cacheEntry == null) { return; } ClaimCache.getInstance().clearCacheEntry(cacheEntry.getClaimCacheKey()); } }
/** * Remove ClaimCache Entry if available. * * @param username * @param userStoreManager */ private void removeClaimCacheEntry(String username, UserStoreManager userStoreManager) throws UserStoreException { AuthenticatedUser authenticatedUser = new AuthenticatedUser(); authenticatedUser.setUserName(username); authenticatedUser.setTenantDomain(IdentityTenantUtil.getTenantDomain(userStoreManager.getTenantId())); authenticatedUser.setUserStoreDomain(UserCoreUtil.getDomainName(userStoreManager.getRealmConfiguration())); ClaimMetaDataCacheEntry cacheEntry = ClaimMetaDataCache.getInstance().getValueFromCache( new ClaimMetaDataCacheKey(authenticatedUser)); if(cacheEntry == null) { return; } ClaimCache.getInstance().clearCacheEntry(cacheEntry.getClaimCacheKey()); } }
@Override public boolean doPreDeleteRole(String roleName, UserStoreManager userStoreManager) throws UserStoreException { if (!isEnable() || isCalledViaIdentityMgtListners()) { return true; } try { DeleteRoleWFRequestHandler deleteRoleWFRequestHandler = new DeleteRoleWFRequestHandler(); String domain = userStoreManager.getRealmConfiguration().getUserStoreProperty(UserCoreConstants.RealmConfig .PROPERTY_DOMAIN_NAME); int tenantId = userStoreManager.getTenantId() ; String currentUser = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); PrivilegedCarbonContext.startTenantFlow(); PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(tenantId, true); PrivilegedCarbonContext.getThreadLocalCarbonContext().setUsername(currentUser); return deleteRoleWFRequestHandler.startDeleteRoleFlow(domain, roleName); } catch (WorkflowException e) { // Sending e.getMessage() since it is required to give error message to end user. throw new UserStoreException(e.getMessage(), e); } finally { PrivilegedCarbonContext.endTenantFlow(); } }