-
Notifications
You must be signed in to change notification settings - Fork 239
Fixm/multi email separate #1078
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -120,7 +120,7 @@ public void handleEvent(Event event) throws IdentityEventException { | |||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| boolean supportMultipleMobileNumbers = | ||||||||||||||||||
| Utils.isMultiEmailsAndMobileNumbersPerUserEnabled(user.getTenantDomain(), user.getUserStoreDomain()); | ||||||||||||||||||
| Utils.isMultiMobileNumbersPerUserEnabled(user.getTenantDomain(), user.getUserStoreDomain()); | ||||||||||||||||||
|
|
||||||||||||||||||
| boolean enable = isMobileVerificationOnUpdateEnabled(user.getTenantDomain()); | ||||||||||||||||||
|
|
||||||||||||||||||
|
|
@@ -342,7 +342,7 @@ private void preSetUserClaimOnMobileNumberUpdate(Map<String, String> claims, Use | |||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| boolean supportMultipleMobileNumbers = | ||||||||||||||||||
| Utils.isMultiEmailsAndMobileNumbersPerUserEnabled(user.getTenantDomain(), user.getUserStoreDomain()); | ||||||||||||||||||
| Utils.isMultiMobileNumbersPerUserEnabled(user.getTenantDomain(), user.getUserStoreDomain()); | ||||||||||||||||||
|
Comment on lines
344
to
+345
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Log Improvement Suggestion No: 2
Suggested change
|
||||||||||||||||||
|
|
||||||||||||||||||
| // Update multiple mobile numbers only if they’re in the claims map. | ||||||||||||||||||
| // This avoids issues with updating the primary mobile number due to user store limitations on multiple | ||||||||||||||||||
|
|
||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -122,7 +122,7 @@ public void handleEvent(Event event) throws IdentityEventException { | |||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| boolean supportMultipleEmails = | ||||||||||||||||||
| Utils.isMultiEmailsAndMobileNumbersPerUserEnabled(user.getTenantDomain(), user.getUserStoreDomain()); | ||||||||||||||||||
| Utils.isMultiEmailAddressesPerUserEnabled(user.getTenantDomain(), user.getUserStoreDomain()); | ||||||||||||||||||
|
Comment on lines
124
to
+125
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Log Improvement Suggestion No: 3
Suggested change
|
||||||||||||||||||
|
|
||||||||||||||||||
| boolean enable = false; | ||||||||||||||||||
|
|
||||||||||||||||||
|
|
@@ -552,7 +552,7 @@ private void preSetUserClaimsOnEmailUpdate(Map<String, String> claims, UserStore | |||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| boolean supportMultipleEmails = | ||||||||||||||||||
| Utils.isMultiEmailsAndMobileNumbersPerUserEnabled(user.getTenantDomain(), user.getUserStoreDomain()); | ||||||||||||||||||
| Utils.isMultiEmailAddressesPerUserEnabled(user.getTenantDomain(), user.getUserStoreDomain()); | ||||||||||||||||||
|
Comment on lines
554
to
+555
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Log Improvement Suggestion No: 4
Suggested change
|
||||||||||||||||||
| // Update multiple email address related claims only if they’re in the claims map. | ||||||||||||||||||
| // This avoids issues with updating the primary email address due to user store limitations on multiple | ||||||||||||||||||
| // email addresses. | ||||||||||||||||||
|
|
||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -694,7 +694,10 @@ public static String getSignUpConfigs(String key, String tenantDomain) throws Id | |||||||||||||
| Property[] connectorConfigs; | ||||||||||||||
| IdentityGovernanceService identityGovernanceService = IdentityRecoveryServiceDataHolder.getInstance() | ||||||||||||||
| .getIdentityGovernanceService(); | ||||||||||||||
| connectorConfigs = identityGovernanceService.getConfiguration(new String[]{key,}, tenantDomain); | ||||||||||||||
| connectorConfigs = identityGovernanceService.getConfiguration(new String[]{key}, tenantDomain); | ||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Log Improvement Suggestion No: 5
Suggested change
|
||||||||||||||
| if (connectorConfigs == null || connectorConfigs.length == 0 || connectorConfigs[0] == null) { | ||||||||||||||
| return null; | ||||||||||||||
| } | ||||||||||||||
| return connectorConfigs[0].getValue(); | ||||||||||||||
| } catch (IdentityGovernanceException e) { | ||||||||||||||
| throw Utils.handleServerException( | ||||||||||||||
|
|
@@ -708,7 +711,10 @@ public static String getConnectorConfig(String key, String tenantDomain) throws | |||||||||||||
| Property[] connectorConfigs; | ||||||||||||||
| IdentityGovernanceService identityGovernanceService = IdentityRecoveryServiceDataHolder.getInstance() | ||||||||||||||
| .getIdentityGovernanceService(); | ||||||||||||||
| connectorConfigs = identityGovernanceService.getConfiguration(new String[]{key,}, tenantDomain); | ||||||||||||||
| connectorConfigs = identityGovernanceService.getConfiguration(new String[]{key}, tenantDomain); | ||||||||||||||
| if (connectorConfigs == null || connectorConfigs.length == 0 || connectorConfigs[0] == null) { | ||||||||||||||
| return null; | ||||||||||||||
| } | ||||||||||||||
| return connectorConfigs[0].getValue(); | ||||||||||||||
| } catch (IdentityGovernanceException e) { | ||||||||||||||
| throw new IdentityEventException("Error while getting connector configurations", e); | ||||||||||||||
|
|
@@ -1524,8 +1530,64 @@ public static boolean isUseVerifyClaimEnabled() { | |||||||||||||
| */ | ||||||||||||||
| public static boolean isMultiEmailsAndMobileNumbersPerUserEnabled(String tenantDomain, String userStoreDomain) { | ||||||||||||||
|
|
||||||||||||||
| if (!Boolean.parseBoolean(IdentityUtil.getProperty( | ||||||||||||||
| IdentityRecoveryConstants.ConnectorConfig.SUPPORT_MULTI_EMAILS_AND_MOBILE_NUMBERS_PER_USER))) { | ||||||||||||||
| return isMultiEmailAddressesPerUserEnabled(tenantDomain, userStoreDomain) | ||||||||||||||
| && isMultiMobileNumbersPerUserEnabled(tenantDomain, userStoreDomain); | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| /** | ||||||||||||||
| * Check if multiple email addresses are supported for the given tenant and user store. | ||||||||||||||
| * | ||||||||||||||
| * @param tenantDomain Tenant domain. | ||||||||||||||
| * @param userStoreDomain User store domain. | ||||||||||||||
| * @return True if multiple email addresses are supported. | ||||||||||||||
| */ | ||||||||||||||
| public static boolean isMultiEmailAddressesPerUserEnabled(String tenantDomain, String userStoreDomain) { | ||||||||||||||
|
|
||||||||||||||
| if (!isMultiEmailOrMobileConfigEnabled()) { | ||||||||||||||
| return false; | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| if (StringUtils.isBlank(tenantDomain) || StringUtils.isBlank(userStoreDomain)) { | ||||||||||||||
| return false; | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| try { | ||||||||||||||
| List<LocalClaim> localClaims = | ||||||||||||||
| IdentityRecoveryServiceDataHolder.getInstance().getClaimMetadataManagementService() | ||||||||||||||
| .getLocalClaims(tenantDomain); | ||||||||||||||
|
|
||||||||||||||
| List<String> requiredEmailClaims = new ArrayList<>(); | ||||||||||||||
| requiredEmailClaims.add(IdentityRecoveryConstants.EMAIL_ADDRESSES_CLAIM); | ||||||||||||||
|
|
||||||||||||||
| boolean isEmailVerificationOnUpdateEnabled; | ||||||||||||||
| try { | ||||||||||||||
| isEmailVerificationOnUpdateEnabled = isEmailVerificationOnUpdateEnabled(tenantDomain); | ||||||||||||||
| } catch (IdentityEventException e) { | ||||||||||||||
| log.error("Error while retrieving email verification on update config.", e); | ||||||||||||||
|
Comment on lines
+1564
to
+1566
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Log Improvement Suggestion No: 6
Suggested change
|
||||||||||||||
| return false; | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| if (isEmailVerificationOnUpdateEnabled) { | ||||||||||||||
| requiredEmailClaims.add(IdentityRecoveryConstants.VERIFIED_EMAIL_ADDRESSES_CLAIM); | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| return areClaimsSupportedForUserStore(localClaims, requiredEmailClaims, userStoreDomain); | ||||||||||||||
| } catch (ClaimMetadataException e) { | ||||||||||||||
| log.error("Error while retrieving multiple emails config.", e); | ||||||||||||||
| return false; | ||||||||||||||
| } | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| /** | ||||||||||||||
| * Check if multiple mobile numbers are supported for the given tenant and user store. | ||||||||||||||
| * | ||||||||||||||
| * @param tenantDomain Tenant domain. | ||||||||||||||
| * @param userStoreDomain User store domain. | ||||||||||||||
| * @return True if multiple mobile numbers are supported. | ||||||||||||||
| */ | ||||||||||||||
| public static boolean isMultiMobileNumbersPerUserEnabled(String tenantDomain, String userStoreDomain) { | ||||||||||||||
|
|
||||||||||||||
| if (!isMultiEmailOrMobileConfigEnabled()) { | ||||||||||||||
| return false; | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
|
|
@@ -1538,21 +1600,55 @@ public static boolean isMultiEmailsAndMobileNumbersPerUserEnabled(String tenantD | |||||||||||||
| IdentityRecoveryServiceDataHolder.getInstance().getClaimMetadataManagementService() | ||||||||||||||
| .getLocalClaims(tenantDomain); | ||||||||||||||
|
|
||||||||||||||
| List<String> requiredClaims = Arrays.asList( | ||||||||||||||
| IdentityRecoveryConstants.VERIFIED_MOBILE_NUMBERS_CLAIM, | ||||||||||||||
| IdentityRecoveryConstants.MOBILE_NUMBERS_CLAIM, | ||||||||||||||
| IdentityRecoveryConstants.EMAIL_ADDRESSES_CLAIM, | ||||||||||||||
| IdentityRecoveryConstants.VERIFIED_EMAIL_ADDRESSES_CLAIM); | ||||||||||||||
| List<String> requiredMobileClaims = new ArrayList<>(); | ||||||||||||||
| requiredMobileClaims.add(IdentityRecoveryConstants.MOBILE_NUMBERS_CLAIM); | ||||||||||||||
|
|
||||||||||||||
| boolean isMobileVerificationOnUpdateEnabled; | ||||||||||||||
| try { | ||||||||||||||
| isMobileVerificationOnUpdateEnabled = isMobileVerificationOnUpdateEnabled(tenantDomain); | ||||||||||||||
| } catch (IdentityEventException e) { | ||||||||||||||
| log.error("Error while retrieving mobile verification on update config.", e); | ||||||||||||||
| return false; | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| // Check if all required claims are valid for the user store. | ||||||||||||||
| return requiredClaims.stream().allMatch(claimUri -> | ||||||||||||||
| isClaimSupportedForUserStore(localClaims, claimUri, userStoreDomain)); | ||||||||||||||
| if (isMobileVerificationOnUpdateEnabled) { | ||||||||||||||
| requiredMobileClaims.add(IdentityRecoveryConstants.VERIFIED_MOBILE_NUMBERS_CLAIM); | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| return areClaimsSupportedForUserStore(localClaims, requiredMobileClaims, userStoreDomain); | ||||||||||||||
| } catch (ClaimMetadataException e) { | ||||||||||||||
| log.error("Error while retrieving multiple emails and mobiles config.", e); | ||||||||||||||
| log.error("Error while retrieving multiple mobile numbers config.", e); | ||||||||||||||
| return false; | ||||||||||||||
| } | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| private static boolean isMultiEmailOrMobileConfigEnabled() { | ||||||||||||||
|
|
||||||||||||||
| return Boolean.parseBoolean(IdentityUtil.getProperty( | ||||||||||||||
| IdentityRecoveryConstants.ConnectorConfig.SUPPORT_MULTI_EMAILS_AND_MOBILE_NUMBERS_PER_USER)); | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| private static boolean isEmailVerificationOnUpdateEnabled(String tenantDomain) throws IdentityEventException { | ||||||||||||||
|
|
||||||||||||||
| String configValue = Utils.getConnectorConfig( | ||||||||||||||
| IdentityRecoveryConstants.ConnectorConfig.ENABLE_EMAIL_VERIFICATION_ON_UPDATE, tenantDomain); | ||||||||||||||
| return Boolean.parseBoolean(configValue); | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| private static boolean isMobileVerificationOnUpdateEnabled(String tenantDomain) throws IdentityEventException { | ||||||||||||||
|
|
||||||||||||||
| String configValue = Utils.getConnectorConfig( | ||||||||||||||
| IdentityRecoveryConstants.ConnectorConfig.ENABLE_MOBILE_NUM_VERIFICATION_ON_UPDATE, tenantDomain); | ||||||||||||||
| return Boolean.parseBoolean(configValue); | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| private static boolean areClaimsSupportedForUserStore(List<LocalClaim> localClaims, List<String> claimUris, | ||||||||||||||
| String userStoreDomain) { | ||||||||||||||
|
|
||||||||||||||
| return claimUris.stream().allMatch(claimUri -> | ||||||||||||||
| isClaimSupportedForUserStore(localClaims, claimUri, userStoreDomain)); | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| /** | ||||||||||||||
| * Check if a claim is supported and not excluded for a specific user store. | ||||||||||||||
| * | ||||||||||||||
|
|
||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log Improvement Suggestion No: 1