Consent Amendment History
Any change that is performed on an active consent is considered as an amendment. WSO2 Open Banking provides the Consent Amendment History feature to retrieve details related to the amendments done to a consent. With this feature, you can achieve your open banking requirements related to consent amendment, which are specific to the relevant specification.
The Asynchronous Event Executor Framework is utilized for the consent amendment history persistence. The following event executor is available in the accelerator to persist the consent amendment data to the database asynchronously:
com.wso2.openbanking.accelerator.consent.extensions.event.executors.ConsentAmendmentHistoryEventExecutor
Info
This is only available as a WSO2 Update from WSO2 Open Banking Identity Server Accelerator Level 3.0.0.33 onwards. For more information on updating, see Getting WSO2 Updates.
Given below is a summary of details related to this feature:
Consent Amendment History Retrieval Endpoint¶
This endpoint retrieves the consent amendment history when the consent ID is provided as a query parameter. The response includes the current consent and an array of consent history data objects.
GET https://<IS_HOST>:9446/api/openbanking/consent/admin/consent-amendment-history?consentId=<CONSENT-ID>
You can implement consent amendment history feature to handle data related to consent amendment history and generate toolkit-specific representation for the data according to your open banking specification, by extending the following class:
com.wso2.openbanking.accelerator.consent.extensions.admin.impl.DefaultConsentAdminHandler
You can override the handleConsentAmendmentHistoryRetrieval
method to generate a representation of the consent history data which is specific to the relevant specification.
Given below is a brief explanation of the Consent Core Service methods you can use or override in your toolkits to achieve Consent Amendment and Consent Amendment History requirements according to the specification:
Note
Following methods can be accessible from Consent Core Service.
amendDetailedConsent method¶
This method amends an entire detailed consent with new values passed to the method. Given below is the method signature:
DetailedConsentResource amendDetailedConsent(
String consentID,
String consentReceipt,
Long consentValidityTime,
String authID,
Map < String, ArrayList < String >> accountIDsMapWithPermissions,
String newConsentStatus,
Map < String, String > consentAttributes,
String userID,
Map < String, Object > additionalAmendmentData) throws ConsentManagementException;
Input parameters:
consentID
: consent ID of the consent that needs to be amendedconsentReceipt
: new consent receiptconsentValidityTime
: new consent validity timeauthID
: authorization ID of the user who invoked the amendmentaccountIDsMapWithPermissions
: accounts IDs with relevant permissionsnewConsentStatus
: new consent statusconsentAttributes
: new consent attributes in a key value mapuserID
: user ID of the user who invoked the amendment to create audit recordadditionalAmendmentData
: a data map to pass any additional data that needs to be amended in the consent-
Following 2 data attributes with the respective key values can be passed in
additionalAmendmentData
. However, if no additional data is available for the amendment, keep this map empty.-
Additional Authorization Resources
- Key: user ID (for each Authorization Resource in the map)
- Value: a map of Authorization Resources
-
Additional Mapping Resources
- Key: user ID (for each mapping resources List in the map)
- Value: a map of mapping resources List
-
-
storeConsentAmendmentHistory method¶
This method stores the details of the previous consent when a consent amendment happens. Given below is the method signature:
boolean storeConsentAmendmentHistory(
String consentID,
ConsentHistoryResource consentHistoryResource,
DetailedConsentResource detailedCurrentConsent)
throws ConsentManagementException
Input parameters:
consentID
: consent ID of the consent. This is a mandatory parameter.consentHistoryResource
: a model that includes the detailed consent resource and other history parameters (for example: amended Timestamp, reason caused the amendment) of the previous consent. This is a mandatory parameter.currentConsentResource
: detailed consent resource of the existing consent. This is an optional parameter.
getConsentAmendmentHistoryData method¶
This method retrieves the consent amendment history for a given consent. Given below is the method signature:
Map < String, ConsentHistoryResource > getConsentAmendmentHistoryData(
String consentID)
throws ConsentManagementException
Input parameter:
consentID
: consent ID of the consent. This is a mandatory parameter.
Data model¶
The following table explains the data model associated with ConsentHistoryResource
.
Click here to see the data model associated with ConsentHistoryResource
.
Parameter | Type | Description |
---|---|---|
consentID | String | The consent ID of the consent to which the history belongs |
timestamp | long | The timestamp that the amendment occurred |
reason | String | The reason caused the amendment on the consent |
detailedConsentResource | DetailedConsentResource | The detailed consent data of the consent which existed prior to the amendment |
Configuring the Consent Amendment History feature¶
-
Once implemented, build a JAR file for the Consent Amendment History feature.
-
To configure the database tables related to the Consent Amendment History feature:
-
Go to the
<IS_HOME>/carbon-home/dbscripts/open-banking/consent-history
directory. -
Execute the relevant script according to your database type against the
OB_CONSENT_HISTORY
database.
-
-
Place the above-created custom JAR file in the
<IS_HOME>/repository/components/lib
directory. -
Open the
<IS_HOME>/repository/conf/deployment.toml
file. -
Locate the
[open_banking.consent.admin]
tag. -
Configure the Consent Amendment History feature using the Fully Qualified Name (FQN) of the new class you wrote by extending
DefaultConsentAdminHandler
. For example:[open_banking.consent.admin] handler="com.wso2.openbanking.accelerator.consent.extensions.admin.impl.DefaultConsentAdminHandler"
-
Add the following configuration and set the
enabled
tag totrue
.[open_banking.consent.amendment_history] enabled=true
-
Configure the event executor with the required priority. For example:
[[open_banking.event.event_executors]] name = "com.wso2.openbanking.accelerator.common.event.executor.DefaultOBEventExecutor" priority = 1 [[open_banking.event.event_executors]] name = "com.wso2.openbanking.accelerator.consent.extensions.event.executors.ConsentAmendmentHistoryEventExecutor" priority = 2