Skip to content

Commit

Permalink
Migrate Property UseNumeric to UseAlphaNumeric.
Browse files Browse the repository at this point in the history
  • Loading branch information
mpmadhavig committed Oct 20, 2023
1 parent 1b7d428 commit 525b836
Showing 1 changed file with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -57,6 +58,11 @@ public void updateConfiguration(String tenantDomain, Map<String, String> 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());
}
Expand Down Expand Up @@ -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));
}
}
}
}

}

0 comments on commit 525b836

Please sign in to comment.