diff --git a/components/org.wso2.carbon.identity.recovery/src/main/java/org/wso2/carbon/identity/recovery/connector/LiteRegistrationConfigImpl.java b/components/org.wso2.carbon.identity.recovery/src/main/java/org/wso2/carbon/identity/recovery/connector/LiteRegistrationConfigImpl.java index 9a855acc28..ed5d99321b 100644 --- a/components/org.wso2.carbon.identity.recovery/src/main/java/org/wso2/carbon/identity/recovery/connector/LiteRegistrationConfigImpl.java +++ b/components/org.wso2.carbon.identity.recovery/src/main/java/org/wso2/carbon/identity/recovery/connector/LiteRegistrationConfigImpl.java @@ -105,6 +105,8 @@ public Map getPropertyNameMapping() { nameMapping .put(IdentityRecoveryConstants.ConnectorConfig.LITE_REGISTRATION_SMSOTP_VERIFICATION_CODE_EXPIRY_TIME, "Lite user registration SMS OTP expiry time"); + nameMapping.put(IdentityRecoveryConstants.ConnectorConfig.LITE_REGISTRATION_SMS_OTP_REGEX, + "Lite user registration SMS OTP regex"); nameMapping.put(IdentityRecoveryConstants.ConnectorConfig.LITE_REGISTRATION_CALLBACK_REGEX, "Lite user registration callback URL regex"); nameMapping.put(LIST_PURPOSE_PROPERTY_KEY, "Manage Lite-Sign-Up purposes"); @@ -144,6 +146,10 @@ public Map getPropertyDescriptionMapping() { descriptionMapping.put( IdentityRecoveryConstants.ConnectorConfig.LITE_REGISTRATION_SMSOTP_VERIFICATION_CODE_EXPIRY_TIME, "Specify the expiry time in minutes for the SMS OTP."); + descriptionMapping.put(IdentityRecoveryConstants.ConnectorConfig.LITE_REGISTRATION_SMS_OTP_REGEX, + "Regex for SMS OTP in format [allowed characters]{length}. Supported character " + + "ranges are a-z, A-Z, 0-9. Minimum OTP length is " + + IdentityMgtConstants.MINIMUM_SMS_OTP_LENGTH); descriptionMapping.put(IdentityRecoveryConstants.ConnectorConfig.LITE_REGISTRATION_CALLBACK_REGEX, "This prefix will be used to validate the callback URL."); descriptionMapping.put(LIST_PURPOSE_PROPERTY_KEY, "Click here to manage Lite-Sign-Up purposes"); @@ -169,6 +175,7 @@ public String[] getPropertyNames() { properties.add(IdentityRecoveryConstants.ConnectorConfig.LITE_REGISTRATION_VERIFICATION_CODE_EXPIRY_TIME); properties .add(IdentityRecoveryConstants.ConnectorConfig.LITE_REGISTRATION_SMSOTP_VERIFICATION_CODE_EXPIRY_TIME); + properties.add(IdentityRecoveryConstants.ConnectorConfig.LITE_REGISTRATION_SMS_OTP_REGEX); properties.add(IdentityRecoveryConstants.ConnectorConfig.LITE_REGISTRATION_CALLBACK_REGEX); properties.add(LIST_PURPOSE_PROPERTY_KEY); properties.add( @@ -182,14 +189,15 @@ public Properties getDefaultPropertyValues(String tenantDomain) throws IdentityG String enableLiteSignUp = "false"; String enableAccountLockOnCreation = "true"; String enableSendOTPInEmail = "false"; - String useUppercaseCharactersInOTP = "true"; - String useLowercaseCharactersInOTP = "true"; - String useNumbersInOTP = "true"; + String useUppercaseCharactersInOTP = StringUtils.EMPTY; + String useLowercaseCharactersInOTP = StringUtils.EMPTY; + String useNumbersInOTP = StringUtils.EMPTY; String otpLength = "6"; String enableNotificationInternallyManage = "true"; String enableLiteRegistrationReCaptcha = "true"; String verificationCodeExpiryTime = "1440"; String verificationSMSOTPExpiryTime = "1"; + String verificationSMSOTPRegex = "[a-zA-Z0-9]{6}"; String liteRegistrationCallbackRegex = IdentityRecoveryConstants.DEFAULT_CALLBACK_REGEX; String resendVerificationOnUserExistence = "false"; @@ -215,6 +223,8 @@ public Properties getDefaultPropertyValues(String tenantDomain) throws IdentityG IdentityRecoveryConstants.ConnectorConfig.LITE_REGISTRATION_VERIFICATION_CODE_EXPIRY_TIME); String verificationSMSOTPExpiryTimeProperty = IdentityUtil.getProperty( IdentityRecoveryConstants.ConnectorConfig.LITE_REGISTRATION_SMSOTP_VERIFICATION_CODE_EXPIRY_TIME); + String verificationSMSOTPRegexProperty = IdentityUtil.getProperty( + IdentityRecoveryConstants.ConnectorConfig.LITE_REGISTRATION_SMS_OTP_REGEX); String selfRegistrationCallbackRegexProperty = IdentityUtil.getProperty( IdentityRecoveryConstants.ConnectorConfig.LITE_REGISTRATION_CALLBACK_REGEX); String selfRegistrationResendVerificationOnUserExistenceProperty = IdentityUtil.getProperty( @@ -252,6 +262,9 @@ public Properties getDefaultPropertyValues(String tenantDomain) throws IdentityG if (StringUtils.isNotEmpty(verificationSMSOTPExpiryTimeProperty)) { verificationSMSOTPExpiryTime = verificationSMSOTPExpiryTimeProperty; } + if (StringUtils.isNotEmpty(verificationSMSOTPRegexProperty)) { + verificationSMSOTPRegex = verificationSMSOTPRegexProperty; + } if (StringUtils.isNotEmpty(selfRegistrationCallbackRegexProperty)) { liteRegistrationCallbackRegex = selfRegistrationCallbackRegexProperty; } @@ -283,6 +296,9 @@ public Properties getDefaultPropertyValues(String tenantDomain) throws IdentityG defaultProperties .put(IdentityRecoveryConstants.ConnectorConfig.LITE_REGISTRATION_SMSOTP_VERIFICATION_CODE_EXPIRY_TIME, verificationSMSOTPExpiryTime); + defaultProperties + .put(IdentityRecoveryConstants.ConnectorConfig.LITE_REGISTRATION_SMS_OTP_REGEX, + verificationSMSOTPRegex); defaultProperties.put( IdentityRecoveryConstants.ConnectorConfig.LITE_REGISTRATION_RESEND_VERIFICATION_ON_USER_EXISTENCE, resendVerificationOnUserExistence); @@ -345,6 +361,9 @@ public Map getMetaData() { meta.put(IdentityRecoveryConstants.ConnectorConfig.LITE_REGISTRATION_SMSOTP_VERIFICATION_CODE_EXPIRY_TIME, getPropertyObject(IdentityMgtConstants.DataTypes.INTEGER.getValue())); + meta.put(IdentityRecoveryConstants.ConnectorConfig.LITE_REGISTRATION_SMS_OTP_REGEX, + getPropertyObject(IdentityMgtConstants.DataTypes.STRING.getValue())); + meta.put(LIST_PURPOSE_PROPERTY_KEY, getPropertyObject(IdentityMgtConstants.DataTypes.URI.getValue())); meta.put(IdentityRecoveryConstants.ConnectorConfig.LITE_REGISTRATION_CALLBACK_REGEX, diff --git a/components/org.wso2.carbon.identity.recovery/src/main/java/org/wso2/carbon/identity/recovery/connector/RecoveryConfigImpl.java b/components/org.wso2.carbon.identity.recovery/src/main/java/org/wso2/carbon/identity/recovery/connector/RecoveryConfigImpl.java index f47ca47e44..e5df69d756 100644 --- a/components/org.wso2.carbon.identity.recovery/src/main/java/org/wso2/carbon/identity/recovery/connector/RecoveryConfigImpl.java +++ b/components/org.wso2.carbon.identity.recovery/src/main/java/org/wso2/carbon/identity/recovery/connector/RecoveryConfigImpl.java @@ -102,6 +102,7 @@ public Map getPropertyNameMapping() { nameMapping.put(IdentityRecoveryConstants.ConnectorConfig.EXPIRY_TIME, "Recovery link expiry time in minutes"); nameMapping.put(IdentityRecoveryConstants.ConnectorConfig.PASSWORD_RECOVERY_SMS_OTP_EXPIRY_TIME, "SMS OTP expiry time"); + nameMapping.put(IdentityRecoveryConstants.ConnectorConfig.PASSWORD_RECOVERY_SMS_OTP_REGEX, "SMS OTP regex"); nameMapping.put(IdentityRecoveryConstants.ConnectorConfig.NOTIFICATION_SEND_RECOVERY_NOTIFICATION_SUCCESS, "Notify when recovery success"); nameMapping.put(IdentityRecoveryConstants.ConnectorConfig.NOTIFICATION_SEND_RECOVERY_SECURITY_START, @@ -160,6 +161,9 @@ public Map getPropertyDescriptionMapping() { "Recovery callback URL regex"); descriptionMapping.put(IdentityRecoveryConstants.ConnectorConfig.PASSWORD_RECOVERY_SMS_OTP_EXPIRY_TIME, "Expiration time of the SMS OTP code for password recovery"); + descriptionMapping.put(IdentityRecoveryConstants.ConnectorConfig.PASSWORD_RECOVERY_SMS_OTP_REGEX, "Regex for " + + "SMS OTP in format [allowed characters]{length}. Supported character ranges are a-z, A-Z, 0-9. " + + "Minimum OTP length is " + IdentityMgtConstants.MINIMUM_SMS_OTP_LENGTH); descriptionMapping.put(IdentityRecoveryConstants.ConnectorConfig.ENABLE_AUTO_LGOIN_AFTER_PASSWORD_RESET, "User will be logged in automatically after completing the Password Reset wizard"); return descriptionMapping; @@ -189,6 +193,7 @@ public String[] getPropertyNames() { properties.add(IdentityRecoveryConstants.ConnectorConfig.NOTIFICATION_SEND_RECOVERY_SECURITY_START); properties.add(IdentityRecoveryConstants.ConnectorConfig.EXPIRY_TIME); properties.add(IdentityRecoveryConstants.ConnectorConfig.PASSWORD_RECOVERY_SMS_OTP_EXPIRY_TIME); + properties.add(IdentityRecoveryConstants.ConnectorConfig.PASSWORD_RECOVERY_SMS_OTP_REGEX); properties.add(IdentityRecoveryConstants.ConnectorConfig.FORCE_ADD_PW_RECOVERY_QUESTION); properties.add(IdentityRecoveryConstants.ConnectorConfig.FORCE_MIN_NO_QUESTION_ANSWERED); properties.add(IdentityRecoveryConstants.ConnectorConfig.RECOVERY_CALLBACK_REGEX); @@ -203,9 +208,9 @@ public Properties getDefaultPropertyValues(String tenantDomain) throws IdentityG String enableNotificationBasedPasswordRecovery = "false"; String enableSendOTPInEmail = "false"; - String useUppercaseCharactersInOTP = "true"; - String useLowercaseCharactersInOTP = "true"; - String useNumbersInOTP = "true"; + String useUppercaseCharactersInOTP = StringUtils.EMPTY; + String useLowercaseCharactersInOTP = StringUtils.EMPTY; + String useNumbersInOTP = StringUtils.EMPTY; String otpLength = "6"; String enableQuestionBasedPasswordRecovery = "false"; String minimumAnswers = "2"; @@ -217,6 +222,7 @@ public Properties getDefaultPropertyValues(String tenantDomain) throws IdentityG String enableNotificationInternallyManage = "true"; String expiryTime = "1440"; String expiryTimeSMSOTP = "1"; + String smsOtpRegex = "[a-zA-Z0-9]{6}"; String notifySuccess = "false"; String notifyStart = "false"; String enableForceChallengeQuestions = "false"; @@ -259,6 +265,8 @@ public Properties getDefaultPropertyValues(String tenantDomain) throws IdentityG String expiryTimeProperty = IdentityUtil.getProperty(IdentityRecoveryConstants.ConnectorConfig.EXPIRY_TIME); String expiryTimeSMSOTPProperty = IdentityUtil .getProperty(IdentityRecoveryConstants.ConnectorConfig.PASSWORD_RECOVERY_SMS_OTP_EXPIRY_TIME); + String smsOtpRegexProperty = IdentityUtil + .getProperty(IdentityRecoveryConstants.ConnectorConfig.PASSWORD_RECOVERY_SMS_OTP_REGEX); String notifySuccessProperty = IdentityUtil.getProperty( IdentityRecoveryConstants.ConnectorConfig.NOTIFICATION_SEND_RECOVERY_NOTIFICATION_SUCCESS); String notifyStartProperty = IdentityUtil.getProperty( @@ -283,6 +291,9 @@ public Properties getDefaultPropertyValues(String tenantDomain) throws IdentityG if (StringUtils.isNotEmpty(expiryTimeSMSOTPProperty)) { expiryTimeSMSOTP = expiryTimeSMSOTPProperty; } + if (StringUtils.isNotEmpty(smsOtpRegexProperty)) { + smsOtpRegex = smsOtpRegexProperty; + } if (StringUtils.isNotEmpty(notificationBasedPasswordRecovery)) { enableNotificationBasedPasswordRecovery = notificationBasedPasswordRecovery; } @@ -396,6 +407,8 @@ public Properties getDefaultPropertyValues(String tenantDomain) throws IdentityG defaultProperties.put(IdentityRecoveryConstants.ConnectorConfig.EXPIRY_TIME, expiryTime); defaultProperties .put(IdentityRecoveryConstants.ConnectorConfig.PASSWORD_RECOVERY_SMS_OTP_EXPIRY_TIME, expiryTimeSMSOTP); + defaultProperties + .put(IdentityRecoveryConstants.ConnectorConfig.PASSWORD_RECOVERY_SMS_OTP_REGEX, smsOtpRegex); defaultProperties.put(IdentityRecoveryConstants.ConnectorConfig.NOTIFICATION_SEND_RECOVERY_NOTIFICATION_SUCCESS, notifySuccess); defaultProperties.put(IdentityRecoveryConstants.ConnectorConfig.NOTIFICATION_SEND_RECOVERY_SECURITY_START, diff --git a/components/org.wso2.carbon.identity.recovery/src/main/java/org/wso2/carbon/identity/recovery/connector/SelfRegistrationConfigImpl.java b/components/org.wso2.carbon.identity.recovery/src/main/java/org/wso2/carbon/identity/recovery/connector/SelfRegistrationConfigImpl.java index 47f4f63df3..e889530ec9 100644 --- a/components/org.wso2.carbon.identity.recovery/src/main/java/org/wso2/carbon/identity/recovery/connector/SelfRegistrationConfigImpl.java +++ b/components/org.wso2.carbon.identity.recovery/src/main/java/org/wso2/carbon/identity/recovery/connector/SelfRegistrationConfigImpl.java @@ -106,6 +106,8 @@ public Map getPropertyNameMapping() { "User self registration verification link expiry time"); nameMapping.put(IdentityRecoveryConstants.ConnectorConfig.SELF_REGISTRATION_SMSOTP_VERIFICATION_CODE_EXPIRY_TIME, "User self registration SMS OTP expiry time"); + nameMapping.put(IdentityRecoveryConstants.ConnectorConfig.SELF_REGISTRATION_SMS_OTP_REGEX, + "User self registration SMS OTP regex"); nameMapping.put(IdentityRecoveryConstants.ConnectorConfig.SELF_REGISTRATION_CALLBACK_REGEX, "User self registration callback URL regex"); nameMapping.put(LIST_PURPOSE_PROPERTY_KEY, "Manage Self-Sign-Up purposes"); @@ -152,6 +154,10 @@ public Map getPropertyDescriptionMapping() { descriptionMapping.put( IdentityRecoveryConstants.ConnectorConfig.SELF_REGISTRATION_SMSOTP_VERIFICATION_CODE_EXPIRY_TIME, "Specify the expiry time in minutes for the SMS OTP."); + descriptionMapping.put(IdentityRecoveryConstants.ConnectorConfig.SELF_REGISTRATION_SMS_OTP_REGEX, + "Regex for SMS OTP in format [allowed characters]{length}. Supported character " + + "ranges are a-z, A-Z, 0-9. Minimum OTP length is " + + IdentityMgtConstants.MINIMUM_SMS_OTP_LENGTH); descriptionMapping.put(IdentityRecoveryConstants.ConnectorConfig.SELF_REGISTRATION_CALLBACK_REGEX, "This prefix will be used to validate the callback URL."); descriptionMapping.put(LIST_PURPOSE_PROPERTY_KEY, "Click here to manage Self-Sign-Up purposes"); @@ -183,6 +189,7 @@ public String[] getPropertyNames() { properties.add(IdentityRecoveryConstants.ConnectorConfig.SELF_REGISTRATION_VERIFICATION_CODE_EXPIRY_TIME); properties .add(IdentityRecoveryConstants.ConnectorConfig.SELF_REGISTRATION_SMSOTP_VERIFICATION_CODE_EXPIRY_TIME); + properties.add(IdentityRecoveryConstants.ConnectorConfig.SELF_REGISTRATION_SMS_OTP_REGEX); properties.add(IdentityRecoveryConstants.ConnectorConfig.SELF_REGISTRATION_CALLBACK_REGEX); properties.add(LIST_PURPOSE_PROPERTY_KEY); properties.add(IdentityRecoveryConstants.ConnectorConfig.SELF_REGISTRATION_NOTIFY_ACCOUNT_CONFIRMATION); @@ -198,15 +205,16 @@ public Properties getDefaultPropertyValues(String tenantDomain) throws IdentityG String enableSelfSignUp = "false"; String enableAccountLockOnCreation = "true"; String enableSendOTPInEmail = "false"; - String useUppercaseCharactersInOTP = "true"; - String useLowercaseCharactersInOTP = "true"; - String useNumbersInOTP = "true"; + String useUppercaseCharactersInOTP = StringUtils.EMPTY; + String useLowercaseCharactersInOTP = StringUtils.EMPTY; + String useNumbersInOTP = StringUtils.EMPTY; String otpLength = "6"; String enableSendNotificationOnCreation = "false"; String enableNotificationInternallyManage = "true"; String enableSelfRegistrationReCaptcha = "true"; String verificationCodeExpiryTime = "1440"; String verificationSMSOTPExpiryTime = "1"; + String verificationSMSOTPRegex = "[a-zA-Z0-9]{6}"; String selfRegistrationCallbackRegex = IdentityRecoveryConstants.DEFAULT_CALLBACK_REGEX; String enableSelfSignUpConfirmationNotification = "false"; String enableResendConfirmationRecaptcha = "false"; @@ -237,6 +245,8 @@ public Properties getDefaultPropertyValues(String tenantDomain) throws IdentityG IdentityRecoveryConstants.ConnectorConfig.SELF_REGISTRATION_VERIFICATION_CODE_EXPIRY_TIME); String verificationSMSOTPExpiryTimeProperty = IdentityUtil.getProperty( IdentityRecoveryConstants.ConnectorConfig.SELF_REGISTRATION_SMSOTP_VERIFICATION_CODE_EXPIRY_TIME); + String verificationSMSOTPRegexProperty = IdentityUtil.getProperty( + IdentityRecoveryConstants.ConnectorConfig.SELF_REGISTRATION_SMS_OTP_REGEX); String selfRegistrationCallbackRegexProperty = IdentityUtil.getProperty( IdentityRecoveryConstants.ConnectorConfig.SELF_REGISTRATION_CALLBACK_REGEX); String selfSignUpConfirmationNotificationProperty = IdentityUtil.getProperty( @@ -284,6 +294,9 @@ public Properties getDefaultPropertyValues(String tenantDomain) throws IdentityG if (StringUtils.isNotEmpty(verificationSMSOTPExpiryTimeProperty)) { verificationSMSOTPExpiryTime = verificationSMSOTPExpiryTimeProperty; } + if (StringUtils.isNotEmpty(verificationSMSOTPRegexProperty)) { + verificationSMSOTPRegex = verificationSMSOTPRegexProperty; + } if (StringUtils.isNotEmpty(selfRegistrationCallbackRegexProperty)) { selfRegistrationCallbackRegex = selfRegistrationCallbackRegexProperty; } @@ -326,6 +339,9 @@ public Properties getDefaultPropertyValues(String tenantDomain) throws IdentityG defaultProperties .put(IdentityRecoveryConstants.ConnectorConfig.SELF_REGISTRATION_SMSOTP_VERIFICATION_CODE_EXPIRY_TIME, verificationSMSOTPExpiryTime); + defaultProperties + .put(IdentityRecoveryConstants.ConnectorConfig.SELF_REGISTRATION_SMS_OTP_REGEX, + verificationSMSOTPRegex); defaultProperties.put(IdentityRecoveryConstants.ConnectorConfig.SELF_REGISTRATION_AUTO_LOGIN, enableSelfRegistrationAutoLogin); defaultProperties.put(IdentityRecoveryConstants.ConnectorConfig.SELF_REGISTRATION_AUTO_LOGIN_ALIAS_NAME, @@ -395,6 +411,9 @@ public Map getMetaData() { meta.put(IdentityRecoveryConstants.ConnectorConfig.SELF_REGISTRATION_SMSOTP_VERIFICATION_CODE_EXPIRY_TIME, getPropertyObject(IdentityMgtConstants.DataTypes.INTEGER.getValue())); + meta.put(IdentityRecoveryConstants.ConnectorConfig.SELF_REGISTRATION_SMS_OTP_REGEX, + getPropertyObject(IdentityMgtConstants.DataTypes.STRING.getValue())); + meta.put(IdentityRecoveryConstants.ConnectorConfig.SELF_REGISTRATION_AUTO_LOGIN, getPropertyObject(IdentityMgtConstants.DataTypes.BOOLEAN.getValue())); diff --git a/components/org.wso2.carbon.identity.recovery/src/test/java/org/wso2/carbon/identity/recovery/connector/RecoveryConfigImplTest.java b/components/org.wso2.carbon.identity.recovery/src/test/java/org/wso2/carbon/identity/recovery/connector/RecoveryConfigImplTest.java index 6e5ba38800..09c9109992 100644 --- a/components/org.wso2.carbon.identity.recovery/src/test/java/org/wso2/carbon/identity/recovery/connector/RecoveryConfigImplTest.java +++ b/components/org.wso2.carbon.identity.recovery/src/test/java/org/wso2/carbon/identity/recovery/connector/RecoveryConfigImplTest.java @@ -111,6 +111,8 @@ public void testGetPropertyNameMapping() { "Recovery link expiry time in minutes"); nameMappingExpected.put(IdentityRecoveryConstants.ConnectorConfig.PASSWORD_RECOVERY_SMS_OTP_EXPIRY_TIME, "SMS OTP expiry time"); + nameMappingExpected.put(IdentityRecoveryConstants.ConnectorConfig.PASSWORD_RECOVERY_SMS_OTP_REGEX, + "SMS OTP regex"); nameMappingExpected.put(IdentityRecoveryConstants.ConnectorConfig.NOTIFICATION_SEND_RECOVERY_NOTIFICATION_SUCCESS, "Notify when recovery success"); nameMappingExpected.put(IdentityRecoveryConstants.ConnectorConfig.NOTIFICATION_SEND_RECOVERY_SECURITY_START, @@ -172,6 +174,9 @@ public void testGetPropertyDescriptionMapping() { "Recovery callback URL regex"); descriptionMappingExpected.put(IdentityRecoveryConstants.ConnectorConfig.PASSWORD_RECOVERY_SMS_OTP_EXPIRY_TIME, "Expiration time of the SMS OTP code for password recovery"); + descriptionMappingExpected.put(IdentityRecoveryConstants.ConnectorConfig.PASSWORD_RECOVERY_SMS_OTP_REGEX, + "Regex for SMS OTP in format [allowed characters]{length}. Supported character ranges are a-z, A-Z, " + + "0-9. Minimum OTP length is " + IdentityMgtConstants.MINIMUM_SMS_OTP_LENGTH); descriptionMappingExpected.put(IdentityRecoveryConstants.ConnectorConfig.ENABLE_AUTO_LGOIN_AFTER_PASSWORD_RESET, "User will be logged in automatically after completing the Password Reset wizard"); Map descriptionMapping = recoveryConfigImpl.getPropertyDescriptionMapping(); @@ -203,6 +208,7 @@ public void testGetPropertyNames() { propertiesExpected.add(IdentityRecoveryConstants.ConnectorConfig.NOTIFICATION_SEND_RECOVERY_SECURITY_START); propertiesExpected.add(IdentityRecoveryConstants.ConnectorConfig.EXPIRY_TIME); propertiesExpected.add(IdentityRecoveryConstants.ConnectorConfig.PASSWORD_RECOVERY_SMS_OTP_EXPIRY_TIME); + propertiesExpected.add(IdentityRecoveryConstants.ConnectorConfig.PASSWORD_RECOVERY_SMS_OTP_REGEX); propertiesExpected.add(IdentityRecoveryConstants.ConnectorConfig.FORCE_ADD_PW_RECOVERY_QUESTION); propertiesExpected.add(IdentityRecoveryConstants.ConnectorConfig.FORCE_MIN_NO_QUESTION_ANSWERED); propertiesExpected.add(IdentityRecoveryConstants.ConnectorConfig.RECOVERY_CALLBACK_REGEX); @@ -222,9 +228,9 @@ public void testGetDefaultPropertyValues() throws IdentityGovernanceException { String testEnableNotificationBasedPasswordRecovery = "false"; String testEnableSendOTPInEmail = "false"; - String testUseUppercaseCharactersInOTP = "true"; - String testUseLowercaseCharactersInOTP = "true"; - String testUseNumbersInOTP = "true"; + String testUseUppercaseCharactersInOTP = StringUtils.EMPTY; + String testUseLowercaseCharactersInOTP = StringUtils.EMPTY; + String testUseNumbersInOTP = StringUtils.EMPTY; String testOtpLength = "6"; String testEnableQuestionBasedPasswordRecovery = "false"; String testMinimumAnswers = "2"; @@ -281,6 +287,8 @@ public void testGetDefaultPropertyValues() throws IdentityGovernanceException { defaultPropertiesExpected.put(IdentityRecoveryConstants.ConnectorConfig.EXPIRY_TIME, testExpiryTime); defaultPropertiesExpected.put(IdentityRecoveryConstants.ConnectorConfig.PASSWORD_RECOVERY_SMS_OTP_EXPIRY_TIME, testExpiryTimeSMSOTP); + defaultPropertiesExpected + .put(IdentityRecoveryConstants.ConnectorConfig.PASSWORD_RECOVERY_SMS_OTP_REGEX, smsOtpRegex); defaultPropertiesExpected.put(IdentityRecoveryConstants.ConnectorConfig.NOTIFICATION_SEND_RECOVERY_NOTIFICATION_SUCCESS, testNotifySuccess); defaultPropertiesExpected.put(IdentityRecoveryConstants.ConnectorConfig.NOTIFICATION_SEND_RECOVERY_SECURITY_START, diff --git a/components/org.wso2.carbon.identity.recovery/src/test/java/org/wso2/carbon/identity/recovery/connector/SelfRegistrationConfigImplTest.java b/components/org.wso2.carbon.identity.recovery/src/test/java/org/wso2/carbon/identity/recovery/connector/SelfRegistrationConfigImplTest.java index ecb25c8089..7465a1681a 100644 --- a/components/org.wso2.carbon.identity.recovery/src/test/java/org/wso2/carbon/identity/recovery/connector/SelfRegistrationConfigImplTest.java +++ b/components/org.wso2.carbon.identity.recovery/src/test/java/org/wso2/carbon/identity/recovery/connector/SelfRegistrationConfigImplTest.java @@ -115,6 +115,8 @@ public void testGetPropertyNameMapping() { "User self registration verification link expiry time"); nameMappingExpected.put(IdentityRecoveryConstants.ConnectorConfig.SELF_REGISTRATION_SMSOTP_VERIFICATION_CODE_EXPIRY_TIME, "User self registration SMS OTP expiry time"); + nameMappingExpected.put(IdentityRecoveryConstants.ConnectorConfig.SELF_REGISTRATION_SMS_OTP_REGEX, + "User self registration SMS OTP regex"); nameMappingExpected.put(IdentityRecoveryConstants.ConnectorConfig.SELF_REGISTRATION_CALLBACK_REGEX, "User self registration callback URL regex"); nameMappingExpected.put(LIST_PURPOSE_PROPERTY_KEY, "Manage Self-Sign-Up purposes"); @@ -163,6 +165,10 @@ public void testGetPropertyDescriptionMapping() { descriptionMappingExpected.put( IdentityRecoveryConstants.ConnectorConfig.SELF_REGISTRATION_SMSOTP_VERIFICATION_CODE_EXPIRY_TIME, "Specify the expiry time in minutes for the SMS OTP."); + descriptionMappingExpected.put(IdentityRecoveryConstants.ConnectorConfig.SELF_REGISTRATION_SMS_OTP_REGEX, + "Regex for SMS OTP in format [allowed characters]{length}. Supported character " + + "ranges are a-z, A-Z, 0-9. Minimum OTP length is " + + IdentityMgtConstants.MINIMUM_SMS_OTP_LENGTH); descriptionMappingExpected.put(IdentityRecoveryConstants.ConnectorConfig.SELF_REGISTRATION_CALLBACK_REGEX, "This prefix will be used to validate the callback URL."); descriptionMappingExpected.put(LIST_PURPOSE_PROPERTY_KEY, "Click here to manage Self-Sign-Up purposes"); @@ -198,6 +204,7 @@ public void testGetPropertyNames() { .add(IdentityRecoveryConstants.ConnectorConfig.SELF_REGISTRATION_VERIFICATION_CODE_EXPIRY_TIME); propertiesExpected .add(IdentityRecoveryConstants.ConnectorConfig.SELF_REGISTRATION_SMSOTP_VERIFICATION_CODE_EXPIRY_TIME); + propertiesExpected.add(IdentityRecoveryConstants.ConnectorConfig.SELF_REGISTRATION_SMS_OTP_REGEX); propertiesExpected.add(IdentityRecoveryConstants.ConnectorConfig.SELF_REGISTRATION_CALLBACK_REGEX); propertiesExpected.add(LIST_PURPOSE_PROPERTY_KEY); propertiesExpected.add(IdentityRecoveryConstants.ConnectorConfig.SELF_REGISTRATION_NOTIFY_ACCOUNT_CONFIRMATION); @@ -219,15 +226,16 @@ public void testGetDefaultPropertyValues() throws IdentityGovernanceException { String testEnableSelfSignUp = "false"; String testEnableAccountLockOnCreation = "true"; String testEnableSendOTPInEmail = "false"; - String testUseUppercaseCharactersInOTP = "true"; - String testUseLowercaseCharactersInOTP = "true"; - String testUseNumbersInOTP = "true"; + String testUseUppercaseCharactersInOTP = StringUtils.EMPTY; + String testUseLowercaseCharactersInOTP = StringUtils.EMPTY; + String testUseNumbersInOTP = StringUtils.EMPTY; String testOtpLength = "6"; String testEnableSendNotificationOnCreation = "false"; String testEnableNotificationInternallyManage = "true"; String testEnableSelfRegistrationReCaptcha = "true"; String testVerificationCodeExpiryTime = "1440"; String testVerificationSMSOTPExpiryTime = "1"; + String testVerificationSMSOTPRegex = "[a-zA-Z0-9]{6}"; String selfRegistrationCallbackRegex = IdentityRecoveryConstants.DEFAULT_CALLBACK_REGEX; String enableSelfSignUpConfirmationNotification = "false"; String enableResendConfirmationRecaptcha = "false"; @@ -260,6 +268,8 @@ public void testGetDefaultPropertyValues() throws IdentityGovernanceException { propertiesExpected.put( IdentityRecoveryConstants.ConnectorConfig.SELF_REGISTRATION_SMSOTP_VERIFICATION_CODE_EXPIRY_TIME, testVerificationSMSOTPExpiryTime); + propertiesExpected.put(IdentityRecoveryConstants.ConnectorConfig.SELF_REGISTRATION_SMS_OTP_REGEX, + testVerificationSMSOTPRegex); propertiesExpected.put(IdentityRecoveryConstants.ConnectorConfig.SELF_REGISTRATION_CALLBACK_REGEX, selfRegistrationCallbackRegex); propertiesExpected.put(IdentityRecoveryConstants.ConnectorConfig.SELF_REGISTRATION_AUTO_LOGIN,