diff --git a/components/org.wso2.openbanking.cds.common/src/main/java/org/wso2/openbanking/cds/common/config/OpenBankingCDSConfigParser.java b/components/org.wso2.openbanking.cds.common/src/main/java/org/wso2/openbanking/cds/common/config/OpenBankingCDSConfigParser.java
index 4054ba77..3e58e91e 100644
--- a/components/org.wso2.openbanking.cds.common/src/main/java/org/wso2/openbanking/cds/common/config/OpenBankingCDSConfigParser.java
+++ b/components/org.wso2.openbanking.cds.common/src/main/java/org/wso2/openbanking/cds/common/config/OpenBankingCDSConfigParser.java
@@ -670,6 +670,23 @@ public boolean getSecondaryUserAccountsEnabled() {
}
}
+ /**
+ * Get secondary user accounts selectable without account metadata status.
+ * This indicates whether the secondary user accounts can be selected when there is no account metadata
+ * available for the given account and user combination.
+ *
+ * @return boolean
+ */
+ public boolean isSecondaryAccountsSelectableWithoutAccountMetadata() {
+
+ Object config = getConfigElementFromKey(CommonConstants.SELECTABLE_WITHOUT_ACCOUNT_METADATA);
+ if (config != null) {
+ return Boolean.parseBoolean((String) config);
+ } else {
+ return false;
+ }
+ }
+
/**
* Get Disclosure Options Management enabled status.
*
diff --git a/components/org.wso2.openbanking.cds.common/src/main/java/org/wso2/openbanking/cds/common/utils/CommonConstants.java b/components/org.wso2.openbanking.cds.common/src/main/java/org/wso2/openbanking/cds/common/utils/CommonConstants.java
index c37b792a..6c80d7e4 100644
--- a/components/org.wso2.openbanking.cds.common/src/main/java/org/wso2/openbanking/cds/common/utils/CommonConstants.java
+++ b/components/org.wso2.openbanking.cds.common/src/main/java/org/wso2/openbanking/cds/common/utils/CommonConstants.java
@@ -115,6 +115,8 @@ public class CommonConstants {
// Secondary user account config constants
public static final String SECONDARY_USER_ACCOUNTS_ENABLED = "SecondaryUserAccounts.Enable";
+ public static final String SELECTABLE_WITHOUT_ACCOUNT_METADATA =
+ "SecondaryUserAccounts.SelectableWithoutAccountMetadata";
// Disclosure Options Management config constants
public static final String DISCLOSURE_OPTIONS_MANAGEMENT_ENABLED = "DisclosureOptionsManagement.Enable";
diff --git a/components/org.wso2.openbanking.cds.common/src/test/java/org/wso2/openbanking/cds/common/OpenBankingCDSConfigParserTest.java b/components/org.wso2.openbanking.cds.common/src/test/java/org/wso2/openbanking/cds/common/OpenBankingCDSConfigParserTest.java
index 24862175..e35ba075 100644
--- a/components/org.wso2.openbanking.cds.common/src/test/java/org/wso2/openbanking/cds/common/OpenBankingCDSConfigParserTest.java
+++ b/components/org.wso2.openbanking.cds.common/src/test/java/org/wso2/openbanking/cds/common/OpenBankingCDSConfigParserTest.java
@@ -247,6 +247,13 @@ public void testIsSecondaryAccountsEnabled() {
Assert.assertTrue(openBankingCDSConfigParser.getSecondaryUserAccountsEnabled());
}
+ @Test(priority = 8)
+ public void testIsSecondaryAccountsSelectableWithoutAccountMetadata() {
+ String dummyConfigFile = absolutePathForTestResources + "/open-banking-cds.xml";
+ OpenBankingCDSConfigParser openBankingCDSConfigParser = OpenBankingCDSConfigParser.getInstance(dummyConfigFile);
+ Assert.assertFalse(openBankingCDSConfigParser.isSecondaryAccountsSelectableWithoutAccountMetadata());
+ }
+
@Test(priority = 8)
public void testIsCeasingSecondaryUserSharingEnabled() {
String dummyConfigFile = absolutePathForTestResources + "/open-banking-cds.xml";
diff --git a/components/org.wso2.openbanking.cds.common/src/test/resources/open-banking-cds.xml b/components/org.wso2.openbanking.cds.common/src/test/resources/open-banking-cds.xml
index 42297d59..a76cdeba 100644
--- a/components/org.wso2.openbanking.cds.common/src/test/resources/open-banking-cds.xml
+++ b/components/org.wso2.openbanking.cds.common/src/test/resources/open-banking-cds.xml
@@ -89,6 +89,7 @@
true
+ false
true
diff --git a/components/org.wso2.openbanking.cds.consent.extensions/src/main/java/org/wso2/openbanking/cds/consent/extensions/authorize/impl/persist/CDSConsentPersistStep.java b/components/org.wso2.openbanking.cds.consent.extensions/src/main/java/org/wso2/openbanking/cds/consent/extensions/authorize/impl/persist/CDSConsentPersistStep.java
index 9b3ebe79..51c5cc59 100644
--- a/components/org.wso2.openbanking.cds.consent.extensions/src/main/java/org/wso2/openbanking/cds/consent/extensions/authorize/impl/persist/CDSConsentPersistStep.java
+++ b/components/org.wso2.openbanking.cds.consent.extensions/src/main/java/org/wso2/openbanking/cds/consent/extensions/authorize/impl/persist/CDSConsentPersistStep.java
@@ -225,6 +225,12 @@ public void execute(ConsentPersistData consentPersistData) throws ConsentExcepti
// bind user consented non-primary accounts with the created consent
bindNonPrimaryAccountsToConsentWithGivenPermissions(consentCoreService, consentResource,
consentData, nonPrimaryAccountIDsMapWithPermissions);
+
+ } else if (!nonPrimaryAccountIDsMapWithPermissions.isEmpty()) {
+ // bind user consented non-primary accounts with the created consent
+ bindNonPrimaryAccountsToConsentWithGivenPermissions(consentCoreService, consentResource,
+ consentData, nonPrimaryAccountIDsMapWithPermissions);
+
} else {
// case where no specific non-primary account permissions provided
bindUserAccountsToConsent(consentCoreService, consentResource, consentData, accountIdList);
diff --git a/components/org.wso2.openbanking.cds.consent.extensions/src/main/java/org/wso2/openbanking/cds/consent/extensions/util/CDSConsentExtensionsUtil.java b/components/org.wso2.openbanking.cds.consent.extensions/src/main/java/org/wso2/openbanking/cds/consent/extensions/util/CDSConsentExtensionsUtil.java
index d73533a8..27ebd4f0 100644
--- a/components/org.wso2.openbanking.cds.consent.extensions/src/main/java/org/wso2/openbanking/cds/consent/extensions/util/CDSConsentExtensionsUtil.java
+++ b/components/org.wso2.openbanking.cds.consent.extensions/src/main/java/org/wso2/openbanking/cds/consent/extensions/util/CDSConsentExtensionsUtil.java
@@ -26,6 +26,7 @@
import com.wso2.openbanking.accelerator.consent.extensions.common.ResponseStatus;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.wso2.openbanking.cds.common.config.OpenBankingCDSConfigParser;
import org.wso2.openbanking.cds.consent.extensions.common.CDSConsentExtensionConstants;
import org.wso2.openbanking.cds.consent.extensions.validate.utils.CDSConsentValidatorUtil;
@@ -38,6 +39,7 @@ public class CDSConsentExtensionsUtil {
private static final Log log = LogFactory.getLog(CDSConsentValidatorUtil.class);
private static AccountMetadataService accountMetadataService = AccountMetadataServiceImpl.getInstance();
+ private static OpenBankingCDSConfigParser cdsConfigParser = OpenBankingCDSConfigParser.getInstance();
/**
* Get secondary user instruction data.
@@ -57,7 +59,7 @@ public static Boolean isUserEligibleForSecondaryAccountDataSharing(String accoun
return CDSConsentExtensionConstants.ACTIVE_STATUS
.equalsIgnoreCase(accountMetadata.get(CDSConsentExtensionConstants.INSTRUCTION_STATUS));
} else {
- return false;
+ return cdsConfigParser.isSecondaryAccountsSelectableWithoutAccountMetadata();
}
} catch (OpenBankingException e) {
log.error("Error occurred while retrieving account metadata for account id : " + accountId, e);
diff --git a/toolkits/ob-is/carbon-home/repository/resources/conf/templates/repository/conf/open-banking-cds.xml.j2 b/toolkits/ob-is/carbon-home/repository/resources/conf/templates/repository/conf/open-banking-cds.xml.j2
index 0c082c29..b65271f1 100644
--- a/toolkits/ob-is/carbon-home/repository/resources/conf/templates/repository/conf/open-banking-cds.xml.j2
+++ b/toolkits/ob-is/carbon-home/repository/resources/conf/templates/repository/conf/open-banking-cds.xml.j2
@@ -233,6 +233,11 @@
{% else %}
false
{% endif %}
+ {% if open_banking_cds.secondary_user_accounts.selectable_without_account_metadata is defined %}
+ {{open_banking_cds.secondary_user_accounts.selectable_without_account_metadata}}
+ {% else %}
+ false
+ {% endif %}
{% if open_banking_cds.secondary_user_accounts.ceasing_secondary_user_sharing_enable is defined %}
{{open_banking_cds.secondary_user_accounts.ceasing_secondary_user_sharing_enable}}
{% else %}
diff --git a/toolkits/ob-is/repository/resources/wso2is-6.0.0-deployment-cds.toml b/toolkits/ob-is/repository/resources/wso2is-6.0.0-deployment-cds.toml
index 09c66add..d2d9288c 100644
--- a/toolkits/ob-is/repository/resources/wso2is-6.0.0-deployment-cds.toml
+++ b/toolkits/ob-is/repository/resources/wso2is-6.0.0-deployment-cds.toml
@@ -961,6 +961,7 @@ validate_accounts_on_retrieval=true
[open_banking_cds.secondary_user_accounts]
enable = true
+selectable_without_account_metadata = false
ceasing_secondary_user_sharing_enable = true
[open_banking_cds.disclosure_options_management]