From 525b8363824eaaafafd873ee1315c4a2b7d326bd Mon Sep 17 00:00:00 2001 From: mpmadhavig Date: Fri, 20 Oct 2023 15:07:56 +0530 Subject: [PATCH] Migrate Property UseNumeric to UseAlphaNumeric. --- .../IdentityGovernanceServiceImpl.java | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/components/org.wso2.carbon.identity.governance/src/main/java/org/wso2/carbon/identity/governance/IdentityGovernanceServiceImpl.java b/components/org.wso2.carbon.identity.governance/src/main/java/org/wso2/carbon/identity/governance/IdentityGovernanceServiceImpl.java index fc98053458..f6a4ae08ab 100644 --- a/components/org.wso2.carbon.identity.governance/src/main/java/org/wso2/carbon/identity/governance/IdentityGovernanceServiceImpl.java +++ b/components/org.wso2.carbon.identity.governance/src/main/java/org/wso2/carbon/identity/governance/IdentityGovernanceServiceImpl.java @@ -34,6 +34,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Objects; /** * Class which contains exposed identity governance services. @@ -57,6 +58,11 @@ public void updateConfiguration(String tenantDomain, Map configu prop.setName(key); if (configurationDetails.containsKey(key)) { prop.setValue(configurationDetails.get(key)); + if (Objects.equals(key, "EmailOTP.OtpRegex.Migrated")) { + prop.setValue("true"); + } else { + prop.setValue(configurationDetails.get(key)); + } } else { prop.setValue(identityMgtProperty.getValue()); } @@ -233,10 +239,34 @@ public ConnectorConfig getConnectorWithConfigs(String tenantDomain, for (ConnectorConfig connectorConfig : connectorListWithConfigs) { if (connectorConfig.getName().equals(connectorName)) { + // Should remove this logic eventually. + migratePropertyUseNumericToUseAlphaNumeric(connectorName, connectorConfig); return connectorConfig; } } return null; } + /** + * This method is used to migrate the property value useNumericCharacters to useAlphanumericCharacters. + * + * @param connectorName Name of the connector. + * @param connectorConfig Connector configuration. + */ + private void migratePropertyUseNumericToUseAlphaNumeric(String connectorName, ConnectorConfig connectorConfig) { + + if (connectorName.equals("email-otp-authenticator")) { + if (connectorConfig.getProperties().length == 6) { + boolean isMigrated = Boolean.parseBoolean(connectorConfig.getProperties()[5].getValue()); + if (!isMigrated && connectorConfig.getProperties()[4].getValue() != null ) { + // Extract the value of the useNumericCharacters property. + boolean useAlphanumericChars = !Boolean.parseBoolean(connectorConfig.getProperties()[4].getValue()); + // Assign the value to the alphanumeric property. + connectorConfig.getProperties()[3].setValue(String.valueOf(useAlphanumericChars)); + connectorConfig.getProperties()[5].setValue(String.valueOf(true)); + } + } + } + } + }