Skip to content
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

Improvements to secondary user scenarios #40

Merged
merged 2 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
</BNR>
<SecondaryUserAccounts>
<Enable>true</Enable>
<SelectableWithoutAccountMetadata>false</SelectableWithoutAccountMetadata>
<CeasingSecondaryUserSharingEnabled>true</CeasingSecondaryUserSharingEnabled>
</SecondaryUserAccounts>
<DisclosureOptionsManagement>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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.
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,11 @@
{% else %}
<Enable>false</Enable>
{% endif %}
{% if open_banking_cds.secondary_user_accounts.selectable_without_account_metadata is defined %}
<SelectableWithoutAccountMetadata>{{open_banking_cds.secondary_user_accounts.selectable_without_account_metadata}}</SelectableWithoutAccountMetadata>
{% else %}
<SelectableWithoutAccountMetadata>false</SelectableWithoutAccountMetadata>
{% endif %}
{% if open_banking_cds.secondary_user_accounts.ceasing_secondary_user_sharing_enable is defined %}
<CeasingSecondaryUserSharingEnabled>{{open_banking_cds.secondary_user_accounts.ceasing_secondary_user_sharing_enable}}</CeasingSecondaryUserSharingEnabled>
{% else %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
Loading